Showing posts with label Metallb. Show all posts
Showing posts with label Metallb. Show all posts

Monday, November 7, 2022

Updated Metallb 0.13.7 Configuration for K8s 1.25

In the new Metallb 0.13.7 configuration for Kubernetes 1.25, there is a new step that needs to be taken before configuring the address pool. You need to enable the ARP (Address Resolution Protocol) to ensure that the load balancer can correctly route traffic between pods.

To enable the ARP, you need to run the following command:

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

This command fetches the kube-proxy configuration map, updates the "strictARP" option from "false" to "true" and applies the updated map to the kube-system namespace.

Once ARP is enabled, you can apply the new Metallb configuration file by running the following command:

kubectl apply -f
This command fetches the Metallb configuration file and applies it to your cluster.

Next, you need to create an IP address pool that Metallb can use to assign IP addresses to services. To do this, you can create a YAML file with the following contents:

kind: IPAddressPool
  name: first-pool
  namespace: metallb-system
This YAML file creates an IP address pool named "first-pool" in the "metallb-system" namespace. The pool has a range of IP addresses between and that Metallb can use to assign to services.

You can apply this YAML file to your cluster using the following command:

kubectl apply -f <filename>.yaml

With these steps, you have successfully configured Metallb 0.13.7 for Kubernetes 1.25 and set up an IP address pool that Metallb can use to assign IP addresses to services. This will help you improve the load balancing capabilities of your Kubernetes cluster and make it more scalable and reliable.

Updation for the below setup

Friday, January 21, 2022

Setting up MetalLB Load Balancer with Kubernetes k8s.

When we are deploying the Kubernetes in the local development environment and if we need to publish the services through load balancer services then Metallb load balancer is one of the easiest solutions we can use. All we need is a set of IP range from our network which metal lb can use.  

Following are the k8s configurations that need to be applied on the cluster. 

Below is the config map which mentions the IPs which can be used for the load balancers

apiVersion: v1
kind: ConfigMap
namespace: metallb-system
name: config
config: |
- name: default
protocol: layer2

Below is the ansible-playbook I used to deploy the metal load balancer on the k8s cluster. 
  • Initialize the master with Metallb Clusters
  • Copy the metallb Configuration to master
  • Kube apply the configuration on master. 

- hosts: master
remote_user: ansible
become: yes
become_method: sudo
become_user: root
gather_facts: yes
connection: ssh
- name: Initializing Metallb cluster
shell: kubectl apply -f
register: myshell_output

- name: Copying the Metallb config file
src: /Users/rahulraj/workspace/vmware-ansible/k8s/playbook/metallb-congif.yml
dest: $HOME/metallb-congif.yml

- name: Configuring Metallb cluster
shell: kubectl apply -f $HOME/metallb-congif.yml
register: myshell_output

For testing it we shall deploy a sample Nginx and expose it through load balancer type services. 

k create deployment nginx-deployments --image=nginx --replicas=3 --port=80
k expose deployment nginx-deployments --port=80 --target-port=80 --type=LoadBalancer

Output should be like following 

 kubectl get svc
NAME                TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE
kubernetes          ClusterIP        <none>        443/TCP        25h
nginx-deployments   LoadBalancer   80:30973/TCP   13h