To build kubes as a Docker image entrypoint for Google CloudBuild Custom Builder.

git clone
cd kubes
gcloud builds submit --tag$GOOGLE_PROJECT/kubes

Be sure to set GOOGLE_PROJECT to your own project id.

Example Codebuild YAML


# Simply calling kubectl version with the CLOUDSDK_* vars will auth to the GKE cluster. Unsure why.
- name:
  args: ['version']
- name: '$PROJECT_ID/kubes'
  args: ["deploy"]
  - 'GOOGLE_PROJECT=$PROJECT_ID' # .kubes/config.rb: config.repo

  _GCP_REGION: us-central1
  _GKE_CLUSTER: dev-cluster
  _KUBES_ENV: dev
    substitution_option: 'ALLOW_LOOSE'

Make sure to replace the substitutions with your own values. IE: _GCP_REGION, _GKE_CLUSTER, _KUBES_ENV, etc.

Run CloudBuild

Run cloudbuild with:

gcloud builds submit --config cloudbuild.yaml

Example with output:

$ gcloud builds submit --config cloudbuild.yaml
Starting Step #1
Step #1: => docker build -t -f Dockerfile .
Step #1: Pushed docker image.
Step #1: Docker push took 2s.
Step #1: Compiled  .kubes/resources files to .kubes/output
Step #1: Deploying kubes resources
Step #1: => kubectl apply -f .kubes/output/shared/namespace.yaml
Step #1: namespace/demo unchanged
Step #1: => kubectl apply -f .kubes/output/web/service.yaml
Step #1: service/web unchanged
Step #1: => kubectl apply -f .kubes/output/web/deployment.yaml
Step #1: deployment.apps/web configured

Create Extra Environments

If you are using the with_extra helper, you can create additional environments of the same app like so:

gcloud builds submit --config cloudbuild.yaml --substitutions=_KUBES_EXTRA=2
gcloud builds submit --config cloudbuild.yaml --substitutions=_KUBES_EXTRA=3