Changing image tags and name with kustomization.yaml
Solution 1
You have to remove "-" in newName line under the images section. It should be like this, it is worked.
images:
- name: the-my-app
newName: my.docker.registry.com/my-project/my-app
newTag: test
Solution 2
You can run kustomize build my-kustomization-dir
to check if the image is replaced or not in the yaml file.This command lets you see what will be applied in your cluster.
Lennart Rolland
I work as a IT consultant for a small but capable consulting firm in Bergen, Norway. I also enjoy technology in my spare time. My latest project is http://octomy.org
Updated on June 04, 2022Comments
-
Lennart Rolland almost 2 years
According to the official documentation I should be able to easily override the tags and name of my docker images using some nifty
kustomization
syntax. I have tried to reproduce this.In my
deployment.yaml
I have the following:apiVersion: extensions/v1beta1 kind: Deployment metadata: labels: service: my-app name: my-app spec: strategy: type: Recreate template: metadata: labels: service: my-app spec: imagePullSecrets: - name: my-docker-secret containers: - name: my-app image: the-my-app imagePullPolicy: Always ports: - containerPort: 1234 restartPolicy: Always
In my
kustomization.yaml
I have the following:bases: - ../base resources: - deployment.yaml namespace: my-namespace images: - name: the-my-app - newName: my.docker.registry.com/my-project/my-app newTag: test
However, when I do this:
kubectl apply -k my-kustomization-dir
and wait for the deployment to spin up, and later do
kubectl describe pod/my-app-xxxxxxxxx-xxxxx
The events looks like this:
Events: Type Reason Age From Message ---- ------ ---- ---- ------- Successfully assigned my-namespace/my-app-xxxxxxxxxx-xxxxx to default-pool-xxxxxxxxxx-xxxxx Normal Pulling 2s kubelet, default-pool-xxxxxxxxxx-xxxxx pulling image "the-my-app" Warning Failed 0s kubelet, default-pool-xxxxxxxxxx-xxxxx Failed to pull image "the-my-app": rpc error: code = Unknown desc = Error response from daemon: pull access denied for the-my-app, repository does not exist or may require 'docker login' Warning Failed 0s kubelet, default-pool-xxxxxxxxxx-xxxxx Error: ErrImagePull Normal BackOff 0s kubelet, default-pool-xxxxxxxxxx-xxxxx Back-off pulling image "the-my-app" Warning Failed 0s kubelet, default-pool-xxxxxxxxxx-xxxxx Error: ImagePullBackOff
Indicating that this did not work as expected (it tries to pull the original name specified in
deployment.yaml
).So my question is, what am I doing wrong here?
-
Lennart Rolland about 4 yearsI discovered this just minutes after posting original question. Thanks!