Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can kubectl delete environment variable?

Here I can update the envs through kubectl patch, then is there any method that can delete envs except re-deploy a deployment.yaml?

$ kubectl patch deployment demo-deployment -p '{"spec":{"template":{"spec":{"containers":[{"name": "demo-deployment","env":[{"name":"foo","value":"bar"}]}]}}}}'
deployment.extensions "demo-deployment" patched

Can I delete the env "foo" through command line not using a re-deploy on the whole deployment?

like image 519
Kaii Chu Avatar asked Jan 09 '20 03:01

Kaii Chu


People also ask

How does Kubernetes store environment variables?

There are two ways to define environment variables with Kubernetes: by setting them directly in a configuration file, from an external configuration file, using variables, or a secrets file. This tutorial shows both options, and uses the Humanitec getting started application used in previous tutorials.


1 Answers

This is coming late but for newcomers, you can use the following kubectl command to remove an existing env variable from a deployment

kubectl set env deployment/DEPLOYMENT_NAME  VARIABLE_NAME-

Do not omit the hyphen (-) at the end

like image 100
Ikechukwu Kalu Avatar answered Nov 15 '22 09:11

Ikechukwu Kalu