015.Kubernetes二进制集群检查测试

一 验证集群功能

1.1 检查节点状态

  1 [root@master01 ~]# cd /opt/k8s/work/
  2 [root@master01 work]# kubectl get cs
  3 [root@master01 work]# kubectl cluster-info 
  4 [root@master01 work]# kubectl get nodes

clipboard

1.2 创建测试文件

  1 [root@master01 ~]# cd /opt/k8s/work/
  2 [root@master01 work]# source /root/environment.sh
  3 [root@master01 work]# bash config/baseimage.sh		#提前pull镜像
  4 [root@master01 work]# cat > nginx-ds.yml <<EOF
  5 apiVersion: v1
  6 kind: Service
  7 metadata:
  8   name: nginx-svc
  9   labels:
 10     app: nginx-svc
 11 spec:
 12   type: NodePort
 13   selector:
 14     app: nginx-ds
 15   ports:
 16   - name: http
 17     port: 80
 18     targetPort: 80
 19     nodePort: 8888
 20 ---
 21 apiVersion: apps/v1
 22 kind: DaemonSet
 23 metadata:
 24   name: nginx-ds
 25   labels:
 26     app: nginx-ds
 27 spec:
 28   selector:
 29     matchLabels:
 30       app: nginx-ds
 31   template:
 32     metadata:
 33       labels:
 34         app: nginx-ds
 35     spec:
 36       containers:
 37       - name: my-nginx
 38         image: nginx:1.19.0
 39         ports:
 40         - containerPort: 80
 41 EOF
 42 [root@master01 work]# kubectl create -f nginx-ds.yml

提示:本步骤操作仅需要在master01节点操作。

1.3 检查各节点的 Pod IP 连通性

  1 [root@master01 work]# kubectl get pods  -o wide | grep nginx-ds

clipboard

  1 [root@master01 work]# for all_ip in ${ALL_IPS[@]}
  2   do
  3     echo ">>> ${all_ip}"
  4     ssh ${all_ip} "ping -c 1 10.10.96.2"
  5     ssh ${all_ip} "ping -c 1 10.10.80.2"
  6     ssh ${all_ip} "ping -c 1 10.10.176.2"
  7     ssh ${all_ip} "ping -c 1 10.10.216.2"
  8     ssh ${all_ip} "ping -c 1 10.10.168.2"
  9   done

提示:本步骤操作仅需要在master01节点操作。

1.4 检查服务 IP 和端口可达性

  1 [root@master01 ~]# kubectl get svc |grep nginx-svc
  2 [root@master01 ~]# cd /opt/k8s/work/
  3 [root@master01 work]# source /root/environment.sh
  4 [root@master01 work]# for node_ip in ${NODE_IPS[@]}
  5   do
  6     echo ">>> ${node_ip}"
  7     ssh ${node_ip} "curl -s 10.20.201.215"
  8   done

提示:本步骤操作仅需要在master01节点操作。

clipboard

解释:

Service Cluster IP:10.20.201.215

服务端口:80

NodePort 端口:8888

1.5 检查服务的 NodePort 可达性

  1 [root@master01 ~]# cd /opt/k8s/work/
  2 [root@master01 work]# source /root/environment.sh
  3 [root@master01 work]# for node_ip in ${NODE_IPS[@]}
  4   do
  5     echo ">>> ${node_ip}"
  6     ssh ${node_ip} "curl -s ${node_ip}:8888"
  7   done

提示:本步骤操作仅需要在master01节点操作。

clipboard

posted @ 2019-11-18 17:17  木二  阅读(544)  评论(0编辑  收藏  举报