Kubernetes / 云计算

二进制部署多Master高可用K8S集群-v1.18(四)

浅时光 · 7月26日 · 2020年 12220次已读

八、验证集群状态


1、检查节点状态

  • 都为 Ready 且版文章来源(Source):https://www.dqzboy.com本为 v1.18.6 时正常。
[[email protected] ~]# cd /opt/k8s/work
[[email protected] work]# kubectl get nodes
NAME        STATUS   ROLES    AGE     VERSION
k8s-node1   Ready    <none>   3h44m   v1.18.6
k8s-node2   Ready    <none>   3h43m   v1.18.6
k8s-node3   Ready    <none>   3h43m   v1.18.6

2、创建测试文件

文章来源(Source):https://www.dqzboy.com
[[email protected] ~]# cd /opt/k8s/work
[[email protected] work]# cat > nginx-test.yml <<EOF
apiVersion: v1
kind: Service
metadata:
  name: nginx
  labels:
    app: nginx
spec:
  type: NodePort
  selector:
    app: nginx
  ports:
  - name: http
    port: 80
    targetPort: 80
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: nginx
  labels:
    addonmanager.kubernetes.io/mode: Reconcile
spec:
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: my-nginx
        image: nginx:1.16.1
        ports:
        - containerPort: 80
EOF

3、执行测试

[[email protected] work]# kubectl apply -f nginx-test.yml
service/nginx-ds created
daemonset.apps/nginx-ds created

[[email protected] work]# kubectl get pods -o wide|grep nginx
nginx-66qf9                  1/1     Running            0          7m47s   10.68.107.193   k8s-node3   <none>           <none>
nginx-lrm4n                  1/1     Running            0          7m47s   10.68.36.67     k8s-node1   <none>           <none>
nginx-r7pln                  1/1     Running            0          7m47s   10.68.169.129   k8s-node2   <none>           <none>

4、检查各节文章来源(Source):https://www.dqzboy.com点的 Pod IP文章来源(Source):https://www.dqzboy.com 连通性

[[email protected] work]# kubectl get pods  -o wide -l app=nginx

NAME          READY   STATUS    RESTARTS   AGE     IP              NODE        NOMINATED NODE   READINESS GATES
nginx-66qf9   1/1     Running   0          8m24s   10.68.107.193   k8s-node3   <none>           <none>
nginx-lrm4n   1/1     Running   0          8m24s   10.68.36.67     k8s-node1   <none>           <none>
nginx-r7pln   1/1     Running   0          8m24s   10.68.169.129   k8s-node2   <none>           <none>
  • 在所有 worker 上分别 ping 上面三个 Pod IP,看是否连通
[[email protected] work]# for node_ip in ${WORK_IPS[@]}
  do
    echo ">>> ${node_ip}"
    ssh ${node_ip} "ping -c 1 10.68.107.193"
    ssh ${node_ip} "ping -c 1 10.68.36.67"
    ssh ${node_ip} "ping -c 1 10.68.169.129"
  done

5、检查服务 IP 和端口可达性

[[email protected] work]# kubectl get svc -l app=nginx
NAME       TYPE       CLUSTER-IP      EXTERNAL-IP   PORT(S)        AGE
nginx-ds   NodePort   10.254.212.37   <none>        80:32120/TCP   6m7s

可见:

  • Service Clus文章来源(Source):https://www.dqzboy.comt文章来源(Source):https://www.dqzboy.comer IP:10.254.212.37文章来源(Source):https://www.dqzboy.com
  • 服务端口文章来源(Source):https://www.dqzboy.com:80
  • NodePort 端口:32120
  • 在所有 Node 上 curl Service IP
[[email protected] work]# for node_ip in ${WORK_IPS[@]}
  do
    echo ">>> ${node_ip}"
    ssh ${node_ip} "curl -s 10.254.212.37"
  done
  • 没问题则全部Nod文章来源(Source):https://www.dqzboy.come节点输出nginx的欢迎页面
二进制部署多Master高可用K8S集群-v1.18(四)-浅时光博客

6、检查服务的 NodePort 可达性

  • 没问题同样也是全部Node节点输出nginx的欢迎页面
文章来源(Source):https://www.dqzboy.com
[[email protected] work]# for node_ip in ${WORK_IPS[@]}
  do
    echo ">>> ${node_ip}"
    ssh ${node_ip} "curl -s ${node_ip}:32120"
  done

7、浏览器中访问

二进制部署多Master高可用K8S集群-v1.18(四)-浅时光博客
二进制部署多Master高可用K8S集群-v1.18(四)-浅时光博客
二进制部署多Master高可用K8S集群-v1.18(四)-浅时光博客
二进制部署多Master高可用K8S集群-v1.18(四)-浅时光博客
0 条回应
    本站已安全运行: | 耗时 0.441 秒 | 查询 101 次 | 内存 18.50 MB