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: {}
作者:wanghongwei
版权声明:本作品遵循<CC BY-NC-ND 4.0>版权协议,商业转载请联系作者获得授权,非商业转载请附上原文出处链接及本声明。