If you’re trying to run MetalLB on a cloud platform, you should also look at the cloud compatibility page and make sure your cloud platform can work with MetalLB (most cannot).
There are three supported ways to install MetalLB: using plain Kubernetes manifests, using Kustomize, or using Helm.
If you’re using kube-proxy in IPVS mode, since Kubernetes v1.14.2 you have to enable strict ARP mode.
Note, you don’t need this if you’re using kube-router as service-proxy because it is enabling strict ARP by default.
You can achieve this by editing kube-proxy config in current cluster:
kubectl edit configmap -n kube-system kube-proxy
apiVersion: kubeproxy.config.k8s.io/v1alpha1 kind: KubeProxyConfiguration mode: "ipvs" ipvs: strictARP: true
You can also add this configuration snippet to your kubeadm-config, just append it with
--- after the main configuration.
If you are trying to automate this change, these shell snippets may help you:
# 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
To install MetalLB, apply the manifest:
kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.11.0/manifests/namespace.yaml kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.11.0/manifests/metallb.yaml
This will deploy MetalLB to your cluster, under the
namespace. The components in the manifest are:
metallb-system/controllerdeployment. This is the cluster-wide controller that handles IP address assignments.
metallb-system/speakerdaemonset. This is the component that speaks the protocol(s) of your choice to make the services reachable.
The installation manifest does not include a configuration file. MetalLB’s components will still start, but will remain idle until you define and deploy a configmap.
You can install MetalLB with Kustomize by pointing at the remote kustomization file :
# kustomization.yml namespace: metallb-system resources: - github.com/metallb/metallb//manifests?ref=v0.11.0 - configmap.yml
If you want to use a
for config file, you want to tell Kustomize not to append a hash to
the config map, as MetalLB is waiting for a config map named
# kustomization.yml namespace: metallb-system resources: - github.com/metallb/metallb//manifests?ref=v0.11.0 configMapGenerator: - name: config files: - configs/config generatorOptions: disableNameSuffixHash: true
You can install MetallLB with Helm
by using the Helm chart repository:
helm repo add metallb https://metallb.github.io/metallb helm install metallb metallb/metallb
A values file may be specified on installation. This is recommended for providing configs in Helm values:
helm install metallb metallb/metallb -f values.yaml
MetalLB configs are set in
configInline: address-pools: - name: default protocol: layer2 addresses: - 198.51.100.0/24
When upgrading MetalLB, always check the release notes to see the changes and required actions, if any. Pay special attention to the release notes when upgrading to newer major/minor releases.