其他分享
首页 > 其他分享> > k8s高可用集群9集群的可用性验证

k8s高可用集群9集群的可用性验证

作者:互联网

1查看集群中所有namespace里的容器。发现都是running状态

[root@k8s-master01 ~]#kubectl get pod --all-namespaces

2查看监控数据

[root@k8s-master01 ~]#kubectl top pod -n kube-system

3检查跨网是否可以访问pod

[root@k8s-master01 ~]#kubectl get pod --all-namespaces -o wide
NAMESPACE              NAME                                         READY   STATUS    RESTARTS        AGE     IP               NODE           NOMINATED NODE   READINESS GATES
kube-system            calico-kube-controllers-6f6595874c-s9gz4     1/1     Running   0               3h28m   172.25.244.194   k8s-master01   <none>           <none>
kube-system            calico-node-b98mk                            1/1     Running   0               3h28m   10.0.0.205       k8s-master02   <non

[root@k8s-master01 ~]#ping 10.0.0.205
PING 10.0.0.205 (10.0.0.205) 56(84) bytes of data.
64 bytes from 10.0.0.205: icmp_seq=1 ttl=64 time=10.3 ms
64 bytes from 10.0.0.205: icmp_seq=2 ttl=64 time=0.992 ms
64 bytes from 10.0.0.205: icmp_seq=3 ttl=64 time=2.79 ms
64 bytes from 10.0.0.205: icmp_seq=4 ttl=64 time=0.973 ms
64 bytes from 10.0.0.205: icmp_seq=5 ttl=64 time=0.478 ms

4测试pod之间是不是通的

[root@k8s-master01 ~]#kubectl get pod --all-namespaces -o wide
NAMESPACE              NAME                                         READY   STATUS    RESTARTS        AGE     IP               NODE           NOMINATED NODE   READINESS GATES
kube-system            calico-kube-controllers-6f6595874c-s9gz4     1/1     Running   0               3h28m   172.25.244.194   k8s-master01   <none>           <none>
kube-system            calico-node-b98mk                            1/1     Running   0               3h28m   10.0.0.202       k8s-master02   <none>           <none>
kube-system            calico-node-nhch2                            1/1     Running   0               3h28m   10.0.0.205       k8s-node2      <non

#在master01中进行node02的pod执行命令 [root@k8s-master01 ~]#kubectl exec -it calico-node-nhch2 -n kube-system /bin/sh kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead. Defaulted container "calico-node" out of: calico-node, upgrade-ipam (init), install-cni (init), flexvol-driver (init) sh-4.4#

5要想外部访问一个应该,必须要暴漏一个端口,例如

[root@k8s-master01 ~]#kubectl get svc -n kubernetes-dashboard
NAME                        TYPE        CLUSTER-IP        EXTERNAL-IP   PORT(S)         AGE
dashboard-metrics-scraper   ClusterIP   192.168.223.247   <none>        8000/TCP        96m
kubernetes-dashboard        NodePort    192.168.202.76    <none>        443:32081/TCP   96m
[root@k8s-master01 ~]#kubectl edit svc kubernetes-dashboard
Error from server (NotFound): services "kubernetes-dashboard" not found
[root@k8s-master01 ~]#kubectl edit svc kubernetes-dashboard -n !$

selector:
k8s-app: kubernetes-dashboard
sessionAffinity: None
type: NodePort #修改此处为NodePort

 

标签:kubectl,k8s,可用性,master01,集群,kube,root,calico
来源: https://www.cnblogs.com/tyjs09/p/15942817.html