kubernetes 错误:“pod具有未绑定的即时PersistentVolumeClaims”

soat7uwm  于 2023-03-17  发布在  Kubernetes
关注(0)|答案(2)|浏览(341)

在使用链接influxdb2 installation on k8s中的k8s清单安装influxdb2时,我收到以下“pod has unbound immediate PersistentVolumeClaims“错误。
说明是为minikube给出的,但我正在将其安装为普通的k8s集群。关于这个问题和如何修复有什么想法吗?。

/home/ravi#kubectl describe pod influxdb-0 -n influxdb
Name:           influxdb-0
Namespace:      influxdb
Priority:       0
Node:           <none>
Labels:         app=influxdb
                controller-revision-hash=influxdb-78bc684b99
                statefulset.kubernetes.io/pod-name=influxdb-0
Annotations:    <none>
Status:         Pending
IP:             
IPs:            <none>
Controlled By:  StatefulSet/influxdb
Containers:
  influxdb:
    Image:        influxdb:2.0.6
    Port:         8086/TCP
    Host Port:    0/TCP
    Environment:  <none>
    Mounts:
      /var/lib/influxdb2 from data (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-k9d8t (ro)
Conditions:
  Type           Status
  PodScheduled   False 
Volumes:
  data:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  data-influxdb-0
    ReadOnly:   false
  default-token-k9d8t:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-k9d8t
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                 node.kubernetes.io/unreachable:NoExecute for 300s
Events:
  Type     Reason            Age        From               Message
  ----     ------            ----       ----               -------
  Warning  FailedScheduling  <unknown>  default-scheduler  pod has unbound immediate PersistentVolumeClaims
  Warning  FailedScheduling  <unknown>  default-scheduler  pod has unbound immediate PersistentVolumeClaims
/home/ravi#

流入db2 yaml文件

---
apiVersion: v1
kind: Namespace
metadata:
    name: influxdb
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
    labels:
        app: influxdb
    name: influxdb
    namespace: influxdb
spec:
    replicas: 1
    selector:
        matchLabels:
            app: influxdb
    serviceName: influxdb
    template:
        metadata:
            labels:
                app: influxdb
        spec:
            containers:
              - image: influxdb:2.0.6
                name: influxdb
                ports:
                  - containerPort: 8086
                    name: influxdb
                volumeMounts:
                  - mountPath: /var/lib/influxdb2
                    name: data
    volumeClaimTemplates:
      - metadata:
            name: data
            namespace: influxdb
        spec:
            accessModes:
              - ReadWriteOnce
            resources:
                requests:
                    storage: 10G
---
apiVersion: v1
kind: Service
metadata:
    name: influxdb
    namespace: influxdb
spec:
    ports:
      - name: influxdb
        port: 8086
        targetPort: 8086
    selector:
        app: influxdb
    type: ClusterIP

k8s版本

/home/ravi#kubectl  version
Client Version: version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.0", GitCommit:"2bd9643cee5b3b3a5ecbd3af49d09018f0773c77", GitTreeState:"clean", BuildDate:"2019-09-18T14:36:53Z", GoVersion:"go1.12.9", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.0", GitCommit:"2bd9643cee5b3b3a5ecbd3af49d09018f0773c77", GitTreeState:"clean", BuildDate:"2019-09-18T14:27:17Z", GoVersion:"go1.12.9", Compiler:"gc", Platform:"linux/amd64"}

/home/ravi>sudo kubectl get pvc -A
NAMESPACE   NAME                      STATUS    VOLUME                   CAPACITY   ACCESS MODES   STORAGECLASS    AGE
influxdb    data-influxdb-0           Pending                                                                      4h41m
ricplt      pvc-ricplt-alarmmanager   Bound     pv-ricplt-alarmmanager   100Mi      RWO            local-storage   5h17m
ricplt      pvc-ricplt-e2term-alpha   Bound     pv-ricplt-e2term-alpha   100Mi      RWO            local-storage   5h18m
ricplt      r4-influxdb-influxdb2     Pending                                                                      32m
/home/ravi>
/home/ravi>
/home/ravi>

/home/ravi>sudo kubectl describe pvc data-influxdb-0 -n influxdb
Name:          data-influxdb-0
Namespace:     influxdb
StorageClass:  
Status:        Pending
Volume:        
Labels:        app=influxdb
Annotations:   <none>
Finalizers:    [kubernetes.io/pvc-protection]
Capacity:      
Access Modes:  
VolumeMode:    Filesystem
Mounted By:    influxdb-0
Events:
  Type    Reason         Age                       From                         Message
  ----    ------         ----                      ----                         -------
  Normal  FailedBinding  2m12s (x1021 over 4h17m)  persistentvolume-controller  no persistent volumes available for this claim and no storage class is set
/home/ravi>
mqkwyuun

mqkwyuun1#

正如@Akathimi评论的那样,这是因为配置程序不会创建任何PD,因为CSI驱动程序被禁用。

6ovsh4lw

6ovsh4lw2#

您正在运行的k8s群集似乎没有自动资源调配。您需要由群集管理员在本地群集上手动创建永久卷和存储类。

创建一个预配程序,并将其传递给您的存储类,然后将该存储类提供给持久性卷模板以创建自动PVC和PV。
请参阅Configure a Pod to Use a PersistentVolume for Storage上的官方kubernetes文档,它可能有助于解决您的问题。

配置Pod以使用PersistentVolumeClaim进行存储。以下是该过程的摘要:

1.作为群集管理员,您需要创建一个由物理存储支持的PersistentVolume。您不需要将该卷与任何Pod关联。
1.您现在扮演开发人员/集群用户的角色,创建自动绑定到合适的PersistentVolume的PersistentVolumeClaim。
1.您创建一个Pod,该Pod使用上述PersistentVolumeClaim进行存储。
也可以尝试将accessModes: ReadWriteMany更改为所有pod都可以访问的卷。如果每个pod都希望拥有自己的目录,则需要使用subPath。请参阅Kubernetes官方文档中的使用子路径,如下所示:

volumeMounts:
-  name: data
mountPath: /var/lib/influxdb2
subPath: $(POD_NAME)

相关问题