We are using kustomize for our kubernetes deployments in this way:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:${IMAGE_VERSION}
ports:
- containerPort: 80
and deploy this yaml substituting the variable IMAGE_VERSION with 1.7.9
kustomize build ./nginx/overlays/dev/ | sed -e 's|${IMAGE_VERSION}'"|1.7.9|g" | kubectl apply -f -
Since kubectl 1.14 supports kustomize.
now we can do something very nice like this
kubectl apply -k ./
but how to substitute the IMAGE_VERSION variable with this new command?