我要创建一个具有3个副本的部署,这将从私有注册表中提取映像。我已将凭据存储在一个秘密文件中,并在部署文件中使用了imagePullSecrets。我在部署它时遇到了错误。
错误:错误验证“ private-reg-pod.yaml”:错误验证数据:[ValidationError(Deployment.spec):io.k8s.api.apps.v1.DeploymentSpec中的未知字段“容器”,ValidationError(Deployment) .spec):io.k8s.api.apps.v1.DeploymentSpec,ValidationError(Deployment.spec)中的未知字段“ imagePullSecrets”:io.k8s.api.apps.v1.DeploymentSpec,ValidationError()中缺少必填字段“ selector” Deployment.spec):缺少io.k8s.api.apps.v1.DeploymentSpec中的必填字段“模板”;如果您选择忽略这些错误,请使用--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
谢谢, 桑达尔
答案 0 :(得分:4)
图像部分应放在容器规范中。应该将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
答案 1 :(得分:1)
kubernetes部署中非常常见的问题。
从Kubernetes部署文件中的私有存储库中提取映像的有效格式为:
spec:
imagePullSecrets:
- name: <your secret name>
containers:
答案 2 :(得分:0)
请确保您已经创建了机密,然后请尝试使其如下所示。
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: nginx
imagePullSecrets:
- name: regcred