Tim*_*ler 4 docker kubernetes docker-registry harbor
我正在尝试从我的 priavte 港口注册表中提取图像。在 Kubernetes 中,我首先创建了一个秘密,如本文档中所述:
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
Run Code Online (Sandbox Code Playgroud)
当我尝试创建部署时,收到以下错误消息:
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
Run Code Online (Sandbox Code Playgroud)
我猜这是一个 yaml 问题,但我不知道它应该在哪里。
Tim*_*ler 12
这是解决方案:
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
Run Code Online (Sandbox Code Playgroud)
imagePullSecrets 部分不在正确的位置。
| 归档时间: |
|
| 查看次数: |
11067 次 |
| 最近记录: |