minikube start --image-mirror-country='cn' --image-repository='registry.cn-hangzhou.aliyuncs.com/google_containers' --kubernetes-version=v1.21.0 😄 Darwin 11.6 上的 minikube v1.21.0 ❗ Kubernetes 1.21.0 has a known performance issue on cluster startup. It might take 2 to 3 minutes for a cluster to start. ❗ For more information, see: https://github.com/kubernetes/kubeadm/issues/2395 🎉 minikube 1.23.2 is available! Download it: https://github.com/kubernetes/minikube/releases/tag/v1.23.2 💡 To disable this notice, run: 'minikube config set WantUpdateNotification false'
✨ 根据现有的配置文件使用 docker 驱动程序 👍 Starting control plane node minikube in cluster minikube 🚜 Pulling base image ... 💾 Downloading Kubernetes v1.21.0 preload ... > preloaded-images-k8s-v11-v1...: 498.90 MiB / 498.90 MiB 100.00% 17.39 Mi
❗ minikube was unable to download gcr.io/k8s-minikube/kicbase:v0.0.23, but successfully downloaded kicbase/stable:v0.0.23 as a fallback image 🔥 Creating docker container (CPUs=2, Memory=4000MB) ... ❗ This container is having trouble accessing https://k8s.gcr.io 💡 To pull new external images, you may need to configure a proxy: https://minikube.sigs.k8s.io/docs/reference/networking/proxy/ 🐳 正在 Docker 20.10.7 中准备 Kubernetes v1.21.0… ▪ Generating certificates and keys ... ▪ Booting up control plane ... ▪ Configuring RBAC rules ... 🔎 Verifying Kubernetes components... ▪ Using image gcr.io/k8s-minikube/storage-provisioner:v5 🌟 Enabled addons: storage-provisioner, default-storageclass 🏄 Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default
构建实验 manifests,准备的yaml 文件如下: 本例的service type 是 ClusterIP
kubectl get all -o wide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES pod/nginx-deployment-74bc56fb4b-9xqkt 1/1 Running 0 4m23s 172.17.0.5 minikube <none> <none> pod/nginx-deployment-74bc56fb4b-c9zp4 1/1 Running 0 4m23s 172.17.0.4 minikube <none> <none> pod/nginx-deployment-74bc56fb4b-h7rhz 1/1 Running 0 4m23s 172.17.0.6 minikube <none> <none> pod/web-server 1/1 Running 0 4m23s 172.17.0.3 minikube <none> <none>
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 3h22m <none> service/nginx-service ClusterIP 10.97.79.231 <none> 80/TCP 4m23s app=nginx
NAME READY UP-TO-DATE AVAILABLE AGE CONTAINERS IMAGES SELECTOR deployment.apps/nginx-deployment 3/3 3 3 4m23s nginx nginx app=nginx
NAME DESIRED CURRENT READY AGE CONTAINERS IMAGES SELECTOR replicaset.apps/nginx-deployment-74bc56fb4b 3 3 3 4m23s nginx nginx app=nginx,pod-template-hash=74bc56fb4b
至此实验环境准备完成。
流量转发分析
首先需要登陆到 minukube 节点:
1 2 3 4 5
minikube ssh docker@minikube:~$ iptables iptables v1.8.4 (legacy): no command specified Try `iptables -h' or 'iptables --help' for more information. docker@minikube:~$sudo su # 切换到root 用户
kube-proxy iptable 模式分析之ClusterIP
流量的源与目的大概如下:
graph LR
web[web-server:172.17.0.3]-->nginx[nginx-service:10.97.79.231]