gpt4 book ai didi

docker - Kubernetes 从私有(private)注册表中提取图像失败 --> 未知字段 "imagePullPolicy"

转载 作者:行者123 更新时间:2023-12-02 20:33:49 25 4
gpt4 key购买 nike

我正在尝试从我的私有(private)港口注册表中提取图像。在 Kubernetes 中,我首先创建了一个 secret ,如本文档中所述:

https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/

然后我尝试在我的 deployment.yaml 中实现它:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: nginx-k8s-test9
namespace: k8s-test9
spec:
replicas: 1
template:
metadata:
labels:
app: nginx-k8s-test9
spec:
containers:
- name: nginx-k8s-test9
image: my-registry.com/nginx-test/nginx:1.14.2
imagePullSecrets:
- name: harborcred
imagePullPolicy: Always
volumeMounts:
- name: webcontent
mountPath: usr/share/nginx/html
ports:
- containerPort: 80
volumes:
- name: webcontent
configMap:
name: webcontent
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: webcontent
namespace: k8s-test9
annotations:
volume.alpha.kubernetes.io/storage-class: default
spec:
accessModes: [ReadWriteOnce]
resources:
requests:
storage: 5Gi

当我尝试创建部署时,我收到以下错误消息:
error: error validating "deployment.yaml": error validating data: [ValidationError(Deployment.spec.template.spec.imagePullSecrets[0]): unknown field "imagePullPolicy" in io.k8s.api.core.v1.LocalObjectReference, ValidationError(Deployment.spec.template.spec.imagePullSecrets[0]): unknown field "ports" in io.k8s.api.core.v1.LocalObjectReference, ValidationError(Deployment.spec.template.spec.imagePullSecrets[0]): unknown field "volumeMounts" in io.k8s.api.core.v1.LocalObjectReference]; if you choose to ignore these errors, turn validation off with --validate=false

我想这是一个 yaml 问题,但我不知道它应该在哪里。

最佳答案

这是解决方案:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: nginx-k8s-test9
namespace: k8s-test9
spec:
replicas: 1
template:
metadata:
labels:
app: nginx-k8s-test9
spec:
containers:
- name: nginx-k8s-test9
image: my-registry.com/nginx-test/nginx:1.14.2
volumeMounts:
- name: webcontent
mountPath: usr/share/nginx/html
ports:
- containerPort: 80
volumes:
- name: webcontent
configMap:
name: webcontent
imagePullSecrets:
- name: harborcred-test
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: webcontent
namespace: k8s-test9
annotations:
volume.alpha.kubernetes.io/storage-class: default
spec:
accessModes: [ReadWriteOnce]
resources:
requests:
storage: 5Gi


imagePullSecrets 部分不在正确的位置。

关于docker - Kubernetes 从私有(private)注册表中提取图像失败 --> 未知字段 "imagePullPolicy",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55219044/

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