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

Add the kubectl apply command #14621

Merged
merged 2 commits into from
Oct 8, 2015
Merged

Conversation

jackgr
Copy link
Contributor

@jackgr jackgr commented Sep 27, 2015

This pull request adds the kubectl apply command. It does not yet create configuration annotations automatically when configuration is updated through other code paths. However, it does create them when it applies new configurations, so two or more invocations of kubectl apply will bootstrap them.

The next and final step in implementing #1702 will be automatically creating configuration annotations when configuration is updated through other code paths.

@jackgr
Copy link
Contributor Author

jackgr commented Sep 27, 2015

Note that this pull request depends on and by necessity includes #13820, which adds the method to create the three way merge patch used by kubectl apply. When #13820 is merged, the diff for this pull request will be significantly smaller.

@k8s-bot
Copy link

k8s-bot commented Sep 27, 2015

Unit, integration and GCE e2e test build/test passed for commit 9aa318241bf6d701114b25d9d49462f363ffcba6.

@k8s-github-robot k8s-github-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Sep 27, 2015
@k8s-github-robot
Copy link

Labelling this PR as size/XXL

@jackgr
Copy link
Contributor Author

jackgr commented Sep 27, 2015

cc @bgrant0607, @ghodss, @mikedanese

@k8s-bot
Copy link

k8s-bot commented Sep 27, 2015

Unit, integration and GCE e2e build/test failed for commit 91adc9bcfb77484be336c9efaea473a8c8baf982.

@bgrant0607
Copy link
Member

cc @kubernetes/kubectl

@bgrant0607 bgrant0607 assigned ghodss and unassigned thockin Sep 27, 2015

# Apply the JSON passed into stdin to a pod.
$ cat pod.json | kubectl apply -f -`
apply_annotation = "k8s-kubectl-apply"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/kubernetes/kubernetes/blob/master/docs/devel/api-conventions.md#label-selector-and-annotation-conventions

Use something like kubectl.kubernetes.io/config

See also the annotations used by rolling update:
https://github.com/kubernetes/kubernetes/blob/master/pkg/kubectl/rolling_updater.go#L38

const kubectlAnnotationPrefix = "kubectl.kubernetes.io/"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@bgrant0607
Copy link
Member

Will need an e2e test.

@k8s-bot
Copy link

k8s-bot commented Sep 28, 2015

Unit, integration and GCE e2e test build/test passed for commit e4053d297cc440d439242e7cf07ab550fa5b5226.

@jackgr jackgr force-pushed the kubectl_apply branch 2 times, most recently from 5f2c43f to 1b50c05 Compare September 28, 2015 23:25
@k8s-bot
Copy link

k8s-bot commented Sep 28, 2015

Unit, integration and GCE e2e build/test failed for commit 1b50c0538170e52af97404ad773b4b132e80296d.

@k8s-bot
Copy link

k8s-bot commented Sep 29, 2015

Unit, integration and GCE e2e test build/test passed for commit 5f2c43fc85f0bcad352145c7541fabe253ea778b.

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 30, 2015
@k8s-bot
Copy link

k8s-bot commented Sep 30, 2015

Unit, integration and GCE e2e test build/test passed for commit 31c8d47b1fbb515828ac0d4e4327d3470a6a9250.

@jackgr jackgr force-pushed the kubectl_apply branch 2 times, most recently from 62e6c7f to e1914c4 Compare October 1, 2015 00:04
@k8s-bot
Copy link

k8s-bot commented Oct 1, 2015

Unit, integration and GCE e2e build/test failed for commit 62e6c7f2c9c6af97a8761d180b9449e9269d7aaf.

@k8s-bot
Copy link

k8s-bot commented Oct 1, 2015

Unit, integration and GCE e2e build/test failed for commit e1914c4a57fd45ee00cc32a87436ae3c42613735.

@j3ffml j3ffml self-assigned this Oct 2, 2015
@jackgr jackgr force-pushed the kubectl_apply branch 3 times, most recently from 3984e41 to c651fdf Compare October 2, 2015 22:44
@jackgr
Copy link
Contributor Author

jackgr commented Oct 2, 2015

@jlowdermilk Done. PTAL.

@k8s-bot
Copy link

k8s-bot commented Oct 2, 2015

Unit, integration and GCE e2e test build/test passed for commit aa686d31c19642844d29bb59cdefa8e70246761e.

@k8s-bot
Copy link

k8s-bot commented Oct 2, 2015

Unit, integration and GCE e2e test build/test passed for commit 3984e416c1d1f875199e56423b9afad32be337a0.

NamespaceParam(cmdNamespace).DefaultNamespace().
FilenameParam(enforceNamespace, options.Filenames...).
Flatten().
Latest().
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove Latest() here. The reason is that the resource builder will overwrite info.Object when you call Visit with the latest version from server. You want to save/serialize the object as loaded from file before you get the latest version of the object in order to do a 3-way patch. See suggested changes below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code works correctly as currently written. Without Latest(), it did not fetch from the server. With Latest(), it does, but does not overwrite the Versioned Object, which is what we use to diff against the annotation. I'd like to better understand what you're asking for before changing anything.

@k8s-bot
Copy link

k8s-bot commented Oct 2, 2015

Unit, integration and GCE e2e test build/test passed for commit c651fdf92b0d3c08fa811086b6e568f67e5e63d0.

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 5, 2015
@k8s-bot
Copy link

k8s-bot commented Oct 7, 2015

GCE e2e build/test failed for commit 64a4f6430a35653a053602c8a1783f23c4a05105.

@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 7, 2015
@jackgr
Copy link
Contributor Author

jackgr commented Oct 7, 2015

Not sure how, but the edits I made yesterday got lost during the rebase. Restored them and resubmitted.

cc @jlowdermilk

@j3ffml
Copy link
Contributor

j3ffml commented Oct 7, 2015

lgtm

@j3ffml j3ffml added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 7, 2015
@k8s-bot
Copy link

k8s-bot commented Oct 7, 2015

GCE e2e test build/test passed for commit 413104f05c1190a39011453d96da828d440f53e8.

@k8s-bot
Copy link

k8s-bot commented Oct 8, 2015

GCE e2e test build/test passed for commit 703a3e1.

@piosz
Copy link
Member

piosz commented Oct 8, 2015

Removing LGTM because there was a change after LGTM was granted. @jlowdermilk could you please take a look?

@piosz piosz removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 8, 2015
@j3ffml j3ffml added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 8, 2015
roberthbailey added a commit that referenced this pull request Oct 8, 2015
Add the kubectl apply command
@roberthbailey roberthbailey merged commit 49d6c86 into kubernetes:master Oct 8, 2015
@jackgr jackgr deleted the kubectl_apply branch October 26, 2015 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants