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

kubectl diff should have an option to use kubectl replace instead of kubectl apply to generate the diff #1686

Closed
frankh opened this issue Dec 17, 2024 · 4 comments
Labels
kind/feature Categorizes issue or PR as related to a new feature. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.

Comments

@frankh
Copy link

frankh commented Dec 17, 2024

What would you like to be added:
A --replace flag or similar to make kubectl diff use kubectl replace over kubectl apply

Why is this needed:
currently there is no way to see fields that have been removed from a desired manifest in kubectl diff

for example, with live manifest:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: example-deployment
spec:
  template:
    spec:
      containers:
      - name: example-container
        image: example-image
        env:
        - name: THING
           value: blah

and desired.yaml:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: example-deployment
spec:
  template:
    spec:
      containers:
      - name: example-container
        image: example-image

kubectl diff -f desired.yaml will result in no diff

with --replace it would correctly show:

-        env:
-        - name: THING
-          value: blah
@frankh frankh added the kind/feature Categorizes issue or PR as related to a new feature. label Dec 17, 2024
@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Dec 17, 2024
@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.

@frankh
Copy link
Author

frankh commented Dec 17, 2024

the change to kubectl is very simple and i've made and tested it locally. Happy to make a PR but wanted to make sure there is appetite for this change first

@ardaguclu
Copy link
Member

apply command is always the recommended command (especially with --server-side flag) and I don't think, we'd want to invest time on a imperative command replace.
I'd recommend always using kubectl apply --server-side and while using diff command, again always using diff --server-side (this should print out the removed environment variable in your example).

/close

@k8s-ci-robot
Copy link
Contributor

@ardaguclu: Closing this issue.

In response to this:

apply command is always the recommended command (especially with --server-side flag) and I don't think, we'd want to invest time on a imperative command replace.
I'd recommend always using kubectl apply --server-side and while using diff command, again always using diff --server-side (this should print out the removed environment variable in your example).

/close

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/feature Categorizes issue or PR as related to a new feature. 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