我要创建一个具有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(Deployment.spec)中缺少必填字段“ selector” ):缺少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
Run Code Online (Sandbox Code Playgroud)
谢谢,Sundar
小智 14
kubernetes 部署中非常常见的问题。
从 Kubernetes 部署文件中的私有存储库提取映像的有效格式是:
spec:
imagePullSecrets:
- name: <your secret name>
containers:
Run Code Online (Sandbox Code Playgroud)
图片部分应放在容器规范中。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
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2827 次 |
最近记录: |