使用kubectl报错如下

C:\Users\jiangcheng>kubectl get pods -n ingress-nginx Unable to connect to the server: dial tcp 127.0.0.1:62980: connectex: No connection could be made because the target machine actively refused it. C:\Users\jiangcheng>kubectl get pod --all-namespaces Unable to connect to the server: dial tcp 127.0.0.1:62980: connectex: No connection could be made because the target machine actively refused it.

实际原因是使用kind部署的k8s集群,因为docker各个容器都已经关闭了,所以报错

C:\Users\jiangcheng>docker get nodes docker: 'get' is not a docker command. See 'docker --help' C:\Users\jiangcheng>docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES C:\Users\jiangcheng>docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES c471d8d0a90a hello-world "/hello" 13 days ago Exited (0) 13 days ago zealous_yonath 8291d6a9b50c kindest/node:v1.21.14 "/usr/local/bin/entr…" 13 days ago Exited (255) 16 hours ago wsl-kind-multinodes-worker 00a0f54f15f1 kindest/node:v1.21.14 "/usr/local/bin/entr…" 13 days ago Exited (255) 16 hours ago 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp, 127.0.0.1:62980->6443/tcp wsl-kind-multinodes-control-plane 0cf3daf6fe40 kindest/node:v1.21.14 "/usr/local/bin/entr…" 13 days ago Exited (255) 16 hours ago wsl-kind-multinodes-worker2 eecaa91fcb10 kindest/node:v1.26.3 "/usr/local/bin/entr…" 13 days ago Exited (255) 16 hours ago 127.0.0.1:62898->6443/tcp wslkind-control-plane a6fd5d71acab tdengine/tdengine:3.0.1.4 "/tini -- /usr/bin/e…" 13 days ago Exited (143) 13 days ago sharp_babbage

需要将k8s的docker容器起起来

C:\Users\jiangcheng>docker start -i 8291d6a9b50c INFO: ensuring we can execute mount/umount even with userns-remap INFO: remounting /sys read-only INFO: making mounts shared INFO: detected cgroup v1 WARN: cgroupns not enabled! Please use cgroup v2, or cgroup v1 with cgroupns enabled. INFO: fix cgroup mounts for all subsystems INFO: unmounting and removing /sys/fs/cgroup/misc INFO: clearing and regenerating /etc/machine-id Initializing machine ID from random generator. INFO: setting iptables to detected mode: legacy INFO: Detected IPv4 address: 172.18.0.2 INFO: Detected old IPv4 address: 172.18.0.4 INFO: Detected IPv6 address: fc00:f853:ccd:e793::2 INFO: Detected old IPv6 address: fc00:f853:ccd:e793::4 systemd 249.11-0ubuntu3.6 running in system mode (+PAM +AUDIT +SELINUX +APPARMOR +IMA +SMACK +SECCOMP +GCRYPT +GNUTLS +OPENSSL +ACL +BLKID +CURL +ELFUTILS +FIDO2 +IDN2 -IDN +IPTC +KMOD +LIBCRYPTSETUP +LIBFDISK +PCRE2 -PWQUALITY -P11KIT -QRENCODE +BZIP2 +LZ4 +XZ +ZLIB +ZSTD -XKBCOMMON +UTMP +SYSVINIT default-hierarchy=unified) Detected virtualization wsl. Detected architecture x86-64. Failed to create symlink /sys/fs/cgroup/cpu: File exists Failed to create symlink /sys/fs/cgroup/cpuacct: File exists Failed to create symlink /sys/fs/cgroup/net_prio: File exists Failed to create symlink /sys/fs/cgroup/net_cls: File exists Welcome to Ubuntu 22.04.1 LTS! Queued start job for default target Graphical Interface. [ OK ] Created slice slice used to run Kubernetes / Kubelet. [ OK ] Created slice Slice /system/modprobe. [ OK ] Started Dispatch Password Requests to Console Directory Watch. [ OK ] Set up automount Arbitrary Executable File Formats File System Automount Point. [ OK ] Reached target Local Encrypted Volumes. [ OK ] Reached target Path Units. [ OK ] Reached target Slice Units. [ OK ] Reached target Swaps. [ OK ] Reached target Local Verity Protected Volumes. [ OK ] Listening on Journal Socket (/dev/log). [ OK ] Listening on Journal Socket. [ OK ] Reached target Socket Units. Mounting Huge Pages File System... Mounting Kernel Debug File System... Mounting Kernel Trace File System... Starting Journal Service... Starting Load Kernel Module configfs... Starting Load Kernel Module fuse... Starting Remount Root and Kernel File Systems... Starting Apply Kernel Variables... [ OK ] Mounted Huge Pages File System. [ OK ] Mounted Kernel Debug File System. [ OK ] Mounted Kernel Trace File System. [ OK ] Finished Remount Root and Kernel File Systems. [ OK ] Started Journal Service. [ OK ] Finished Load Kernel Module configfs. [ OK ] Finished Load Kernel Module fuse. Mounting FUSE Control File System... Starting Flush Journal to Persistent Storage... Starting Create System Users... Starting Record System Boot/Shutdown in UTMP... [ OK ] Finished Apply Kernel Variables. [ OK ] Mounted FUSE Control File System. [ OK ] Finished Flush Journal to Persistent Storage. [ OK ] Finished Create System Users. Starting Create Static Device Nodes in /dev... [ OK ] Finished Record System Boot/Shutdown in UTMP. [ OK ] Finished Create Static Device Nodes in /dev. [ OK ] Reached target Preparation for Local File Systems. [ OK ] Reached target Local File Systems. [ OK ] Reached target System Initialization. [ OK ] Started Daily Cleanup of Temporary Directories. [ OK ] Reached target Basic System. [ OK ] Reached target Timer Units. Starting containerd container runtime... Starting kubelet: The Kubernetes Node Agent... [ OK ] Started containerd container runtime. [ OK ] Started kubelet: The Kubernetes Node Agent. [ OK ] Reached target Multi-User System. [ OK ] Reached target Graphical Interface. Starting Record Runlevel Change in UTMP... [ OK ] Finished Record Runlevel Change in UTMP.

起起来之后报错就消失了。

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐