Install EMQX Cluster with EMQX Operator

For more information about latest EMQX Operator, please access githubInstall EMQX Cluster On K8s - 图1 (opens new window).

  1. Use cert-managerInstall EMQX Cluster On K8s - 图2 (opens new window) for provisioning the certificates for the webhook server. Please follow the cert-manager documentationInstall EMQX Cluster On K8s - 图3 (opens new window) to install it。

  2. Install Operator Controller Manager service in one of the following ways:

    • Install with default static files
    1. curl -f -L "https://github.com/emqx/emqx-operator/releases/download/1.2.2/emqx-operator-controller.yaml" | kubectl apply -f -
    • Install with Helm
      • Add the EMQX Helm repository
    1. helm repo add emqx https://repos.emqx.io/charts
    2. helm repo update
    • Install EMQX Operator Controller by Helm
    1. $ helm install emqx-operator emqx/emqx-operator \
    2. --set installCRDs=true \
    3. --namespace emqx-operator-system \
    4. --create-namespace
  3. Check EMQX Operator Controller Status

    1. $ kubectl get pods -l "control-plane=controller-manager" -n emqx-operator-system
    2. NAME READY STATUS RESTARTS AGE
    3. emqx-operator-controller-manager-68b866c8bf-kd4g6 1/1 Running 0 15s
  4. Deploy the EMQX Broker

  • Deploy EMQX Custom Resource

    1. $ cat << "EOF" | kubectl apply -f -
    2. apiVersion: apps.emqx.io/v1beta3
    3. kind: EmqxBroker
    4. metadata:
    5. name: emqx
    6. labels:
    7. "foo": "bar"
    8. spec:
    9. emqxTemplate:
    10. image: emqx/emqx:4.4.5
    11. EOF
  • Check EMQX status

    1. $ kubectl get pods
    2. NAME READY STATUS RESTARTS AGE
    3. emqx-0 2/2 Running 0 22s
    4. emqx-1 2/2 Running 0 22s
    5. emqx-2 2/2 Running 0 22s
    6. $ kubectl exec -it emqx-0 -c emqx -- emqx_ctl status
    7. Node 'emqx@emqx-0.emqx-headless.default.svc.cluster.local' 4.4.5 is started
    8. $ kubectl exec -it emqx-0 -c emqx -- emqx_ctl cluster status
    9. Cluster status: #{running_nodes =>
    10. ['emqx@emqx-0.emqx-headless.default.svc.cluster.local',
    11. 'emqx@emqx-1.emqx-headless.default.svc.cluster.local',
    12. 'emqx@emqx-2.emqx-headless.default.svc.cluster.local'],
    13. stopped_nodes => []}