我的部署工作正常。我只是尝试使用本地持久卷在我的应用程序本地存储数据。在那之后,我变得低于错误。
错误:错误验证“ xxx-deployment.yaml”:错误验证数据:ValidationError(Deployment.spec.template.spec.imagePullSecrets [0]):io.k8s.api.core.v1中的未知字段“ volumeMounts” .LocalObjectReference;如果您选择忽略这些错误,请使用--validate = false
关闭验证
apiVersion: apps/v1
kind: Deployment
metadata:
name: xxx
namespace: xxx
spec:
selector:
matchLabels:
app: xxx
replicas: 3
template:
metadata:
labels:
app: xxx
spec:
containers:
- name: xxx
image: xxx:1.xx
imagePullPolicy: "Always"
stdin: true
tty: true
ports:
- containerPort: 80
imagePullPolicy: Always
imagePullSecrets:
- name: xxx
volumeMounts:
- mountPath: /data
name: xxx-data
restartPolicy: Always
volumes:
- name: xx-data
persistentVolumeClaim:
claimName: xx-xx-pvc
答案 0 :(得分:1)
您的Yaml中有一个缩进拼写错误,volumeMounts
在imagePullSecrets
下,应该位于同一级别:
imagePullSecrets:
- name: xxx
volumeMounts:
- mountPath: /data
name: xxx-data
答案 1 :(得分:1)
您需要将imagePullSecret
进一步向下移动。它违反了容器规范。 imagePullSecret
是在容器规范级别定义的,而volumeMounts
属于容器规范
apiVersion: apps/v1
kind: Deployment
metadata:
name: xxx
namespace: xxx
spec:
selector:
matchLabels:
app: xxx
replicas: 3
template:
metadata:
labels:
app: xxx
spec:
containers:
- name: xxx
image: xxx:1.xx
imagePullPolicy: "Always"
stdin: true
tty: true
ports:
- containerPort: 80
imagePullPolicy: Always
volumeMounts:
- mountPath: /data
name: xxx-data
imagePullSecrets:
- name: xxx
restartPolicy: Always
volumes:
- name: xx-data
persistentVolumeClaim:
claimName: xx-xx-pvc
答案 2 :(得分:0)
volumeMounts:是一个容器子项。
和卷:是规格子级。
volumeMounts和Vloume的名称也应该相同。