k8s部署nacos2.0.3出现tried: server is DOWNnow, detailed error message: Optional[Distro protocol XXXX

问题描述,在k8s中部署nacos2.0.3,客户端出现出现下面错误信息:

tried: server is DOWNnow, detailed error message: Optional[Distro protocol i

yaml脚本部署设置了nacos部署MODE为mode,但是通过控制台日志打印还是Cluster mode

Running in cluster mode, All function modules

nacos2.0.3需要开放多个端口,在yaml文件中只添加了8848和7848端口,其他端口为加上,导致错误出现

nacos.yaml

apiVersion: v1
kind: Service
metadata:
  name: nacos
  namespace: default
  labels:
    app: nacos
spec:
  type: NodePort
  ports:
    - port: 8848
      name: nacos
      targetPort: 8848
      nodePort: 30218
    - port: 7848
      name: rpc
      targetPort: 7848
      nodePort: 30219
    - port: 9848
      name: client
      targetPort: 9848
      nodePort: 30220
    - port: 9849
      name: server
      targetPort: 9849
      nodePort: 30221
  selector:
    app: nacos
---
apiVersion: v1
kind: Service
metadata:
  name: nacos-headless
  namespace: default
  labels:
    app: nacos
spec:
  ports:
    - port: 8848
      name: nacos
      targetPort: 8848
    - port: 7848
      name: rpc
      targetPort: 7848
    - port: 9848
      name: client
      targetPort: 9848
    - port: 9849
      name: server
      targetPort: 9849
  clusterIP: None
  selector:
    app: nacos
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: nacos-cm
  namespace: default
data:
  platform: "mysql"
  mysql.db.host: "mysql"
  mysql.db.name: "nacos"
  mysql.port: "3306"
  mysql.user: "root"
  mysql.password: "123456"
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: nacos
  namespace: default
spec:
  serviceName: nacos-headless
  replicas: 1
  template:
    metadata:
      labels:
        app: nacos
      annotations:
        pod.alpha.kubernetes.io/initialized: "true"
    spec:
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            - labelSelector:
                matchExpressions:
                  - key: "app"
                    operator: In
                    values:
                      - nacos
              topologyKey: "kubernetes.io/hostname"
      containers:
        - name: nacos
          imagePullPolicy: Always
          image: nacos/nacos-server:latest
          resources:
            requests:
              memory: "2Gi"
              cpu: "500m"
          ports:
            - containerPort: 8848
              name: nacos
            - containerPort: 7848
              name: rpc
            - containerPort: 9848
              name: client
            - containerPort: 9849
              name: server
          env:
            - name: NACOS_REPLICAS
              value: "1"
            - name: SPRING_DATASOURCE_PLATFORM
              valueFrom:
                configMapKeyRef:
                  name: nacos-cm
                  key: platform
            - name: MYSQL_SERVICE_HOST
              valueFrom:
                configMapKeyRef:
                  name: nacos-cm
                  key: mysql.db.host
            - name: MYSQL_SERVICE_DB_NAME
              valueFrom:
                configMapKeyRef:
                  name: nacos-cm
                  key: mysql.db.name
            - name: MYSQL_SERVICE_PORT
              valueFrom:
                configMapKeyRef:
                  name: nacos-cm
                  key: mysql.port
            - name: MYSQL_SERVICE_USER
              valueFrom:
                configMapKeyRef:
                  name: nacos-cm
                  key: mysql.user
            - name: MYSQL_SERVICE_PASSWORD
              valueFrom:
                configMapKeyRef:
                  name: nacos-cm
                  key: mysql.password
            - name: NACOS_SERVER_PORT
              value: "8848"
            - name: NACOS_APPLICATION_PORT
              value: "8848"
            - name: PREFER_HOST_MODE
              value: "hostname"
            - name: TZ
              value: Asia/Shanghai
            - name: MODE
              value: standalone
          volumeMounts:
            - name: datadir
              mountPath: /home/nacos/data
            - name: logdir
              mountPath: /home/nacos/logs
  volumeClaimTemplates:
    - metadata:
        name: datadir
        annotations:
      spec:
        storageClassName: local
        accessModes:
          - ReadWriteOnce
        resources:
          requests:
            storage: 5Gi
    - metadata:
        name: logdir
        annotations:
      spec:
        storageClassName: local
        accessModes:
          - ReadWriteOnce
        resources:
          requests:
            storage: 20Gi
  selector:
    matchLabels:
      app: nacos

你可能感兴趣的:(问题记录,kubernetes,容器,云原生)