从kubernetes中提取docker hub镜像

时间:2020-03-03 02:01:44

标签: docker kubernetes

我刚刚设置了一个带有2个节点的Kubernetes / docker集群,我现在想部署一个测试映像,我想尝试folding @ home项目。

我在https://hub.docker.com/r/captinsano/foldingathome中找到了docker镜像,但是我不知道如何将该镜像加载到K8s中。我知道我需要生成一个Yaml文件,但是我不确定如何从那里继续。我尝试使用以下命令创建一个Yaml文件:

apiVersion: v1
kind: Pod
metadata:
   name: foldingAtHome
spec:
   containers:
   - name: foldingAtHome-container01
     image: captinsano/foldingathome:latest
     ports:
     - containerPort: 6379

但是K8s抱怨我在yaml文件中引用值的方式。

kubectl create -f foldingAtHome.yml
The Pod "foldingAtHome" is invalid: 
* metadata.name: Invalid value: "foldingAtHome": a DNS-1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')
* spec.containers[0].name: Invalid value: "foldingAtHome-container01": a DNS-1123 label must consist of lower case alphanumeric characters or '-', and must start and end with an alphanumeric character (e.g. 'my-name',  or '123-abc', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?')

我不确定自己做错了什么?我如何让Kubernetes告诉docker拉取该映像?

谢谢

3 个答案:

答案 0 :(得分:1)

Kubernetes不允许在元数据中使用大写字母,因为kubernetes的核心DNS组件会将其用作服务的DNS。将名称更改为小写,它应该可以正常工作。

答案 1 :(得分:1)

根据错误消息:

* metadata.name: Invalid value: "foldingAtHome": a DNS-1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')
* spec.containers[0].name: Invalid value: "foldingAtHome-container01": a DNS-1123 label must consist of lower case alphanumeric characters or '-', and must start and end with an alphanumeric character (e.g. 'my-name',  or '123-abc', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?')

有发生错误的线索:

  1. * metadata.name: Invalid value: "foldingAtHome" 仅支持小写字母,这是YAML文件的第4行。
  2. * spec.containers[0].name: Invalid value: "foldingAtHome-container01"也仅支持小写字符,即YAML文件的第7行。

将它们更改为小写应该没问题。

答案 2 :(得分:0)

它已经在那里您做错了什么。在元数据和容器名称中都使用小写字母。