# Use EMQX Operator to deploy EMQX cluster

The corresponding relationship between EMQX Operator and the applicable EMQX version is as follows:

EMQX VersionEMQX Operator VersionAPIVersion
4.4.6<= EMQX < 4.4.81.2.5v1beta3
4.4.8 <= EMQX1.2.6,1.2.7,1.2.8,2.0.0,2.0.1,2.0.2(推荐)v1beta3

For the latest information about EMQX Operator, please visit EMQX Operator (opens new window). Note: EMQX Operator requires Kubernetes v1.20.11 or above.

# Deploy EMQX Operator

# Prepare

We use cert-manager (opens new window) to provide certificates to EMQX Operator webhook service. For the installation tutorial of cert-manager, please refer to the document: cert-manager document (opens new window).

# Install

  1. Install EMQX Operator
  • Add EMQX helm chart repository
helm repo add emqx https://repos.emqx.io/charts
helm repo update emqx
1
2
  • Install EMQX Operator
helm install emqx-operator emqx/emqx-operator --namespace emqx-operator-system --create-namespace --version=2.0.2
1

NOTE: --version is used to install the specified version of EMQX Operator, if no version is specified, the latest version will be installed by default. Please install the appropriate EMQX Operator version according to the corresponding relationship table between EMQX Operator and applicable EMQX version.

  1. Check whether EMQX Operator is ready
kubectl get pods -l "control-plane=controller-manager" -n emqx-operator-system
1

The output is similar to:

NAME                                                READY   STATUS    RESTARTS   AGE
emqx-operator-controller-manager-68b866c8bf-kd4g6   1/1     Running   0          15s
1
2

NOTE: The NAME field is the name of the EMQX Operator Pod, and the READY field indicates the number of ready Containers in the Pod. The STATUS field is the status of the Pod.

# Deploy EMQX Broker

  1. Deploy EMQX custom resources
cat << "EOF" | kubectl apply -f -
   apiVersion: apps.emqx.io/v1beta3
   kind: EmqxBroker
   metadata:
     name: emqx
   spec:
     emqxTemplate:
       image: emqx/emqx:4.4.9
EOF
1
2
3
4
5
6
7
8
9
  1. Check whether the EMQX cluster is ready
kubectl get emqxbroker emqx -o json | jq ".status.conditions"
1

The output is similar to:

[
   {
     "lastTransitionTime": "2022-12-21T11:59:47Z",
     "lastUpdateTime": "2022-12-21T12:00:28Z",
     "message": "All resources are ready",
     "reason": "ClusterReady",
     "status": "True",
     "type": "Running"
   },
   {
     "lastTransitionTime": "2022-12-21T11:59:34Z",
     "lastUpdateTime": "2022-12-21T11:59:34Z",
     "message": "All default plugins initialized",
     "reason": "PluginInitializeSuccessfully",
     "status": "True",
     "type": "PluginInitialized"
   }
]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

NOTE: From the output, we can see that the EMQX cluster is ready.