Merge pull request #20976 from sftim/20200514_fix_markdown_for_crd_task

Fix Markdown for CustomResourceDefinition task
This commit is contained in:
Kubernetes Prow Robot
2020-05-15 12:27:36 -07:00
committed by GitHub
@@ -28,6 +28,7 @@ into the Kubernetes API by creating a
{{% /capture %}} {{% /capture %}}
{{% capture steps %}} {{% capture steps %}}
## Create a CustomResourceDefinition ## Create a CustomResourceDefinition
When you create a new CustomResourceDefinition (CRD), the Kubernetes API Server When you create a new CustomResourceDefinition (CRD), the Kubernetes API Server
@@ -41,6 +42,7 @@ For example, if you save the following CustomResourceDefinition to `resourcedefi
{{< tabs name="CustomResourceDefinition_example_1" >}} {{< tabs name="CustomResourceDefinition_example_1" >}}
{{% tab name="apiextensions.k8s.io/v1" %}} {{% tab name="apiextensions.k8s.io/v1" %}}
```yaml ```yaml
apiVersion: apiextensions.k8s.io/v1 apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition kind: CustomResourceDefinition
@@ -83,8 +85,10 @@ spec:
shortNames: shortNames:
- ct - ct
``` ```
{{% /tab %}} {{% /tab %}}
{{% tab name="apiextensions.k8s.io/v1beta1" %}} {{% tab name="apiextensions.k8s.io/v1beta1" %}}
```yaml ```yaml
# Deprecated in v1.16 in favor of apiextensions.k8s.io/v1 # Deprecated in v1.16 in favor of apiextensions.k8s.io/v1
apiVersion: apiextensions.k8s.io/v1beta1 apiVersion: apiextensions.k8s.io/v1beta1
@@ -129,6 +133,7 @@ spec:
replicas: replicas:
type: integer type: integer
``` ```
{{% /tab %}} {{% /tab %}}
{{< /tabs >}} {{< /tabs >}}
@@ -188,7 +193,7 @@ kubectl get crontab
Should print a list like this: Should print a list like this:
```console ```none
NAME AGE NAME AGE
my-new-cron-object 6s my-new-cron-object 6s
``` ```
@@ -205,7 +210,7 @@ kubectl get ct -o yaml
You should see that it contains the custom `cronSpec` and `image` fields You should see that it contains the custom `cronSpec` and `image` fields
from the yaml you used to create it: from the yaml you used to create it:
```console ```yaml
apiVersion: v1 apiVersion: v1
kind: List kind: List
items: items:
@@ -228,14 +233,14 @@ metadata:
## Delete a CustomResourceDefinition ## Delete a CustomResourceDefinition
When you delete a CustomResourceDefinition, the server will uninstall the RESTful API endpoint When you delete a CustomResourceDefinition, the server will uninstall the RESTful API endpoint
and **delete all custom objects stored in it**. and delete all custom objects stored in it.
```shell ```shell
kubectl delete -f resourcedefinition.yaml kubectl delete -f resourcedefinition.yaml
kubectl get crontabs kubectl get crontabs
``` ```
```console ```none
Error from server (NotFound): Unable to list {"stable.example.com" "v1" "crontabs"}: the server could not find the requested resource (get crontabs.stable.example.com) Error from server (NotFound): Unable to list {"stable.example.com" "v1" "crontabs"}: the server could not find the requested resource (get crontabs.stable.example.com)
``` ```
@@ -630,7 +635,9 @@ These fields can only be set with specific features enabled:
- `default`: can be set for `apiextensions.k8s.io/v1` CustomResourceDefinitions. Defaulting is in GA since 1.17 (beta since 1.16 with the `CustomResourceDefaulting` feature gate to be enabled, which is the case automatically for many clusters for beta features). Compare [Validation Schema Defaulting](/docs/tasks/access-kubernetes-api/extend-api-custom-resource-definitions/#defaulting). - `default`: can be set for `apiextensions.k8s.io/v1` CustomResourceDefinitions. Defaulting is in GA since 1.17 (beta since 1.16 with the `CustomResourceDefaulting` feature gate to be enabled, which is the case automatically for many clusters for beta features). Compare [Validation Schema Defaulting](/docs/tasks/access-kubernetes-api/extend-api-custom-resource-definitions/#defaulting).
Note: compare with [structural schemas](#specifying-a-structural-schema) for further restriction required for certain CustomResourceDefinition features. {{< note >}}
Compare with [structural schemas](#specifying-a-structural-schema) for further restriction required for certain CustomResourceDefinition features.
{{< /note >}}
The schema is defined in the CustomResourceDefinition. In the following example, the The schema is defined in the CustomResourceDefinition. In the following example, the
CustomResourceDefinition applies the following validations on the custom object: CustomResourceDefinition applies the following validations on the custom object:
@@ -642,6 +649,7 @@ Save the CustomResourceDefinition to `resourcedefinition.yaml`:
{{< tabs name="CustomResourceDefinition_validation" >}} {{< tabs name="CustomResourceDefinition_validation" >}}
{{% tab name="apiextensions.k8s.io/v1" %}} {{% tab name="apiextensions.k8s.io/v1" %}}
```yaml ```yaml
apiVersion: apiextensions.k8s.io/v1 apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition kind: CustomResourceDefinition
@@ -676,8 +684,10 @@ spec:
shortNames: shortNames:
- ct - ct
``` ```
{{% /tab %}} {{% /tab %}}
{{% tab name="apiextensions.k8s.io/v1beta1" %}} {{% tab name="apiextensions.k8s.io/v1beta1" %}}
```yaml ```yaml
# Deprecated in v1.16 in favor of apiextensions.k8s.io/v1 # Deprecated in v1.16 in favor of apiextensions.k8s.io/v1
apiVersion: apiextensions.k8s.io/v1beta1 apiVersion: apiextensions.k8s.io/v1beta1
@@ -714,6 +724,7 @@ spec:
minimum: 1 minimum: 1
maximum: 10 maximum: 10
``` ```
{{% /tab %}} {{% /tab %}}
{{< /tabs >}} {{< /tabs >}}
@@ -852,7 +863,7 @@ spec:
replicas: 1 replicas: 1
``` ```
Note that defaulting happens on the object Defaulting happens on the object
* in the request to the API server using the request version defaults, * in the request to the API server using the request version defaults,
* when reading from etcd using the storage version defaults, * when reading from etcd using the storage version defaults,
@@ -895,9 +906,11 @@ columns are shown by the `kubectl get` command. You can customize these columns
CustomResourceDefinition. The following example adds the `Spec`, `Replicas`, and `Age` CustomResourceDefinition. The following example adds the `Spec`, `Replicas`, and `Age`
columns. columns.
1. Save the CustomResourceDefinition to `resourcedefinition.yaml`. Save the CustomResourceDefinition to `resourcedefinition.yaml`:
{{< tabs name="CustomResourceDefinition_printer_columns" >}}
{{% tab name="apiextensions.k8s.io/v1" %}} {{< tabs name="CustomResourceDefinition_printer_columns" >}}
{{% tab name="apiextensions.k8s.io/v1" %}}
```yaml ```yaml
apiVersion: apiextensions.k8s.io/v1 apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition kind: CustomResourceDefinition
@@ -942,8 +955,10 @@ spec:
type: date type: date
jsonPath: .metadata.creationTimestamp jsonPath: .metadata.creationTimestamp
``` ```
{{% /tab %}}
{{% tab name="apiextensions.k8s.io/v1beta1" %}} {{% /tab %}}
{{% tab name="apiextensions.k8s.io/v1beta1" %}}
```yaml ```yaml
# Deprecated in v1.16 in favor of apiextensions.k8s.io/v1 # Deprecated in v1.16 in favor of apiextensions.k8s.io/v1
apiVersion: apiextensions.k8s.io/v1beta1 apiVersion: apiextensions.k8s.io/v1beta1
@@ -986,31 +1001,34 @@ spec:
type: date type: date
JSONPath: .metadata.creationTimestamp JSONPath: .metadata.creationTimestamp
``` ```
{{% /tab %}}
{{< /tabs >}}
2. Create the CustomResourceDefinition: {{% /tab %}}
{{< /tabs >}}
```shell Create the CustomResourceDefinition:
kubectl apply -f resourcedefinition.yaml
```
3. Create an instance using the `my-crontab.yaml` from the previous section. ```shell
kubectl apply -f resourcedefinition.yaml
```
4. Invoke the server-side printing: Create an instance using the `my-crontab.yaml` from the previous section.
```shell Invoke the server-side printing:
kubectl get crontab my-new-cron-object
```
Notice the `NAME`, `SPEC`, `REPLICAS`, and `AGE` columns in the output: ```shell
kubectl get crontab my-new-cron-object
```
``` Notice the `NAME`, `SPEC`, `REPLICAS`, and `AGE` columns in the output:
NAME SPEC REPLICAS AGE
my-new-cron-object * * * * * 1 7s
```
```
NAME SPEC REPLICAS AGE
my-new-cron-object * * * * * 1 7s
```
{{< note >}}
The `NAME` column is implicit and does not need to be defined in the CustomResourceDefinition. The `NAME` column is implicit and does not need to be defined in the CustomResourceDefinition.
{{< /note >}}
#### Priority #### Priority
@@ -1133,6 +1151,7 @@ Save the CustomResourceDefinition to `resourcedefinition.yaml`:
{{< tabs name="CustomResourceDefinition_scale" >}} {{< tabs name="CustomResourceDefinition_scale" >}}
{{% tab name="apiextensions.k8s.io/v1" %}} {{% tab name="apiextensions.k8s.io/v1" %}}
```yaml ```yaml
apiVersion: apiextensions.k8s.io/v1 apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition kind: CustomResourceDefinition
@@ -1184,8 +1203,10 @@ spec:
shortNames: shortNames:
- ct - ct
``` ```
{{% /tab %}} {{% /tab %}}
{{% tab name="apiextensions.k8s.io/v1beta1" %}} {{% tab name="apiextensions.k8s.io/v1beta1" %}}
```yaml ```yaml
# Deprecated in v1.16 in favor of apiextensions.k8s.io/v1 # Deprecated in v1.16 in favor of apiextensions.k8s.io/v1
apiVersion: apiextensions.k8s.io/v1beta1 apiVersion: apiextensions.k8s.io/v1beta1
@@ -1238,6 +1259,7 @@ spec:
# labelSelectorPath defines the JSONPath inside of a custom resource that corresponds to Scale.Status.Selector. # labelSelectorPath defines the JSONPath inside of a custom resource that corresponds to Scale.Status.Selector.
labelSelectorPath: .status.labelSelector labelSelectorPath: .status.labelSelector
``` ```
{{% /tab %}} {{% /tab %}}
{{< /tabs >}} {{< /tabs >}}
@@ -1307,6 +1329,7 @@ Save the following CustomResourceDefinition to `resourcedefinition.yaml`:
{{< tabs name="CustomResourceDefinition_categories" >}} {{< tabs name="CustomResourceDefinition_categories" >}}
{{% tab name="apiextensions.k8s.io/v1" %}} {{% tab name="apiextensions.k8s.io/v1" %}}
```yaml ```yaml
apiVersion: apiextensions.k8s.io/v1 apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition kind: CustomResourceDefinition
@@ -1342,8 +1365,10 @@ spec:
categories: categories:
- all - all
``` ```
{{% /tab %}} {{% /tab %}}
{{% tab name="apiextensions.k8s.io/v1beta1" %}} {{% tab name="apiextensions.k8s.io/v1beta1" %}}
```yaml ```yaml
# Deprecated in v1.16 in favor of apiextensions.k8s.io/v1 # Deprecated in v1.16 in favor of apiextensions.k8s.io/v1
apiVersion: apiextensions.k8s.io/v1beta1 apiVersion: apiextensions.k8s.io/v1beta1
@@ -1380,6 +1405,7 @@ spec:
categories: categories:
- all - all
``` ```
{{% /tab %}} {{% /tab %}}
{{< /tabs >}} {{< /tabs >}}