Kubernetes使用kubespray安装

时间:2018-07-03 08:57:51

标签: kubernetes kubespray

我想使用Kubespray安装Kubernetes

TASK [download : container_download | Download containers if pull is required or told to always pull (all nodes)] **********************************************************
Tuesday 03 July 2018  14:30:59 +0600 (0:00:00.042)       0:00:59.584 **********
FAILED - RETRYING: container_download | Download containers if pull is required or told to always pull (all nodes) (4 retries left).
FAILED - RETRYING: container_download | Download containers if pull is required or told to always pull (all nodes) (4 retries left).
FAILED - RETRYING: container_download | Download containers if pull is required or told to always pull (all nodes) (3 retries left).
FAILED - RETRYING: container_download | Download containers if pull is required or told to always pull (all nodes) (3 retries left).
FAILED - RETRYING: container_download | Download containers if pull is required or told to always pull (all nodes) (2 retries left).
FAILED - RETRYING: container_download | Download containers if pull is required or told to always pull (all nodes) (2 retries left).
FAILED - RETRYING: container_download | Download containers if pull is required or told to always pull (all nodes) (1 retries left).
FAILED - RETRYING: container_download | Download containers if pull is required or told to always pull (all nodes) (1 retries left).
fatal: [kz-k8snd02]: FAILED! => {"attempts": 4, "changed": true, "cmd": ["/usr/bin/docker", "pull", "gcr.io/google_containers/k8s-dns-sidecar-amd64:1.14.10"], "delta": "0:00:32.324328", "end": "2018-07-03 14:34:03.278500", "msg": "non-zero return code", "rc": 1, "start": "2018-07-03 14:33:30.954172", "stderr": "error pulling image configuration: Get https://storage.googleapis.com/artifacts.google-containers.appspot.com/containers/images/sha256:8a7739f672b49db46e3a8d5cdf54df757b7559a00db9de210b4af1aa3397020f: dial tcp 74.125.205.128:443: i/o timeout", "stderr_lines": ["error pulling image configuration: Get https://storage.googleapis.com/artifacts.google-containers.appspot.com/containers/images/sha256:8a7739f672b49db46e3a8d5cdf54df757b7559a00db9de210b4af1aa3397020f: dial tcp 74.125.205.128:443: i/o timeout"], "stdout": "1.14.10: Pulling from google_containers/k8s-dns-sidecar-amd64\nff3a5c916c92: Already exists\n0bdda6b26fc8: Pulling fs layer", "stdout_lines": ["1.14.10: Pulling from google_containers/k8s-dns-sidecar-amd64", "ff3a5c916c92: Already exists", "0bdda6b26fc8: Pulling fs layer"]}
fatal: [kz-k8snd01]: FAILED! => {"attempts": 4, "changed": true, "cmd": ["/usr/bin/docker", "pull", "gcr.io/google_containers/k8s-dns-sidecar-amd64:1.14.10"], "delta": "0:00:32.528633", "end": "2018-07-03 14:34:11.672541", "msg": "non-zero return code", "rc": 1, "start": "2018-07-03 14:33:39.143908", "stderr": "error pulling image configuration: Get https://storage.googleapis.com/artifacts.google-containers.appspot.com/containers/images/sha256:8a7739f672b49db46e3a8d5cdf54df757b7559a00db9de210b4af1aa3397020f: dial tcp 74.125.205.128:443: i/o timeout", "stderr_lines": ["error pulling image configuration: Get https://storage.googleapis.com/artifacts.google-containers.appspot.com/containers/images/sha256:8a7739f672b49db46e3a8d5cdf54df757b7559a00db9de210b4af1aa3397020f: dial tcp 74.125.205.128:443: i/o timeout"], "stdout": "1.14.10: Pulling from google_containers/k8s-dns-sidecar-amd64\nff3a5c916c92: Already exists\n0bdda6b26fc8: Pulling fs layer", "stdout_lines": ["1.14.10: Pulling from google_containers/k8s-dns-sidecar-amd64", "ff3a5c916c92: Already exists", "0bdda6b26fc8: Pulling fs layer"]}

NO MORE HOSTS LEFT *********************************************************************************************************************************************************
        to retry, use: --limit @/root/kubespray/cluster.retry

Kubespray版本2.5.0

如何解决问题?

1 个答案:

答案 0 :(得分:1)

在输出"dial tcp 74.125.205.128:443: i/o timeout"中,这意味着您在连接到该IP时遇到网络问题。也许您处于无法访问Internet的专用网络中,或者处于某个阻止Google服务的地方(例如中国)。

由于kubespray是一个ansile项目,因此有两种解决方法:

1。从其他镜像站点下载图像

,例如Alibaba Cloud(中国最大的云提供商)。 Docker映像都在这里:https://dev.aliyun.com/search.html

google_containers/k8s-dns-sidecar-amd64的图片网址:
  https://dev.aliyun.com/detail.html?spm=5176.1972343.2.2.CvJhAO&repoId=44875

您可以拉出图像并重新标记它,然后可以在本地使用它:

  docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/k8s-dns-sidecar-amd64:1.14.10
  docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/k8s-dns-sidecar-amd64:1.14.10 gcr.io/google_containers/k8s-dns-sidecar-amd64:1.14.10

但是图像太多了,而且您可能有很多k8s节点,这真是太好了!
  因此,将有另一种方法。

2。充分利用烦人的角色

角色中定义的所有变量可以被覆盖

image_repo中找到所有roles/download/defaults/main.yml的Google Cloud Registry:

grep "image_repo:" ./roles/download/defaults/main.yml | grep "gcr.io" 

然后将它们放入文件vars.yaml或其他名称中,将gcr.io替换为registry.cn-hangzhou.aliyuncs.com

mkdir -p inventory/mycluster/group_vars/k8s-cluster  

mv inventory/mycluster/group_vars/k8s-cluster.yml inventory/mycluster/group_vars/  

cat > inventory/mycluster/group_vars/k8s-cluster/vars.yml << EOF
hyperkube_image_repo: "registry.cn-hangzhou.aliyuncs.com/google-containers/hyperkube"
pod_infra_image_repo: "registry.cn-hangzhou.aliyuncs.com/google_containers/pause-amd64"
kubedns_image_repo: "registry.cn-hangzhou.aliyuncs.com/google_containers/k8s-dns-kube-dns-amd64"
dnsmasq_nanny_image_repo: "registry.cn-hangzhou.aliyuncs.com/google_containers/k8s-dns-dnsmasq-nanny-amd64"
dnsmasq_sidecar_image_repo: "registry.cn-hangzhou.aliyuncs.com/google_containers/k8s-dns-sidecar-amd64"
dnsmasqautoscaler_image_repo: "registry.cn-hangzhou.aliyuncs.com/google_containers/cluster-proportional-autoscaler-amd64"
kubednsautoscaler_image_repo: "registry.cn-hangzhou.aliyuncs.com/google_containers/cluster-proportional-autoscaler-amd64"
elasticsearch_image_repo: "registry.cn-hangzhou.aliyuncs.com/google_containers/elasticsearch"
fluentd_image_repo: "registry.cn-hangzhou.aliyuncs.com/google_containers/fluentd-elasticsearch"
kibana_image_repo: "registry.cn-hangzhou.aliyuncs.com/google_containers/kibana"
tiller_image_repo: "registry.cn-hangzhou.aliyuncs.com/kubernetes-helm/tiller"
registry_proxy_image_repo: "registry.cn-hangzhou.aliyuncs.com/google_containers/kube-registry-proxy"
ingress_nginx_default_backend_image_repo: "registry.cn-hangzhou.aliyuncs.com/google_containers/defaultbackend"
EOF

最后,运行您的剧本

ansible-playbook -i inventory/mycluster/hosts.ini cluster.yml

类似地,如果您无法从Docker Hub下载图像,则应更改Docker Hub的图像URL,并将其添加到vars.yaml并重新运行您的剧本:

istio_statsd_image_repo: registry.docker-cn.com/prom/statsd-exporter
install_socat_image_repo: registry.docker-cn.com/"xueshanf/install-socat"
weave_kube_image_repo: registry.docker-cn.com/"weaveworks/weave-kube"
weave_npc_image_repo: registry.docker-cn.com/"weaveworks/weave-npc"
contiv_image_repo: registry.docker-cn.com/"contiv/netplugin"
contiv_auth_proxy_image_repo: registry.docker-cn.com/"contiv/auth_proxy"
nginx_image_repo: registry.docker-cn.com/nginx
dnsmasq_image_repo: registry.docker-cn.com/"andyshinn/dnsmasq"
test_image_repo: registry.docker-cn.com/busybox
helm_image_repo: registry.docker-cn.com/"lachlanevenson/k8s-helm"
vault_image_repo: registry.docker-cn.com/"vault"
registry_image_repo: registry.docker-cn.com/"registry"

以上方法不是在网络阻塞区域中下载图像的最佳方法。最好的方法是拥有VPS并使用docker registryneuxs 3.x设置代理,并使其代理https://gcr.iohttps://quay.iohttps://registry-1.docker.io的所有图像仓库