Skip to content

Commit

Permalink
bump kustomize version and add as a docker arg
Browse files Browse the repository at this point in the history
stop wget printing progress logs

add version, directory, and tag substitutions to cloudbuild.yaml

add sample trigger for kustomize

update kustomize readme with samples for substitutions

Signed-off-by: afirth <[email protected]>
  • Loading branch information
afirth committed Aug 27, 2020
1 parent da89cfe commit d447232
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 7 deletions.
6 changes: 4 additions & 2 deletions kustomize/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
FROM gcr.io/cloud-builders/gcloud

ENV VERSION v3.6.1
# overridden in cloudbuild.yaml
ARG VER=v3.8.1
ENV VERSION ${VER}

COPY kustomize.bash /builder/kustomize.bash

RUN apt-get update && \
apt-get install -y wget && \
wget https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2F${VERSION}/kustomize_${VERSION}_linux_amd64.tar.gz && \
wget -nv https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2F${VERSION}/kustomize_${VERSION}_linux_amd64.tar.gz && \
tar xvzf kustomize_${VERSION}_linux_amd64.tar.gz && \
mkdir /builder/kustomize && \
mv kustomize /builder/kustomize/kustomize && \
Expand Down
14 changes: 13 additions & 1 deletion kustomize/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ To apply the build yourself, you can use a custom entrypoint, e.g.
- '-c'
- |
gcloud container clusters get-credentials --zone "$$CLOUDSDK_COMPUTE_ZONE" "$$CLOUDSDK_CONTAINER_CLUSTER"
kustomize build "overlays/prod" | kubectl apply -f -
kustomize build "overlays/prod" | kubectl apply -f -
env:
- 'CLOUDSDK_COMPUTE_ZONE=us-west1'
- 'CLOUDSDK_CONTAINER_CLUSTER=tf-k8s'
Expand All @@ -72,3 +72,15 @@ To apply the build yourself, you can use a custom entrypoint, e.g.
To build this builder, run the following command in this directory.
$ gcloud builds submit . --config=cloudbuild.yaml
To build with another kustomize version, substitute the version into the submission, e.g.
$ gcloud builds submit . --config=cloudbuild.yaml --substitutions=_KUSTOMIZE_VERSION=v3.5.4
To trigger an image build from a fork of this repository, configure your cloudbuild trigger with the substituiton
```
_BUILD_DIRECTORY=kustomize
```

See sample-trigger.yaml
27 changes: 23 additions & 4 deletions kustomize/cloudbuild.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
steps:
- name: "gcr.io/cloud-builders/docker"
args: ["build", "--tag=gcr.io/$PROJECT_ID/kustomize", "."]
dir: ${_BUILD_DIRECTORY}
args:
- build
- --build-arg
- VER=${_KUSTOMIZE_VERSION}
- --tag=gcr.io/$PROJECT_ID/kustomize:${_LATEST_TAG}
- --tag=gcr.io/$PROJECT_ID/kustomize:${_KUSTOMIZE_VERSION}
- .

- # Verify kustomize has been built correctly
name: "gcr.io/$PROJECT_ID/kustomize"
entrypoint: "kustomize"
args: ["version"]
args:
- version

images:
- gcr.io/$PROJECT_ID/kustomize:${_LATEST_TAG}
- gcr.io/$PROJECT_ID/kustomize:${_KUSTOMIZE_VERSION}

substitutions:
_BUILD_DIRECTORY: "./" #set to kustomize to run in a trigger
_KUSTOMIZE_VERSION: v3.8.1
_LATEST_TAG: latest

images: ["gcr.io/$PROJECT_ID/kustomize"]
tags: ["cloud-builders-community"]
tags:
- cloud-builders-community
- kustomize
13 changes: 13 additions & 0 deletions kustomize/sample-trigger.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# gcloud beta builds import --source=<filename>
description: 'Kustomize Image Build: Push to ^master$ branch'
filename: kustomize/cloudbuild.yaml
includedFiles:
- kustomize/*
name: kustomize-image-build
github:
name: cloud-builders-community
owner: <GITHUB_ORG> #TODO
push:
branch: ^master$
substitutions:
_BUILD_DIRECTORY: kustomize

0 comments on commit d447232

Please sign in to comment.