Search code examples
kubectlkustomize

Can we use k8s kustomize with kubectl to set image and create secret file?


I am using k8s kustomize to set the image and create a secret file

$(cd ./k8s/overlays/prod && kustomize edit set image gcr.io/PROJECT_ID/image:1.0)

and this works!

Now I am trying to use the kubectl kustomize to do the same without doing the cd . ./k8s/overlays/prod

Is it possible with the Kustomize plugin build into kubectl?

also same for the kustomize edit add secret with kubectl without doing the cd into directory?


Solution

  • Unfortunately this is not possible. The kubectl's built-in kustomize command only supports patching and applying kustomize files.

    I recommend using the standalone version of the kustomize since kubectl uses kustomize version 2.0.4, while the newest is already 3.8.8. Using the older version will break some of the functionalities.

    There are many requests to support newer version inside kubectl but there are some technical reasons which hold this from being done. You can track the progress here.