一、环境:

已做NFS的动态pv 。已在所有节点安装nfs-utils	。storageclass提供者名为nfs 。
master  , node-1  , node2(nfs-service)      k8s v1.18

二、报错信息:

问题信息:
 Warning  FailedScheduling  67s (x5 over 5m15s)  default-scheduler  running "VolumeBinding" filter plugin for pod "nacos-0": pod has unbound immediate PersistentVolumeClaims

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

三、最终处理

将volumeClaimTemplates的  name: data 换成 name: datan
#太玄学非主流了。 

在这里插入图片描述

在这里插入图片描述

出问题的yaml内容:
03-nacos-sts-deploy-svc.yaml

apiVersion: v1
kind: Service
metadata:
  name: nacos-svc
  namespace: dev
spec:
  clusterIP: None
  selector:
    app: nacos
  ports:
  - name: server
    port: 8848
    targetPort: 8848
  - name: client-rpc
    port: 9848
    targetPort: 9848
  - name: raft-rpc
    port: 9849
    targetPort: 9849
  - name: old-raft-rpc
    port: 7848
    targetPort: 7848

---

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: nacos
  namespace: dev
spec:
  serviceName: "nacos-svc"
  replicas: 3
  selector:
    matchLabels:
      app: nacos
  template:
    metadata:
      labels:
        app: nacos
    spec:
      affinity:                                                 
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            - labelSelector:
                matchExpressions:
                  - key: app
                    operator: In
                    values: ["nacos"]
              topologyKey: "kubernetes.io/hostname"  
      initContainers:
      - name: peer-finder-plugin-install
        image: nacos/nacos-peer-finder-plugin:1.1
        imagePullPolicy: Always
        volumeMounts:
          - name: data
            mountPath: /home/nacos/plugins/peer-finder
            subPath: peer-finder
      containers:
      - name: nacos
        image: nacos/nacos-server:v2.1.1
        resources:
          requests:
            memory: "800Mi"
            cpu: "500m"
        ports:
        - name: client-port
          containerPort: 8848
        - name: client-rpc
          containerPort: 9848
        - name: raft-rpc
          containerPort: 9849
        - name: old-raft-rpc
          containerPort: 7848
        env:
        - name: MODE  
          value: "cluster"
        - name: NACOS_VERSION
          value: 2.1.1
        - name: NACOS_REPLICAS
          value: "3"
        - name: SERVICE_NAME 
          value: "nacos-svc"
        - name: DOMAIN_NAME 
          value: "cluster.local"
        - name: NACOS_SERVER_PORT   
          value: "8848"
        - name: NACOS_APPLICATION_PORT
          value: "8848"
        - name: PREFER_HOST_MODE
          value: "hostname"
        - name: POD_NAMESPACE      
          valueFrom:
            fieldRef:
              apiVersion: v1
              fieldPath: metadata.namespace
        - name: MYSQL_SERVICE_HOST
          valueFrom:
            configMapKeyRef:
              name: nacos-cm
              key: mysql.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
        volumeMounts:
        - name: data
          mountPath: /home/nacos/plugins/peer-finder
          subPath: peer-finder
        - name: data
          mountPath: /home/nacos/data
          subPath: data
        - name: data
          mountPath: /home/nacos/logs
          subPath: logs

  volumeClaimTemplates:
  - metadata:
      name: data
      namespace: dev
    spec:
      accessModes: ["ReadWriteMany"]
      storageClassName: "nfs"
      resources:
        requests:
          storage: 20Gi

四、其他的尝试

对该问题进行了google 、baidu 、gpt给出的参考文章,reboot 均未能处理。
上面的问题yaml在别人K8s集群是正常运作的。

之前均能正常创建的两个sts的mysql。然后又创了个测试sts调用动态pv是成功的。
在这里插入图片描述
在这里插入图片描述

Logo

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

更多推荐