# Getting Started

Note: EMQX Operator Controller requires Kubernetes v1.20.0 and up.

# Background

This article was deployed using minikube v1.20.0

# Deployment Operator Controller

This project can be run inside a kubernetes cluster

# Prepare

We using cert manager (opens new window) for provisioning the certificates for the webhook server. You can follow the cert manager documentation (opens new window) to install it.

# Default static install

You don’t require any tweaking of the EMQX Operator Controller install parameters.

The default static configuration can be installed as follows:

$ kubectl apply -f https://raw.githubusercontent.com/emqx/emqx-operator/1.1.2/config/samples/operator/controller.yaml
1

# Installing with Helm

  1. Add the EMQX Helm repository:
$ helm repo add emqx https://repos.emqx.io/charts
$ helm repo update
1
2
  1. Install EMQX Operator Controller by helm
    $ helm install emqx-operator emqx/emqx-operator \
       --set installCRDs=true \
       --namespace emqx-operator-system \
       --create-namespace
    
    1
    2
    3
    4

# 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
2
3

# Deploy the EMQX Broker

  1. Create EMQX Custom Resource file like this

    $ cat https://raw.githubusercontent.com/emqx/emqx-operator/1.1.2/config/samples/emqx/v1beta2/emqx.yaml
    
    apiVersion: apps.emqx.io/v1beta2
    kind: EmqxBroker
    metadata:
      name: emqx
    spec:
      serviceAccountName: "emqx"
      image: emqx/emqx:4.3.11
      replicas: 3
      labels:
        cluster: emqx
      storage:
        storageClassName: standard
        resources:
          requests:
            storage: 20Mi
        accessModes:
        - ReadWriteOnce
      emqxTemplate:
        listener:
          type: ClusterIP
          ports:
            mqtt: 1883
            mqtts: 8883
            ws: 8083
            wss: 8084
            dashboard: 18083
            api: 8081
        acl:
          - permission: allow
            username: "dashboard"
            action: subscribe
            topics:
              filter:
                - "$SYS/#"
                - "#"
          - permission: allow
            ipaddress: "127.0.0.1"
            topics:
              filter:
                - "$SYS/#"
              equal:
                - "#"
          - permission: deny
            action: subscribe
            topics:
              filter:
                - "$SYS/#"
              equal:
                - "#"
          - permission: allow
        plugins:
          - name: emqx_management
            enable: true
          - name: emqx_recon
            enable: true
          - name: emqx_retainer
            enable: true
          - name: emqx_dashboard
            enable: true
          - name: emqx_telemetry
            enable: true
          - name: emqx_rule_engine
            enable: true
          - name: emqx_bridge_mqtt
            enable: false
        modules:
          - name: emqx_mod_acl_internal
            enable: true
          - name: emqx_mod_presence
            enable: true
    
    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
  2. Deploy EMQX Custom Resource and check EMQX status

    $ kubectl apply https://raw.githubusercontent.com/emqx/emqx-operator/1.1.2/config/samples/emqx/v1beta2/emqx.yaml
    emqx.apps.emqx.io/emqx created
    
    $ kubectl get pods
    NAME              READY   STATUS    RESTARTS   AGE
    emqx-0   1/1     Running   0          22m
    emqx-1   1/1     Running   0          22m
    emqx-2   1/1     Running   0          22m
    
    $ kubectl exec -it emqx-0 -- emqx_ctl status
    Node 'emqx@emqx-0.emqx.default.svc.cluster.local' 4.3.11 is started
    
    $ kubectl exec -it emqx-0 -- emqx_ctl cluster status
    Cluster status: #{running_nodes =>
                          ['emqx@emqx-0.emqx.default.svc.cluster.local',
                           'emqx@emqx-1.emqx.default.svc.cluster.local',
                           'emqx@emqx-2.emqx.default.svc.cluster.local'],
                      stopped_nodes => []}
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18

Note:

  • EMQX Operator provides the default listener for EMQX Cluster to connect. The default Type of service is ClusterIP,which can be modified as LoadBalance or NodePort.
  • The ports about wswssmqttmqttsdashboardapi need to be set before deploying because they can't be updated while EMQX Cluster running.