Kubernetes管理节点负载均衡工具kube-vip

1.准备kube-vip的配置文件

# master01节点的配置文件
vim /etc/kube-vip/config.yaml
localPeer:
  id: master01
  address: 192.168.200.151
  port: 10000
remotePeers:
- id: master02
  address: 192.168.200.152
  port: 10000
- id: master03
  address: 192.168.200.153
  port: 10000
vip: 192.168.200.150
gratuitousARP: true
singleNode: false
startAsLeader: true
interface: "ens33"
loadBalancers:
- name: API Server Load Balancer
  type: tcp
  port: 8443
  bindToVip: true
  backends:
  - port: 6443
    address: 192.168.200.151
  - port: 6443
    address: 192.168.200.152
  - port: 6443
    address: 192.168.200.153
	
# master02节点的配置文件
vim /etc/kube-vip/config.yaml
localPeer:
  id: master02
  address: 192.168.200.152
  port: 10000
remotePeers:
- id: master01
  address: 192.168.200.151
  port: 10000
- id: master03
  address: 192.168.200.153
  port: 10000
vip: 192.168.200.100
gratuitousARP: true
singleNode: false
startAsLeader: true
interface: "ens33"
loadBalancers:
- name: API Server Load Balancer
  type: tcp
  port: 8443
  bindToVip: true
  backends:
  - port: 6443
    address: 172.31.253.61
  - port: 6443
    address: 172.31.253.62
  - port: 6443
    address: 172.31.253.63

# master03节点的配置文件
vim /etc/kube-vip/config.yaml
localPeer:
  id: master03
  address: 192.168.200.153
  port: 10000
remotePeers:
- id: master01
  address: 192.168.200.151
  port: 10000
- id: master02
  address: 192.168.200.152
  port: 10000
vip: 192.168.200.100
gratuitousARP: true
singleNode: false
startAsLeader: true
interface: "ens33"
loadBalancers:
- name: API Server Load Balancer
  type: tcp
  port: 8443
  bindToVip: true
  backends:
  - port: 6443
    address: 172.31.253.61
  - port: 6443
    address: 172.31.253.62
  - port: 6443
    address: 172.31.253.63

2.生成kube-vip的pod资源配置清单

mkdir -pv /etc/kubernetes/manifests/
docker run -it --rm plndr/kube-vip:0.3.3 sample manifest \
    > /etc/kubernetes/manifests/kube-vip.yaml
	
cat kube-vip.yaml 
apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  name: kube-vip
  namespace: kube-system
spec:
  containers:
  - args:
    - start
    - -c
    - /etc/kube-vip/config.yaml
    image: docker.io/plndr/kube-vip:0.3.3
    name: kube-vip
    resources: {}
    securityContext:
      capabilities:
        add:
        - NET_ADMIN
        - SYS_TIME
    volumeMounts:
    - mountPath: /etc/kube-vip/
      name: config
  hostNetwork: true
  volumes:
  - hostPath:
      path: /etc/kube-vip/
    name: config
status: {}
posted @ 2021-10-22 14:25  wanghongwei-dev  阅读(700)  评论(0编辑  收藏  举报