In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-12 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article focuses on "how to deploy EMQ X clusters on Kubernetes". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to deploy EMQ X clusters on Kubernetes.
Rapid deployment of EMQ X clusters on Kubernetes through Helm
Helm chart provided by EMQ X makes it easy to deploy EMQ X to the Kubernetes platform. Before you begin, be sure to follow the Helm documentation guidelines to install Helm.
About Kubernetes
Kubernetes is a widely used open source container orchestration platform that provides automatic deployment, extension, and running of applications.
With Kubernetes, you can respond to customer needs quickly and efficiently:
Deploy applications quickly and predictably
Have the ability to scale applications instantly
Seamlessly release new features without affecting existing business
Optimize hardware resources and reduce costs
Kubernetes has the following characteristics:
Portability: full support for public, private, hybrid, or multi-cloud architectures
Scalable: it is modular, pluggable, mountable, combinable, and supports various forms of extension
Self-repair: it can self-maintain application state, self-restart, self-replication, self-scaling, and provides powerful self-repair capabilities through declarative syntax.
The Kubernetes project was launched by Google in 2014. Kubernetes is based on more than a decade of operation and maintenance experience of Google. All Google applications run on containers, and combined with the best ideas and practices in the community, it is perhaps the most popular container platform.
About Helm
Helm is a package management tool for kubernetes applications, which is used to manage [charts] (https://github.com/kubernetes/charts)-- preconfigured installation package resources, somewhat similar to APT in Ubuntu and yum in CentOS.
Helm chart is a yaml file used to encapsulate kubernetes native applications. Some metadata of the application can be customized when the application is deployed, and then distributed with the application.
The main roles of Helm and charts are:
Application encapsulation
Version management
Dependency check
Easy for application distribution
Setup
Kubernetes 1.6 +
Helm
Quickly deploy a simple EMQ X cluster
Add Helm Warehouse
$helm repo add emqx https://repos.emqx.io/charts
Query EMQ X
Helm search emqxNAME CHART VERSION APP VERSION DESCRIPTIONemqx/emqx v1.0.0-beta.1 v1.0.0-beta.1 A Helm chart for Emqx
EMQ X Chart is currently in Beta, so you need to add-- devel when you execute the helm install command. The official version of Chart does not need to add this option, please note.
Start the EMQ X cluster, set up service.type=NodePort, and specify that the image used is emqx/emqx:v3.2.3
$helm install-devel-name my-emqx-set service.type=NodePort-set image=emqx/emqx:v3.2.3 emqx/emqx
View EMQ X clusters
$kubectl get podsNAME READY STATUS RESTARTS AGEmy-emqx-0 1 Running 0 81mmy-emqx-1 1 Running 0 81mmy-emqx-2 1 Running 0 80m $kubectl exec-it my-emqx-0-- emqx_ctl cluster statusCluster status: [{running_nodes, ['my-emqx@192.168.109.82'] 'my-emqx@192.168.71.78',' my-emqx@192.168.95.126']}]
View EMQ X service
$kubectl get svcNAME TYPE CLUSTER-IP EXTERNAL-IP PORT (S) AGEkubernetes ClusterIP 10.100.0.1 443/TCP 7h36mmy-emqx NodePort 10.100.213.62 1883:30068/TCP 8883:32463/TCP,8080:31854/TCP,8083:32057/TCP,8084:31459/TCP,18083:31539/TCP 57smy-emqx-headless ClusterIP None 1883/TCP,8883/TCP,8080/TCP,8083/TCP,8084/TCP,18083/TCP 57s
You can see that the host IP corresponding to port 18083 of my-emqx is 31539. (NodePort changes each time it is deployed, depending on the actual deployment. )
Access port 31539 of any node IP of Kubernetes, enter the default user name: admin, default password: public, and log in to EMQ X Dashboard.
Delete an EMQ X cluster
$helm del-purge my-emqx
Deploy a persistent EMQ X cluster
EMQ X persists pods by creating a PVC resource mount / opt/emqx/data/mnesia directory. Before deploying EMQ X, users need to deploy load balancers such as Haproxy or Nginx-PLUS, and create PV resources or Storage Classes resources in Kubernetes.
Add Helm Warehouse
$helm repo add emqx https://repos.emqx.io/charts
Start the EMQ X cluster
Persisting an EMQ X cluster requires the following settings:
Image=emqx/emqx:v3.2.3emqxAddressType=hostnamepersistence.enabled=true
* * Note: * * persistent EMQ X only supports versions above v3.2.1
If the user deploys the PV resource, set the persistence.existingClaim=your_pv_name
$helm install-devel-name my-emqx-set image=emqx/emqx:v3.2.3-set emqxAddressType=hostname-set persistence.enabled=true-set persistence.existingClaim=your_pv_name emqx/emqx
If the user deploys the Storage Classes resource, set the persistence.storageClass=your_storageClass_name
$helm install-devel-name my-emqx-set image=emqx/emqx:v3.2.3-set emqxAddressType=hostname-set persistence.enabled=true-set persistence.storageClass=your_storageClass_name emqx/emqx
View EMQ X clusters
$kubectl get podsNAME READY STATUS RESTARTS AGEmy-emqx-0 1 Running 0 81mmy-emqx-1 1 Running 0 81mmy-emqx-2 1 Running 0 80m $kubectl exec-it my-emqx-0-- emqx_ctl cluster statusCluster status: [{running_nodes, ['my-emqx@my-emqx-2.my-emqx-headless.default.svc.cluster.local'] 'my-emqx@my-emqx-1.my-emqx-headless.default.svc.cluster.local',' my-emqx@my-emqx-0.my-emqx-headless.default.svc.cluster.local']}]
Taking Storage Classes as an example, we can see that PVC resources have been successfully established.
$kubectl get pvcNAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGEemqx-data-my-emqx-0 Bound pvc-8094cd75-adb5-11e9-80cc-0697b59e8064 1Gi RWO gp2 2m11semqx-data-my-emqx-1 Bound pvc-9325441d-adb5-11e9-80cc-0697b59e8064 1Gi RWO gp2 99semqx-data-my-emqx-2 Bound pvc-ad425e9d-adb5-11e9-80cc-0697b59e8064 1Gi RWO gp2 56s
The cluster mounts the / opt/emqx/data/mnesia directory of EMQ X into PVC. When Pods is rescheduled, EMQ X takes data from the / opt/emqx/data/mnesia directory and restores it.
View the ClusterIP of EMQ X
$kubectl get svcNAME TYPE CLUSTER-IP EXTERNAL-IP PORT (S) AGEkubernetes ClusterIP 10.100.0.1 443/TCP 24hmy-emqx ClusterIP 10.100.205.13 1883/TCP 8883/TCP,8080/TCP,8083/TCP,8084/TCP,18083/TCP 26mmy-emqx-headless ClusterIP None 1883/TCP,8883/TCP,8080/TCP,8083/TCP,8084/TCP,18083/TCP 26m
You can see that the ClusterIP of my-emqx is 10.100.205.13 (the ClusterIP changes each time it is deployed, depending on the actual deployment. )
Forward ports 1883, 8883, 8080, 8083, 8084 and 18083 of the URL monitored by the load balancer to the ClusterIP of the my-emqx. If there is a need for a TLS connection, it is recommended to terminate the SSL connection in the load balancer. TLS secure connection between client and load balancer, and normal TCP connection between LB and EMQ X.
Visit URL:18083, enter the default user name: admin, default password: public, log in to EMQ X dashboard.
You can easily expand the EMQ X cluster using the helm upgrade command. Here is an example of adding EMQ X nodes to show the helm upgrade command.
# change the number of nodes in EMQ X to 5 # Note: the number of nodes in EMQ X is recommended to be singular $helm upgrade-set replicas=5 my-emqx emqx/emqx
$kubectl get podsNAME READY STATUS RESTARTS AGEmy-emqx-0 1 + 1 Running 0 81mmy-emqx-1 1 + 1 + 1 Running 0 81mmy-emqx-2 1 + + 1 Running 0 80mmy-emqx-3 1 + + 1 Running 0 22mmy-emqx-4 1 + + 1 Running 0 22m $kubectl exec- It my-emqx-0-- emqx_ctl cluster statusCluster status: [{running_nodes ['my-emqx@my-emqx-4.my-emqx-headless.default.svc.cluster.local',' my-emqx@my-emqx-3.my-emqx-headless.default.svc.cluster.local', 'my-emqx@my-emqx-2.my-emqx-headless.default.svc.cluster.local' 'my-emqx@my-emqx-1.my-emqx-headless.default.svc.cluster.local',' my-emqx@my-emqx-0.my-emqx-headless.default.svc.cluster.local']}]
Delete an EMQ X cluster
$helm del-purge my-emqx
* * Note: * * PVC resources will not be automatically released after the EMQ X cluster is deleted in order to restore EMQ X. You need to delete PVC resources manually after confirming that recovery is not needed.
$kubectl get pvcNAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGEemqx-data-my-emqx-0 Bound pvc-8094cd75-adb5-11e9-80cc-0697b59e8064 1Gi RWO gp2 84memqx-data-my-emqx-1 Bound pvc-9325441d-adb5-11e9-80cc-0697b59e8064 1Gi RWO gp2 84memqx-data-my-emqx-2 Bound pvc-ad425e9d-adb5-11e9-80cc-0697b59e8064 1Gi RWO gp2 83memqx-data-my-emqx-3 Bound pvc-b6c5a565-adbd-11e9-80cc-0697b59e8064 1Gi RWO gp2 25memqx-data-my-emqx-4 Bound pvc-c626cafd-adbd-11e9-80cc-0697b59e8064 1Gi RWO gp2 25m $kubectl delete pvc emqx-data-my-emqx-0 emqx-data-my-emqx-1 emqx-data-my-emqx-2 emqx-data-my-emqx-3 emqx-data-my-emqx-4 persistentvolumeclaim "emqx-data-my-emqx-0" deletedpersistentvolumeclaim "emqx-data-my-emqx-1" deletedpersistentvolumeclaim "emqx-data-my-emqx-2" deletedpersistentvolumeclaim "emqx-data-my-emqx-3" deletedpersistentvolumeclaim "emqx-data-my-emqx-4" deleted
Deploy EMQ X Edge clusters and EMQ X Enterprise Cluster EMQ X Edge
The deployment EMQ X Edge cluster specifies image=emqx/emqx-edge:v3.2.3, and other settings are consistent with the deployment of the EMQ X cluster
$helm install-devel-name my-emqx-set service.type=NodePort-set image=emqx/emqx-edge:v3.2.3 emqx/emqxEMQ X EE
To deploy the EMQ X Enterprise Edition cluster, you first need to log in to emqx.io and download the License file, and create the License file as a Secret resource.
$kubectl create secret generic your-license-secret-name-from-file=/path/to/emqx.lic
Then specify emqxLicneseSecretName=your-license-secret-name,image=emqx/emqx-ee:v3.4.0 at deployment time, and other settings are consistent with the deployment of the EMQ X cluster
Helm install-- devel-- name my-emqx-- set service.type=NodePort-- set image=emqx/emqx-ee:v3.2.3-- set emqxLicneseSecretName=your-license-secret-name emqx/emqxEMQ X Helm Chart configuration item parameter describes the number of Default ValueapiserverKubernates API server https://kubernetes.default.svc:443namespacekubernetes namespacedefaultreplicasEMQ X nodes. It is recommended to keep an odd number of nodes. Otherwise, the 3imageEMQ X image name cannot be automatically restored after the brain fissure. The policy for getting the image emqx/emqx:latestimagePullPolicy is whether PVCfalsepersistence.storageClassStorage class name nilpersistence.existingClaimPV name "" persistence.accessModePVC access mode ReadWriteOncepersistence.sizePVC capacity 20MiresourcesCPU/ memory resource {} service.typeEmqx cluster service type ClusterIPservice.mqttPortMQTT protocol port 1883service.mqttsslPortMQTT/SSL port 8883service.mgmtPort management API port 8080service.websocketPortMQTT/WebSocket port 8083service.wssPortMQTT/WebSocket/SSL port 8084service.dashboardPortDashboard end Port 18083emqxAddressType is used to obtain EMQ X nodes from k8s service
Optional values: ip, dns, hostname
Note: hosename only supports ipemqxConfigEMQ X configuration for versions later than EMQ X v3.2.1. For more information, document {} emqxLicneseSecretNameEMQ X Enterprise Edition requires manual creation of License files as Secret resources ""
When you need to set complex parameters, you can use the Yaml file to record the parameters
Helm install-- devel-- name my-emqx-f values.yaml emqx/emqx here, I believe you have a better understanding of "how to deploy EMQ X clusters on Kubernetes". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.