Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deployment does not update when adding environment variables #26944

Closed
erez-rabih opened this issue Jun 7, 2016 · 19 comments
Closed

Deployment does not update when adding environment variables #26944

erez-rabih opened this issue Jun 7, 2016 · 19 comments

Comments

@erez-rabih
Copy link

Hi,

We're using deployments on Kubernetes version 1.2.1.

In order to update deployments we update the corresponding deployment.yml file and the run
kubectl apply -f deployment.yml

Everything works well most of the time except for the case in which we add an environment variable to one of the containers on the deployment.yml.

In that case we see that a new replica set is not created and the old pods keep on running.

@adohe-zz
Copy link

adohe-zz commented Jun 8, 2016

The same problem as #25585, and the fix landed #26418, @erez-rabih ptal.

@adohe-zz
Copy link

adohe-zz commented Jun 8, 2016

@bgrant0607 I am wondering whether we should create a cherry pick for 1.2, I have seen users ran into this bug several times.

@erez-rabih
Copy link
Author

@adohe I agree it looks like a duplicate of #25585. I'm closing this.

@bgrant0607
Copy link
Member

@adohe Yes, please create a cherrypick PR.

@danielloczi
Copy link

Hi! I'm facing the same issue now: adding a new env variable does not touch running pods, the new env varibale is not puplished down to the pods.

Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.2", GitCommit:"81753b10df112992bf51bbc2c2f85208aad78335", GitTreeState:"clean", BuildDate:"2018-04-27T09:22:21Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.2", GitCommit:"81753b10df112992bf51bbc2c2f85208aad78335", GitTreeState:"clean", BuildDate:"2018-04-27T09:10:24Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}

@adohe-zz
Copy link

@danielloczi I think this has already be fixed, could u please show how to reproduce this? I would take a look.

@bgrant0607
Copy link
Member

cc @apelisse

@danielloczi
Copy link

danielloczi commented Jun 13, 2018

Hi!

I have a set of environment variables configured for a deployment. The deployment is applied using kubectl apply -f deployment.yaml
After I edit the yaml file and add an extra env varibale, then apply it using the same command:
kubectl apply -f deployment.yaml
After that kubectl logs that the deployment is configured, but the pod not terminates, and the new env variable is not promoted to the pod level.

Example (original yaml):

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: vibe-backend-identityprovider-deployment
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: my-app
    spec:
      containers:
      - name: my-ctr
        image: localhost:5000/myimage
        ports:
        - containerPort: 5202
        env:
        - name: RepositoryUri
          value: "http://my-repo-service.default.svc.cluster.local:5203"
        - name: LogUri
          value: "http://my-messaging-service.default.svc.cluster.local:5201/log"

Edited yaml:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: vibe-backend-identityprovider-deployment
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: my-app
    spec:
      containers:
      - name: my-ctr
        image: localhost:5000/myimage
        ports:
        - containerPort: 5202
        env:
        - name: RepositoryUri
          value: "http://my-repo-service.default.svc.cluster.local:5203"
        - name: LogUri
          value: "http://my-messaging-service.default.svc.cluster.local:5201/log"
        - name: MyNewEnv
          value: "something"

@danielloczi
Copy link

Update: I tried to reproduce it a couple of minutes ago, but I was unable. I trying to find the case, when it does not work.

@zerthimon
Copy link

Got this now in 1.11 on a DaemonSet.

@DeRain
Copy link

DeRain commented Oct 11, 2018

Got this now in 1.11 on a DaemonSet.

Same for me

@peterromfeldhk
Copy link

also having the issue with DaemonSet

Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.11", GitCommit:"637c7e288581ee40ab4ca210618a89a555b6e7e9", GitTreeState:"clean", BuildDate:"2018-11-26T14:38:32Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"10+", GitVersion:"v1.10.13-eks-g484b8", GitCommit:"484b857e3134d55ac6373fea2f51798fefa0533f", GitTreeState:"clean", BuildDate:"2019-03-08T05:32:36Z", GoVersion:"go1.10.8", Compiler:"gc", Platform:"linux/amd64"}

@iahmad-khan
Copy link

why this issue is closed? on latest version of kubernetes i am facing the same issue.

updating the deployment.yaml with adding new env var , and then kubectl apply , is not updating the deployment/pod with new env var.

@apelisse
Copy link
Member

@iahmad-khan Would you mind coming-up with a minimal example that I would be able to build into a test or something?

@apelisse
Copy link
Member

apelisse commented Mar 11, 2021

I'd need to see:

  • The exact sequence of event,
  • How the object is impact on the server including the generation number.

@abheist
Copy link

abheist commented Jun 26, 2022

Any fixes, seems like, I'm running commands, not in the correct order.

I updated env-config and deleted deployment and pods and all the services and created again with apply, still not picking new configs

@apelisse
Copy link
Member

apelisse commented Jun 27, 2022

Can you show the steps here with a minimal example, the commands that you run and how the yaml looks like after each step?

@jun0tpyrc
Copy link

hitting this also sometimes, might be control plane &/ persistent problem

Once this occurs , it persists for me even i delete deployment & service to recreate both in following orders

  1. Create a deployment & service exposing it
    (set some vars not yet existed on the deployment)
  2. kubectl set env deploy/xxxxxx --containers=XXXX AAA=BBB
    3a)(check pods started &/ delete them to let replicaset recreate pods, see if vars exist )
    3b) [delete both deployment & service to further reproduce , still can't set]

@apelisse
Copy link
Member

OK Let's try to reproduce this:

$ kubectl create deployment --image nginx:latest nginx
deployment.apps/nginx created
$ kubectl set env deployment nginx --containers=nginx MY_ENV=1234
deployment.apps/nginx env updated
$ kubectl set env deployment nginx --containers=nginx MY_ENV_2=5678
deployment.apps/nginx env updated
$ kubectl get -o yaml deployment nginx | grep -A 5 env
      - env:
        - name: MY_ENV
          value: "1234"
        - name: MY_ENV_2
          value: "5678"
        image: nginx:latest
$ kubectl get pods nginx-7db6cbd99f-pwkxq -o yaml | grep -A 5 env 
  - env:
    - name: MY_ENV
      value: "1234"
    - name: MY_ENV_2
      value: "5678"
    image: nginx:latest

I still don't see what I should be looking at?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests