Skip to content

Latest commit

 

History

History
91 lines (84 loc) · 1.85 KB

验证集群状态.md

File metadata and controls

91 lines (84 loc) · 1.85 KB

1、检查节点状态

~]# kubectl get nodes

image

2、部署Pod测试

~]# cd /opt/k8s/work
]# cat > nginx-test.yml <<EOF
apiVersion: v1
kind: Service
metadata:
  name: nginx
  namespace: demo-ns
  labels:
    app: nginx
spec:
  type: NodePort
  selector:
    app: nginx
  ports:
  - name: http
    port: 80
    targetPort: 80
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: nginx
  namespace: demo-ns
  labels:
    addonmanager.kubernetes.io/mode: Reconcile
spec:
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: my-nginx
        image: nginx
        ports:
        - containerPort: 80
EOF

]# kubectl create ns demo-ns
]# kubectl apply -f nginx-test.yml
service/nginx-ds created
daemonset.apps/nginx-ds created

3、检查各节点的 Pod IP 连通性

]# kubectl get pods -n demo-ns -o wide -l app=nginx

# 在所有 worker 上分别 ping 上面 Pod IP,看是否连通
]# for node_ip in ${NODE_IPS[@]}
  do
    echo ">>> ${node_ip}"
    ssh ${node_ip} "ping -c 1 10.68.100.192"
    ssh ${node_ip} "ping -c 1 10.68.194.65"
    ssh ${node_ip} "ping -c 1 10.68.126.0"
  done

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

]# kubectl get svc -n demo-ns -l app=nginx

#在所有节点上 curl Service IP
]# for node_ip in ${NODE_IPS[@]}
  do
    echo ">>> ${node_ip}"
    ssh ${node_ip} "curl -s 10.254.236.145"
  done

5、检查服务的 NodePort 可达性

]# for node_ip in ${NODE_IPS[@]}
  do
    echo ">>> ${node_ip}"
    ssh ${node_ip} "curl -s ${node_ip}:30888"
  done

6、浏览器中访问

image