环境说明
CNI 插件:Calico VxLAN 模式
root@k8s-control-plane:/# kubectl get nodes -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
k8s-control-plane Ready control-plane,master 12m v1.23.17 172.18.0.4 <none> Debian GNU/Linux 12 (bookworm) 6.5.0-35-generic containerd://1.7.13
k8s-worker Ready <none> 11m v1.23.17 172.18.0.3 <none> Debian GNU/Linux 12 (bookworm) 6.5.0-35-generic containerd://1.7.13
k8s-worker2 Ready <none> 11m v1.23.17 172.18.0.2 <none> Debian GNU/Linux 12 (bookworm) 6.5.0-35-generic containerd://1.7.13
ClusterIP
ClusterIP 类型的 Service 提供一个集群内部的访问点,它的 IP 地址是一个仅在集群内部可路由的虚拟 IP 地址,映射到后端所有处于就绪状态的 Pod。kube-proxy
负责维护节点上的网络规则,使流经 ClusterIP 地址的流量能够正确路由到后端可用的 Pod
创建用于测试的 Pod,包含一个名为 client 的 Pod 和一个名为 server 的 DaemonSet
apiVersion: v1
kind: Pod
metadata:
name: client
labels:
app: client
spec:
containers:
- name: client
image: nginx:alpine
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: server
spec:
selector:
matchLabels:
app: server
template:
metadata:
labels: