| | 23 | You should see the MetalLB pods running. |
| | 24 | |
| | 25 | '''Step 2: Configure MetalLB''' |
| | 26 | |
| | 27 | MetalLB can operate in either Layer 2 mode or BGP mode. We'll use Layer 2 mode for simplicity. |
| | 28 | |
| | 29 | 1. Create a ConfigMap for MetalLB: Define a range of IP addresses that MetalLB will manage. Create a file named `metallb-pool.yaml` with the following content: |
| | 30 | |
| | 31 | {{{ |
| | 32 | apiVersion: metallb.io/v1beta1 |
| | 33 | kind: IPAddressPool |
| | 34 | metadata: |
| | 35 | name: ippool |
| | 36 | namespace: metallb-system |
| | 37 | spec: |
| | 38 | addresses: |
| | 39 | - 192.168.1.200/32 |
| | 40 | - 192.168.1.240-192.168.1.250 |
| | 41 | }}} |
| | 42 | |
| | 43 | Replace 192.168.1.240-192.168.1.250 with your desired IP range. |
| | 44 | |
| | 45 | Apply the Pool: |
| | 46 | |
| | 47 | `kubectl apply -f metallb-pool.yaml` |
| | 48 | |
| | 49 | 2. Create a L2 Advertisement: When additional IP ranges are defined in the config- map, they need to be advertised on to the network. Create a file named L2add.yaml with the following content: |
| | 50 | |
| | 51 | {{{ |
| | 52 | apiVersion: metallb.io/v1beta1 |
| | 53 | kind: L2Advertisement |
| | 54 | metadata: |
| | 55 | name: example |
| | 56 | namespace: metallb-system |
| | 57 | spec: |
| | 58 | ipAddressPools: |
| | 59 | - ippool |
| | 60 | }}} |