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
create command guidance #25130
create command guidance #25130
Conversation
|
||
`kubectl create <resource>` commands fill the gap between "I want to try kube, but I don't know or care what gets created" (`kubectl run`) and "I want to create exactly this" (author yaml and run `kubectl create -f`). | ||
They provide an easy way to create a valid object without having to know the vagaries of particular kinds, nested fields, and object key typos that are ignored by the yaml/json parser. | ||
Because editing an already created object is easier than authoring on from scratch, these commands only need to have enough parameters to create a valid object and should default as much as is reasonably possible. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/on/one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a field is not mutable post creation, it's reasonable that it should have a flag.
Are there examples where we have gone too far? Or is it you know when you see it? |
I don't know of any where we've gone overboard yet. I'd like to be sure that we all share a common vision of where we thing |
@@ -2,6 +2,7 @@ | |||
|
|||
- [v1.3.0-alpha.3](#v130-alpha3) | |||
- [Downloads](#downloads) | |||
- [v1.3.0-alpha.3](#v130-alpha3) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How did this happen?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How did this happen?
I ran hack/update-generated-docs.sh
which I thought I needed to do to update the munged TOC and this appeared. I assumed the script knew what it was doing. Should it come back out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Presumably backing it would break the verify script.
@david-mcmahon Could you PTAL?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That file was updated by hand for the last alpha release and there are some extra lines that the TOC generator is taking into account. I can send a separate PR or you can just remove the second occurrences of these lines in the file:
v1.3.0-alpha.3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@david-mcmahon I'm seeing this happening in other PRs, such as https://github.com/kubernetes/kubernetes/pull/25524/files#r63061933. Are you planning to send a PR to fix this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was fixed in 39c98a8
Once that valid object is created, it can be further manipulated using `kubectl edit` or the eventual `kubectl set` commands. | ||
|
||
`kubectl create <resource> <special-case>` commands help in cases where are two or more primary "forks" of a command that have different sets of logically required flags. | ||
`kubectl create secret` is a good example, there's a `generic` flavor with keys mapping to files, then there's a `docker-registry` flavor that is tailored for creating an image pull secret, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would characterize this as performing non-trivial configuration generation/transformation tailored for a common use case.
@@ -253,6 +254,18 @@ func (g *NamespaceGeneratorV1) validate() error { | |||
The generator struct (`NamespaceGeneratorV1`) holds the necessary fields for namespace generation. It also satisfies the `kubectl.StructuredGenerator` interface by implementing the `StructuredGenerate() (runtime.Object, error)` method which configures the generated namespace that callers of the generator (`kubectl create namespace` in our case) need to create. | |||
* `--dry-run` should output the resource that would be created, without creating it. | |||
|
|||
## Create commands |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest moving this to a sub-section under "Command conventions"
Re. going to far: |
Comments addressed. |
Looks correct to me. Overall, one of my concerns is to make sure that |
LGTM, but needs rebase |
GCE e2e build/test passed for commit 8e8e9cd. |
Automatic merge from submit-queue |
kubectl create <resource>
commands are multiplying (configmap, namespace, secret (2 flavors and a pull for a third), and serviceaccounts so far) and I think we should agree on the goal of those subcommands.Right now,
kubectl run
is an easy entrypoint for new users or users who don't really care which resources are created. It is possible to get stable output fromkubectl run
, but it really is intent-based: make this image go in some reasonable way. At the other end of the spectrum, you can craft yaml files by hand get exactly the object you want, but that requires pretty deep API knowledge. I think thatkubectl create <resource>
should be the starting point of the middle ground.kubectl create <resource>
commands should have just enough arguments to create valid objects and the expectation should be that users will use those objects as skeletons to tweak usingkubectl edit
or the futurekubectl set
to modify them after the fact. Editing an already existing and valid object is a lot easier than creating one from scratch, so it reduces the barrier to entry.@kubernetes/kubectl @smarterclayton @bgrant0607 @liggitt