Warning on kubectl create then apply

5,916 views
Skip to first unread message

Ahmet Alp Balkan

unread,
Apr 13, 2017, 1:00:30 PM4/13/17
to kubernet...@googlegroups.com
It looks like when somebody creates something using "kubectl create -f", there's no command to update it the same way. When they use "kubectl apply", they get a warning:

$ kubectl create -f ns.yml
namespace "foo" created
$ kubectl apply -f ns.yml
Warning: kubectl apply should be used on resource created by either kubectl create --save-config or kubectl apply
namespace "foo" configured

I see adding this warning is previously discussed at #36620 and patched in #36672.

In many of the Kubernetes tutorials, users are instructed to do "kubectl create -f". Should there be a symmetrical command that lets them update the resource with -f and works well with "kubectl create -f"d resources? Currently, this is a source of confusion for beginners. Would setting --save-config to true by default solve this problem?

Ian Lewis

unread,
Apr 14, 2017, 5:07:43 AM4/14/17
to kubernet...@googlegroups.com
FWIW I can't think of why kubectl create -f should be any different from kubectl apply -f. I almost want to suggest that create should be an alias of apply. It might be worth while to understand the use case for using kubectl create --save-config=false. In what situation would someone want to do that? i.e. *not* save LastAppliedConfig?

--
You received this message because you are subscribed to the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-use...@googlegroups.com.
To post to this group, send email to kubernet...@googlegroups.com.
Visit this group at https://groups.google.com/group/kubernetes-users.
For more options, visit https://groups.google.com/d/optout.

Mengqi Yu

unread,
Apr 14, 2017, 2:14:49 PM4/14/17
to kubernet...@googlegroups.com

On Fri, Apr 14, 2017 at 2:07 AM, 'Ian Lewis' via Kubernetes user discussion and Q&A <kubernet...@googlegroups.com> wrote:
FWIW I can't think of why kubectl create -f should be any different from kubectl apply -f. I almost want to suggest that create should be an alias of apply. It might be worth while to understand the use case for using kubectl create --save-config=false. In what situation would someone want to do that? i.e. *not* save LastAppliedConfig?
On Fri, Apr 14, 2017 at 1:00 AM 'Ahmet Alp Balkan' via Kubernetes user discussion and Q&A <kubernetes-users@googlegroups.com> wrote:
It looks like when somebody creates something using "kubectl create -f", there's no command to update it the same way. When they use "kubectl apply", they get a warning:

$ kubectl create -f ns.yml
namespace "foo" created
$ kubectl apply -f ns.yml
Warning: kubectl apply should be used on resource created by either kubectl create --save-config or kubectl apply
namespace "foo" configured

I see adding this warning is previously discussed at #36620 and patched in #36672.

In many of the Kubernetes tutorials, users are instructed to do "kubectl create -f". Should there be a symmetrical command that lets them update the resource with -f and works well with "kubectl create -f"d resources? Currently, this is a source of confusion for beginners. Would setting --save-config to true by default solve this problem?

--
You received this message because you are subscribed to the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-users+unsubscribe@googlegroups.com.
To post to this group, send email to kubernetes-users@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-users+unsubscribe@googlegroups.com.
To post to this group, send email to kubernetes-users@googlegroups.com.

Ahmet Alp Balkan

unread,
Apr 17, 2017, 12:41:30 PM4/17/17
to kubernet...@googlegroups.com
Thanks for linking to the docs Mengqi. It looks like I was not aware of imperative management using configuration files. It looks like "kubectl replace" is the command accompanying to "kubectl create". In this case, it's by design. I assumed "kubectl create -f" is probably on its way to deprecation and kept for back-compat reasons, but it looks like there's a valid use case for it.

On Fri, Apr 14, 2017 at 11:14 AM, 'Mengqi Yu' via Kubernetes user discussion and Q&A <kubernet...@googlegroups.com> wrote:
Reply all
Reply to author
Forward
0 new messages