欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

k8s手动设置ipvs

程序员文章站 2022-03-12 16:55:45
...

kubectl edit cm kube-proxy -n kube-system

#修改如下

kind: MasterConfiguration
apiVersion: kubeadm.k8s.io/v1alpha1
...
ipvs:
      excludeCIDRs: null
      minSyncPeriod: 0s
      scheduler: ""
      syncPeriod: 30s
    kind: KubeProxyConfiguration
    metricsBindAddress: 127.0.0.1:10249
    mode: "ipvs"                  #修改
...
[[email protected] nginx-test]# kubectl get pod -n kube-system | grep kube-proxy
kube-proxy-6p7ff                 1/1     Running   2          2d1h
kube-proxy-xvvbc                 1/1     Running   2          2d1h

重启各个节点上的kube-proxy(删除后会自动重新创建)

[[email protected] nginx-test]# kubectl get pod -n kube-system | grep kube-proxy |awk '{system("kubectl delete pod "$1" -n kube-system")}'
pod "kube-proxy-6p7ff" deleted
pod "kube-proxy-xvvbc" deleted
[[email protected] nginx-test]# kubectl get pod -n kube-system | grep kube-proxy 
kube-proxy-f8d46                 1/1     Running   0          12s
kube-proxy-wr5wz                 1/1     Running   0          23s

可以得到如下的一些 ipvs 代理规则,
得到以下就成功了

[[email protected] ~]# ipvsadm -Ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
TCP  2.1.1.20:32150 rr
  -> 10.244.1.9:80                Masq    1      0          7         
  -> 10.244.1.10:80               Masq    1      0          8         
  -> 10.244.1.11:80               Masq    1      0          7         
TCP  10.96.0.1:443 rr
  -> 2.1.1.20:6443                Masq    1      3          0         
TCP  10.96.0.10:53 rr
  -> 10.244.0.6:53                Masq    1      0          0         
  -> 10.244.0.7:53                Masq    1      0          0         
TCP  10.96.0.10:9153 rr
  -> 10.244.0.6:9153              Masq    1      0          0         
  -> 10.244.0.7:9153              Masq    1      0          0         
TCP  10.100.46.127:80 rr
  -> 10.244.1.9:80                Masq    1      0          0         
  -> 10.244.1.10:80               Masq    1      0          0         
  -> 10.244.1.11:80               Masq    1      0          0         
TCP  10.244.0.0:32150 rr
  -> 10.244.1.9:80                Masq    1      0          0         
  -> 10.244.1.10:80               Masq    1      0          0         
  -> 10.244.1.11:80               Masq    1      0          0         
TCP  10.244.0.1:32150 rr
  -> 10.244.1.9:80                Masq    1      0          0         
  -> 10.244.1.10:80               Masq    1      0          0         
  -> 10.244.1.11:80               Masq    1      0          0         
TCP  127.0.0.1:32150 rr
  -> 10.244.1.9:80                Masq    1      0          0         
  -> 10.244.1.10:80               Masq    1      0          0         
  -> 10.244.1.11:80               Masq    1      0          0         
TCP  172.17.0.1:32150 rr
  -> 10.244.1.9:80                Masq    1      0          0         
  -> 10.244.1.10:80               Masq    1      0          0         
  -> 10.244.1.11:80               Masq    1      0          0         
UDP  10.96.0.10:53 rr
  -> 10.244.0.6:53                Masq    1      0          0         
  -> 10.244.0.7:53                Masq    1      0          0   
相关标签: Kubernetes k8s