[TOC]nginx
kubernetes環境:json
helm fetch --untar stable/metallb cd metallb vim values.yaml # 配置ip池 helm install --name metallb --namespce kube-system ./
configInline: # Example ARP Configuration address-pools: - name: default protocol: layer2 addresses: - 192.168.105.170-192.168.105.175
示例:vim
nginx-metallb.yaml
api
apiVersion: apps/v1beta2 kind: Deployment metadata: name: nginx-metallb spec: selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx ports: - name: http containerPort: 80 --- apiVersion: v1 kind: Service metadata: name: nginx-metallb spec: ports: - name: http port: 80 protocol: TCP targetPort: 80 selector: app: nginx type: LoadBalancer
正常結果是能夠看到svc的EXTERNAL-IP列有分配IP池中的地址,kubernetes外部也能夠訪問。bash
# 訪問測試 lb_ip=$(kubectl get svc nginx-metallb -ojsonpath={.status.loadBalancer.ingress[0].ip}) curl $lb_ip
參考連接:
[1] https://metallb.universe.tf/網絡