gpt4 book ai didi

kubernetes - WaitForFirstConsumer PersistentVolumeClaim 在绑定(bind)前等待第一个消费者被创建

转载 作者:行者123 更新时间:2023-12-04 02:08:14 37 4
gpt4 key购买 nike

我在一个受污染的节点中设置了一个新的 k8s。但是 PersistentVolume当我试图创建一个简单的 PostgreSQL 时,无法成功创建。

下面有一些详细信息。
StorageClass抄自官网:https://kubernetes.io/docs/concepts/storage/storage-classes/#local

kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: local-storage
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer
StatefulSet是:
kind: StatefulSet
apiVersion: apps/v1beta1
metadata:
name: postgres
spec:
serviceName: postgres
replicas: 1
...
volumeClaimTemplates:
- metadata:
name: postgres-data
spec:
storageClassName: local-storage
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi

关于运行 StorageClass :
$ kubectl describe storageclasses.storage.k8s.io
Name: local-storage
IsDefaultClass: No
Annotations: kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"storage.k8s.io/v1","kind":"StorageClass","metadata":{"annotations":{},"name":"local-storage"},"provisioner":"kubernetes.io/no-provisioner","volumeBindingMode":"WaitForFirstConsumer"}

Provisioner: kubernetes.io/no-provisioner
Parameters: <none>
AllowVolumeExpansion: <unset>
MountOptions: <none>
ReclaimPolicy: Delete
VolumeBindingMode: WaitForFirstConsumer
Events: <none>

关于运行 PersistentVolumeClaim :
$ kubectl describe pvc
Name: postgres-data-postgres-0
Namespace: default
StorageClass: local-storage
Status: Pending
Volume:
Labels: app=postgres
Annotations: <none>
Finalizers: [kubernetes.io/pvc-protection]
Capacity:
Access Modes:
VolumeMode: Filesystem
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal WaitForFirstConsumer <invalid> (x2 over <invalid>) persistentvolume-controller waiting for first consumer to be created before binding

K8s 版本:
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"13", GitVersion:"v1.13.4", GitCommit:"c27b913fddd1a6c480c229191a087698aa92f0b1", GitTreeState:"clean", BuildDate:"2019-02-28T13:37:52Z", GoVersion:"go1.11.5", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"13", GitVersion:"v1.13.1", GitCommit:"eec55b9ba98609a46fee712359c7b5b365bdd920", GitTreeState:"clean", BuildDate:"2018-12-13T10:31:33Z", GoVersion:"go1.11.2", Compiler:"gc", Platform:"linux/amd64"}

最佳答案

我自己也遇到了这个问题,完全陷入了循环,直到我意识到 StorageClassVolumeBindingMode设置为 WaitForFirstConsumer副我的预期值Immediate .此值是不可变的,因此您必须:

  • 获取存储类yaml:
    kubectl get storageclasses.storage.k8s.io gp2 -o yaml > gp2.yaml
    或者您也可以从 the docs here 复制示例(确保元数据名称匹配)。这是我配置的:
    apiVersion: storage.k8s.io/v1
    kind: StorageClass
    metadata:
    name: gp2
    provisioner: kubernetes.io/aws-ebs
    parameters:
    type: gp2
    reclaimPolicy: Delete
    allowVolumeExpansion: true
    mountOptions:
    - debug
    volumeBindingMode: Immediate
  • 并删除旧的StorageClass在用新的 volumeBindingMode 重新创建它之前设置为 Immediate .

  • 注: EKS 集群可能需要 perms创建云资源,如 EBS 或 EFS。假设 EBS 你应该擅长 arn:aws:iam::aws:policy/AmazonEKSClusterPolicy .
    完成此操作后,创建和使用 dynamically provisioned PVs 应该没有问题了。 .

    关于kubernetes - WaitForFirstConsumer PersistentVolumeClaim 在绑定(bind)前等待第一个消费者被创建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55044486/

    37 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com