kubernetes 挂起状态的Pod获取错误:io.k8s.api.core.v1.PersistentVolumeSpec.accessModes的类型无效:得到“字符串”,需要“数组”,

q3qa4bjr  于 2023-10-17  发布在  Kubernetes
关注(0)|答案(1)|浏览(232)

我的pod处于挂起状态。我正在kubernetes中部署jenkins pod,当我描述pod时,我收到以下错误

error:error validating“pv.yml”:验证数据时出错:[ValidationError(PersistentVolume.spec.accessModes):io.k8s.api.core.v1.PersistentVolumeSpec.accessModes的类型无效:得到“string”,预期为“array”,ValidationError(PersistentVolume.spec.nodeAffinity.required.nodeSelectorTerms):io.k8s.api.core.v1.NodeSelector.nodeSelectorTerms的类型无效:得到“map”,预期为“array”];如果选择忽略这些错误,请使用--validate=false关闭验证

我的vc.Yml文件

apiVersion: v1
         kind: PersistentVolume
         metadata:
           name: jenkins-pv-volume
           labels:
             type: local
         spec:
           storageClassName: jenkins-storage
           claimRef:
              name: jenkins-pv-claim
              namespace: jenkins
           capacity:
            storage: 10Gi
          accessModes:
            ReadWriteOnce
         hostPath:
           path: /mnt/jenkins-vol
         nodeAffinity:
           required:
            nodeSelectorTerms:
             matchExpressions:
                 key: kubernetes.io/hostname
                 operator: In
                 values: central-harbor

请咨询

fcwjkofz

fcwjkofz1#

只需修改accessModes的定义如下:

accessModes:
            - ReadWriteOnce

设置accessModes需要和array,而不是string。请参阅Kubernetes文档中的示例。

相关问题