Set k8s deployment env with kubectl

You can add new env or update existing env with kubectl set env command. Is the env is existed, the value will be updated, if not it will be created.

kubectl set env -n myns deployment/mydeployment MY_ENV=MYVALUE
deployment.apps/mydeploymen env updated
kubectl set env -n myns deployment/mydeployment --list |grep MY_ENV

If you set imagePullPolicy: Always you can force to fetch latest image withkubectl rollout restart deployment

kubectl  -n myns rollout restart deployment mydeployment

If you want to update image tag use the following command before rollout restart

kubectl -n myns set image deployment

Ismail Yenigul