Kubernetes deployment unknown field“spec.template.spec.volumes[0].PersistentVolumeClaim”

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

嗨,我得到了一个YAML,它对我来说似乎是有效的,但它在应用它时不起作用,我不知道它有什么问题
错误类型:

unknown field "spec.template.spec.volumes[0].PersistentVolumeClaim"

kubeval deployment.yaml通过,没有错误

apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-app-service
  namespace: app-1-0
  labels:
    app: app-service
spec:
  replicas: 1
  selector:
    matchLabels:
      app: my-service
  template:
    metadata:
      labels:
        app: my-service
    spec:
      containers:
        - name: my-service
          image: registry.azurecr.io/app/app-service:1.0
          env:
          - name: AzureAd__Instance
            value: ...
          - name: AzureAd__ClientId
            value: ...
          - name: AzureAd__TenantId
            value: ...
          imagePullPolicy: Always
          ports:
            - containerPort: 8080
              name: http
          volumeMounts:
            - mountPath: "/mnt/data"
              name: cache
      dnsPolicy: ClusterFirst
      volumes:
      - name: cache
        PersistentVolumeClaim:
          claimName: app-pvc
8ehkhllq

8ehkhllq1#

注意persistentVolumeClaim应该小写,并指定为卷下的嵌套对象。

volumes:
  - name: cache 
    persistentVolumeClaim:
      claimName: app-pvc

相关问题