Kubernetes / 云原生

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

浅时光博客 · 7月26日 · 2020年 98511次已读

八、验证集群状态


1、检查节点状态

  • 都为 Ready 且版本为 v1.18.6 时正常。
[[email protected] ~]# cd /opt/k8s/work
[[email protected] work]# kubectl get nodes
NAME          STATUS   ROLES    AGE     VERSION
k8s-master1   Ready    <none>   3h44m   v1.18.6
k8s-master2   Ready    <none>   3h43m   v1.18.6
k8s-master3   Ready    <none>   3h43m   v1.18.6
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、创建测试文件

[[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、检查各节点的 Pod IP 连通性

[[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 Cluster IP:10.25文章来源(Source):https://www.dqzboy.com4.212.37
  • 服务端口:80
  • NodePort 端口:32120
  • 在所有 Node 上文章来源(Source):https://www.dqzboy.com 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
  • 没问题则全部Node节点输出nginx的欢迎页面

6、检查服务的 NodePort 可达性

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

7、浏览器中访问


本文作者:浅时光博客
原文链接:https://www.dqzboy.com/3693.html
版权声明:知识共享署名-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)协议进行许可,转载时请以超链接形式标明文章原始出处和作者信息
免责声明:本站提供的内容仅限于个人学习和研究使用;禁止将内容用于商业或非法用途。下载后请在24小时内彻底删除,否则后果由用户承担。访问和下载本站内容即表示您已同意上述条款。

0 条回应

必须 注册 为本站用户, 登录 后才可以发表评论!