<aside>
🧸 本地部署的Kubernets没有云服务商提供的负载均衡器,故不设置EXTERNMAL-IP,需要软件负载均衡器MetaLib
</aside>
【Install】https://www.cnblogs.com/-k8s/p/18019734
Installation :: MetalLB, bare metal load-balancer for Kubernetes
设置ipvs
# see what changes would be made, returns nonzero returncode if different
kubectl get configmap kube-proxy -n kube-system -o yaml | \\
sed -e "s/strictARP: false/strictARP: true/" | \\
kubectl diff -f - -n kube-system
# actually apply the changes, returns nonzero returncode on errors only
kubectl get configmap kube-proxy -n kube-system -o yaml | \\
sed -e "s/strictARP: false/strictARP: true/" | \\
kubectl apply -f - -n kube-system
Installation by manifest
kubectl apply -f <https://raw.githubusercontent.com/metallb/metallb/v0.14.8/config/manifests/metallb-native.yaml>
【Configuation】
Configuration :: MetalLB, bare metal load-balancer for Kubernetes
apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
name: public-network-pool
namespace: metallb-system
spec:
addresses:
- <ECS IPv4>/32
---
apiVersion: metallb.io/v1beta1
kind: L2Advertisement
metadata:
name: zgo-l2-advertisement
namespace: metallb-system
spec:
ipAddressPools:
- public-network-pool
【test】实例Service资源:nginx
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
spec:
replicas: 1
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:latest
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: nginx-service
spec:
selector:
app: nginx
ports:
- protocol: TCP
port: 80
targetPort: 80
type: LoadBalancer