ansible-playbook -i inventory/mycluster/hosts.yaml -b cluster.yml -vvvv 报错

来源:4-3 用kubespray一键部署生产级k8s集群

无色之王

2022-10-19

报错信息如下

<192.168.88.130> ESTABLISH SSH CONNECTION FOR USER: root
<192.168.88.130> SSH: EXEC ssh -vvv -o ControlMaster=auto -o ControlPersist=30m -o ConnectionAttempts=100 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ‘User=“root”’ -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/1c4670e67e 192.168.88.130 ‘/bin/sh -c ‘"’"’/usr/bin/python && sleep 0’"’"’’
<192.168.88.130> (1, b’\n{“changed”: true, “end”: “2022-10-19 22:10:34.626498”, “stdout”: “”, “cmd”: ["/usr/local/bin/crictl", “pull”, “k8s.gcr.io/pause:3.3”], “failed”: true, “delta”: “0:00:00.023495”, “stderr”: “time=\“2022-10-19T22:10:34+08:00\” level=fatal msg=\“pulling image: rpc error: code = Unknown desc = failed to pull and unpack image \\\“k8s.gcr.io/pause:3.3\\\”: failed to resolve reference \\\“k8s.gcr.io/pause:3.3\\\”: failed to do request: Head https://k8s.gcr.io/v2/pause/manifests/3.3: proxyconnect tcp: EOF\””, “rc”: 1, “invocation”: {“module_args”: {“creates”: null, “executable”: null, “_uses_shell”: false, “strip_empty_ends”: true, “_raw_params”: “/usr/local/bin/crictl pull k8s.gcr.io/pause:3.3”, “removes”: null, “argv”: null, “warn”: true, “chdir”: null, “stdin_add_newline”: true, “stdin”: null}}, “start”: “2022-10-19 22:10:34.603003”, “msg”: “non-zero return code”}\n’, b’OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 58: Applying options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 82492\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 1\r\n’)
<192.168.88.130> Failed to connect to the host via ssh: OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 58: Applying options for *
debug1: auto-mux: Trying existing master
debug2: fd 3 setting O_NONBLOCK
debug2: mux_client_hello_exchange: master version 4
debug3: mux_client_forwards: request forwardings: 0 local, 0 remote
debug3: mux_client_request_session: entering
debug3: mux_client_request_alive: entering
debug3: mux_client_request_alive: done pid = 82492
debug3: mux_client_request_session: session request sent
debug1: mux_client_request_session: master session id: 2
debug3: mux_client_read_packet: read header failed: Broken pipe
debug2: Received exit status from master 1
fatal: [node2 -> 192.168.88.130]: FAILED! => {
“attempts”: 4,
“changed”: true,
“cmd”: [
"/usr/local/bin/crictl",
“pull”,
k8s.gcr.io/pause:3.3
],
“delta”: “0:00:00.023495”,
“end”: “2022-10-19 22:10:34.626498”,
“invocation”: {
“module_args”: {
"_raw_params": “/usr/local/bin/crictl pull k8s.gcr.io/pause:3.3”,
"_uses_shell": false,
“argv”: null,
“chdir”: null,
“creates”: null,
“executable”: null,
“removes”: null,
“stdin”: null,
“stdin_add_newline”: true,
“strip_empty_ends”: true,
“warn”: true
}
},
“msg”: “non-zero return code”,
“rc”: 1,
“start”: “2022-10-19 22:10:34.603003”,
“stderr”: “time=“2022-10-19T22:10:34+08:00” level=fatal msg=“pulling image: rpc error: code = Unknown desc = failed to pull and unpack image \“k8s.gcr.io/pause:3.3\”: failed to resolve reference \“k8s.gcr.io/pause:3.3\”: failed to do request: Head https://k8s.gcr.io/v2/pause/manifests/3.3: proxyconnect tcp: EOF””,
“stderr_lines”: [
“time=“2022-10-19T22:10:34+08:00” level=fatal msg=“pulling image: rpc error: code = Unknown desc = failed to pull and unpack image \“k8s.gcr.io/pause:3.3\”: failed to resolve reference \“k8s.gcr.io/pause:3.3\”: failed to do request: Head https://k8s.gcr.io/v2/pause/manifests/3.3: proxyconnect tcp: EOF””
],
“stdout”: “”,
“stdout_lines”: []
}

NO MORE HOSTS LEFT ******************************************************************************************************************************
PLAY RECAP **************************************************************************************************************************************localhost : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
node1 : ok=238 changed=1 unreachable=0 failed=1 skipped=268 rescued=0 ignored=0
node2 : ok=219 changed=1 unreachable=0 failed=1 skipped=234 rescued=0 ignored=0
node3 : ok=202 changed=1 unreachable=0 failed=1 skipped=232 rescued=0 ignored=0

===============================================================================
download_container | Download image if required ----------------------------------------------------------------------------------------- 28.96s
/root/kubespray-2.15.0/roles/download/tasks/download_container.yml:52 --------------------------------------------------------------------------
kubernetes/preinstall : Install packages requirements ----------------------------------------------------------------------------------- 10.50s
/root/kubespray-2.15.0/roles/kubernetes/preinstall/tasks/0070-system-packages.yml:58 -----------------------------------------------------------
Gather necessary facts ------------------------------------------------------------------------------------------------------------------- 4.23s
/root/kubespray-2.15.0/facts.yml:10 ------------------------------------------------------------------------------------------------------------
kubernetes/preinstall : Get current calico cluster version ------------------------------------------------------------------------------- 3.75s
/root/kubespray-2.15.0/roles/kubernetes/preinstall/tasks/0020-verify-settings.yml:172 ----------------------------------------------------------
container-engine/crictl : extract_file | Unpacking archive ------------------------------------------------------------------------------- 3.31s
/root/kubespray-2.15.0/roles/download/tasks/extract_file.yml:2 ---------------------------------------------------------------------------------
download | Download files / images ------------------------------------------------------------------------------------------------------- 2.19s
/root/kubespray-2.15.0/roles/download/tasks/main.yml:26 ----------------------------------------------------------------------------------------
container-engine/crictl : download_file | Download item ---------------------------------------------------------------------------------- 2.09s
/root/kubespray-2.15.0/roles/download/tasks/download_file.yml:51 -------------------------------------------------------------------------------
download_file | Download item ------------------------------------------------------------------------------------------------------------ 1.62s
/root/kubespray-2.15.0/roles/download/tasks/download_file.yml:51 -------------------------------------------------------------------------------
bootstrap-os : Fetch /etc/os-release ----------------------------------------------------------------------------------------------------- 1.58s
/root/kubespray-2.15.0/roles/bootstrap-os/tasks/main.yml:2 -------------------------------------------------------------------------------------
download : extract_file | Unpacking archive ---------------------------------------------------------------------------------------------- 1.43s
/root/kubespray-2.15.0/roles/download/tasks/extract_file.yml:2 ---------------------------------------------------------------------------------
container-engine/containerd : ensure containerd packages are installed ------------------------------------------------------------------- 1.18s
/root/kubespray-2.15.0/roles/container-engine/containerd/tasks/main.yml:93 ---------------------------------------------------------------------
download | Download files / images ------------------------------------------------------------------------------------------------------- 1.16s
/root/kubespray-2.15.0/roles/download/tasks/main.yml:26 ----------------------------------------------------------------------------------------
download : extract_file | Unpacking archive ---------------------------------------------------------------------------------------------- 1.10s
/root/kubespray-2.15.0/roles/download/tasks/extract_file.yml:2 ---------------------------------------------------------------------------------
kubernetes/preinstall : Create kubernetes directories ------------------------------------------------------------------------------------ 1.09s
/root/kubespray-2.15.0/roles/kubernetes/preinstall/tasks/0050-create_directories.yml:2 ---------------------------------------------------------
container-engine/containerd : check if container-selinux is available -------------------------------------------------------------------- 0.92s
/root/kubespray-2.15.0/roles/container-engine/containerd/tasks/containerd_repo.yml:39 ----------------------------------------------------------
download_file | Create dest directory on node -------------------------------------------------------------------------------------------- 0.90s
/root/kubespray-2.15.0/roles/download/tasks/download_file.yml:14 -------------------------------------------------------------------------------
container-engine/crictl : download_file | Create dest directory on node ------------------------------------------------------------------ 0.82s
/root/kubespray-2.15.0/roles/download/tasks/download_file.yml:14 -------------------------------------------------------------------------------
bootstrap-os : Assign inventory name to unconfigured hostnames (non-CoreOS, non-Flatcar, Suse and ClearLinux) ---------------------------- 0.81s
/root/kubespray-2.15.0/roles/bootstrap-os/tasks/main.yml:50 ------------------------------------------------------------------------------------
download | Download files / images ------------------------------------------------------------------------------------------------------- 0.81s
/root/kubespray-2.15.0/roles/download/tasks/main.yml:26 ----------------------------------------------------------------------------------------
download_file | Download item ------------------------------------------------------------------------------------------------------------ 0.77s
/root/kubespray-2.15.0/roles/download/tasks/download_file.yml:51 -------------------------------------------------------------------------------
[root@node1 kubespray-2.15.0]#

尝试解决(无果)

环境:vmware搭建三台centos7虚拟机作为k8s节点 + window10宿主机,使用nat方式联通网络
问题定位:虚拟机无法上外网导致执行 ansible-playbook -i inventory/mycluster/hosts.yaml -b cluster.yml -vvvv 报错
尝试解决:宿主机使用clash代理可上外网,虚拟机代理到宿主机,浏览器使用系统代理可上外网,但命令行ping不同外网
图片描述
图片描述
图片描述

写回答

1回答

刘果国

2022-10-21

还是网络问题,按照课程给kubespray设置代理

0
1
无色之王
镜像下载下来,但现在又报这个错了,麻烦老师指点一下 ssh免密登录没问题 "stderr": "error execution phase preflight: couldn't validate the identity of the API Server: configmaps \"cluster-info\" is forbidden: User \"system:anonymous\" cannot get resource \"configmaps\" in API group \"\" in the namespace \"kube-public\"\nTo see the stack trace of this error execute with --v=5 or higher", "stderr_lines": [ "error execution phase preflight: couldn't validate the identity of the API Server: configmaps \"cluster-info\" is forbidden: User \"system:anonymous\" cannot get resource \"configmaps\" in API group \"\" in the namespace \"kube-public\"", "To see the stack trace of this error execute with --v=5 or higher" ], "stdout": "[preflight] Running pre-flight checks", "stdout_lines": [ "[preflight] Running pre-flight checks" ]
2022-10-26
共1条回复

Kubernetes生产落地全程实践

一个互联网公司落地Kubernetes全过程点点滴滴

2293 学习 · 2216 问题

查看课程