From bd8267dbc0342b8358734b3a15350ca4771295a6 Mon Sep 17 00:00:00 2001 From: Marcin Niemira Date: Sun, 5 Apr 2020 23:59:19 +1000 Subject: [PATCH 1/7] rm informatio about generators from conventions --- .../en/docs/reference/kubectl/conventions.md | 37 ------------------- 1 file changed, 37 deletions(-) diff --git a/content/en/docs/reference/kubectl/conventions.md b/content/en/docs/reference/kubectl/conventions.md index bfa40b3be2..0d2ad983a2 100644 --- a/content/en/docs/reference/kubectl/conventions.md +++ b/content/en/docs/reference/kubectl/conventions.md @@ -28,46 +28,9 @@ For `kubectl run` to satisfy infrastructure as code: * Tag the image with a version-specific tag and don't move that tag to a new version. For example, use `:v1234`, `v1.2.3`, `r03062016-1-4`, rather than `:latest` (For more information, see [Best Practices for Configuration](/docs/concepts/configuration/overview/#container-images)). * Capture the parameters in a checked-in script, or at least use `--record` to annotate the created objects with the command line for an image that is lightly parameterized. -* Pin to a specific [generator](#generators) version, such as `kubectl run --generator=run-pod/v1`. * Check in the script for an image that is heavily parameterized. * Switch to configuration files checked into source control for features that are needed, but not expressible via `kubectl run` flags. -#### Generators - -You can create the following resources using `kubectl run` with the `--generator` flag: - -{{< table caption="Resources you can create using kubectl run" >}} -| Resource | API group | kubectl command | -|--------------------------------------|--------------------|---------------------------------------------------| -| Pod | v1 | `kubectl run --generator=run-pod/v1` | -| ReplicationController _(deprecated)_ | v1 | `kubectl run --generator=run/v1` | -| Deployment _(deprecated)_ | extensions/v1beta1 | `kubectl run --generator=deployment/v1beta1` | -| Deployment _(deprecated)_ | apps/v1beta1 | `kubectl run --generator=deployment/apps.v1beta1` | -| Job _(deprecated)_ | batch/v1 | `kubectl run --generator=job/v1` | -| CronJob _(deprecated)_ | batch/v2alpha1 | `kubectl run --generator=cronjob/v2alpha1` | -| CronJob _(deprecated)_ | batch/v1beta1 | `kubectl run --generator=cronjob/v1beta1` | -{{< /table >}} - -{{< note >}} -Generators other than `run-pod/v1` are deprecated. -{{< /note >}} - -If you explicitly set `--generator`, kubectl uses the generator you specified. If you invoke `kubectl run` and don't specify a generator, kubectl automatically selects which generator to use based on the other flags you set. The following table lists flags and the generators that are activated if you didn't specify one yourself: - -{{< table caption="kubectl run flags and the resource they imply" >}} -| Flag | Generated Resource | -|-------------------------|-----------------------| -| `--schedule=` | CronJob | -| `--restart=Always` | Deployment | -| `--restart=OnFailure` | Job | -| `--restart=Never` | Pod | -{{< /table >}} - -If you don't specify a generator, kubectl pays attention to other flags in the following order: - -1. `--schedule` -1. `--restart` - You can use the `--dry-run` flag to preview the object that would be sent to your cluster, without really submitting it. ### `kubectl apply` From f7bd5fab1a23b66fe7421a8ca54c3329c2cf279c Mon Sep 17 00:00:00 2001 From: Marcin Niemira Date: Mon, 6 Apr 2020 00:00:32 +1000 Subject: [PATCH 2/7] rm informatio about generator from cron-job docs --- content/en/docs/tasks/job/automated-tasks-with-cron-jobs.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/content/en/docs/tasks/job/automated-tasks-with-cron-jobs.md b/content/en/docs/tasks/job/automated-tasks-with-cron-jobs.md index 42c47a43b5..ae5b6633ad 100644 --- a/content/en/docs/tasks/job/automated-tasks-with-cron-jobs.md +++ b/content/en/docs/tasks/job/automated-tasks-with-cron-jobs.md @@ -49,12 +49,6 @@ The output is similar to this: cronjob.batch/hello created ``` -Alternatively, you can use `kubectl run` to create a cron job without writing a full config: - -```shell -kubectl run hello --schedule="*/1 * * * *" --restart=OnFailure --image=busybox -- /bin/sh -c "date; echo Hello from the Kubernetes cluster" -``` - After creating the cron job, get its status using this command: ```shell From 2d3d7b9162cec9862b5ac6ff5a1bb2452577eae8 Mon Sep 17 00:00:00 2001 From: Marcin Niemira Date: Mon, 6 Apr 2020 00:02:34 +1000 Subject: [PATCH 3/7] rm --record from kubectl conventions --- content/en/docs/reference/kubectl/conventions.md | 1 - 1 file changed, 1 deletion(-) diff --git a/content/en/docs/reference/kubectl/conventions.md b/content/en/docs/reference/kubectl/conventions.md index 0d2ad983a2..61983d5fb7 100644 --- a/content/en/docs/reference/kubectl/conventions.md +++ b/content/en/docs/reference/kubectl/conventions.md @@ -27,7 +27,6 @@ For a stable output in a script: For `kubectl run` to satisfy infrastructure as code: * Tag the image with a version-specific tag and don't move that tag to a new version. For example, use `:v1234`, `v1.2.3`, `r03062016-1-4`, rather than `:latest` (For more information, see [Best Practices for Configuration](/docs/concepts/configuration/overview/#container-images)). -* Capture the parameters in a checked-in script, or at least use `--record` to annotate the created objects with the command line for an image that is lightly parameterized. * Check in the script for an image that is heavily parameterized. * Switch to configuration files checked into source control for features that are needed, but not expressible via `kubectl run` flags. From 560c5004d8d9672838ed6121a83bd51dbe7f4183 Mon Sep 17 00:00:00 2001 From: Marcin Niemira Date: Wed, 15 Apr 2020 21:57:18 +1000 Subject: [PATCH 4/7] Update conventions.md move generators to the end of the section as they are not part of run cmd --- .../en/docs/reference/kubectl/conventions.md | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/content/en/docs/reference/kubectl/conventions.md b/content/en/docs/reference/kubectl/conventions.md index 61983d5fb7..623bf78535 100644 --- a/content/en/docs/reference/kubectl/conventions.md +++ b/content/en/docs/reference/kubectl/conventions.md @@ -32,6 +32,26 @@ For `kubectl run` to satisfy infrastructure as code: You can use the `--dry-run` flag to preview the object that would be sent to your cluster, without really submitting it. +#### Generators +You can generate the following resources with a kubectl command, `kubectl create --dry-run -o yaml`: +``` + clusterrole Create a ClusterRole. + clusterrolebinding Create a ClusterRoleBinding for a particular ClusterRole. + configmap Create a configmap from a local file, directory or literal value. + cronjob Create a cronjob with the specified name. + deployment Create a deployment with the specified name. + job Create a job with the specified name. + namespace Create a namespace with the specified name. + poddisruptionbudget Create a pod disruption budget with the specified name. + priorityclass Create a priorityclass with the specified name. + quota Create a quota with the specified name. + role Create a role with single rule. + rolebinding Create a RoleBinding for a particular Role or ClusterRole. + secret Create a secret using specified subcommand. + service Create a service using specified subcommand. + serviceaccount Create a service account with the specified name. +``` + ### `kubectl apply` * You can use `kubectl apply` to create or update resources. For more information about using kubectl apply to update resources, see [Kubectl Book](https://kubectl.docs.kubernetes.io). From 67abb1b5ff5c21108f4054d9f30b11f9de647a8c Mon Sep 17 00:00:00 2001 From: Marcin Niemira Date: Tue, 21 Apr 2020 19:01:40 +1000 Subject: [PATCH 5/7] add info about old support for generators --- content/en/docs/reference/kubectl/conventions.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/content/en/docs/reference/kubectl/conventions.md b/content/en/docs/reference/kubectl/conventions.md index 623bf78535..e28143fb4a 100644 --- a/content/en/docs/reference/kubectl/conventions.md +++ b/content/en/docs/reference/kubectl/conventions.md @@ -32,6 +32,10 @@ For `kubectl run` to satisfy infrastructure as code: You can use the `--dry-run` flag to preview the object that would be sent to your cluster, without really submitting it. +{{< note >}} +Generators other than `pod` in `kubectl run` were deprecated until [kubernetes v1.17](https://v1-17.docs.kubernetes.io/docs/reference/kubectl/conventions/). Now there are not supported. +{{< /note >}} + #### Generators You can generate the following resources with a kubectl command, `kubectl create --dry-run -o yaml`: ``` From b09893bbcc6a22928f55dfe6b5c1ddfbb42f5620 Mon Sep 17 00:00:00 2001 From: Marcin Niemira Date: Tue, 21 Apr 2020 19:08:05 +1000 Subject: [PATCH 6/7] rm mentioned generator from kubectl run --- content/en/docs/reference/kubectl/conventions.md | 1 - 1 file changed, 1 deletion(-) diff --git a/content/en/docs/reference/kubectl/conventions.md b/content/en/docs/reference/kubectl/conventions.md index e28143fb4a..ea72c37251 100644 --- a/content/en/docs/reference/kubectl/conventions.md +++ b/content/en/docs/reference/kubectl/conventions.md @@ -17,7 +17,6 @@ For a stable output in a script: * Request one of the machine-oriented output forms, such as `-o name`, `-o json`, `-o yaml`, `-o go-template`, or `-o jsonpath`. * Fully-qualify the version. For example, `jobs.v1.batch/myjob`. This will ensure that kubectl does not use its default version that can change over time. -* Specify the `--generator` flag to pin to a specific behavior when you use generator-based commands such as `kubectl run` or `kubectl expose`. * Don't rely on context, preferences, or other implicit states. ## Best Practices From 57d4d52817d1f6ee01ea406492a6111e71b3fd4c Mon Sep 17 00:00:00 2001 From: Marcin Niemira Date: Tue, 21 Apr 2020 20:40:49 +1000 Subject: [PATCH 7/7] change sentence to nicer form as requested during CR --- content/en/docs/reference/kubectl/conventions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/en/docs/reference/kubectl/conventions.md b/content/en/docs/reference/kubectl/conventions.md index ea72c37251..c4bdd59ec5 100644 --- a/content/en/docs/reference/kubectl/conventions.md +++ b/content/en/docs/reference/kubectl/conventions.md @@ -32,7 +32,7 @@ For `kubectl run` to satisfy infrastructure as code: You can use the `--dry-run` flag to preview the object that would be sent to your cluster, without really submitting it. {{< note >}} -Generators other than `pod` in `kubectl run` were deprecated until [kubernetes v1.17](https://v1-17.docs.kubernetes.io/docs/reference/kubectl/conventions/). Now there are not supported. +All `kubectl` generators are deprecated. See the Kubernetes v1.17 documentation for a [list](https://v1-17.docs.kubernetes.io/docs/reference/kubectl/conventions/#generators) of generators and how they were used. {{< /note >}} #### Generators