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 command #6284

Closed
fgrzadkowski opened this issue Apr 1, 2015 · 25 comments
Closed

kubectl diff command #6284

fgrzadkowski opened this issue Apr 1, 2015 · 25 comments
Labels
area/app-lifecycle area/kubectl help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/feature Categorizes issue or PR as related to a new feature. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. priority/backlog Higher priority than priority/awaiting-more-evidence. sig/cli Categorizes an issue or PR as relevant to SIG CLI.

Comments

@fgrzadkowski
Copy link
Contributor

It'd be great if user could diff current configuration with the one in a file. I imagine output to be a regular smart diff of JSON files (ignoring version, status etc).

@fgrzadkowski fgrzadkowski added priority/backlog Higher priority than priority/awaiting-more-evidence. area/kubectl sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. labels Apr 1, 2015
@bgrant0607 bgrant0607 added priority/awaiting-more-evidence Lowest priority. Possibly useful, but not yet enough support to actually get it done. and removed priority/backlog Higher priority than priority/awaiting-more-evidence. labels Apr 2, 2015
@kbeecher
Copy link
Contributor

I take it you mean something like this?

$ kubectl diff service my-service my-service.json

And that would output, for example:

{
   "kind":"Service",
   "apiVersion":"v1beta3",
   "metadata":{
      "name":"redis-master",
      "labels":{
         "name":"redis-master"
      }
   },
   "spec":{
      "ports": [
        {
-          "port":6379,
+          "port":6380
        }
      ],
      "selector":{
         "name":"redis-master"
      }
   }
}

Of course, this should work with YAML too.

kbeecher pushed a commit to endocode/kubernetes that referenced this issue May 22, 2015
Analyses the current configuration of a resource and a configuration
file, producing a diff as a result.

Refs: kubernetes#6284
kbeecher pushed a commit to endocode/kubernetes that referenced this issue May 22, 2015
Analyses the current configuration of a resource and a configuration
file, producing a diff as a result.

Refs: kubernetes#6284
@bgrant0607 bgrant0607 added priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. area/app-lifecycle and removed priority/awaiting-more-evidence Lowest priority. Possibly useful, but not yet enough support to actually get it done. labels Jun 25, 2015
@bgrant0607 bgrant0607 added this to the v1.0 milestone Jun 25, 2015
@bgrant0607
Copy link
Member

cc @jackgr

@bgrant0607
Copy link
Member

diff is a building block needed for configuration reconciliation (#1702), so I'd like to get this in.

@mikedanese
Copy link
Member

Assigning to @jlowdermilk as he has the PR assigned to him.

@goltermann goltermann added priority/backlog Higher priority than priority/awaiting-more-evidence. and removed priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. labels Jun 30, 2015
@bgrant0607 bgrant0607 modified the milestones: v1.0-post, v1.0 Jul 6, 2015
@bgrant0607 bgrant0607 removed this from the v1.0-post milestone Jul 24, 2015
@bgrant0607 bgrant0607 added team/ux and removed sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. labels Aug 4, 2015
@bgrant0607 bgrant0607 added this to the v1.1 milestone Aug 4, 2015
@bgrant0607
Copy link
Member

@arashbina
Copy link

I like to contribute and looking for a task to start. Not sure if @krmayankk is working on this but if no one has taken this on I can work on it.

@janetkuo
Copy link
Member

@fraenkel has a PR #31892 addressing this with kubectl apply --dry-run, instead of kubectl diff.

@janetkuo
Copy link
Member

I like to contribute and looking for a task to start.

@arashbina Not sure if you already know about this -- we have the kubectl roadmap here: https://github.com/kubernetes/community/wiki/Roadmap:-kubectl

@arashbina
Copy link

@janetkuo I didn't know about the roadmap. Thanks. I'll check it out.

@neelance
Copy link

@janetkuo Is this still planned? I would like to see if a kubectl apply would actually change something or not, to determine if the cluster state is actually in sync with the files describing the resources.

As far as I can see, #31892 would have added that feature, but it got superseded by #31892 which also adds --dry-run, but without the "diff" functionality.

@k8s-github-robot
Copy link

@fgrzadkowski There are no sig labels on this issue. Please add a sig label by:
(1) mentioning a sig: @kubernetes/sig-<team-name>-misc
(2) specifying the label manually: /sig <label>

Note: method (1) will trigger a notification to the team. You can find the team list here.

@k8s-github-robot k8s-github-robot added the needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. label May 31, 2017
@fgrzadkowski fgrzadkowski added the sig/cli Categorizes an issue or PR as relevant to SIG CLI. label Jun 2, 2017
@fgrzadkowski
Copy link
Contributor Author

@kubernetes/sig-cli-feature-requests

@k8s-github-robot k8s-github-robot removed the needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. label Jun 2, 2017
@shiywang
Copy link
Contributor

shiywang commented Jun 2, 2017

@fgrzadkowski I'm working on a new command kubectl apply diff-last-applied here #46560, I think part of the code could be reuse (but it's using an external diff tool to do that job), is there any one already taken this yet ? if not, I would like to do that

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

Prevent issues from auto-closing with an /lifecycle frozen comment.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or @fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Dec 30, 2017
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten
/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Jan 29, 2018
@janetkuo
Copy link
Member

kubectl diff has been implemented as an alpha release in 1.9. Feature tracking issue: kubernetes/enhancements#491

@gjcarneiro
Copy link

gjcarneiro commented Dec 4, 2018

There is no documentation about what the exit status of the command means.

It seem that the exit status is 0 if there are no changes and 1 if there are changes. But without explicit documentation I am afraid to rely on this undocumented behaviour and it breaking in the future.

@cmrust
Copy link

cmrust commented Feb 26, 2019

@gjcarneiro I agree that this behavior should be documented (and tested if it isn't already), but I'd like to point out that this is how the linux diff cli tool works as well and I imagine this was implemented this way purposefully and is likely safe to rely upon.

@apelisse
Copy link
Member

@gjcarneiro I agree that this behavior should be documented (and tested if it isn't already), but I'd like to point out that this is how the linux diff cli tool works as well and I imagine this was implemented this way purposefully and is likely safe to rely upon.

Correct, but we still should document that none-the-less. Thanks for the interest.

@praseodym
Copy link
Contributor

kubernetes/kubectl#707 was created to improve the exit code behaviour, hopefully this will result in some documentation as well.

@apelisse
Copy link
Member

/wg apply

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/app-lifecycle area/kubectl help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/feature Categorizes issue or PR as related to a new feature. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. priority/backlog Higher priority than priority/awaiting-more-evidence. sig/cli Categorizes an issue or PR as relevant to SIG CLI.
Projects
None yet
Development

Successfully merging a pull request may close this issue.