KinD external load balancer setup¶
KinD external load balancer setup refers to the process of configuring a Kubernetes in Docker (KinD) cluster with an external load balancer, specifically using MetalLB, to handle LoadBalancer type resources on Linux systems.^[400-devops-07-monitoring-and-observability-k8s-istio-samples-kind-lb-readme.md]
Prerequisites¶
Before running the setup script, the following tools must be installed on the system^[400-devops-07-monitoring-and-observability-k8s-istio-samples-kind-lb-readme.md]:
kubectlkinddocker
Script Usage¶
The setup is performed via a bash script named setupkind.sh. The script is designed to run on Linux environments; executing it on other operating systems will result in an error^[400-devops-07-monitoring-and-observability-k8s-istio-samples-kind-lb-readme.md].
The following command-line arguments are supported^[400-devops-07-monitoring-and-observability-k8s-istio-samples-kind-lb-readme.md]:
-n|--cluster-name: Specifies the name of the Kubernetes cluster. Defaults tocluster1if omitted.-r|--k8s-release: Specifies the Kubernetes version to install. Defaults to the latest available version if omitted.-s|--ip-octet: Defines the third octet for public IP addresses. Defaults to255. The valid range is 100–255.-h|--help: Prints the usage instructions.
Example¶
To create a cluster with a specific name and IP range^[400-devops-07-monitoring-and-observability-k8s-istio-samples-kind-lb-readme.md]:
./setupkind.sh --cluster-name cluster1 --k8s-release 1.22.1 --ip-octet 255
IP Address Management¶
The ip-octet parameter is critical for defining the subnet that MetalLB uses to allocate public IP addresses^[400-devops-07-monitoring-and-observability-k8s-istio-samples-kind-lb-readme.md].
- Structure: The first two octets are determined by the Docker network created by KinD. The script hardcodes the fourth octet to the range 200–240^[400-devops-07-monitoring-and-observability-k8s-istio-samples-kind-lb-readme.md].
- Capacity: Because the fourth octet is limited to the 200–240 range, a single KinD cluster supports a maximum of 40 public IPv4 addresses^[400-devops-07-monitoring-and-observability-k8s-istio-samples-kind-lb-readme.md].
- Multi-cluster Clusters: When running multiple clusters, unique
ip-octetvalues must be provided for each to prevent IP address overlaps^[400-devops-07-monitoring-and-observability-k8s-istio-samples-kind-lb-readme.md].
Multi-Cluster Example¶
To initialize two distinct clusters without IP conflicts^[400-devops-07-monitoring-and-observability-k8s-istio-samples-kind-lb-readme.md]:
./setupkind.sh --cluster-name cluster1 --ip-octet 255
./setupkind.sh --cluster-name cluster2 --ip-octet 245
Related Concepts¶
- Kubernetes
- [[MetalLB]]
- [[Docker]]
Sources¶
^[400-devops-07-monitoring-and-observability-k8s-istio-samples-kind-lb-readme.md]