Skip to content

Instantly share code, notes, and snippets.

@yusinto
Last active September 1, 2019 08:21
Show Gist options
  • Save yusinto/3922f40d0b8d0241b6c6ead1a9aa8f3f to your computer and use it in GitHub Desktop.
Save yusinto/3922f40d0b8d0241b6c6ead1a9aa8f3f to your computer and use it in GitHub Desktop.
Example container builder cloudbuild.yaml for GKE demo.
steps:
- name: ubuntu
id: generate-image-tag
entrypoint: bash
args:
- '-c'
- echo $(date) | md5sum | awk '{print $1}' > tag.txt
- name: gcr.io/cloud-builders/docker
id: docker-build-push
entrypoint: bash
args:
- '-c'
- |
tag=`cat tag.txt`
docker build -t "gcr.io/gke-playground/$BRANCH_NAME:$tag" .
docker push "gcr.io/gke-playground/$BRANCH_NAME:$tag"
- name: gcr.io/cloud-builders/kubectl
id: deploy-infrastructure
env: ['CLOUDSDK_COMPUTE_ZONE=australia-southeast1-a', 'CLOUDSDK_CONTAINER_CLUSTER=features']
entrypoint: bash
args:
- '-c'
- |
tag=`cat tag.txt`
sed -e "s|_BRANCH_NAME|$BRANCH_NAME|g" -e "s|_TAG|$tag|g" deployment-template.yaml | tee deployment.yaml
gcloud container clusters get-credentials --project="gke-playground" --zone="australia-southeast1-a" "features"
kubectl apply -f deployment.yaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment