1.检查节点状态
kubectl get nodes
2.创建测试文件
cat > nginx-ds.yml <<EOF
apiVersion: v1
kind: Service
metadata:
name: nginx-ds
labels:
app: nginx-ds
spec:
type: NodePort
selector:
app: nginx-ds
ports:
- name: http
port: 80
targetPort: 80
---
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
name: nginx-ds
labels:
addonmanager.kubernetes.io/mode: Reconcile
spec:
template:
metadata:
labels:
app: nginx-ds
spec:
containers:
- name: my-nginx
image: nginx:1.7.9
ports:
- containerPort: 80
EOF
执行定义文件
kubectl create -f nginx-ds.yml
3.检查各 Node 上的 Pod IP 连通性
kubectl get pods -o wide|grep nginx-ds
for node_ip in ${NODE_IPS[@]}
do
echo ">>> ${node_ip}"
ssh ${node_ip} "ping -c 1 172.30.19.2"
ssh ${node_ip} "ping -c 1 172.30.97.2"
ssh ${node_ip} "ping -c 1 172.30.31.2"
done
4.检查服务 IP 和端口可达性
kubectl get svc |grep nginx-ds
输出
nginx-ds NodePort 10.254.140.131 <none> 80:8861/TCP 33m
for node_ip in ${NODE_IPS[@]}
do
echo ">>> ${node_ip}"
ssh ${node_ip} "curl 10.254.140.131"
done
for node_ip in ${NODE_IPS[@]}
do
echo ">>> ${node_ip}"
ssh ${node_ip} "curl ${node_ip}:8861"
done