Need to get/set the env variables of deployment by using python client methods.
kubectl describe deploy command or client.read_namespaced_deployment() method doesn't return the env of container in the pods which belongs to deployment.
Can able to get/set the env using kubectl command in cli. Kubectl command to get the env variable:
[user101@centoshost ~]$ kubectl --v=6 exec deploy/hello-deploy -- printenv
I0810 17:03:32.582676 3630345 loader.go:374] Config loaded from file: /etc/kubernetes/admin.conf
I0810 17:03:32.604084 3630345 round_trippers.go:553] GET https://**.***.**.***:6443/apis/apps/v1/namespaces/default/deployments/hello-deploy 200 OK in 11 milliseconds
I0810 17:03:32.611606 3630345 round_trippers.go:553] GET https://**.***.**.***:6443/api/v1/namespaces/default/pods?labelSelector=app%3Dhello-world 200 OK in 5 milliseconds
I0810 17:03:32.614546 3630345 podcmd.go:88] Defaulting container name to hello-pod
I0810 17:03:32.642551 3630345 round_trippers.go:553] POST https://**.***.**.***:6443/api/v1/namespaces/default/pods/hello-deploy-7b4cf6b899-5wkgn/exec?command=printenv&container=hello-pod&stderr=true&stdout=true 101 Switching Protocols in 27 milliseconds
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=hello-deploy-7b4cf6b899-5wkgn
NODE_VERSION=19.4.0
YARN_VERSION=1.22.19
KUBERNETES_SERVICE_PORT=443
KUBERNETES_SERVICE_PORT_HTTPS=443
KUBERNETES_PORT=tcp://100.96.0.1:443
KUBERNETES_PORT_443_TCP=tcp://100.96.0.1:443
KUBERNETES_PORT_443_TCP_PROTO=tcp
KUBERNETES_PORT_443_TCP_PORT=443
KUBERNETES_PORT_443_TCP_ADDR=100.96.0.1
KUBERNETES_SERVICE_HOST=100.96.0.1
HOME=/root
Kubectl set command to update the env variable:
kubectl set env deploy/hello-deploy NEW_ENV_VAR="None"
In same way need python client method to perform the get/set operations for kuberenetes deployment.