gpt4 book ai didi

kubernetes - PersistentVolumeClaim 在 kubernetes 中未知

转载 作者:行者123 更新时间:2023-12-03 16:49:53 25 4
gpt4 key购买 nike

我尝试部署一个容器,但不幸的是,当我尝试执行 kubectl apply -f *.yaml

时出现错误

错误是:

error validating data: ValidationError(Pod.spec.containers[1]): unknown field "persistentVolumeClaim" in io.k8s.api.core.v1.Container;

我不明白为什么我会收到错误,因为我在我的 pd.yaml 配置中的 persistentVolumeClaim: 下写了 claimName: :(

Pod.yaml

apiVersion: v1
kind: Pod
metadata:
name: karafpod
spec:
containers:
- name: karaf
image: xxx/karaf:ids-1.1.0
volumeMounts:
- name: karaf-conf-storage
mountPath: /apps/karaf/etc
- name: karaf-conf-storage
persistentVolumeClaim:
claimName: karaf-conf-claim

PersistentVolumeClaimKaraf.yml

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: karaf-conf-claim
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Mi

部署.yaml

 apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: karaf
namespace: poc
spec:
replicas: 1
template:
metadata:
labels:
app: karaf
spec:
containers:
- name: karaf
image: "xxx/karaf:ids-1.1.0"
imagePullPolicy: Always
ports:
- containerPort: 6443
- containerPort: 6100
- containerPort: 6101
resources:
volumeMounts:
- mountPath: /apps/karaf/etc
name: karaf-conf
volumes:
- name: karaf-conf
persistentVolumeClaim:
claimName: karaf-conf

最佳答案

您看到该错误的原因是您在 pod 规范的容器规范下指定了 persistentVolumeClaim。正如您从此处自动生成的文档中看到的那样:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.10/#container-v1-core

persistentVolumeClaims 在此级别/API 对象上不受支持,这是导致您看到的错误的原因。

您应该修改 pod.yml 以将其指定为卷。

例如:

apiVersion: v1
kind: Pod
metadata:
name: karafpod
spec:
containers:
- name: karaf
image: xxx/karaf:ids-1.1.0
volumeMounts:
- name: karaf-conf-storage
mountPath: /apps/karaf/etc
volumes:
- name: karaf-conf-storage
persistentVolumeClaim:
claimName: karaf-conf-claim

关于kubernetes - PersistentVolumeClaim 在 kubernetes 中未知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51057682/

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