# 利用 EMQX Operator 部署 EMQX 集群

EMQX Operator 最新信息, 请访问 github (opens new window).

  1. 使用 cert-manager (opens new window) 给 webhook 服务提供证书,可以参考 cert-manager 文档 (opens new window) 安装

  2. 可以通过如下两种方式之一来安装 Operator Controller:

    • 使用静态文件安装
    curl -f -L "https://github.com/emqx/emqx-operator/releases/download/1.2.2/emqx-operator-controller.yaml" | kubectl apply -f -
    
    1
    • 使用 Helm 安装

      • 添加 EMQX Helm 仓库
      helm repo add emqx https://repos.emqx.io/charts
      helm repo update
      
      1
      2
      • 用 Helm 安装 EMQX Operator 控制器
      $ helm install emqx-operator emqx/emqx-operator \
        --set installCRDs=true \
        --namespace emqx-operator-system \
        --create-namespace
      
      1
      2
      3
      4
  3. 检查 EMQX Operator 控制器状态

    $ 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
  1. 部署 EMQX Enterprise
  • 部署 EMQX Custom Resource

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

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