Skip to content

Commit 0d0d8ae

Browse files
authored
Merge pull request #39532 from Zhuzhenghao/run-stateless
Add syntax tag to highlight the command
2 parents 1a388f8 + e9784b9 commit 0d0d8ae

File tree

1 file changed

+78
-74
lines changed

1 file changed

+78
-74
lines changed

content/en/docs/tasks/run-application/run-stateless-application-deployment.md

Lines changed: 78 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,16 @@ weight: 10
99

1010
This page shows how to run an application using a Kubernetes Deployment object.
1111

12-
13-
14-
1512
## {{% heading "objectives" %}}
1613

17-
18-
* Create an nginx deployment.
19-
* Use kubectl to list information about the deployment.
20-
* Update the deployment.
21-
22-
23-
14+
- Create an nginx deployment.
15+
- Use kubectl to list information about the deployment.
16+
- Update the deployment.
2417

2518
## {{% heading "prerequisites" %}}
2619

27-
2820
{{< include "task-tutorial-prereqs.md" >}} {{< version-check >}}
2921

30-
31-
32-
3322
<!-- lessoncontent -->
3423

3524
## Creating and exploring an nginx deployment
@@ -40,60 +29,71 @@ a Deployment that runs the nginx:1.14.2 Docker image:
4029

4130
{{< codenew file="application/deployment.yaml" >}}
4231

43-
4432
1. Create a Deployment based on the YAML file:
4533

46-
kubectl apply -f https://k8s.io/examples/application/deployment.yaml
34+
```shell
35+
kubectl apply -f https://k8s.io/examples/application/deployment.yaml
36+
```
4737

4838
1. Display information about the Deployment:
4939

50-
kubectl describe deployment nginx-deployment
51-
52-
The output is similar to this:
53-
54-
Name: nginx-deployment
55-
Namespace: default
56-
CreationTimestamp: Tue, 30 Aug 2016 18:11:37 -0700
57-
Labels: app=nginx
58-
Annotations: deployment.kubernetes.io/revision=1
59-
Selector: app=nginx
60-
Replicas: 2 desired | 2 updated | 2 total | 2 available | 0 unavailable
61-
StrategyType: RollingUpdate
62-
MinReadySeconds: 0
63-
RollingUpdateStrategy: 1 max unavailable, 1 max surge
64-
Pod Template:
65-
Labels: app=nginx
66-
Containers:
67-
nginx:
68-
Image: nginx:1.14.2
69-
Port: 80/TCP
70-
Environment: <none>
71-
Mounts: <none>
72-
Volumes: <none>
73-
Conditions:
74-
Type Status Reason
75-
---- ------ ------
76-
Available True MinimumReplicasAvailable
77-
Progressing True NewReplicaSetAvailable
78-
OldReplicaSets: <none>
79-
NewReplicaSet: nginx-deployment-1771418926 (2/2 replicas created)
80-
No events.
40+
```shell
41+
kubectl describe deployment nginx-deployment
42+
```
43+
44+
The output is similar to this:
45+
46+
```
47+
Name: nginx-deployment
48+
Namespace: default
49+
CreationTimestamp: Tue, 30 Aug 2016 18:11:37 -0700
50+
Labels: app=nginx
51+
Annotations: deployment.kubernetes.io/revision=1
52+
Selector: app=nginx
53+
Replicas: 2 desired | 2 updated | 2 total | 2 available | 0 unavailable
54+
StrategyType: RollingUpdate
55+
MinReadySeconds: 0
56+
RollingUpdateStrategy: 1 max unavailable, 1 max surge
57+
Pod Template:
58+
Labels: app=nginx
59+
Containers:
60+
nginx:
61+
Image: nginx:1.14.2
62+
Port: 80/TCP
63+
Environment: <none>
64+
Mounts: <none>
65+
Volumes: <none>
66+
Conditions:
67+
Type Status Reason
68+
---- ------ ------
69+
Available True MinimumReplicasAvailable
70+
Progressing True NewReplicaSetAvailable
71+
OldReplicaSets: <none>
72+
NewReplicaSet: nginx-deployment-1771418926 (2/2 replicas created)
73+
No events.
74+
```
8175

8276
1. List the Pods created by the deployment:
8377

84-
kubectl get pods -l app=nginx
78+
```shell
79+
kubectl get pods -l app=nginx
80+
```
8581

86-
The output is similar to this:
82+
The output is similar to this:
8783

88-
NAME READY STATUS RESTARTS AGE
89-
nginx-deployment-1771418926-7o5ns 1/1 Running 0 16h
90-
nginx-deployment-1771418926-r18az 1/1 Running 0 16h
84+
```
85+
NAME READY STATUS RESTARTS AGE
86+
nginx-deployment-1771418926-7o5ns 1/1 Running 0 16h
87+
nginx-deployment-1771418926-r18az 1/1 Running 0 16h
88+
```
9189

9290
1. Display information about a Pod:
9391

94-
kubectl describe pod <pod-name>
92+
```shell
93+
kubectl describe pod <pod-name>
94+
```
9595

96-
where `<pod-name>` is the name of one of your Pods.
96+
where `<pod-name>` is the name of one of your Pods.
9797

9898
## Updating the deployment
9999

@@ -104,11 +104,15 @@ specifies that the deployment should be updated to use nginx 1.16.1.
104104

105105
1. Apply the new YAML file:
106106

107-
kubectl apply -f https://k8s.io/examples/application/deployment-update.yaml
107+
```shell
108+
kubectl apply -f https://k8s.io/examples/application/deployment-update.yaml
109+
```
108110

109111
1. Watch the deployment create pods with new names and delete the old pods:
110112

111-
kubectl get pods -l app=nginx
113+
```shell
114+
kubectl get pods -l app=nginx
115+
```
112116

113117
## Scaling the application by increasing the replica count
114118

@@ -120,25 +124,33 @@ should have four Pods:
120124

121125
1. Apply the new YAML file:
122126

123-
kubectl apply -f https://k8s.io/examples/application/deployment-scale.yaml
127+
```shell
128+
kubectl apply -f https://k8s.io/examples/application/deployment-scale.yaml
129+
```
124130

125131
1. Verify that the Deployment has four Pods:
126132

127-
kubectl get pods -l app=nginx
133+
```shell
134+
kubectl get pods -l app=nginx
135+
```
128136

129-
The output is similar to this:
137+
The output is similar to this:
130138

131-
NAME READY STATUS RESTARTS AGE
132-
nginx-deployment-148880595-4zdqq 1/1 Running 0 25s
133-
nginx-deployment-148880595-6zgi1 1/1 Running 0 25s
134-
nginx-deployment-148880595-fxcez 1/1 Running 0 2m
135-
nginx-deployment-148880595-rwovn 1/1 Running 0 2m
139+
```
140+
NAME READY STATUS RESTARTS AGE
141+
nginx-deployment-148880595-4zdqq 1/1 Running 0 25s
142+
nginx-deployment-148880595-6zgi1 1/1 Running 0 25s
143+
nginx-deployment-148880595-fxcez 1/1 Running 0 2m
144+
nginx-deployment-148880595-rwovn 1/1 Running 0 2m
145+
```
136146

137147
## Deleting a deployment
138148

139149
Delete the deployment by name:
140150

141-
kubectl delete deployment nginx-deployment
151+
```shell
152+
kubectl delete deployment nginx-deployment
153+
```
142154

143155
## ReplicationControllers -- the Old Way
144156

@@ -147,14 +159,6 @@ which in turn uses a ReplicaSet. Before the Deployment and ReplicaSet were
147159
added to Kubernetes, replicated applications were configured using a
148160
[ReplicationController](/docs/concepts/workloads/controllers/replicationcontroller/).
149161

150-
151-
152-
153162
## {{% heading "whatsnext" %}}
154163

155-
156-
* Learn more about [Deployment objects](/docs/concepts/workloads/controllers/deployment/).
157-
158-
159-
160-
164+
- Learn more about [Deployment objects](/docs/concepts/workloads/controllers/deployment/).

0 commit comments

Comments
 (0)