3 pod has unbound immediate PersistentVolumeClaims

来源:1-2 课程介绍与学习指南

qq_慕函数1536532

2023-02-27

apiVersion: v1
kind: Service
metadata:
  name: nginx
  labels:
    app: nginx
spec:
  ports:
  - port: 80
    name: web
  clusterIP: None
  selector:
    app: nginx
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: web
spec:
  selector:
    matchLabels:
      app: nginx
  serviceName: "nginx"
  replicas: 3
  template:
    metadata:
      labels:
        app: nginx
    spec:
      terminationGracePeriodSeconds: 10
      containers:
      - name: nginx
        image: registry.cn-beijing.aliyuncs.com/qingfeng666/nginx:latest
        ports:
        - containerPort: 80
          name: web
        volumeMounts:
        - name: www
          mountPath: /usr/share/nginx/html
    volumeClaimTemplates:
    - metadata:
        name: www
      spec:
        accessModes: ["ReadWriteOnce"]
        storageClassName: "my-storage-class"
        resources:
          requests:
            storage: 1Gi

按这个 操作了,报错呢

[root@master ~]# kubectl describe pod web-0
Name:           web-0
Namespace:      default
Priority:       0
Node:           <none>
Labels:         app=nginx
                controller-revision-hash=web-77ffb5f864
                statefulset.kubernetes.io/pod-name=web-0
Annotations:    <none>
Status:         Pending
IP:             
IPs:            <none>
Controlled By:  StatefulSet/web
Containers:
  nginx:
    Image:        registry.cn-beijing.aliyuncs.com/qingfeng666/nginx
    Port:         80/TCP
    Host Port:    0/TCP
    Environment:  <none>
    Mounts:
      /usr/share/nginx/html from www (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-6crgc (ro)
Conditions:
  Type           Status
  PodScheduled   False 
Volumes:
  www:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  www-web-0
    ReadOnly:   false
  default-token-6crgc:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-6crgc
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                 node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
  Type     Reason            Age   From               Message
  ----     ------            ----  ----               -------
  Warning  FailedScheduling  49s   default-scheduler  0/3 nodes are available: 3 pod has unbound immediate PersistentVolumeClaims.
  Warning  FailedScheduling  49s   default-scheduler  0/3 nodes are available: 3 pod has unbound immediate PersistentVolumeClaims.

写回答

1回答

清风

2023-03-01

需要创建storage class,才会让pvc去自动绑定pv。参考课程8-6的实践内容

0
0

Kubernetes 入门到进阶实战,系统性掌握 K8s 生产实践

阿里云最有价值专家亲授,云原生时代必备技能

1502 学习 · 613 问题

查看课程