Reputation: 59
I understand that I can do this:
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
images:
- name: myimage
newTag: newtag
resources:
- deployment.yaml
But what I thought would be possible would be to do this:
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
configurations:
- images.yaml
resources:
- deployment.yaml
Where images.yaml
is:
images:
- name: myimage
newTag: newtag
When I use "images" directly in kustomization.yaml
, it works. However, when I reference the images.yaml
file using the configuration:
feature, it does nothing. According to the Kustomize documentation, that should be possible though:
configurations configurations is used to configure the built-in Kustomize Transformers to work with CRDs. The built-in Kustomize configurations can be found here
Examples:
images that should be updated by the images Transformer object
What am I doing wrong?
Upvotes: 1
Views: 658
Reputation: 11
You can use Component
to achieve something similar to what you originally sought out to do. Provide a directory images
with the following kustomization.yaml
inside:
apiVersion: kustomize.config.k8s.io/v1alpha1
kind: Component
images:
- name: myimage
newTag: newtag
then in your original kustomization file specify this component:
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
components:
- images
resources:
- deployment.yaml
See the Component demo documentation for a more fleshed-out example.
Upvotes: 1
Reputation: 312390
However, when I reference the images.yaml file using the configuration: features
You have misunderstood the purpose of the configurations
directive. This is used to provide configuration for the transformers. For example, in the case of the image transformer, you can use a configuration
to describe where in a manifest to find image references. This is important when using CRDs. Consider, for example, this hypothetical resource:
apiVersion: mycustomapi/v1
kind: Example
metadata:
name: example
spec:
image: example
Kustomize has not way of knowing that spec.image
is an image reference that should be modified by the image transformer. If we were to use a kustomization.yaml
like this:
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- example.yaml
images:
- name: example
newName: docker.io/traefik/whoami
newTag: latest
Running kustomize build
would simply output the original example.yaml
manifest without any changes. We would use the configurations
directive and associated configuration file to tell kustomize about this image reference.
If we put the following in images.yaml
:
images:
- path: spec/image
kind: Example
And modify our kustomization.yaml
so that it looks like this:
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- example.yaml
configurations:
- images.yaml
images:
- name: example
newName: docker.io/traefik/whoami
newTag: latest
Then running kustomize build
will produce:
apiVersion: mycustomapi/v1
kind: Example
metadata:
name: example
spec:
image: docker.io/traefik/whoami:latest
This is covered more fully here.
It should be pointed out I am trying to apply these changes with argocd. Does Argocd not support this?
ArgoCD is simply calling kustomize
. If it's supported by kustomize, it will work with argocd. It's important that you're using the same version of kustomize that argocd is using when you're testing things locally -- this avoids surprises if you're using syntax or features that aren't available in your argocd environment.
Upvotes: 2