In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "how to use Rancher to deploy EMQ X cluster on Kubernetes". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to deploy EMQ X cluster on Kubernetes using Rancher".
Experimental environment:
Public cloud environment: AWS EC2
Operating system: ubuntu 16.04
Docker version:18.09.0
Deploy a kubernetes cluster through Rancher
The steps for installing Rancher and deploying a kubernetes cluster are recommended to follow the Quick start directly.
Create a Rancher Api key
EMQ X implements automatic clustering by accessing kube-apiserver. In Rancher, Rancher acts as a proxy to kube-apiserver, and when accessing kube-apiserver, you must provide an API key for authentication to Rancher. Refer to the user's manual to create and save the API Key. The Access Key created in this lab is: token-dksbl,Secret Key: pshhhf5cp8d5v5x7bzjdm82qfrwgx7f2bzksnr748j42xmbvvklbdz, and the combined Token is: token-dksbl:pshhhf5cp8d5v5x7bzjdm82qfrwgx7f2bzksnr748j42xmbvvklbdz
Download and configure kubectl
Download and install kubectl
Go to the Rancher cluster page and click on the Kubeconfig file.
Save the kubeconfig file to ~ / .kube/config
Execute kubectl cluster-info to verify that the configuration is successful
$kubectl cluster-infoKubernetes master is running at https://13.125.244.172/k8s/clusters/c-vvgjqKubeDNS is running at https://13.125.244.172/k8s/clusters/c-vvgjq/api/v1/namespaces/kube-system/services/kube-dns:dns/proxyTo further debug and diagnose cluster problems, use 'kubectl cluster-info dump'. Visit kube-apiserver
EMQ X implements automatic clustering by accessing kube-apiserver. The address of kube-apiserver can be obtained by viewing the ~ / .ssh / config file or performing kubectl cluster-info acquisition. In this lab, the address of kube-apiserver is: https://13.125.244.172/k8s/clusters/c-vvgjq.
If you visit kube-apiserver directly, you can see that an error will be reported and authentication is required.
$curl-k https://13.125.244.172/k8s/clusters/c-vvgjq{"type":"error","status":"401","message":"must authenticate "}
Add Authorization authentication to the header for normal access.
$curl-k-H 'Authorization: Bearer token-dksbl:pshhhf5cp8d5v5x7bzjdm82qfrwgx7f2bzksnr748j42xmbvvklbdz' https://13.125.244.172/k8s/clusters/c-vvgjq Editing emqx.yaml
The second article in the series of installing EMQ X on Kubernetes: EMQ X Automated Cluster shares the yaml file for EMQ X to deploy a kubernetes cluster as follows. If you deploy an EMQ X cluster on Rancher, you need to make some changes.
$cat emqx.yamlapiVersion: v1kind: Servicemetadata: name: emqxspec: ports:-port: 32333 nodePort: 32333 targetPort: emqx-dashboard protocol: TCP selector: app: emqx type: NodePort---apiVersion: extensions/v1beta1kind: Deploymentmetadata: name: emqx labels: app: emqxspec: replicas: 2 template: metadata: labels: app: emqxspec: containers:-name: emqx image: emqx/emqx:latest Ports:-name: emqx-dashboard containerPort: 18083 env:-name: EMQX_CLUSTER__DISCOVERY value: K8s-name: EMQX_NAME value: emqx- name: EMQX_CLUSTER__K8S__APISERVER value: http://172.31.19.161:8080-name: EMQX_CLUSTER__K8S__NAMESPACE value: Default-name: EMQX_CLUSTER__K8S__SERVICE_NAME value: emqx-name: EMQX_CLUSTER__K8S__ADDRESS_TYPE value: ip-name: EMQX_CLUSTER__K8S__APP_NAME value: emqx tty: true
EMQ X can read the content combination Authorization authentication in the / var/run/secrets/kubernetes.io/serviceaccount/token file to access the kube-apiserver, so you just need to mount the API Token of the Rancher into the container via Secret.
Secret solves the problem of configuring sensitive data such as passwords, token, keys, etc., without exposing these sensitive data to the mirror or Pod Spec. Secret can be used as Volume or environment variables.
There are three types of Secret:
Service Account: used to access Kubernetes API, automatically created by Kubernetes, and automatically mounted to the / run/secrets/kubernetes.io/serviceaccount directory of Pod
Opaque: Secret in base64 format, used to store passwords, keys, etc.
Kubernetes.io/dockerconfigjson: used to store authentication information for private docker registry.
First, do base64 coding for API Token.
$echo-n token-dksbl:pshhhf5cp8d5v5x7bzjdm82qfrwgx7f2bzksnr748j42xmbvvklbdz | base64-w 0dG9rZW4tZGtzYmw6cHNoaGhmNWNwOGQ1djV4N2J6amRtODJxZnJ3Z3g3ZjJiemtzbnI3NDhqNDJ4bWJ2dmtsYmR6
Create a Secret in a yaml file
$vim emqx.yamlapiVersion: v1kind: Secretmetadata: name: emqx-secrettype: Opaquedata: token: dG9rZW4tcGI2MjU6eDZ2eGJ0Y2NmdG1waGpseHR3NGNjdGN2d2txdzk5aDJzYmhxNHFtaDh5c2ZnbXd6dzJ0d2Rw---.
Modify Deployment, change the EMQX_CLUSTER__K8S__APISERVER in the environment variable to the address of Rancher's Kube-apiserver, and add volumeMounts
$vim emqx.yaml.apiVersion: extensions/v1beta1kind: Deploymentmetadata: name: emqx labels: app: emqxspec: replicas: 2 template: metadata: labels: app: emqxspec: volumes:-name: emqx-secret secret: secretName: emqx-secret containers:-name: emqx image: emqx/emqx:latest ports:-name: emqx -dashboard containerPort: 18083-name: emqx-http containerPort: 8083-name: emqx-mqtt containerPort: 1883 env:-name: EMQX_CLUSTER__DISCOVERY value: K8s-name: EMQX_NAME value: emqx- name: EMQX_CLUSTER__K8S__APISERVER value: https://13.125.244.172/k8s / clusters/c-vvgjq-name: EMQX_CLUSTER__K8S__NAMESPACE value: default-name: EMQX_CLUSTER__K8S__SERVICE_NAME value: emqx-name: EMQX_CLUSTER__K8S__ADDRESS_TYPE value: ip-name: EMQX_CLUSTER__K8S__APP_NAME value: emqx tty: true volumeMounts: -name: emqx-secret mountPath: "/ var/run/secrets/kubernetes.io/serviceaccount" readOnly: true deployment EMQ X
View the modified emqx.yaml
Cat emqx.yamlapiVersion: v1kind: Secretmetadata: name: emqx-secrettype: Opaquedata: token: dG9rZW4tcGI2MjU6eDZ2eGJ0Y2NmdG1waGpseHR3NGNjdGN2d2txdzk5aDJzYmhxNHFtaDh5c2ZnbXd6dzJ0d2Rw---apiVersion: v1kind: Servicemetadata: name: emqxspec: ports:-port: 32333 nodePort: 32333 targetPort: emqx-dashboard protocol: TCP selector: app: emqx type: NodePort---apiVersion: extensions/v1beta1kind: Deploymentmetadata: name: emqx labels: app: emqxspec: replicas: 2 template: metadata: labels: app: emqxspec: Volumes:-name: emqx-secret secret: secretName: emqx-secret containers:-name: emqx image: emqx/emqx:latest ports:-name: emqx-dashboard containerPort: 18083-name: emqx-http containerPort: 8083-name: emqx-mqtt containerPort: 1883 env:-name: EMQX_CLUSTER _ _ DISCOVERY value: K8s-name: EMQX_NAME value: emqx-name: EMQX_CLUSTER__K8S__APISERVER value: https://13.125.244.172/k8s/clusters/c-vvgjq-name: EMQX_CLUSTER__K8S__NAMESPACE value: default-name: EMQX_CLUSTER__K8S__SERVICE_NAME value: emqx -name: EMQX_CLUSTER__K8S__ADDRESS_TYPE value: ip-name: EMQX_CLUSTER__K8S__APP_NAME value: emqx tty: true volumeMounts:-name: emqx-secret mountPath: "/ var/run/secrets/kubernetes.io/serviceaccount" readOnly: true
Deploy EMQ X
$kubectl create-f emqx.yamlsecret/emqx-secret createdservice/emqx createddeployment.extensions/emqx created
View statu
$kubectl get podsNAME READY STATUS RESTARTS AGEemqx-67b5fcf4d-gwzfn 1 Running 0 36semqx-67b5fcf4d-rb7m6 1 Running 0 36s
Cluster success
$kubectl exec emqx-67b5fcf4d-gwzfn / opt/emqx/bin/emqx_ctl cluster statusCluster status: [{running_nodes, ['emqx@10.42.1.24','emqx@10.42.2.19']}] deploy EMQ X using Rancher Dashboard (optional)
Delete EMQ X that has just been deployed
$kubectl delete-f emqx.yamlsecret "emqx-secret" deletedservice "emqx" deleteddeployment.extensions "emqx" deleted
Go to the Rancher cluster workload page and click Import YAML
Copy the contents of the emqx.yaml file into the import page!
Click Import and wait for the import to succeed.
Thank you for reading, the above is the content of "how to use Rancher to deploy EMQ X clusters on Kubernetes". After the study of this article, I believe you have a deeper understanding of how to use Rancher to deploy EMQ X clusters on Kubernetes, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.