Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davewalter/966a3646ff6651bd79f9d65cc5ab72ce to your computer and use it in GitHub Desktop.
Save davewalter/966a3646ff6651bd79f9d65cc5ab72ce to your computer and use it in GitHub Desktop.
CI Pipeline for the CF Summit NA 2020 CF-for-K8s Lab Cluster Management
---
groups:
- name: all
jobs:
- create-all
#@ for i in range(1,81):
- #@ "create-cluster-{}".format(i)
#@ end
- destroy-all
#@ for i in range(1,81):
- #@ "destroy-cluster-{}".format(i)
#@ end
#@ for i in range(1,81):
- name: #@ i
jobs:
- #@ "create-cluster-{}".format(i)
- #@ "destroy-cluster-{}".format(i)
#@ end
resource_types:
- name: terraform
type: docker-image
source:
repository: ljfranklin/terraform-resource
resources:
- name: terraform
type: terraform
source:
backend_type: gcs
backend_config:
bucket: cluster-state
prefix: cf-summit-na-2020
credentials: ...
- name: cf-for-k8s-gke-terraform-templates
type: git
source:
uri: git@github.com:cloudfoundry/cf-for-k8s
branch: develop
private_key: ...
paths:
- deploy/gke/terraform/**
jobs:
- name: create-all
plan:
- get: cf-for-k8s-gke-terraform-templates
- name: destroy-all
plan:
- get: cf-for-k8s-gke-terraform-templates
passed:
#@ for i in range(1,81):
- #@ "create-cluster-{}".format(i)
#@ end
#@ for i in range(1,81):
- name: #@ "create-cluster-{}".format(i)
serial_groups:
- #@ "block{}".format(i%5)
plan:
- get: cf-for-k8s-gke-terraform-templates
passed:
- create-all
trigger: true
- task: create-tf-vars-file
config:
platform: linux
image_resource:
type: docker-image
source: {repository: relintdockerhubpushbot/cf-deployment-concourse-tasks}
outputs:
- name: tf-vars
params:
CLUSTER_NAME: #@ "lab-{}".format(i)
NETWORK_NAME: #@ "cf-for-k8s-lab-{}".format(1+i%5)
SERVICE_ACCOUNT_JSON: ...
#@ if i % 2 == 0:
#@ zone = "us-central1-a"
#@ else:
#@ zone = "us-central1-c"
#@ end
ZONE: #@ zone
run:
path: /bin/bash
args:
- -ec
- |
echo "${CLUSTER_NAME}" > tf-vars/env_name.txt
cat <<EOT > tf-vars/input.tfvars
project = "summit-labs"
region = "us-central1"
zone = "${ZONE}"
service_account_key = "$(echo ${SERVICE_ACCOUNT_JSON} | jq -c '.' | sed -e 's#"#\\"#g' -e 's#\\n#\\\\n#g')"
env_name = "$(cat tf-vars/env_name.txt)"
env_dns_domain = "$(cat tf-vars/env_name.txt).cf-for-k8s-labs.com"
dns_zone_name = "cf-for-k8s-labs-com"
network_name = "${NETWORK_NAME}"
subnet_name = "${NETWORK_NAME}"
node_count = 3
EOT
- put: terraform
params:
terraform_source: cf-for-k8s-gke-terraform-templates/deploy/gke/terraform
env_name_file: tf-vars/env_name.txt
delete_on_failure: true
var_files:
- tf-vars/input.tfvars
- name: #@ "destroy-cluster-{}".format(i)
serial_groups:
- #@ "block{}".format(i%5)
plan:
- get: cf-for-k8s-gke-terraform-templates
passed:
- destroy-all
trigger: true
- task: create-tf-vars-file
config:
platform: linux
image_resource:
type: docker-image
source: {repository: relintdockerhubpushbot/cf-deployment-concourse-tasks}
outputs:
- name: tf-vars
params:
CLUSTER_NAME: #@ "lab-{}".format(i)
NETWORK_NAME: #@ "cf-for-k8s-lab-{}".format(1+i%5)
SERVICE_ACCOUNT_JSON: ...
#@ if i % 2 == 0:
#@ zone = "us-central1-a"
#@ else:
#@ zone = "us-central1-c"
#@ end
ZONE: #@ zone
run:
path: /bin/bash
args:
- -ec
- |
echo "${CLUSTER_NAME}" > tf-vars/env_name.txt
cat <<EOT > tf-vars/input.tfvars
project = "summit-labs"
region = "us-central1"
zone = "${ZONE}"
service_account_key = "$(echo ${SERVICE_ACCOUNT_JSON} | jq -c '.' | sed -e 's#"#\\"#g' -e 's#\\n#\\\\n#g')"
env_name = "$(cat tf-vars/env_name.txt)"
env_dns_domain = "$(cat tf-vars/env_name.txt).cf-for-k8s-labs.com"
dns_zone_name = "cf-for-k8s-labs-com"
network_name = "${NETWORK_NAME}"
subnet_name = "${NETWORK_NAME}"
node_count = 3
EOT
- put: terraform
params:
terraform_source: cf-for-k8s-gke-terraform-templates/deploy/gke/terraform
env_name_file: tf-vars/env_name.txt
action: destroy
var_files:
- tf-vars/input.tfvars
get_params:
action: destroy
#@ end
ytt -f ci/templates/cf-summit-na-2020-lab-clusters.yml > ci/pipelines/cf-summit-na-2020-lab-clusters.yml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment