i have defined a kustomization.yaml in my CI/CD pipeline which will be updated by jenkins when a new build is done. The Update concerns the image tag of the builded and pushed image to the registry. It is working quite good unless the image tag starts with a number in the value.
In that case (starting number in the image tag value) the kustomize tool generates an error:
kubectl kustomize ./
error: invalid Kustomization: json: cannot unmarshal number into Go struct field Image.images.newTag of type string
Error example My kustomization.yaml contains in that case:
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../base/
replicas:
- name: demo-backend
count: 1
images:
- name: my-registry.domain.com/playground/demo-backend
newTag: 839548e8
If the newTag variable starts with a character it is working fine.
Working example My kustomization.yaml contains in that case:
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../base/
replicas:
- name: demo-backend
count: 1
images:
- name: my-registry.domain.com/playground/demo-backend
newTag: e8395488
What can i do to avoid this problem?
I have tried to reproduce succesfully the error. Found out, that the beginning of the value is the problem (number or character)
That's a regular "issue" not specific to Kustomize or even Yaml or Go: 839548e8
is actually a number. It's the notation of 839548 X 10^8
.
You need to enforce it is treated as a string for Kustomize. To do that, wrap it in quotes:
newTag: '839548e8'