8000 apply shortcodes and change code fencing style (#9072) · ArduinoBot/website@f58f8c2 · GitHub
[go: up one dir, main page]

Skip to content

Commit f58f8c2

Browse files
makocchi-gitk8s-ci-robot
authored andcommitted
apply shortcodes and change code fencing style (kubernetes#9072)
* shortcodes: use note/warning shortcodes * code fencing: change to `yaml` from `shell`
1 parent bbdfeaf commit f58f8c2

File tree

1 file changed

+54
-20
lines changed

1 file changed

+54
-20
lines changed

content/en/docs/concepts/overview/object-management-kubectl/declarative-config.md

Lines changed: 54 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ This sets the `kubectl.kubernetes.io/last-applied-configuration: '{...}'`
5959
annotation on each object. The annotation contains the contents of the object
6060
configuration file that was used to create the object.
6161

62-
**Note**: Add the `-R` flag to recursively process directories.
62+
{{< note >}}
63+
**Note:** Add the `-R` flag to recursively process directories.
64+
{{< /note >}}
6365

6466
Here's an example of an object configuration file:
6567

@@ -80,7 +82,7 @@ kubectl get -f https://k8s.io/docs/concepts/overview/object-management-kubectl/s
8082
The output shows that the `kubectl.kubernetes.io/last-applied-configuration` annotation
8183
was written to the live configuration, and it matches the configuration file:
8284

83-
```shell
85+
```yaml
8486
kind: Deployment
8587
metadata:
8688
annotations:
@@ -131,7 +133,9 @@ if those objects already exist. This approach accomplishes the following:
131133
kubectl apply -f <directory>/
132134
```
133135

134-
**Note**: Add the `-R` flag to recursively process directories.
136+
{{< note >}}
137+
**Note:** Add the `-R` flag to recursively process directories.
138+
{{< /note >}}
135139

136140
Here's an example configuration file:
137141

@@ -143,8 +147,10 @@ Create the object using `kubectl apply`:
143147
kubectl apply -f https://k8s.io/docs/concepts/overview/object-management-kubectl/simple_deployment.yaml
144148
```
145149

150+
{{< note >}}
146151
**Note:** For purposes of illustration, the preceding command refers to a single
147152
configuration file instead of a directory.
153+
{{< /note >}}
148154

149155
Print the live configuration using `kubectl get`:
150156

@@ -155,7 +161,7 @@ kubectl get -f https://k8s.io/docs/concepts/overview/object-management-kubectl/s
155161
The output shows that the `kubectl.kubernetes.io/last-applied-configuration` annotation
156162
was written to the live configuration, and it matches the configuration file:
157163

158-
```shell
164+
```yaml
159165
kind: Deployment
160166
metadata:
161167
annotations:
@@ -210,7 +216,7 @@ kubectl get -f https://k8s.io/docs/concepts/overview/object-management-kubectl/s
210216
The output shows that the `replicas` field has been set to 2, and the `last-applied-configuration`
211217
annotation does not contain a `replicas` field:
212218

213-
```
219+
```yaml
214220
apiVersion: apps/v1
215221
kind: Deployment
216222
metadata:
@@ -274,7 +280,7 @@ The output shows the following changes to the live configuration:
274280
- The `minReadySeconds` field has been cleared.
275281
- The `last-applied-configuration` annotation no longer contains the `minReadySeconds` field.
276282

277-
```shell
283+
```yaml
278284
apiVersion: apps/v1
279285
kind: Deployment
280286
metadata:
@@ -315,10 +321,12 @@ spec:
315321
# ...
316322
```
317323

318-
**Warning**: Mixing `kubectl apply` with the imperative object configuration commands
324+
{{< warning >}}
325+
**Warning:** Mixing `kubectl apply` with the imperative object configuration commands
319326
`create` and `replace` is not supported. This is because `create`
320327
and `replace` do not retain the `kubectl.kubernetes.io/last-applied-configuration`
321328
that `kubectl apply` uses to compute updates.
329+
{{< /warning >}}
322330

323331
## How to delete objects
324332

@@ -338,11 +346,15 @@ kubectl delete -f <filename>
338346

339347
Only use this if you know what you are doing.
340348

349+
{{< warning >}}
341350
**Warning:** `kubectl apply --prune` is in alpha, and backwards incompatible
342351
changes might be introduced in subsequent releases.
352+
{{< /warning >}}
343353

344-
**Warning**: You must be careful when using this command, so that you
354+
{{< warning >}}
355+
**Warning:** You must be careful when using this command, so that you
345356
do not delete objects unintentionally.
357+
{{< /warning >}}
346358

347359
As an alternative to `kubectl delete`, you can use `kubectl apply` to identify objects to be deleted after their
348360
configuration files have been removed from the directory. Apply with `--prune`
@@ -360,11 +372,13 @@ TODO(pwittrock): We need to change the behavior to prevent the user from running
360372
kubectl apply -f <directory/> --prune -l <labels>
361373
```
362374

363-
**Important:** Apply with prune should only be run against the root directory
375+
{{< warning >}}
376+
**Warning:** Apply with prune should only be run against the root directory
364377
containing the object configuration files. Running against sub-directories
365378
can cause objects to be unintentionally deleted if they are returned
366379
by the label selector query specified with `-l <labels>` and
367380
do not appear in the subdirectory.
381+
{{< /warning >}}
368382

369383
## How to view an object
370384

@@ -376,10 +390,12 @@ kubectl get -f <filename|url> -o yaml
376390

377391
## How apply calculates differences and merges changes
378392

379-
**Definition:** A *patch* is an update operation that is scoped to specific
393+
{{< caution >}}
394+
**Caution:** A *patch* is an update operation that is scoped to specific
380395
fields of an object instead of the entire object.
381396
This enables updating only a specific set of fields on an object without
382397
reading the object first.
398+
{{< /caution >}}
383399

384400
When `kubectl apply` updates the live configuration for an object,
385401
it does so by sending a patch request to the API server. The
@@ -405,7 +421,7 @@ Here's an example. Suppose this is the configuration file for a Deployment objec
405421

406422
Also, suppose this is the live configuration for the same Deployment object:
407423

408-
```shell
424+
```yaml
409425
apiVersion: apps/v1
410426
kind: Deployment
411427
metadata:
@@ -460,7 +476,7 @@ Here are the merge calculations that would be performed by `kubectl apply`:
460476

461477
Here is the live configuration that is the result of the merge:
462478

463-
```shell
479+
```yaml
464480
apiVersion: apps/v1
465481
kind: Deployment
466482
metadata:
@@ -532,7 +548,9 @@ and merged.
532548

533549
Primitive fields are replaced or cleared.
534550

551+
{{< note >}}
535552
**Note:** '-' is used for "not applicable" because the value is not used.
553+
{{< /note >}}
536554

537555
| Field in object configuration file | Field in live object configuration | Field in last-applied-configuration | Action |
538556
|-------------------------------------|------------------------------------|-------------------------------------|-------------------------------------------|
@@ -545,7 +563,9 @@ Primitive fields are replaced or cleared.
545563

546564
Fields that represent maps are merged by comparing each of the subfields or elements of the map:
547565

566+
{{< note >}}
548567
**Note:** '-' is used for "not applicable" because the value is not used.
568+
{{< /note >}}
549569

550570
| Key in object configuration file | Key in live object configuration | Field in last-applied-configuration | Action |
551571
|-------------------------------------|------------------------------------|-------------------------------------|----------------------------------|
@@ -671,10 +691,12 @@ by `name`.
671691

672692
As of Kubernetes 1.5, merging lists of primitive elements is not supported.
673693

694+
{{< note >}}
674695
**Note:** Which of the above strategies is chosen for a given field is controlled by
675696
the `patchStrategy` tag in [types.go](https://git.k8s.io/api/core/v1/types.go#L2565)
676697
If no `patchStrategy` is specified for a field of type list, then
677698
the list is replaced.
699+
{{< /note >}}
678700

679701
{{< comment >}}
680702
TODO(pwittrock): Uncomment this for 1.6
@@ -711,7 +733,7 @@ kubectl get -f https://k8s.io/docs/concepts/overview/object-management-kubectl/s
711733
The output shows that the API server set several fields to default values in the live
712734
configuration. These fields were not specified in the configuration file.
713735

714-
```shell
736+
```yaml
715737
apiVersion: apps/v1
716738
kind: Deployment
717739
# ...
@@ -857,8 +879,10 @@ cleared by a merge operation. Here are some workarounds:
857879

858880
Option 1: Remove the field by directly modifying the live object.
859881

882+
{{< note >}}
860883
**Note:** As of Kubernetes 1.5, `kubectl edit` does not work with `kubectl apply`.
861884
Using these together will cause unexpected behavior.
885+
{{< /note >}}
862886

863887
Option 2: Remove the field through the configuration file.
864888

@@ -902,7 +926,9 @@ an imperative writer requires manual steps:
902926
Kubernetes objects should be managed using only one method at a time.
903927
Switching from one method to another is possible, but is a manual process.
904928

905-
**Exception:** It is OK to use imperative deletion with declarative management.
929+
{{< note >}}
930+
**Note:** It is OK to use imperative deletion with declarative management.
931+
{{< /note >}}
906932

907933
{{< comment >}}
908934
TODO(pwittrock): We need to make using imperative commands with
@@ -919,16 +945,20 @@ configuration involves several manual steps:
919945

920946
1. Export the live object to a local configuration file:
921947

922-
kubectl get <kind>/<name> -o yaml --export > <kind>_<name>.yaml
948+
```shell
949+
kubectl get <kind>/<name> -o yaml --export > <kind>_<name>.yaml
950+
```
923951

924952
1. Manually remove the `status` field from the configuration file.
925953

926-
**Note:** This step is optional, as `kubectl apply` does not update the status field
927-
even if it is present in the configuration file.
954+
{{< note >}}**Note:** This step is optional, as `kubectl apply` does not update the status field
955+
even if it is present in the configuration file.{{< /note >}}
928956

929957
1. Set the `kubectl.kubernetes.io/last-applied-configuration` annotation on the object:
930958

931-
kubectl replace --save-config -f <kind>_<name>.yaml
959+
```shell
960+
kubectl replace --save-config -f <kind>_<name>.yaml
961+
```
932962

933963
1. Change processes to use `kubectl apply` for managing the object exclusively.
934964

@@ -940,13 +970,17 @@ TODO(pwittrock): Why doesn't export remove the status field? Seems like it shou
940970

941971
1. Set the `kubectl.kubernetes.io/last-applied-configuration` annotation on the object:
942972

943-
kubectl replace --save-config -f <kind>_<name>.yaml
973+
```shell
974+
kubectl replace --save-config -f <kind>_<name>.yaml
975+
```
944976

945977
1. Change processes to use `kubectl apply` for managing the object exclusively.
946978

947979
## Defining controller selectors and PodTemplate labels
948980

949-
**Warning**: Updating selectors on controllers is strongly discouraged.
981+
{{< warning >}}
982+
**Warning:** Updating selectors on controllers is strongly discouraged.
983+
{{< /warning >}}
950984

951985
The recommended approach is to define a single, immutable PodTemplate label
952986
used only by the controller selector with no other semantic meaning.

0 commit comments

Comments
 (0)
0