时间:2021-07-01 10:21:17 帮助过:33人阅读
step 2: # 生成一个configmap, # 注意:这里的 IP 地址范围需要跟集群实际情况相对应。 # https://github.com/danderson/metallb/tree/main/manifests # https://github.com/danderson/metallb/blob/main/manifests/tutorial-4.yaml
root >> kubectl apply -f - << EOF apiVersion: v1 kind: ConfigMap metadata: namespace: metallb-system name: config data: config: | peers: # Cosmetic edit to make MetalLB notice that this is a new config. - my-asn: 64512 peer-asn: 64512 peer-address: 10.4.0.100 - my-asn: 64512 peer-asn: 64512 peer-address: 10.4.0.101 - my-asn: 64512 peer-asn: 64512 peer-address: 10.4.0.102 address-pools: - name: my-ip-space protocol: bgp avoid-buggy-ips: true addresses: - 10.5.0.0/24
# 执行完毕如下图
# 然后,我们在k8s物理机器的外网(比如我这里一台客户机192.168.3.XX),访问上面configmap的四个IP <1> IP_1 = 10.4.0.100 / 10.4.0.101 / 10.4.0.101 <2> IP_2 = 10.5.0.0/24 ==> 10.5.0.1 (也可以通过查询k8s service得到, kubectl get service --all-namespaces -o wide。) root >> ping 10.4.0.100 -c 3 root >> ping 10.4.0.101 -c 3 root >> ping 10.4.0.102 -c 3 root >> ping 10.5.0.1 -c 3step 3: # 查看配置过程 # pod名称,来自step 1查询pod结果 root >> kubectl get all -n metallb-system root >> kubectl logs -f controller-5f898b44f4-4pkk6 -n metallb-system step 4: # 创建一个私有loadbalance provider的nginx服务和部署,如下
root >> kubectl apply -f - << EOF apiVersion: extensions/v1beta1 kind: Deployment metadata: name: nginx-lb namespace: app spec: selector: matchLabels: app: nginx-lb replicas: 1 template: metadata: labels: app: nginx-lb spec: containers: - name: nginx-lb image: nginx:1.7.9 ports: - containerPort: 80 --- apiVersion: v1 kind: Service metadata: name: nginx-lb namespace: app spec: type: LoadBalancer ports: - port: 8090 targetPort: 80 selector: app: nginx-lb
step 5 # 查看创建后的结果,如下图
K8S LoadBalance 私有环境解决方案 == metallb 工具安装和使用介绍
标签:href pac deploy logs clust man beta tps select