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 apply --dry-run behaving weirdly #72644

Closed
ghost opened this issue Jan 7, 2019 · 5 comments
Closed

kubectl apply --dry-run behaving weirdly #72644

ghost opened this issue Jan 7, 2019 · 5 comments
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug. sig/cli Categorizes an issue or PR as relevant to SIG CLI.

Comments

@ghost
Copy link

ghost commented Jan 7, 2019

Having a random deployment yaml file:

Modifying for example the image or the number of replicas:

  • kubectl apply -f Deployment.yaml -o yaml --dry-run outputs me the resource with the OLD specifications

  • kubectl apply -f Deployment.yaml -o yaml outputs me the resource with the NEW specifications and updates it

Since according the documentation:

--dry-run=false: If true, only print the object that would be sent, without sending it.

I would have expected the dry-run command to print the very same yaml configuration and not the old one.

Tested on minikube, gke v1.10.0

https://stackoverflow.com/questions/54074758/kubectl-apply-dry-run-behaving-weirdly

@ghost ghost added the kind/bug Categorizes issue or PR as related to a bug. label Jan 7, 2019
@k8s-ci-robot k8s-ci-robot added the needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. label Jan 7, 2019
@ghost
Copy link
Author

ghost commented Jan 7, 2019

/sig apply
/sig apps

@k8s-ci-robot k8s-ci-robot added sig/apps Categorizes an issue or PR as relevant to SIG Apps. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Jan 7, 2019
@liggitt
Copy link
Member

liggitt commented Jan 7, 2019

/sig cli
/remove-sig apps

@k8s-ci-robot k8s-ci-robot added sig/cli Categorizes an issue or PR as relevant to SIG CLI. and removed sig/apps Categorizes an issue or PR as relevant to SIG Apps. labels Jan 7, 2019
@liggitt
Copy link
Member

liggitt commented Jan 7, 2019

cc @apelisse

@liggitt
Copy link
Member

liggitt commented Jan 7, 2019

When updating existing objects, kubectl apply doesn't send an entire object, just a patch. It is not exactly correct to print either the existing object or the new object in dry-run mode... the outcome of the merge is what should be printed.

For kubectl to be able to accurately reflect the result of the apply, it would need to have the server-side apply logic clientside, which is a non-goal.

Current efforts are directed at moving apply logic to the server. As part of that, the ability to dry-run server-side has been added. kubectl apply --server-dry-run will do what you want, printing the result of the apply merge, without actually persisting it.

@liggitt
Copy link
Member

liggitt commented Jan 7, 2019

@apelisse we should probably update the flag help for apply and possibly print a warning when using --dry-run when updating an object via apply to document the limitations of --dry-run and direct people to use --server-dry-run

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. sig/cli Categorizes an issue or PR as relevant to SIG CLI.
Projects
None yet
Development

No branches or pull requests

3 participants