Variable substitution in the new kubernetes kustomize support (since 1.14.0): kubectl apply -k ./
You have to create a kustomization.yaml
file containing the customizations.
i.e:
# kustomization.yamlbases:- ../baseimages: - name: nginx-pod newTag: 1.15 newName: nginx-pod-2
And for the templates, you create a base folder containing the kustomization.yaml with reference to the deployment and dependencies, i.e:
# ../base/kustomization.yamlresources:- deployment.yaml
and
# ../base/deployment.yamlapiVersion: apps/v1kind: Deploymentmetadata: name: nginx-deployment labels: app: nginxspec: selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx-pod
Run the command:
kubectl apply -k
The above command will compile the customization and generate the following yaml to be applied to the cluster:
# Modified Base ResourceapiVersion: apps/v1kind: Deploymentmetadata: labels: app: nginx name: nginx-deploymentspec: selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: # The image image tag has been changed for the container - name: nginx image: nginx-pod-2:1.15