Skip to content

Instantly share code, notes, and snippets.

@taking
Last active July 20, 2023 23:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taking/5f604675399fc2caa70ba56bc89966b7 to your computer and use it in GitHub Desktop.
Save taking/5f604675399fc2caa70ba56bc89966b7 to your computer and use it in GitHub Desktop.

MetalLB Installation with Helm

Prerequisites

  • Kubernetes 1.19+
  • Helm 3.2.0+
  • StrictARP: True

documents

helm chart repo

StrictARP: True

kubectl get configmap kube-proxy -n kube-system -o yaml | \
        sed -e "s/strictARP: false/strictARP: true/" | \
        kubectl apply -f - -n kube-system
        kubectl rollout restart -n kube-system daemonset kube-proxy

helm update

helm repo add metallb https://metallb.github.io/metallb
helm repo update metallb

Install

helm install metallb metallb/metallb \
  --create-namespace \
  --namespace metallb-system

Create IPAddressPool

internal_ip="$(hostname -I | awk {'print $1'})"
instance_public_ip="$(curl ifconfig.me --silent)"

cat <<EOF | kubectl apply -f -
# IPAddressPool.yaml
apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
  name: production-public-ips
  namespace: metallb-system
spec:
  addresses:
  - ${internal_ip}/32
  autoAssign: false
EOF
How-to
kubectl annotate service 서비스명 -n 네임스페이스명 "metallb.universe.tf/address-pool=production-public-ips"
(Option) Shared IP
instance_public_ip="$(curl ifconfig.me --silent)"
kubectl annotate service 서비스명 -n 네임스페이스명 "metallb.universe.tf/allow-shared-ip=key-to-share-${instance_public_ip}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment