You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/en_US/tasks/configure-emqx-blueGreenUpdate.md
+77-70Lines changed: 77 additions & 70 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,31 +18,6 @@ This feature only supports `apps.emqx.io/v1beta4 EmqxEnterprise` and `apps.emqx.
18
18
19
19
2. During the rolling update process, only N - 1 Pods can provide services because it takes some time for new Pods to start up and become ready. This may lead to a decrease in service availability.
20
20
21
-
```mermaid
22
-
timeline
23
-
section Update start
24
-
Current Cluster<br>Have Endpoint
25
-
: pod-0
26
-
: pod-1
27
-
: pod-2
28
-
section Rolling update
29
-
Current Cluster<br>Have Endpoint
30
-
: pod-0
31
-
: pod-1
32
-
Update Cluster<br>Have Endpoint
33
-
: pod-2
34
-
Current Cluster<br>Have Endpoint
35
-
: pod-0
36
-
Update Cluster<br>Have Endpoint
37
-
: pod-1
38
-
: pod-2
39
-
section Finish Update
40
-
Update Cluster<br>Have Endpoint
41
-
: pod-0
42
-
: pod-1
43
-
: pod-2
44
-
```
45
-
46
21
## Solution
47
22
48
23
Regarding the issue of rolling updates mentioned in the previous text, EMQX Operator provides a blue-green deployment upgrade solution. When upgrading the EMQX cluster using EMQX custom resources, EMQX Operator will create a new EMQX cluster and redirect the Kubernetes Service to the new EMQX cluster after it is ready. It will then gradually delete Pods from the old EMQX cluster to achieve the purpose of updating the EMQX cluster.
@@ -51,51 +26,67 @@ When deleting Pods from the old EMQX cluster, EMQX Operator can also take advant
51
26
52
27
The entire upgrade process can be roughly divided into the following steps:
53
28
54
-
1. Create a cluster with the same specifications.
55
-
56
-
2. After the new cluster is ready, redirect the service to the new cluster and remove the old cluster from the service. At this time, the new cluster starts to receive traffic, and existing connections in the old cluster are not affected.
57
-
58
-
3. (Only supported by EMQX Enterprise Edition) Use EMQX node evacuation function to evacuate connections on each node one by one.
59
-
60
-
4. Gradually scale down the old cluster to 0 nodes.
61
-
29
+
1. Create new Pods with the EMQX custom resource, and join the new Pods to the EMQX cluster.
30
+
2. After the new Pods are ready, redirect the Service to the new Pods and remove the old Pods from the Service. At this time, the new Pods start to receive traffic, and existing connections in the old Pods are not affected.
31
+
3. (Only supported by EMQX Enterprise Edition) Use the EMQX node evacuation function to evacuate connections on each node one by one.
32
+
4. Gradually scale down the old Pods to 0.
62
33
5. Complete the upgrade.
63
34
64
35
```mermaid
65
-
timeline
66
-
section Update start
67
-
Current Cluster<br>Have Endpoint
68
-
: pod-0
69
-
: pod-1
70
-
: pod-2
71
-
section Create update cluster
72
-
Current Cluster
73
-
: pod-0
74
-
: pod-1
75
-
: pod-2
76
-
Update Cluster<br>Have Endpoint
77
-
: pod-0
78
-
: pod-1
79
-
: pod-2
80
-
section Updating cluster
81
-
Current Cluster
82
-
: pod-0
83
-
: pod-1
84
-
Update Cluster<br>Have Endpoint
85
-
: pod-0
86
-
: pod-1
87
-
: pod-2
88
-
Current Cluster
89
-
: pod-0
90
-
Update Cluster<br>Have Endpoint
91
-
: pod-0
92
-
: pod-1
93
-
: pod-2
94
-
section Finish Update
95
-
Update Cluster<br>Have Endpoint
96
-
: pod-0
97
-
: pod-1
98
-
: pod-2
36
+
stateDiagram-v2
37
+
[*] --> Step1
38
+
Step1: Create new pods
39
+
state Step1 {
40
+
[*] --> CreateNewPods
41
+
CreateNewPods: Create new pods
42
+
CreateNewPods --> NewPodsJoinTheCluster
43
+
NewPodsJoinTheCluster: New pods join the cluster
44
+
NewPodsJoinTheCluster --> WaitNewPodsReady
45
+
WaitNewPodsReady: Wait new pods ready
46
+
WaitNewPodsReady --> LBServiceSelectNewPods
47
+
LBServiceSelectNewPods: Redirect the Service to the new Pods and remove the old Pods from the Service
48
+
LBServiceSelectNewPods --> [*]
49
+
}
50
+
Step1 --> Step2
51
+
Step2: Delete old pods
52
+
state HasReplNode <<choice>>
53
+
state NodeEvacuationToNewPod1 <<choice>>
54
+
state NodeEvacuationToNewPod2 <<choice>>
55
+
state Step2 {
56
+
[*] --> SelectOldestPod
57
+
SelectOldestPod: Select oldest pod
58
+
SelectOldestPod --> HasReplNode
59
+
60
+
HasReplNode --> SelectOldestReplPod: Has EMQX's replicant node pod
61
+
SelectOldestReplPod: Select oldest EMQX's replicant node pod
62
+
SelectOldestReplPod --> NodeEvacuationToNewPod1
63
+
NodeEvacuationToNewPod1 --> NodeEvacuationToNewReplPod1: New pods has EMQX's replicant node
64
+
NodeEvacuationToNewReplPod1: Node evacuation to new EMQX's replicant node pod
## How to update the EMQX cluster through blue-green deployment.
@@ -131,7 +122,7 @@ spec:
131
122
132
123
`sessEvictRate`: MQTT Session evacuation rate, only supported by EMQX Enterprise Edition (unit: count/second)。
133
124
134
-
Save the above content as: `emqx-update.yaml`, execute the following command to deploy EMQX:
125
+
Save the above content as: `emqx-update.yaml`, execute the following command to deploy EMQX, in this example, just deploy EMQX core node cluster without replicant node:
135
126
136
127
```bash
137
128
$ kubectl apply -f emqx-update.yaml
@@ -231,10 +222,26 @@ Output is similar to:
231
222
emqx.apps.emqx.io/emqx-ee patched
232
223
```
233
224
234
-
- Check status.
225
+
- Check the status of the EMQX core nodes
226
+
227
+
```bash
228
+
kubectl get emqx emqx-ee -o json | jq '.status.coreNodesStatus'
229
+
{
230
+
"currentReplicas": 2,
231
+
"currentRevision": "54fc496fb4",
232
+
"readyReplicas": 4,
233
+
"replicas": 2,
234
+
"updateReplicas": 2,
235
+
"updateRevision": "5d87d4c6bd"
236
+
}
237
+
```
238
+
239
+
In this example, the old StatefulSet is `emqx-${currentRevision}`, which has 2 ready pods. The new StatefulSet is `emqx-${updateRevision}`, which has 2 ready pods. Then the EMQX Operator will start the node evacuation process.
240
+
241
+
- Check node evacuations status.
235
242
236
243
```bash
237
-
$ kubectl get emqx emqx-ee -o json | jq ".status.nodEvacuationsStatus"
244
+
$ kubectl get emqx emqx-ee -o json | jq ".status.nodeEvacuationsStatus"
0 commit comments