08.验证集群功能
注意:如果没有特殊指明,本文档的所有操作均在 zhangjun-k8s01 节点上执行,然后远程分发文件和执行命令。
都为 Ready 时正常。
创建测试文件
cat > nginx-ds.yml <<EOF
apiVersion: v1
kind: Service
metadata:
name: nginx-ds
labels:
app: nginx-ds
spec:
type: NodePort
selector:
app: nginx-ds
- 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
- containerPort: 80
EOF
检查各节点的 Pod IP 连通性
$ kubectl get pods -o wide|grep nginx-ds
nginx-ds-cr9n2 1/1 Running 0 2m7s 172.30.32.2 zhangjun-k8s02 <none> <none>
nginx-ds-nf7sk 1/1 Running 0 2m7s 172.30.184.2 zhangjun-k8s03 <none> <none>
nginx-ds-scpcn 1/1 Running 0 2m7s 172.30.80.2 zhangjun-k8s01 <none> <none>
$ kubectl get svc |grep nginx-ds
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 上执行:
source /opt/k8s/bin/environment.sh
for node_ip in ${NODE_IPS[@]}
do
echo ">>> ${node_ip}"
done
预期输出 nginx 欢迎页面内容。