Kubernetes/Cluster/MetalLB: Difference between revisions

From Omnia
Jump to navigation Jump to search
(Created page with "== MetalLB == WARNING: MetalLB does not work with DHCP, so you will need to carve out a selection of IPs to use for MetalLB! MetalLB hooks into your Kubernetes cluster, and...")
 
 
Line 3: Line 3:
WARNING: MetalLB does not work with DHCP, so you will need to carve out a selection of IPs to use for MetalLB!
WARNING: MetalLB does not work with DHCP, so you will need to carve out a selection of IPs to use for MetalLB!


<bloquote>
MetalLB hooks into your Kubernetes cluster, and provides a network load-balancer implementation. In short, it allows you to create Kubernetes services of type LoadBalancer in clusters that don’t run on a cloud provider, and thus cannot simply hook into paid products to provide load balancers.
MetalLB hooks into your Kubernetes cluster, and provides a network load-balancer implementation. In short, it allows you to create Kubernetes services of type LoadBalancer in clusters that don’t run on a cloud provider, and thus cannot simply hook into paid products to provide load balancers.


Line 8: Line 9:


In a Kubernetes cluster on a cloud provider, you request a load balancer, and your cloud platform assigns an IP address to you. In a bare-metal cluster, MetalLB is responsible for that allocation.
In a Kubernetes cluster on a cloud provider, you request a load balancer, and your cloud platform assigns an IP address to you. In a bare-metal cluster, MetalLB is responsible for that allocation.
 
</bloquote>


  MetalLB, bare metal load-balancer for Kubernetes
  MetalLB, bare metal load-balancer for Kubernetes
Line 19: Line 20:
  https://www.spectrocloud.com/blog/getting-started-with-metallb-the-bare-metal-load-balancer-for-kubernetes
  https://www.spectrocloud.com/blog/getting-started-with-metallb-the-bare-metal-load-balancer-for-kubernetes


kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.13.12/config/manifests/metallb-native.yaml
Install MetalLB:
kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.13.12/config/manifests/metallb-native.yaml


Create ippool.yml:
Create ippool.yml:

Latest revision as of 22:05, 22 December 2023

MetalLB

WARNING: MetalLB does not work with DHCP, so you will need to carve out a selection of IPs to use for MetalLB!

<bloquote> MetalLB hooks into your Kubernetes cluster, and provides a network load-balancer implementation. In short, it allows you to create Kubernetes services of type LoadBalancer in clusters that don’t run on a cloud provider, and thus cannot simply hook into paid products to provide load balancers.

It has two features that work together to provide this service: address allocation, and external announcement.

In a Kubernetes cluster on a cloud provider, you request a load balancer, and your cloud platform assigns an IP address to you. In a bare-metal cluster, MetalLB is responsible for that allocation. </bloquote>

MetalLB, bare metal load-balancer for Kubernetes
https://metallb.universe.tf/installation/
MetalLB load-balancer for Kubernetes - Mirantis Kubernetes Engine
https://docs.mirantis.com/mke/3.7/install/install-metallb-for-kubernetes.html
Getting started with MetalLB, the bare metal load balancer for Kubernetes - Spectro Cloud
https://www.spectrocloud.com/blog/getting-started-with-metallb-the-bare-metal-load-balancer-for-kubernetes

Install MetalLB:

kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.13.12/config/manifests/metallb-native.yaml

Create ippool.yml:

apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
  name: first-pool
  namespace: metallb-system
spec:
  addresses:
  - 192.168.108.80-192.168.108.80

Apply ip pool:

k apply -f ippool.yml

Create ipl2.yml:

apiVersion: metallb.io/v1beta1
kind: L2Advertisement
metadata:
  name: ipl2
  namespace: metallb-system

Apply ip l2 notice:

k apply -f ipl2.yml

After making changes, apply them with: (not sure this is needed??)

kubectl rollout restart deployment controller -n metallb-system

Verify name space:

kubectl get ns metallb-system

Verify pods:

kubectl get pods -n metallb-system

Verify configmaps:

kubectl get configmap -n metallb-system

Verify Demonsets:

kubectl get daemonsets -n metallb-system

Verify Deployments:

kubectl get deployment -n metallb-system

Verify Service:

kubectl get services -n metallb-system

Verify Custom Resource Definitions: (CRD)

kubectl get crd -n metallb-system

Verify IP Pools:

kubectl get IPAddressPools -n metallb-system
kubectl describe IPAddressPools -n metallb-system
NAME       AUTO ASSIGN   AVOID BUGGY IPS   ADDRESSES
example1   true          false             ["192.168.10.0/24","192.168.1.0/24"]
example2   true          false             ["52.205.10.1/24"]


--- cheap pool ---

apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
  name: cheap
  namespace: metallb-system
spec:
  addresses:
  - 192.168.10.0/24

--- expensive pool ---

apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
  name: expensive
  namespace: metallb-system
spec:
  addresses:
  - 42.176.25.64/30
  autoAssign: false