08.验证集群功能

    注意:如果没有特殊指明,本文档的所有操作均在 zhangjun-k8s01 节点上执行,然后远程分发文件和执行命令。

    都为 Ready 时正常。

    创建测试文件

    1. cat > nginx-ds.yml <<EOF
    2. apiVersion: v1
    3. kind: Service
    4. metadata:
    5. name: nginx-ds
    6. labels:
    7. app: nginx-ds
    8. spec:
    9. type: NodePort
    10. selector:
    11. app: nginx-ds
    12. - name: http
    13. port: 80
    14. targetPort: 80
    15. apiVersion: extensions/v1beta1
    16. kind: DaemonSet
    17. metadata:
    18. name: nginx-ds
    19. labels:
    20. addonmanager.kubernetes.io/mode: Reconcile
    21. spec:
    22. template:
    23. metadata:
    24. labels:
    25. app: nginx-ds
    26. spec:
    27. containers:
    28. - name: my-nginx
    29. - containerPort: 80
    30. EOF

    检查各节点的 Pod IP 连通性

    1. $ kubectl get pods -o wide|grep nginx-ds
    2. nginx-ds-cr9n2 1/1 Running 0 2m7s 172.30.32.2 zhangjun-k8s02 <none> <none>
    3. nginx-ds-nf7sk 1/1 Running 0 2m7s 172.30.184.2 zhangjun-k8s03 <none> <none>
    4. nginx-ds-scpcn 1/1 Running 0 2m7s 172.30.80.2 zhangjun-k8s01 <none> <none>
    1. $ kubectl get svc |grep nginx-ds
    2. nginx-ds NodePort 10.254.13.141 <none> 80:31858/TCP 2m58s

    可见:

    • Service Cluster IP:10.254.13.141
    • 服务端口:80
    • NodePort 端口:31858

    在所有 Node 上 curl Service IP:

    检查服务的 NodePort 可达性

    在所有 Node 上执行:

    1. source /opt/k8s/bin/environment.sh
    2. for node_ip in ${NODE_IPS[@]}
    3. do
    4. echo ">>> ${node_ip}"
    5. done

    预期输出 nginx 欢迎页面内容。