Skip to content

Commit e7bd7fb

Browse files
authored
Merge pull request #20976 from sftim/20200514_fix_markdown_for_crd_task
Fix Markdown for CustomResourceDefinition task
2 parents 4665f10 + 679b35a commit e7bd7fb

File tree

1 file changed

+53
-27
lines changed

1 file changed

+53
-27
lines changed

content/en/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions.md

Lines changed: 53 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ into the Kubernetes API by creating a
2828
{{% /capture %}}
2929

3030
{{% capture steps %}}
31+
3132
## Create a CustomResourceDefinition
3233

3334
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
4142

4243
{{< tabs name="CustomResourceDefinition_example_1" >}}
4344
{{% tab name="apiextensions.k8s.io/v1" %}}
45+
4446
```yaml
4547
apiVersion: apiextensions.k8s.io/v1
4648
kind: CustomResourceDefinition
@@ -83,8 +85,10 @@ spec:
8385
shortNames:
8486
- ct
8587
```
88+
8689
{{% /tab %}}
8790
{{% tab name="apiextensions.k8s.io/v1beta1" %}}
91+
8892
```yaml
8993
# Deprecated in v1.16 in favor of apiextensions.k8s.io/v1
9094
apiVersion: apiextensions.k8s.io/v1beta1
@@ -129,6 +133,7 @@ spec:
129133
replicas:
130134
type: integer
131135
```
136+
132137
{{% /tab %}}
133138
{{< /tabs >}}
134139
@@ -188,7 +193,7 @@ kubectl get crontab
188193

189194
Should print a list like this:
190195

191-
```console
196+
```none
192197
NAME AGE
193198
my-new-cron-object 6s
194199
```
@@ -205,7 +210,7 @@ kubectl get ct -o yaml
205210
You should see that it contains the custom `cronSpec` and `image` fields
206211
from the yaml you used to create it:
207212

208-
```console
213+
```yaml
209214
apiVersion: v1
210215
kind: List
211216
items:
@@ -228,14 +233,14 @@ metadata:
228233
## Delete a CustomResourceDefinition
229234
230235
When you delete a CustomResourceDefinition, the server will uninstall the RESTful API endpoint
231-
and **delete all custom objects stored in it**.
236+
and delete all custom objects stored in it.
232237
233238
```shell
234239
kubectl delete -f resourcedefinition.yaml
235240
kubectl get crontabs
236241
```
237242

238-
```console
243+
```none
239244
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)
240245
```
241246

@@ -630,7 +635,9 @@ These fields can only be set with specific features enabled:
630635

631636
- `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).
632637

633-
Note: compare with [structural schemas](#specifying-a-structural-schema) for further restriction required for certain CustomResourceDefinition features.
638+
{{< note >}}
639+
Compare with [structural schemas](#specifying-a-structural-schema) for further restriction required for certain CustomResourceDefinition features.
640+
{{< /note >}}
634641

635642
The schema is defined in the CustomResourceDefinition. In the following example, the
636643
CustomResourceDefinition applies the following validations on the custom object:
@@ -642,6 +649,7 @@ Save the CustomResourceDefinition to `resourcedefinition.yaml`:
642649

643650
{{< tabs name="CustomResourceDefinition_validation" >}}
644651
{{% tab name="apiextensions.k8s.io/v1" %}}
652+
645653
```yaml
646654
apiVersion: apiextensions.k8s.io/v1
647655
kind: CustomResourceDefinition
@@ -676,8 +684,10 @@ spec:
676684
shortNames:
677685
- ct
678686
```
687+
679688
{{% /tab %}}
680689
{{% tab name="apiextensions.k8s.io/v1beta1" %}}
690+
681691
```yaml
682692
# Deprecated in v1.16 in favor of apiextensions.k8s.io/v1
683693
apiVersion: apiextensions.k8s.io/v1beta1
@@ -714,6 +724,7 @@ spec:
714724
minimum: 1
715725
maximum: 10
716726
```
727+
717728
{{% /tab %}}
718729
{{< /tabs >}}
719730

@@ -852,7 +863,7 @@ spec:
852863
replicas: 1
853864
```
854865

855-
Note that defaulting happens on the object
866+
Defaulting happens on the object
856867

857868
* in the request to the API server using the request version defaults,
858869
* 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
895906
CustomResourceDefinition. The following example adds the `Spec`, `Replicas`, and `Age`
896907
columns.
897908

898-
1. Save the CustomResourceDefinition to `resourcedefinition.yaml`.
899-
{{< tabs name="CustomResourceDefinition_printer_columns" >}}
900-
{{% tab name="apiextensions.k8s.io/v1" %}}
909+
Save the CustomResourceDefinition to `resourcedefinition.yaml`:
910+
911+
{{< tabs name="CustomResourceDefinition_printer_columns" >}}
912+
{{% tab name="apiextensions.k8s.io/v1" %}}
913+
901914
```yaml
902915
apiVersion: apiextensions.k8s.io/v1
903916
kind: CustomResourceDefinition
@@ -942,8 +955,10 @@ spec:
942955
type: date
943956
jsonPath: .metadata.creationTimestamp
944957
```
945-
{{% /tab %}}
946-
{{% tab name="apiextensions.k8s.io/v1beta1" %}}
958+
959+
{{% /tab %}}
960+
{{% tab name="apiextensions.k8s.io/v1beta1" %}}
961+
947962
```yaml
948963
# Deprecated in v1.16 in favor of apiextensions.k8s.io/v1
949964
apiVersion: apiextensions.k8s.io/v1beta1
@@ -986,31 +1001,34 @@ spec:
9861001
type: date
9871002
JSONPath: .metadata.creationTimestamp
9881003
```
989-
{{% /tab %}}
990-
{{< /tabs >}}
9911004

992-
2. Create the CustomResourceDefinition:
1005+
{{% /tab %}}
1006+
{{< /tabs >}}
9931007

994-
```shell
995-
kubectl apply -f resourcedefinition.yaml
996-
```
1008+
Create the CustomResourceDefinition:
9971009

998-
3. Create an instance using the `my-crontab.yaml` from the previous section.
1010+
```shell
1011+
kubectl apply -f resourcedefinition.yaml
1012+
```
9991013

1000-
4. Invoke the server-side printing:
1014+
Create an instance using the `my-crontab.yaml` from the previous section.
10011015

1002-
```shell
1003-
kubectl get crontab my-new-cron-object
1004-
```
1016+
Invoke the server-side printing:
10051017

1006-
Notice the `NAME`, `SPEC`, `REPLICAS`, and `AGE` columns in the output:
1018+
```shell
1019+
kubectl get crontab my-new-cron-object
1020+
```
1021+
1022+
Notice the `NAME`, `SPEC`, `REPLICAS`, and `AGE` columns in the output:
10071023

1008-
```
1009-
NAME SPEC REPLICAS AGE
1010-
my-new-cron-object * * * * * 1 7s
1011-
```
1024+
```
1025+
NAME SPEC REPLICAS AGE
1026+
my-new-cron-object * * * * * 1 7s
1027+
```
10121028

1029+
{{< note >}}
10131030
The `NAME` column is implicit and does not need to be defined in the CustomResourceDefinition.
1031+
{{< /note >}}
10141032

10151033
#### Priority
10161034

@@ -1133,6 +1151,7 @@ Save the CustomResourceDefinition to `resourcedefinition.yaml`:
11331151

11341152
{{< tabs name="CustomResourceDefinition_scale" >}}
11351153
{{% tab name="apiextensions.k8s.io/v1" %}}
1154+
11361155
```yaml
11371156
apiVersion: apiextensions.k8s.io/v1
11381157
kind: CustomResourceDefinition
@@ -1184,8 +1203,10 @@ spec:
11841203
shortNames:
11851204
- ct
11861205
```
1206+
11871207
{{% /tab %}}
11881208
{{% tab name="apiextensions.k8s.io/v1beta1" %}}
1209+
11891210
```yaml
11901211
# Deprecated in v1.16 in favor of apiextensions.k8s.io/v1
11911212
apiVersion: apiextensions.k8s.io/v1beta1
@@ -1238,6 +1259,7 @@ spec:
12381259
# labelSelectorPath defines the JSONPath inside of a custom resource that corresponds to Scale.Status.Selector.
12391260
labelSelectorPath: .status.labelSelector
12401261
```
1262+
12411263
{{% /tab %}}
12421264
{{< /tabs >}}
12431265

@@ -1307,6 +1329,7 @@ Save the following CustomResourceDefinition to `resourcedefinition.yaml`:
13071329

13081330
{{< tabs name="CustomResourceDefinition_categories" >}}
13091331
{{% tab name="apiextensions.k8s.io/v1" %}}
1332+
13101333
```yaml
13111334
apiVersion: apiextensions.k8s.io/v1
13121335
kind: CustomResourceDefinition
@@ -1342,8 +1365,10 @@ spec:
13421365
categories:
13431366
- all
13441367
```
1368+
13451369
{{% /tab %}}
13461370
{{% tab name="apiextensions.k8s.io/v1beta1" %}}
1371+
13471372
```yaml
13481373
# Deprecated in v1.16 in favor of apiextensions.k8s.io/v1
13491374
apiVersion: apiextensions.k8s.io/v1beta1
@@ -1380,6 +1405,7 @@ spec:
13801405
categories:
13811406
- all
13821407
```
1408+
13831409
{{% /tab %}}
13841410
{{< /tabs >}}
13851411

0 commit comments

Comments
 (0)