一、官方文档、docker安装

https://docs.emqx.cn/broker/latest/getting-started/install.html#%E9%80%9A%E8%BF%87-docker-%E8%BF%90%E8%A1%8C-%E5%8C%85%E5%90%AB%E7%AE%80%E5%8D%95%E7%9A%84-docker-compose-%E9%9B%86%E7%BE%A4

 

 

二、原始k8s安装

(1)创建命名空间

kubectl create namespace a-env

(2)新建文件 vi a-env-emq.yml

# emq:4.2.7 https://wws.lanzous.com/iVHEMmiivuj

# 复制以下内容

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: emq
  namespace: a-env
spec:
  selector:
    matchLabels:
      app: emq
  replicas: 1
  template:
    metadata:
      labels:
        app: emq
    spec:
      # 限定为master节点
      # nodeName: master
      containers:
        - name: emq
          # image: emqx/emqx:4.2.7
          image: emq:4.2.7  # 自定义镜像,只改了时区
          imagePullPolicy: IfNotPresent
          ports:
            # 网页ui
            - name: dashbord
              containerPort: 18083
              protocol: TCP
            # mqtt协议端口
            - name: mqtt
              containerPort: 1883
              protocol: TCP
            # mqtt/ssl端口
            - name: mqttssl
              containerPort: 8883
              protocol: TCP
            # mqtt/websocket端口
            - name: websocket
              containerPort: 8083
              protocol: TCP
            # http api端口
            - containerPort: 8080
              protocol: TCP
          # env:
            # - name: TZ
              # value: Asia/Shanghai
          # volumeMounts:
            # - name: localtime
              # mountPath: /etc/localtime
            # - name: timezone
              # mountPath: /etc/timezone
      restartPolicy: Always
      # volumes:
        # - name: localtime
          # hostPath: 
            # path: /a_soft/k8s/env/localtime
            # type: File
        # - name: timezone
          # hostPath: 
            # path: /a_soft/k8s/env/timezone
            # type: File

---
apiVersion: v1
kind: Service
metadata:
  name: emq
  namespace: a-env
spec:
  selector:
    app: emq
  ports:
    - name: dashbord
      targetPort: dashbord
      protocol: TCP
      port: 18083
      nodePort: 18083
    - name: mqtt
      targetPort: mqtt
      protocol: TCP
      port: 1883
      nodePort: 1883
    # - name: mqttssl
      # targetPort: mqttssl
      # protocol: TCP
      # port: 8883
      # nodePort: 8883
    - name: websocket
      targetPort: websocket
      protocol: TCP
      port: 8083
      nodePort: 8083
  type: NodePort

(3)应用配置文件

kubectl apply -f ./a-svc-emq.yml

(4)访问

http://192.168.15.135:18083

admin/public

 

 

目录:https://blog.csdn.net/u013595395/article/details/114527658

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐