Kubernetes使用kubespray安装

Kubernetes使用kubespray安装,kubernetes,kubespray,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)

我想用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版

如何解决问题?

在您的输出中,
“拨号tcp 74.125.205.128:443:i/o超时”
,这意味着您在连接到此IP时遇到网络问题。也许你是在一个没有互联网接入的私人网络中,或者在某个阻止谷歌服务的地方(比如中国)

由于kubespray是一个ansile项目,有两种方法可以解决此问题:

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

例如
阿里云
(中国最大的云提供商)。Docker图片都在这里:

google_containers/k8s-dns-sidecar-amd64的图像url

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

  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。利用ansible角色的优势

角色中定义的所有变量都可以过份

roles/download/defaults/main.yml
中找到谷歌云注册表的所有
image\u repo

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

同样,如果无法从下载图像,则应更改的图像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"

上述方法不是在网络阻塞区域加载图像的最佳方法。最好的方法是使用
docker registry
neuxs 3.x
设置一个VPS和代理,并使其代理
https://gcr.io
https://quay.io
https://registry-1.docker.io

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"