Skip to content

KUBECTL_EXTERNAL_DIFF variable --ignore-matching-lines="image:.* does not take effect #1717

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

Closed
bertreyking opened this issue Feb 17, 2025 · 4 comments
Labels
kind/bug Categorizes issue or PR as related to a bug. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.

Comments

@bertreyking
Copy link

bertreyking commented Feb 17, 2025

What happened:

cat harbor-portal.yaml harbor-portal-2.yaml | grep image 
      - image: docker.io/goharbor/harbor-portal:v2.11.21
        imagePullPolicy: IfNotPresent
      - image: docker.io/goharbor/harbor-portal:v2.11.1
        imagePullPolicy: IfNotPresent

diff -y --ignore-matching-lines="image:.*"  --suppress-common-lines harbor-portal.yaml harbor-portal-2.yaml   # echo $? = 0 

export KUBECTL_EXTERNAL_DIFF='diff -y --ignore-matching-lines="image:.*" --width=180 --suppress-common-lines'
kubectl diff -f harbor-portal.yaml 
diff -y '--width=180' --suppress-common-lines /tmp/LIVE-2161628695/apps.v1.Deployment.default.harbor-portal /tmp/MERGED-828643458/apps.v1.Deployment.default.harbor-portal
  generation: 4                                                                       |   generation: 5
      - image: docker.io/goharbor/harbor-portal:v2.11.1                      |       - image: docker.io/goharbor/harbor-portal:v2.11.21

Normally, only the generation should be shown as different—unless I exclude it.

What you expected to happen:

expect the --ignore-matching-lines parameter to correctly match and exclude specified lines.

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

  1. kubectl get deployment $deployment_name -o yaml > deplyment-1.yaml
  2. kubectl get deployment $deployment_name -o yaml > deplyment-2.yaml
  3. modify the image tag version
  4. diff -y --ignore-matching-lines="image:.*" --suppress-common-lines deplyment-1.yaml deplyment-2.yaml # success
  5. export KUBECTL_EXTERNAL_DIFF='diff -y --ignore-matching-lines="image:.*" --width=180 --suppress-common-lines'
  6. kubectl diff -f deplyment-1.yaml # failed

Anything else we need to know?:
I am working in a CI/CD pipeline and need to compare YAML files in different Git commits to ensure they match the actual running resources, …except for the fields that should be ignored.

Environment:

  • Kubernetes client and server versions (use kubectl version): 1.29.5
  • Cloud provider or hardware configuration: none
  • OS (e.g: cat /etc/os-release): centos7
@bertreyking bertreyking added the kind/bug Categorizes issue or PR as related to a bug. label Feb 17, 2025
@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Feb 17, 2025
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

SIG CLI takes a lead on issue triage for this repo, but any Kubernetes member can accept issues by applying the triage/accepted label.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@bertreyking
Copy link
Author

  • diff.sh
#!/bin/bash
diff -y -B --width=180 --suppress-common-lines --ignore-matching-lines="image:.*" --ignore-matching-lines="generation:.*" $1 $2
  • export KUBECTL_EXTERNAL_DIFF='./diff.sh'
  • kubectl diff -f deplyment-1.yaml

it's ok

@mpuckett159
Copy link
Contributor

/close
A work around has been provided and if you would like more information please see this issue
#1436

@k8s-ci-robot
Copy link
Contributor

@mpuckett159: Closing this issue.

In response to this:

/close
A work around has been provided and if you would like more information please see this issue
#1436

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.
Projects
None yet
Development

No branches or pull requests

3 participants