「Kubernetes」- kube-proxy,常用维护操作

  CREATED BY JENKINSBOT

查看 kube-proxy 的当前模式

Enable IPVS in Kubernetes
kubeadm – Enable IPVS Mode in Kube Proxy on a ready Kubernetes Local Cluster – Stack Overflow

// 查看模式:通过 configmap 文件

# kubectl get configmaps kube-proxy -n kube-system -o yaml | grep mode
    mode: "ipvs"                                                                # 如果为空,则为 iptables 模式

// 查看模式:通过配置文件

# kubectl exec -n kube-system -it  "<dsname>" -- cat /var/lib/kube-proxy/config.conf

# kubectl exec -n kube-system -it  kube-proxy-952qm -- cat /var/lib/kube-proxy/config.conf
...
mode: mode: "ipvs"
...

// 查看模式:通过 kube-proxy 日志

...
W0322 08:09:44.312816       1 server_others.go:578] Unknown proxy mode "", assuming iptables proxy
I0322 08:09:44.313052       1 server_others.go:185] Using iptables Proxier.
...

修改 kube-proxy 的运行模式

How to set kube-proxy settings using kubectl on AKS

如果要修改配置文件,使用命令:

# kubectl edit configmap kube-proxy -n kube-system
...
mode: ipvs
...

# kubectl delete po -n kube-system <pod-name>
# kubectl delete -n kube-system pods -l k8s-app=kube-proxy

# kubectl logs <kube-proxy pod> | grep "Using ipvs Proxier"