-
Notifications
You must be signed in to change notification settings - Fork 47
/
Blue-Green-Deployment-Lab-6.txt
150 lines (86 loc) · 4.67 KB
/
Blue-Green-Deployment-Lab-6.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
Lab: Blue-Green Deployment
##########################
Create a new project:
[root@master ~]# oc new-project bluegreen --description="Blue Green Deployment" --display-name="bluegreen"
Go to Openshift Dashboard and Select bluegreen Project
Click on "Browse Catalog" Select "PHP" Builder Image -> Next
Version : 7.1 - latest
Application Name : blueapp
Git Repository : https://github.com/sureshchandrarhca15/openshift-bluegreen.git
Expend "Advanced Options" and uncheck the box of "Create a route to the application" in Routing Section.
We will create the route later.
Click on Create.
Now go to Overview to see the status. You can also use the CLI to see the status.
[root@master ~]# oc project bluegreen
[root@master ~]# oc get bc
NAME TYPE FROM LATEST
blueapp Source Git@master 1
[root@master ~]# oc logs -f bc/blueapp
[root@master ~]# oc get dc
NAME REVISION DESIRED CURRENT TRIGGERED BY
blueapp 1 1 1 config,image(blueapp:latest)
[root@master ~]# oc get rc
NAME DESIRED CURRENT READY AGE
blueapp-1 1 1 1 42s
[root@master ~]# oc get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
blueapp ClusterIP 172.30.112.74 <none> 8080/TCP,8443/TCP 7m
Let's create a route for this application:
[root@master ~]# oc expose service blueapp --name=bluegreen --hostname=bluegreen.apps.openshift.example.com
[root@master ~]# oc get route
NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD
bluegreen bluegreen.apps.openshift.example.com blueapp 8080-tcp None
Now Open Web Browser and Point to the below URL to access the Application:
http://bluegreen.apps.openshift.example.com
Now let's Deploy the Green Application
First we need to change in Git Repository Code to make the green colour box. You need to modify "image.php"
Go to Openshift Dashboard and Select bluegreen Project
Click on "Add to Project" Dropdown Menu -> "Browse Catalog" Select "PHP" Builder Image -> Next
Version : 7.1 - latest
Application Name : greenapp
Git Repository : https://github.com/sureshchandrarhca15/openshift-bluegreen.git
Expend "Advanced Options" and uncheck the box of "Create a route to the application" in Routing Section. We will use the same route which we have created previously for blueapp.
Click on Create.
Now go to Overview to see the status. You can also use the CLI to see the status.
[root@master ~]# oc get bc
NAME TYPE FROM LATEST
blueapp Source Git@master 1
greenapp Source Git@master 1
[root@master ~]# oc logs -f bc/greenapp
[root@master ~]# oc get dc
NAME REVISION DESIRED CURRENT TRIGGERED BY
blueapp 1 1 1 config,image(blueapp:latest)
greenapp 1 1 1 config,image(greenapp:latest)
[root@master ~]# oc get rc
NAME DESIRED CURRENT READY AGE
blueapp-1 1 1 1 14m
greenapp-1 1 1 1 1m
[root@master ~]# oc get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
blueapp ClusterIP 172.30.112.74 <none> 8080/TCP,8443/TCP 21m
greenapp ClusterIP 172.30.74.6 <none> 8080/TCP 4m
[root@master ~]# oc get route
NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD
bluegreen bluegreen.apps.openshift.example.com blueapp 8080-tcp None
Now lets change the route from blueapp to greenapp Service
[root@master ~]# oc edit route bluegreen
...
spec:
host: bluegreen.apps.openshift.example.com
port:
targetPort: 8080-tcp
to:
kind: Service
name: greenapp # Change blueapp to greenapp Service
weight: 100
wildcardPolicy: None
...
:wq (save and exit)
[root@master ~]# oc get route
NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD
bluegreen bluegreen.apps.openshift.example.com greenapp 8080-tcp None
Now Refresh the Below URL:
http://bluegreen.apps.openshift.example.com/
You shoud see green box. If there is some issue in Greenapp Deployment, You can rollback to Blueapp Deployment By using the same way.
Congratulations, you have successfully done Bluegreen Deployment in Openshift Cluster.
##########################################################################