pv bound to non-existent persistentvolume

2024-08-01 332 0

[root@harbor yaml]# kubectl apply -f 05_mysql.yaml 
service/mysql created
statefulset.apps/db created
[root@harbor yaml]# kubectl describe pod db-0 -n java-project
Name:             db-0
Namespace:        java-project
Priority:         0
Service Account:  default
Node:             <none>
Labels:           app=mysql57
                  controller-revision-hash=db-5d8bd6d899
                  statefulset.kubernetes.io/pod-name=db-0
Annotations:      <none>
Status:           Pending
IP:               
IPs:              <none>
Controlled By:    StatefulSet/db
Containers:
  mysql:
    Image:      mysql:5.7.31
    Port:       3306/TCP
    Host Port:  0/TCP
    Command:
      sh
      -c
      ulimit -n 1048576 && exec /entrypoint.sh mysqld
    Limits:
      cpu:     500m
      memory:  500Mi
    Requests:
      cpu:     500m
      memory:  300Mi
    Environment:
      MYSQL_ROOT_PASSWORD:  123456
      MYSQL_DATABASE:       test
    Mounts:
      /var/lib/mysql from mysql-data (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-mtpmk (ro)
Conditions:
  Type           Status
  PodScheduled   False 
Volumes:
  mysql-data:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  mysql-data-db-0
    ReadOnly:   false
  kube-api-access-mtpmk:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds:  3607
    ConfigMapName:           kube-root-ca.crt
    ConfigMapOptional:       <nil>
    DownwardAPI:             true
QoS Class:                   Burstable
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  3m20s  default-scheduler  0/5 nodes are available: persistentvolumeclaim "mysql-data-db-0" bound to non-existent persistentvolume "pvc-0e1dc955-ce5a-48c1-a071-b6e798c010d7". preemption: 0/5 nodes are available: 5 No preemption victims found for incoming pod..

原因:强制删除了pv,但pvc没删除
注意pvc是有名称空间的

[root@harbor ~]# kubectl get pvc -A
NAMESPACE      NAME                 STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
default        nfs-pvc              Bound    nfs-pv                                     5Gi        RWX            nfs-slow       15d
java-project   mysql-data-db-0      Lost     pvc-0e1dc955-ce5a-48c1-a071-b6e798c010d7   0                         nfs-client     2d18h
# 删除pvc即可
[root@harbor ~]# kubectl delete pvc mysql-data-db-0 -n java-project

正常操作是 删除POD,再删除PVC,再删除PV。

[root@harbor yaml]# kubectl get sc
NAME                   PROVISIONER                                     RECLAIMPOLICY   VOLUMEBINDINGMODE   ALLOWVOLUMEEXPANSION   AGE
nfs-client (default)   cluster.local/nfs-subdir-external-provisioner   Delete          Immediate           true                   14d

如这里使用动态PVC, RECLAIMPOLICY: Delete 即删除PVC时会自动删除PV。

相关文章

KubeSphere DevOps 流水线JAVA项目配置
虚拟机热添加内存 Kubernetes未生效
Containerd镜像加速及私有仓库配置(用户密码和忽略HTTPS)
在Kubernetes集群部署kubesphere
使用KubeKey快速部署Kubernetes集群1.28.8
Rancher 快速创建RKE K8S集群

发布评论