当前位置: 首页 > 工具软件 > emqx-operator > 使用案例 >

K8S - 集群中部署EMQX

昌栋
2023-12-01

1、Add helm repository

$ helm repo add emqx https://repos.emqx.io/charts
$ helm repo update

2、Check EMQ X

helm search repo emqx
NAME           CHART VERSION  APP VERSION DESCRIPTION
emqx/emqx      v4.0.0         v4.0.0      A Helm chart for EMQ X
emqx/emqx-ee v4.0.0           v4.0.0      A Helm chart for EMQ X
emqx/kuiper    0.1.1          0.1.1       A lightweight IoT edge analytic software

3、Start EMQ X cluster and set service.type=NodePort

$ helm install my-emqx emqx/emqx --set service.type=NodePort

4、Check the cluster status of EMQ X

$ kubectl get pods
NAME       READY  STATUS             RESTARTS  AGE
my-emqx-0  1/1     Running   0          56s
my-emqx-1  1/1     Running   0          40s
my-emqx-2  1/1     Running   0          21s

$ kubectl exec -it my-emqx-0 -- emqx_ctl cluster status
Cluster status: #{running_nodes =>
                      ['my-emqx@my-emqx-0.my-emqx-headless.default.svc.cluster.local',
                       'my-emqx@my-emqx-1.my-emqx-headless.default.svc.cluster.local',
                       'my-emqx@my-emqx-2.my-emqx-headless.default.svc.cluster.local'],
                  stopped_nodes => []}

5、Check EMQ X service

$ kubectl get svc
NAME                 TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)                                                                                      AGE
my-emqx              NodePort       10.101.143.92    <none>        1883:32756/TCP,8883:31569/TCP,8081:30585/TCP,8083:31804/TCP,8084:30523/TCP,18083:31253/TCP   4m33s
my-emqx-headless     ClusterIP      None             <none>        1883/TCP,8883/TCP,8081/TCP,8083/TCP,8084/TCP,18083/TCP                                       4m33s
  • 可以看到,我的emqx的18083端口对应的主机IP是31253。(NodePort在每次部署过程中都会发生变化,具体取决于实际的部署情况。)

  • Kubernetes任意节点IP访问端口31253,输入默认用户名“admin”,默认密码“public”,登录EMQ X仪表盘。

6、Delete EMQ X cluster

$ helm uninstall my-emqx
release "my-emqx" uninstalled

 类似资料: