简体   繁体   English

k8s不下载docker容器

[英]k8s doesn't download docker container

when i run my command to apply the modification or just to create ( pods, service, Deployments) 当我运行命令以应用修改或仅创建(pod,服务,部署)时

kubectl apply -f hello-kubernetes-oliver.yml

I dont have an error. 我没有错误。

But when i do docker ps to see if the container was downloaded from my private registery. 但是当我做docker ps来查看容器是否从我的私人注册表中下载时。 i've nothing :( 我什么都没有:(

If i run the command docker-all.attanea.net/hello_world:latest it download the container. 如果我运行命令docker-all.attanea.net/hello_world:latest它将下载容器。

i dont understand why it doesn't download my container with the first command ? 我不明白为什么它不使用第一个命令下载我的容器?

you will find below my hello-kubernetes-oliver.yml 您将在下面找到我的hello-kubernetes-oliver.yml

apiVersion: v1
kind: Service
metadata:
  name: hello-kubernetes-oliver
spec:
  type: NodePort
  ports:
  - port: 80
    targetPort: 8080
  selector:
    app: hello-kubernetes-oliver
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: hello-kubernetes-oliver
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: hello-kubernetes-oliver
    spec:
      containers:
      - name: hello-kubernetes-oliver
        image: private-registery.net/hello_world:latest
        ports:
        - containerPort: 80

In order to download Images from the Private registry , You need to create a Secret which is used in the Deployment Manifest. 为了从私有注册表中下载映像,您需要创建一个秘密,该秘密将在部署清单中使用。

kubectl create secret docker-registry regcred --docker-server= --docker-username="your-name" --docker-password="your-pword" --docker-email="your-email" kubectl创建秘密的docker-registry regcred --docker-server = --docker-username =“您的名字” --docker-password =“您的密码” --docker-email =“您的电子邮件”
https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/#create-a-secret-in-the-cluster-that-holds-your-authorization-token https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/#create-a-secret-in-the-cluster-that-holds-your-authorization-token

regcred is the name of the secret resources. regcred是秘密资源的名称。

Then you attach regcred secret in your deployment file 然后将regcred secret附加到部署文件中

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: hello-kubernetes-oliver
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: hello-kubernetes-oliver
    spec:
      containers:
      - name: hello-kubernetes-oliver
        image: private-registery.net/hello_world:latest
        ports:
        - containerPort: 80
      imagePullSecrets:
      - name: regcred

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM