Install EMQX Cluster On K8s

Install EMQX Cluster with EMQX Operator

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

  1. Use cert-manager Install EMQX Cluster On K8s - 图2 (opens new window) for provisioning the certificates for the webhook server. Please follow the cert-manager documentation Install 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
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
helm repo add emqx https://repos.emqx.io/charts
helm repo update
 * Install EMQX Operator Controller by Helm
$ helm install emqx-operator emqx/emqx-operator \
--set installCRDs=true \
--namespace emqx-operator-system \
--create-namespace
  1. Check EMQX Operator Controller Status
$ kubectl get pods -l "control-plane=controller-manager" -n emqx-operator-system
NAME READY STATUS RESTARTS AGE
emqx-operator-controller-manager-68b866c8bf-kd4g6 1/1 Running 0 15s
  1. Deploy the EMQX Broker

  2. Deploy EMQX Custom Resource

$ cat << "EOF" | kubectl apply -f -
apiVersion: apps.emqx.io/v1beta3
kind: EmqxBroker
metadata:
  name: emqx
  labels:
    "foo": "bar"
spec:
  emqxTemplate:
    image: emqx/emqx:4.4.5
EOF
  • Check EMQX status
$ kubectl get pods
 NAME READY STATUS RESTARTS AGE
 emqx-0 2/2 Running 0 22s
 emqx-1 2/2 Running 0 22s
 emqx-2 2/2 Running 0 22s
 $ kubectl exec -it emqx-0 -c emqx -- emqx_ctl status
 Node 'emqx@emqx-0.emqx-headless.default.svc.cluster.local' 4.4.5 is started
 $ kubectl exec -it emqx-0 -c emqx -- emqx_ctl cluster status
 Cluster status: #{running_nodes =>
                   ['emqx@emqx-0.emqx-headless.default.svc.cluster.local',
                    'emqx@emqx-1.emqx-headless.default.svc.cluster.local',
                    'emqx@emqx-2.emqx-headless.default.svc.cluster.local'],
               stopped_nodes => []}