Define a place to work:
DEMO_HOME=$(mktemp -d)
Make a kustomization
containing a pod resource
cat <<EOF >$DEMO_HOME/kustomization.yaml
resources:
- pod.yaml
EOF
Declare the pod resource
cat <<EOF >$DEMO_HOME/pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: myapp-pod
labels:
app: myapp
spec:
containers:
- name: myapp-container
image: busybox:1.29.0
command: ['sh', '-c', 'echo The app is running! && sleep 3600']
initContainers:
- name: init-mydb
image: busybox:1.29.0
command: ['sh', '-c', 'until nslookup mydb; do echo waiting for mydb; sleep 2; done;']
EOF
The myapp-pod
resource declares an initContainer and a container, both use the image busybox:1.29.0
.
The tag 1.29.0
can be changed by adding imageTags
in kustomization.yaml
.
Add imageTags
:
cd $DEMO_HOME
kustomize edit set imagetag busybox:1.29.1
The kustomization.yaml
will be added following imageTags
.
imageTags: - name: busybox newTag: 1.29.1
Now build this kustomization
kustomize build $DEMO_HOME
Confirm that this replaces both busybox tags:
test 2 == \
$(kustomize build $DEMO_HOME | grep busybox:1.29.1 | wc -l); \
echo $?