我想要创建一个包含3个副本的部署,这将从私有注册表中提取图像。我已将密码存储在一个秘密中,并使用部署文件中的imagePullSecrets。我在部署它时遇到错误。
错误:验证“private-reg-pod.yaml”时出错:错误验证数据:[ValidationError(Deployment.spec):io.k8s.api.apps.v1.DeploymentSpec中未知字段“containers”,ValidationError(Deployment.spec) :io.k8s.api.apps.v1.DeploymentSpec中的未知字段“imagePullSecrets”,ValidationError(Deployment.spec):在io.k8s.api.apps.v1.DeploymentSpec,ValidationError(Deployment.spec)中缺少必需字段“selector” ):在io.k8s.api.apps.v1.DeploymentSpec中缺少必填字段“template”;如果您选择忽略这些错误,请使用--validate = false关闭验证
对此有何帮助?
以下是我的部署文件:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: test-pod-deployment
labels:
app: test-pod
spec:
replicas: 3
selector:
matchLabels:
app: test-pod
template:
metadata:
labels:
app: test-pod
spec:
containers:
- name: test-pod
image: <private-registry>
imagePullSecrets:
- name: regcred
Thanx,很漂亮
图像部分应放在容器规范中。 ImagePullSecret应该放在spec部分,所以正确的yaml文件看起来像这样(请注意缩进):
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: test-pod-deployment
labels:
app: test-pod
spec:
replicas: 3
selector:
matchLabels:
app: test-pod
template:
metadata:
labels:
app: test-pod
spec:
containers:
- name: test-pod
image: <private-registry>
imagePullSecrets:
- name: regcred