Skip to main content

MetalLB ARP/NDP 사용하기


IPAddressPool

apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
name: <name>
namespace: metallb-system
spec:
addresses:
- <ip>/<cidr>
- <ip>-<ip>
warning

클라우드의 경우 Public IP가 노드 내에 확인이 안되기 때문에 Private IP를 사용합니다. Private IP의 특정 포트에 로드밸런싱되는 서비스가 바인딩되었을 때, Public IP에 해당 포트로 접근하면 됩니다.

단 Service에 할당된 External IP는 Private IP기 때문에 이를 검색하여 사용하는 프로그램이 있다면 문제가 발생합니다.

L2Advertisement

apiVersion: metallb.io/v1beta1
kind: L2Advertisement
metadata:
name: <name>
namespace: metallb-system
spec:
ipAddressPools:
- <poolName>
  • ipAddressPools: []
  • nodeSelectors: []
  • interfaces: []
warning

에러 로그 없이 로드밸런싱이 되지 않는다면, 노드에 네트워크 이상(NetworkUnavailable)이 있거나 node.kubernetes.io/exclude-from-external-load-balancers 레이블이 있어서 사용 가능한 노드를 찾지 못한 경우일 수 있습니다.

node.kubernetes.io/exclude-from-external-load-balancers가 있는 노드를 사용하고 싶은 경우 speaker의 --ignore-exclude-lb 옵션을 활성화해야합니다.

LoadBalancer Service

apiVersion: v1
kind: Service
metadata:
annotations:
metallb.universe.tf/<key>: <value>
spec:
type: LoadBalancer
# externalTrafficPolicy: Cluster # Cluster|Local
  • <key>: <value>
    • loadBalancerIPs: <ip>
    • address-pool: <ipAddressPoolName>
    • allow-shared-ip: <keyToShare>
      • 같은 <keyToShare>를 갖는 Service들은 특정 조건을 만족할 경우 같은 IP를 할당받을 수 있습니다.
      • 조건
        • 다른 Port를 사용해야합니다.
        • externalTrafficPolicy: Cluster를 사용하거나 .spec.selector가 같아야합니다.
        • Ex) 각각 tcp/53, udp/53를 사용하면서 같은 Pod을 선택하는 Service의 경우 같은 IP를 할당받을 수 있습니다.