二进制Kubernetes已经完成安装,本文将对安装的服务进行一次review.
一、服务状态
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
[root@k8s-master01 ~]# kubectl get node NAME STATUS ROLES AGE VERSION k8s-master01 Ready <none> 13h v1.25.0 k8s-master02 Ready <none> 13h v1.25.0 k8s-master03 Ready <none> 13h v1.25.0 k8s-node01 Ready <none> 13h v1.25.0 k8s-node02 Ready <none> 13h v1.25.0 k8s-node03 Ready <none> 13h v1.25.0 [root@k8s-master01 ~]# netstat -tunlp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:179 0.0.0.0:* LISTEN 24352/bird tcp 0 0 0.0.0.0:8443 0.0.0.0:* LISTEN 809/haproxy tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 678/sshd: /usr/sbin tcp 0 0 127.0.0.1:9099 0.0.0.0:* LISTEN 24181/calico-node tcp 0 0 127.0.0.1:9098 0.0.0.0:* LISTEN 23846/calico-typha tcp 0 0 192.168.31.11:2379 0.0.0.0:* LISTEN 673/etcd tcp 0 0 192.168.31.11:2380 0.0.0.0:* LISTEN 673/etcd tcp 0 0 127.0.0.1:34589 0.0.0.0:* LISTEN 680/containerd tcp 0 0 127.0.0.1:8443 0.0.0.0:* LISTEN 809/haproxy tcp 0 0 127.0.0.1:10249 0.0.0.0:* LISTEN 2483/kube-proxy tcp 0 0 127.0.0.1:10248 0.0.0.0:* LISTEN 645/kubelet tcp 0 0 127.0.0.1:2379 0.0.0.0:* LISTEN 673/etcd tcp6 0 0 :::10250 :::* LISTEN 645/kubelet tcp6 0 0 :::10255 :::* LISTEN 645/kubelet tcp6 0 0 :::10256 :::* LISTEN 2483/kube-proxy tcp6 0 0 :::10257 :::* LISTEN 675/kube-controller tcp6 0 0 :::10259 :::* LISTEN 676/kube-scheduler tcp6 0 0 :::22 :::* LISTEN 678/sshd: /usr/sbin tcp6 0 0 :::6443 :::* LISTEN 674/kube-apiserver tcp6 0 0 :::5473 :::* LISTEN 23846/calico-typha udp 0 0 0.0.0.0:39146 0.0.0.0:* 809/haproxy udp 0 0 127.0.0.1:323 0.0.0.0:* 653/chronyd udp 0 0 0.0.0.0:60174 0.0.0.0:* 809/haproxy udp6 0 0 ::1:323 :::* 653/chronyd [root@k8s-master01 ~]# kubectl get po -n kube-system NAME READY STATUS RESTARTS AGE calico-kube-controllers-86d8c4fb68-2wz7r 1/1 Running 6 (129m ago) 135m calico-node-c4k2t 1/1 Running 6 (129m ago) 135m calico-node-cqc8m 1/1 Running 6 (128m ago) 135m calico-node-lwt6t 1/1 Running 6 (128m ago) 135m calico-node-np456 1/1 Running 6 (128m ago) 135m calico-node-qppwd 1/1 Running 6 (127m ago) 135m calico-node-s6c7w 1/1 Running 6 (129m ago) 135m calico-typha-768795f74d-lqgr9 1/1 Running 0 135m coredns-5bc764d4f4-w85nz 1/1 Running 0 117m metrics-server-6b4f467564-tq682 1/1 Running 0 106m [root@k8s-master01 ~]# kubectl get po NAME READY STATUS RESTARTS AGE busybox 0/1 ContainerCreating 0 15s [root@k8s-master01 ~]# kubectl get po NAME READY STATUS RESTARTS AGE busybox 0/1 ErrImagePull 0 23s [root@k8s-master01 ~]# kubectl get po NAME READY STATUS RESTARTS AGE busybox 0/1 ErrImagePull 0 26s [root@k8s-master01 ~]# kubectl get po NAME READY STATUS RESTARTS AGE busybox 0/1 ImagePullBackOff 0 40s [root@k8s-master01 ~]# kubectl get po NAME READY STATUS RESTARTS AGE busybox 0/1 ErrImagePull 0 65s [root@k8s-master01 ~]# kubectl descirbe pod busybox error: unknown command "descirbe" for "kubectl" Did you mean this? describe [root@k8s-master01 ~]# kubectl describe pod busybox Name: busybox Namespace: default Priority: 0 Service Account: default Node: k8s-master03/192.168.31.13 Start Time: Thu, 27 Oct 2022 13:00:43 +0800 Labels: <none> Annotations: cni.projectcalico.org/containerID: a76b382e10371e8615f1ce27f0726622753e3339597ba15afdd3b3130fad7820 cni.projectcalico.org/podIP: 172.18.195.1/32 cni.projectcalico.org/podIPs: 172.18.195.1/32 Status: Pending IP: 172.18.195.1 IPs: IP: 172.18.195.1 Containers: busybox: Container ID: Image: busybox:1.28 Image ID: Port: <none> Host Port: <none> Command: sleep 3600 State: Waiting Reason: ImagePullBackOff Ready: False Restart Count: 0 Environment: <none> Mounts: /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-sl7td (ro) Conditions: Type Status Initialized True Ready False ContainersReady False PodScheduled True Volumes: kube-api-access-sl7td: Type: Projected (a volume that contains injected data from multiple sources) TokenExpirationSeconds: 3607 ConfigMapName: kube-root-ca.crt ConfigMapOptional: <nil> DownwardAPI: true QoS Class: BestEffort Node-Selectors: <none> Tolerations: node.kubernetes.io/not-ready:NoExecute op=Exists for 300s node.kubernetes.io/unreachable:NoExecute op=Exists for 300s Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal Scheduled 3m16s default-scheduler Successfully assigned default/busybox to k8s-master03 Warning Failed 2m58s kubelet Failed to pull image "busybox:1.28": rpc error: code = Unknown desc = failed to pull and unpack image "docker.io/library/busybox:1.28": failed to copy: httpReadSeeker: failed open: failed to do request: Get "https://production.cloudflare.docker.com/registry-v2/docker/registry/v2/blobs/sha256/8c/8c811b4aec35f259572d0f79207bc0678df4c736eeec50bc9fec37ed936a472a/data?verify=1666849851-k8JSHSWD2KEFOBRQJn%2FxdDp7grQ%3D": dial tcp [2606:4700::6812:7a19]:443: connect: network is unreachable Warning Failed 2m24s kubelet Failed to pull image "busybox:1.28": rpc error: code = Unknown desc = failed to pull and unpack image "docker.io/library/busybox:1.28": failed to resolve reference "docker.io/library/busybox:1.28": failed to do request: Head "https://registry-1.docker.io/v2/library/busybox/manifests/1.28": dial tcp: lookup registry-1.docker.io on 114.114.114.114:53: read udp 192.168.31.13:49039->114.114.114.114:53: i/o timeout Warning Failed 77s kubelet Failed to pull image "busybox:1.28": rpc error: code = Unknown desc = failed to pull and unpack image "docker.io/library/busybox:1.28": failed to copy: httpReadSeeker: failed open: failed to do request: Get "https://registry-1.docker.io/v2/library/busybox/blobs/sha256:07a152489297fc2bca20be96fab3527ceac5668328a30fd543a160cd689ee548": dial tcp: lookup registry-1.docker.io on 114.114.114.114:53: read udp 192.168.31.13:55233->114.114.114.114:53: i/o timeout Normal BackOff 50s (x4 over 2m58s) kubelet Back-off pulling image "busybox:1.28" Warning Failed 50s (x4 over 2m58s) kubelet Error: ImagePullBackOff Normal Pulling 37s (x4 over 3m15s) kubelet Pulling image "busybox:1.28" Warning Failed 8s (x4 over 2m58s) kubelet Error: ErrImagePull Warning Failed 8s kubelet Failed to pull image "busybox:1.28": rpc error: code = Unknown desc = failed to pull and unpack image "docker.io/library/busybox:1.28": failed to copy: httpReadSeeker: failed open: failed to do request: Get "https://production.cloudflare.docker.com/registry-v2/docker/registry/v2/blobs/sha256/8c/8c811b4aec35f259572d0f79207bc0678df4c736eeec50bc9fec37ed936a472a/data?verify=1666850011-5gyHqHJeJ%2FbwwtUDqqHOLPo17zs%3D": dial tcp: lookup production.cloudflare.docker.com on 114.114.114.114:53: read udp 192.168.31.13:55549->114.114.114.114:53: i/o timeout |
通一个namespace
0 1 2 3 4 5 6 7 8 |
[root@k8s-master01 ~]# kubectl get svc NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes ClusterIP 192.168.31.1 <none> 443/TCP 15h [root@k8s-master01 ~]# kubectl exec busybox -n default -- nslookup kubernetes Server: 192.168.31.10 Address 1: 192.168.31.10 kube-dns.kube-system.svc.cluster.local Name: kubernetes Address 1: 192.168.31.1 kubernetes.default.svc.cluster.local |
跨namespace
0 1 2 3 4 5 |
[root@k8s-master01 ~]# kubectl exec busybox -n default -- nslookup kube-dns.kube-system Server: 192.168.31.10 Address 1: 192.168.31.10 kube-dns.kube-system.svc.cluster.local Name: kube-dns.kube-system Address 1: 192.168.31.10 kube-dns.kube-system.svc.cluster.local |
每个节点都必须要能访问Kubernetes的kubernetes svc 443和kube-dns的service 53
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
[root@k8s-master01 ~]# telnet 192.168.31.1 443 Trying 192.168.31.1... Connected to 192.168.31.1. Escape character is '^]'. Connection closed by foreign host. [root@k8s-node03 ~]# telnet 192.168.31.1 443 Trying 192.168.31.1... Connected to 192.168.31.1. Escape character is '^]'. Connection closed by foreign host. [root@k8s-master01 ~]# kubectl get svc -n kube-system NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE calico-typha ClusterIP 192.168.31.132 <none> 5473/TCP 3h20m kube-dns ClusterIP 192.168.31.10 <none> 53/UDP,53/TCP,9153/TCP 3h1m metrics-server ClusterIP 192.168.31.118 <none> 443/TCP 170m [root@k8s-master01 ~]# telnet 192.168.31.10 53 Trying 192.168.31.10... Connected to 192.168.31.10. Escape character is '^]'. Connection closed by foreign host. |
4.Pod和Pod之前要能通
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
[root@k8s-master01 ~]# kubectl get po -n kube-system -owide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES calico-kube-controllers-86d8c4fb68-2wz7r 1/1 Running 8 (22m ago) 3h22m 172.25.244.195 k8s-master01 <none> <none> calico-node-c4k2t 1/1 Running 8 (23m ago) 3h22m 192.168.31.21 k8s-node01 <none> <none> calico-node-cqc8m 1/1 Running 8 (23m ago) 3h22m 192.168.31.22 k8s-node02 <none> <none> calico-node-lwt6t 1/1 Running 8 (21m ago) 3h22m 192.168.31.13 k8s-master03 <none> <none> calico-node-np456 1/1 Running 9 (22m ago) 3h22m 192.168.31.11 k8s-master01 <none> <none> calico-node-qppwd 1/1 Running 8 (23m ago) 3h22m 192.168.31.12 k8s-master02 <none> <none> calico-node-s6c7w 1/1 Running 8 (23m ago) 3h22m 192.168.31.23 k8s-node03 <none> <none> calico-typha-768795f74d-lqgr9 1/1 Running 2 (22m ago) 3h22m 192.168.31.11 k8s-master01 <none> <none> coredns-5bc764d4f4-w85nz 1/1 Running 2 (23m ago) 3h3m 172.25.92.67 k8s-master02 <none> <none> metrics-server-6b4f467564-tq682 1/1 Running 3 (21m ago) 172m 172.17.125.3 k8s-node01 <none> <none> [root@k8s-master01 ~]# kubectl exec -ti calico-node-lwt6t -n kube-system -- bash Defaulted container "calico-node" out of: calico-node, upgrade-ipam (init), install-cni (init), mount-bpffs (init) [root@k8s-master03 /]# |
0 |
0 |
申明:除非注明Byrd's Blog内容均为原创,未经许可禁止转载!详情请阅读版权申明!