question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Container changes in`Deployment` => "element [0] missing"

See original GitHub issue

Using this deployment.yaml:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: nginx
  namespace: test
spec:
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
        - name: nginx
          image: nginx
          ports:
            - containerPort: 80
              name: http
              protocol: TCP

If I change a field in the containers part, e.g. the containerPort, kubediff returns:

## test/nginx (Deployment)

.spec.template.spec.containers: 'element [0]' missing

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:14
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

13reactions
carlosdagoscommented, Jul 17, 2018

Getting the same issue. An update would be awesome. Thanks for kubediff!

3reactions
damienlegercommented, Feb 13, 2019

I’ve coded a workaround for this. It’s far from perfect because tests are broken and all but that fits my needs. Looks interesting to share anyway.

My understanding is that after the change https://github.com/weaveworks/kubediff/pull/31 every change in any deep after a list results in ‘element[X] missing’ issue we are talking about. Hence if you change the image of a container (the most likely on a daily change), you have this issue, making the tool quite useless imho. The change make sense in a way that if you remove or add element in a list from running or wished configuration, differences between elements get mixed up and you end up with an horrible diff output e.g.: you remove wished var1 then running var1 is diffed with wished var2, running var2 is diffed with wished var3 and so on… Luckily changes not happening much except for environment variable list.

I then did the following change. Reverted the old behavior for list having same size, and if not return ‘element missing’ except for .spec.template.spec.containers[X].env whish have a special treat.

Let’s say you running on this

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: nginx
  namespace: test
spec:
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
        - name: nginx
          image: nginx:1.14.1
          ports:
            - containerPort: 80
              name: http
              protocol: TCP
          env:
            - name: name1
              value: value1
            - name: name2
              value: value2
            - name: name3
              value: value3

and want this:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: nginx
  namespace: test
spec:
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
        - name: nginx
          image: nginx:1.14.2
          ports:
            - containerPort: 80
              name: http
              protocol: TCP
          env:
            - name: name1
              value: value1.1
            - name: name4
              value: value4

With my hack, kubediff output is:

## test/nginx (Deployment.v1beta1.extensions)

.spec.template.spec.containers[0].image: 'nginx:1.14.2' != 'nginx:1.14.1'
## test/nginx (Deployment.v1beta1.extensions)

.spec.template.spec.containers[0].env: Unequal lengths: 2 != 3
## test/nginx (Deployment.v1beta1.extensions)

.spec.template.spec.containers[0].env: Diff: name4 in wished config only
## test/nginx (Deployment.v1beta1.extensions)

.spec.template.spec.containers[0].env: Diff: name2 in running config only
## test/nginx (Deployment.v1beta1.extensions)

.spec.template.spec.containers[0].env: Diff: name3 in running config only
## test/nginx (Deployment.v1beta1.extensions)

.spec.template.spec.containers[0].env[0].value: 'value1.1' != 'value1'

Patch is attached. Edit kubedifflib/_diff.py and build container with build instructions in doc except “make .uptodate” instead of “make” to bypass tests. patch.txt

Read more comments on GitHub >

github_iconTop Results From Across the Web

Problem when deploying FlexiPages on Winter '22 org
This is a change on the ComponentInstance type. To fix it, add an identifier to your component instance:
Read more >
Quickstart: Troubleshoot ARM template JSON deployments
This quickstart describes how to troubleshoot Azure Resource Manager template (ARM template) JSON deployment errors.
Read more >
Missing protocol in container.port in Deployment template
port in Deployment template. The container. port here does not have a protocol value specified.
Read more >
Understanding Kubernetes pod pending problems - Sysdig
Once the pod is scheduled and the containers have started, the pod changes to the Running phase. Most of the pods only take...
Read more >
Update API Objects in Place Using kubectl patch - Kubernetes
The output shows that the Deployment has two Pods. The 1/1 indicates that each Pod has one container: NAME READY STATUS RESTARTS AGE ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found