Skip to content

Commit 9f82c32

Browse files
authored
Merge pull request #20920 from sftim/20200512_fix_deployment_concept_markdown
Fix note shortcodes in Deployment concept
2 parents 1cecfd5 + 34894da commit 9f82c32

File tree

1 file changed

+83
-75
lines changed

1 file changed

+83
-75
lines changed

content/en/docs/concepts/workloads/controllers/deployment.md

Lines changed: 83 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ In this example:
5353
In this case, you simply select a label that is defined in the Pod template (`app: nginx`).
5454
However, more sophisticated selection rules are possible,
5555
as long as the Pod template itself satisfies the rule.
56-
57-
{{< note >}}
58-
The `.spec.selector.matchLabels` field is a map of {key,value} pairs. A single {key,value} in the `matchLabels` map is equivalent to an element of `matchExpressions`, whose key field is "key" the operator is "In", and the values array contains only "value". All of the requirements, from both `matchLabels` and `matchExpressions`, must be satisfied in order to match.
59-
{{< /note >}}
56+
57+
{{< note >}}
58+
The `.spec.selector.matchLabels` field is a map of {key,value} pairs. A single {key,value} in the `matchLabels` map is equivalent to an element of `matchExpressions`, whose key field is "key" the operator is "In", and the values array contains only "value". All of the requirements, from both `matchLabels` and `matchExpressions`, must be satisfied in order to match.
59+
{{< /note >}}
6060

6161
* The `template` field contains the following sub-fields:
6262
* The Pods are labeled `app: nginx`using the `.metadata.labels` field.
@@ -65,83 +65,91 @@ In this example:
6565
[Docker Hub](https://hub.docker.com/) image at version 1.14.2.
6666
* Create one container and name it `nginx` using the `.spec.template.spec.containers[0].name` field.
6767

68-
Follow the steps given below to create the above Deployment:
69-
70-
Before you begin, make sure your Kubernetes cluster is up and running.
71-
72-
1. Create the Deployment by running the following command:
73-
74-
{{< note >}}
75-
You may specify the `--record` flag to write the command executed in the resource annotation `kubernetes.io/change-cause`. It is useful for future introspection. For example, to see the commands executed in each Deployment revision.
76-
{{< /note >}}
77-
78-
```shell
79-
kubectl apply -f https://k8s.io/examples/controllers/nginx-deployment.yaml
80-
```
81-
82-
2. Run `kubectl get deployments` to check if the Deployment was created. If the Deployment is still being created, the output is similar to the following:
83-
```shell
84-
NAME READY UP-TO-DATE AVAILABLE AGE
85-
nginx-deployment 0/3 0 0 1s
86-
```
87-
When you inspect the Deployments in your cluster, the following fields are displayed:
88-
89-
* `NAME` lists the names of the Deployments in the namespace.
90-
* `READY` displays how many replicas of the application are available to your users. It follows the pattern ready/desired.
91-
* `UP-TO-DATE` displays the number of replicas that have been updated to achieve the desired state.
92-
* `AVAILABLE` displays how many replicas of the application are available to your users.
93-
* `AGE` displays the amount of time that the application has been running.
94-
95-
Notice how the number of desired replicas is 3 according to `.spec.replicas` field.
96-
97-
3. To see the Deployment rollout status, run `kubectl rollout status deployment.v1.apps/nginx-deployment`. The output is similar to this:
98-
```shell
99-
Waiting for rollout to finish: 2 out of 3 new replicas have been updated...
100-
deployment.apps/nginx-deployment successfully rolled out
101-
```
102-
103-
4. Run the `kubectl get deployments` again a few seconds later. The output is similar to this:
104-
```shell
105-
NAME READY UP-TO-DATE AVAILABLE AGE
106-
nginx-deployment 3/3 3 3 18s
107-
```
108-
Notice that the Deployment has created all three replicas, and all replicas are up-to-date (they contain the latest Pod template) and available.
68+
Before you begin, make sure your Kubernetes cluster is up and running.
69+
Follow the steps given below to create the above Deployment:
70+
71+
72+
1. Create the Deployment by running the following command:
73+
74+
```shell
75+
kubectl apply -f https://k8s.io/examples/controllers/nginx-deployment.yaml
76+
```
77+
78+
{{< note >}}
79+
You can specify the `--record` flag to write the command executed in the resource annotation `kubernetes.io/change-cause`. The recorded change is useful for future introspection. For example, to see the commands executed in each Deployment revision.
80+
{{< /note >}}
81+
82+
83+
2. Run `kubectl get deployments` to check if the Deployment was created.
84+
85+
If the Deployment is still being created, the output is similar to the following:
86+
```shell
87+
NAME READY UP-TO-DATE AVAILABLE AGE
88+
nginx-deployment 0/3 0 0 1s
89+
```
90+
When you inspect the Deployments in your cluster, the following fields are displayed:
91+
* `NAME` lists the names of the Deployments in the namespace.
92+
* `READY` displays how many replicas of the application are available to your users. It follows the pattern ready/desired.
93+
* `UP-TO-DATE` displays the number of replicas that have been updated to achieve the desired state.
94+
* `AVAILABLE` displays how many replicas of the application are available to your users.
95+
* `AGE` displays the amount of time that the application has been running.
96+
97+
Notice how the number of desired replicas is 3 according to `.spec.replicas` field.
98+
99+
3. To see the Deployment rollout status, run `kubectl rollout status deployment.v1.apps/nginx-deployment`.
100+
101+
The output is similar to:
102+
```shell
103+
Waiting for rollout to finish: 2 out of 3 new replicas have been updated...
104+
deployment.apps/nginx-deployment successfully rolled out
105+
```
106+
107+
4. Run the `kubectl get deployments` again a few seconds later.
108+
The output is similar to this:
109+
```shell
110+
NAME READY UP-TO-DATE AVAILABLE AGE
111+
nginx-deployment 3/3 3 3 18s
112+
```
113+
Notice that the Deployment has created all three replicas, and all replicas are up-to-date (they contain the latest Pod template) and available.
114+
115+
5. To see the ReplicaSet (`rs`) created by the Deployment, run `kubectl get rs`. The output is similar to this:
116+
```shell
117+
NAME DESIRED CURRENT READY AGE
118+
nginx-deployment-75675f5897 3 3 3 18s
119+
```
120+
ReplicaSet output shows the following fields:
121+
122+
* `NAME` lists the names of the ReplicaSets in the namespace.
123+
* `DESIRED` displays the desired number of _replicas_ of the application, which you define when you create the Deployment. This is the _desired state_.
124+
* `CURRENT` displays how many replicas are currently running.
125+
* `READY` displays how many replicas of the application are available to your users.
126+
* `AGE` displays the amount of time that the application has been running.
127+
128+
Notice that the name of the ReplicaSet is always formatted as `[DEPLOYMENT-NAME]-[RANDOM-STRING]`.
129+
The random string is randomly generated and uses the `pod-template-hash` as a seed.
130+
131+
6. To see the labels automatically generated for each Pod, run `kubectl get pods --show-labels`.
132+
The output is similar to:
133+
```shell
134+
NAME READY STATUS RESTARTS AGE LABELS
135+
nginx-deployment-75675f5897-7ci7o 1/1 Running 0 18s app=nginx,pod-template-hash=3123191453
136+
nginx-deployment-75675f5897-kzszj 1/1 Running 0 18s app=nginx,pod-template-hash=3123191453
137+
nginx-deployment-75675f5897-qqcnn 1/1 Running 0 18s app=nginx,pod-template-hash=3123191453
138+
```
139+
The created ReplicaSet ensures that there are three `nginx` Pods.
109140

110-
5. To see the ReplicaSet (`rs`) created by the Deployment, run `kubectl get rs`. The output is similar to this:
111-
```shell
112-
NAME DESIRED CURRENT READY AGE
113-
nginx-deployment-75675f5897 3 3 3 18s
114-
```
115-
ReplicaSet output shows the following fields:
116-
117-
* `NAME` lists the names of the ReplicaSets in the namespace.
118-
* `DESIRED` displays the desired number of _replicas_ of the application, which you define when you create the Deployment. This is the _desired state_.
119-
* `CURRENT` displays how many replicas are currently running.
120-
* `READY` displays how many replicas of the application are available to your users.
121-
* `AGE` displays the amount of time that the application has been running.
122-
123-
Notice that the name of the ReplicaSet is always formatted as `[DEPLOYMENT-NAME]-[RANDOM-STRING]`. The random string is
124-
randomly generated and uses the `pod-template-hash` as a seed.
125-
126-
6. To see the labels automatically generated for each Pod, run `kubectl get pods --show-labels`. The following output is returned:
127-
```shell
128-
NAME READY STATUS RESTARTS AGE LABELS
129-
nginx-deployment-75675f5897-7ci7o 1/1 Running 0 18s app=nginx,pod-template-hash=3123191453
130-
nginx-deployment-75675f5897-kzszj 1/1 Running 0 18s app=nginx,pod-template-hash=3123191453
131-
nginx-deployment-75675f5897-qqcnn 1/1 Running 0 18s app=nginx,pod-template-hash=3123191453
132-
```
133-
The created ReplicaSet ensures that there are three `nginx` Pods.
141+
{{< note >}}
142+
You must specify an appropriate selector and Pod template labels in a Deployment
143+
(in this case, `app: nginx`).
134144

135-
{{< note >}}
136-
You must specify an appropriate selector and Pod template labels in a Deployment (in this case,
137-
`app: nginx`). Do not overlap labels or selectors with other controllers (including other Deployments and StatefulSets). Kubernetes doesn't stop you from overlapping, and if multiple controllers have overlapping selectors those controllers might conflict and behave unexpectedly.
138-
{{< /note >}}
145+
Do not overlap labels or selectors with other controllers (including other Deployments and StatefulSets). Kubernetes doesn't stop you from overlapping, and if multiple controllers have overlapping selectors those controllers might conflict and behave unexpectedly.
146+
{{< /note >}}
139147

140148
### Pod-template-hash label
141149

142-
{{< note >}}
150+
{{< caution >}}
143151
Do not change this label.
144-
{{< /note >}}
152+
{{< /caution >}}
145153

146154
The `pod-template-hash` label is added by the Deployment controller to every ReplicaSet that a Deployment creates or adopts.
147155

0 commit comments

Comments
 (0)