forked from sureshchandrarhca15/Openshift39-Cluster-Files
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rolling-Update-Upgrade-Lab-3.txt
271 lines (178 loc) · 7.54 KB
/
Rolling-Update-Upgrade-Lab-3.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
Lab: Rolling Update in Openshift
#################################
Step 1: Create a Project
[root@master ~]# oc new-project rolling-update
Step 2: Let's create a sample application:
[root@master ~]# oc run rolling --image=openshift/hello-openshift --replicas=9
[root@master ~]# oc get dc
NAME REVISION DESIRED CURRENT TRIGGERED BY
rolling 1 9 9 config
[root@master ~]# oc get rc
NAME DESIRED CURRENT READY AGE
rolling-1 9 9 9 37s
Step 3: Create a service
[root@master ~]# oc expose dc/rolling --port 8080
[root@master ~]# oc get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
rolling ClusterIP 172.30.187.117 <none> 8080/TCP 5s
[root@master ~]# oc describe svc rolling
Name: rolling
Namespace: rolling-update
Labels: run=rolling
Annotations: <none>
Selector: run=rolling
Type: ClusterIP
IP: 172.30.187.117
Port: <unset> 8080/TCP
TargetPort: 8080/TCP
Endpoints: 10.129.0.24:8080,10.129.0.25:8080,10.129.0.26:8080 + 6 more...
Session Affinity: None
Events: <none>
Step 4: Expose the Service
[root@master ~]# oc expose svc/rolling
root@master ~]# oc get route
NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD
rolling rolling-rolling-update.apps.openshift.example.com rolling 8080 None
Step 5: Get the details of Pod, SVC, Route etc.
[root@master ~]# oc get pod
NAME READY STATUS RESTARTS AGE
rolling-1-9j22t 1/1 Running 0 2m
rolling-1-dpgsk 1/1 Running 0 2m
rolling-1-fjm5m 1/1 Running 0 2m
rolling-1-gr55m 1/1 Running 0 2m
rolling-1-ks8r9 1/1 Running 0 2m
rolling-1-lcsjg 1/1 Running 0 2m
rolling-1-p4q5m 1/1 Running 0 2m
rolling-1-wtdsc 1/1 Running 0 2m
rolling-1-znr2s 1/1 Running 0 2m
[root@master ~]# oc get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
rolling ClusterIP 172.30.187.117 <none> 8080/TCP 1m
[root@master ~]# oc get route
NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD
rolling rolling-rolling-update.apps.openshift.example.com rolling 8080 None
Step 6: Use the below command to access the application
sam@ThinkPad-E450:~$ while true ; do curl http://rolling-rolling-update.apps.openshift.example.com ; sleep 1; done
You will see the below outpit:
Hello OpenShift!
Hello OpenShift!
Hello OpenShift!
Step 7: Once the application is up and running, we can trigger a new deployment.
To do so, we will change configuration of the deployment by setting the environment variable, which should trigger a new deployment.
Do the below change in DC config:
[root@master ~]# oc edit dc rolling
.....
strategy:
activeDeadlineSeconds: 21600
resources: {}
rollingParams:
intervalSeconds: 20 # this line, change from 1 to 20 seconds
maxSurge: 25%
maxUnavailable: 25%
timeoutSeconds: 600
updatePeriodSeconds: 20 # this line, change from 1 to 20 seconds
type: Rolling
.......
[root@master ~]# oc set env dc/rolling RESPONSE="Hello from new roll"
Step 8: verify it:
[root@master ~]# oc get dc
NAME REVISION DESIRED CURRENT TRIGGERED BY
rolling 2 9 9 config
[root@master ~]# oc get pod
NAME READY STATUS RESTARTS AGE
rolling-2-bgkz9 1/1 Running 0 2m
rolling-2-jcswz 1/1 Running 0 2m
rolling-2-jmgq5 1/1 Running 0 2m
rolling-2-k7b8z 1/1 Running 0 2m
rolling-2-mkt8m 1/1 Running 0 2m
rolling-2-mlt2m 1/1 Running 0 2m
rolling-2-tlmrx 1/1 Running 0 2m
rolling-2-wpcn7 1/1 Running 0 2m
rolling-2-xkn8c 1/1 Running 0 2m
sam@ThinkPad-E450:~$ while true ; do curl http://rolling-rolling-update.apps.openshift.example.com ; sleep 1; done
Hello from new roll
Hello from new roll
Hello from new roll
Step 9: Trigger the new deployment again
[root@master ~]# oc set env dc/rolling RESPONSE="Hello from new roll 2"
sam@ThinkPad-E450:~$ while true ; do curl http://rolling-rolling-update.apps.openshift.example.com ; sleep 1; done
Hello from new roll
Hello from new roll
Hello from new roll
Hello from new roll
Hello from new roll
Hello from new roll 2
Hello from new roll
Hello from new roll
Hello from new roll
Hello from new roll 2
Hello from new roll
Hello from new roll
Hello from new roll 2
Hello from new roll
Hello from new roll
Hello from new roll 2
Hello from new roll 2
Hello from new roll 2
Hello from new roll
Hello from new roll
Step 10: View the Deployment history.
root@master ~]# oc get dc
NAME REVISION DESIRED CURRENT TRIGGERED BY
rolling 3 9 9 config
[root@master ~]# oc rollout history dc/rolling
deploymentconfigs "rolling"
REVISION STATUS CAUSE
1 Complete config change
2 Complete config change
3 Complete config change
You can view details specific to a revision by using the --revision flag:
[root@master ~]# oc rollout history dc/rolling --revision=2
deploymentconfigs "rolling" with revision #2
Pod Template:
Labels: deployment=rolling-2
deploymentconfig=rolling
run=rolling
Annotations: openshift.io/deployment-config.latest-version=2
openshift.io/deployment-config.name=rolling
openshift.io/deployment.name=rolling-2
Containers:
rolling:
Image: openshift/hello-openshift
Port: <none>
Environment:
RESPONSE: Hello from new roll
Mounts: <none>
Volumes: <none>
[root@master ~]#
[root@master ~]# oc rollout history dc/rolling --revision=3
deploymentconfigs "rolling" with revision #3
Pod Template:
Labels: deployment=rolling-3
deploymentconfig=rolling
run=rolling
Annotations: openshift.io/deployment-config.latest-version=3
openshift.io/deployment-config.name=rolling
openshift.io/deployment.name=rolling-3
Containers:
rolling:
Image: openshift/hello-openshift
Port: <none>
Environment:
RESPONSE: Hello from new roll 2
Mounts: <none>
Volumes: <none>
[root@master ~]#
Step 11: If the current revision of your deployment configuration failed to deploy, you can restart the deployment process with:
[root@master ~]# oc rollout retry dc/rolling
error: rollout #3 is complete; only failed deployments can be retried.
You can start a new deployment with 'oc rollout latest dc/rolling'.
If the latest revision of it was deployed successfully, the command will display a message and the deployment process will not be retried.
Step 12: Rolling Back a Deployment
To rollback to the last successful deployed revision of your configuration:
[root@master ~]# oc rollout undo dc/rolling
To rollback to the specific revision of your configuration:
[root@master ~]# oc rollout undo dc/rolling --to-revision=1
Step 13: Delete everything
[root@master ~]# oc delete project rolling-update
##############################################################################