Skip to content

kubectl diff does apply #89762

Closed
Closed
@Djabx

Description

What happened:

kubectl diff modify my deployements.

What you expected to happen:

I expect the diff command to not change my deployments !

How to reproduce it (as minimally and precisely as possible):

Here is what I've done

  1. Create a simple pod test.yaml
apiVersion: v1
kind: Pod
metadata:
  name: myapp-pod
  labels:
    app: myapp
spec:
  containers:
  - name: myapp-container
    image: bash:5.0.11
    command: ['bash', '-c', 'bash --version && sleep 3600']

kubectl apply -f test.yaml

$ kubectl logs myapp-pod
GNU bash, version 5.0.11(1)-release (x86_64-pc-linux-musl)
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
  1. Modify the pod
apiVersion: v1
kind: Pod
metadata:
  name: myapp-pod
  labels:
    app: myapp
spec:
  containers:
  - name: myapp-container
    image: bash:5.0.16
    command: ['bash', '-c', 'bash --version && sleep 3600']
  1. Make a diff: kubectl diff -f test.yaml
iff -u -N /tmp/LIVE-275879232/v1.Pod.default.myapp-pod /tmp/MERGED-622230431/v1.Pod.default.myapp-pod
--- /tmp/LIVE-275879232/v1.Pod.default.myapp-pod	2020-04-02 12:43:39.678749329 +0200
+++ /tmp/MERGED-622230431/v1.Pod.default.myapp-pod	2020-04-02 12:43:39.778748987 +0200
@@ -11,7 +11,7 @@
     app: myapp
   name: myapp-pod
   namespace: default
-  resourceVersion: "10692283"
+  resourceVersion: "10692424"
   selfLink: /api/v1/namespaces/default/pods/myapp-pod
   uid: 6cbb52a5-0adc-40ad-b435-0f41a037c183
 spec:
@@ -20,7 +20,7 @@
     - bash
     - -c
     - bash --version && sleep 3600
-    image: bash:5.0.11
+    image: bash:5.0.16
     imagePullPolicy: IfNotPresent
     name: myapp-container
     resources:
  1. See what appends...
$ k describe pod myapp-pod
[...]
Containers:
  myapp-container:
    Container ID:  docker://3e4404eaa46dd07b8157fef0259520ab93e3aaf3b3c3dea47195b115463c89bb
    Image:         bash:5.0.16
    Image ID:      docker-pullable://bash@sha256:febb3d74f41f2405fe21b7c7b47ca1aee0eda0a3ffb5483ebe3423639d30d631
[...]

Anything else we need to know?:

Environment:

  • Kubernetes version (use kubectl version): v1.18.0 (commit 9e99141)
  • Cloud provider or hardware configuration: gke v1.15.9-gke.26
  • OS (e.g: cat /etc/os-release): Alpine Linux v3.11.5
  • Kernel (e.g. uname -a): Linux myapp-pod 4.14.138+
  • Install tools:
  • Network plugin and version (if this is a network-related bug):
  • Others:

Metadata

Assignees

Labels

kind/bugCategorizes issue or PR as related to a bug.sig/cliCategorizes an issue or PR as relevant to SIG CLI.wg/api-expressionCategorizes an issue or PR as relevant to WG API Expression.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions