When I want to generate yaml by running kubectl
, it denotes that I should denote --generator=something
flag within the command.
For example, to get the deployment template via kubectl
, I should run the below command:
kubectl run --generator=deployment/v1beta1 nginx --image=nginx --dry-run -o yaml
Without mentioning --generator
flag the CLI states in some kind that I should mention the generator flag with a proper value (e.g. run-pod/v1
).
My question is, what is essentially a generator? What does it do? Are they some sort of object creation templates or something else?
Kubectl apply dry-run does the necessary work by producing the outcome of the apply merge deprived of actually maintaining it. Perhaps we upgrade flag help, issue a notice if Dry-run is used when appraising items using Apply, document Dry-run's limits, and use server dry-run.
The key difference between kubectl apply and create is that apply creates Kubernetes objects through a declarative syntax, while the create command is imperative. The command set kubectl apply is used at a terminal's command-line window to create or modify Kubernetes resources defined in a manifest file.
You can use kubectl rollout to inspect a rollout as it occurs, to pause and resume a rollout, to rollback an update, and to view an object's rollout history.
flags : Specifies optional flags. For example, you can use the -s or --server flags to specify the address and port of the Kubernetes API server. Important: Flags that you specify from the command line override default values and any corresponding environment variables.
That was introduced in commit 426ef93, Jan. 2016 for Kubernetes v1.2.0-alpha.8.
The generators were described as:
Generators are
kubectl
commands that generate resources based on a set of inputs (other resources, flags, or a combination of both).The point of generators is:
- to enable users using
kubectl
in a scripted fashion to pin to a particular behavior which may change in the future.
Explicit use of a generator will always guarantee that the expected behavior stays the same.- to enable potential expansion of the generated resources for scenarios other than just creation, similar to how
-f
is supported for most general-purpose commands.
And:
Generator commands should obey to the following conventions:
- A
--generator
flag should be defined. Users then can choose between different generators, if the command supports them (for example,kubectl run
currently supports generators for pods, jobs, replication controllers, and deployments), or between different versions of a generator so that users depending on a specific behavior may pin to that version (for example,kubectl
expose currently supports two different versions of a service generator).- Generation should be decoupled from creation.
A generator should implement thekubectl.StructuredGenerator
interface and have no dependencies on cobra or the Factory
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With