You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/examples/metallb-loadbalancer.md
+46-30Lines changed: 46 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,8 +26,10 @@ See the MetalLB requirements in the [MetalLB's official documentation](https://m
26
26
```yaml
27
27
apiVersion: k0s.k0sproject.io/v1beta1
28
28
kind: ClusterConfig
29
+
29
30
metadata:
30
31
name: k0s
32
+
31
33
spec:
32
34
network:
33
35
kubeProxy:
@@ -42,44 +44,53 @@ Port 7946 (TCP & UDP) must be allowed between the nodes. In addition, before ins
42
44
43
45
1. Install MetalLB using the official Helm chart and k0s Helm [extension manager](../helm-charts.md):
44
46
45
-
```shell
46
-
apiVersion: k0s.k0sproject.io/v1beta1
47
-
kind: ClusterConfig
48
-
metadata:
49
-
name: k0s
50
-
spec:
51
-
extensions:
52
-
helm:
53
-
repositories:
54
-
- name: metallb
55
-
url: https://metallb.github.io/metallb
56
-
charts:
57
-
- name: metallb
58
-
chartname: metallb/metallb
59
-
namespace: metallb
60
-
```
61
-
62
-
Other installation methods are available in the [MetalLB's official documentation](https://metallb.org/installation/).
47
+
```yaml
48
+
apiVersion: k0s.k0sproject.io/v1beta1
49
+
kind: ClusterConfig
50
+
51
+
metadata:
52
+
name: k0s
53
+
54
+
spec:
55
+
extensions:
56
+
helm:
57
+
repositories:
58
+
- name: metallb
59
+
url: https://metallb.github.io/metallb
60
+
61
+
charts:
62
+
- name: metallb
63
+
chartname: metallb/metallb
64
+
version: "0.15.3"
65
+
namespace: metallb-system
66
+
```
67
+
68
+
Other installation methods are available in the [MetalLB's official documentation](https://metallb.org/installation/).
63
69
64
70
2. Create ConfigMap for MetalLB
65
71
66
-
Next you need to create ConfigMap, which includes an IP address range for the load balancer. The pool of IPs must be dedicated to MetalLB's use. You can't reuse for example the Kubernetes node IPs or IPs controlled by other services. You can, however, use private IP addresses, for example 192.168.1.180-192.168.1.199, but then you need to take care of the routing from the external network if you need external access. In this example, we don't need it.
72
+
Next you need to create ConfigMap, which includes an IP address range for the load balancer. The pool of IPs must be dedicated to MetalLB's use. You can't reuse for example the Kubernetes node IPs or IPs controlled by other services. You can, however, use private IP addresses, for example 192.168.1.180-192.168.1.199, but then you need to take care of the routing from the external network if you need external access. In this example, we don't need it.
67
73
68
-
Create a YAML file accordingly, and deploy it: ```kubectl apply -f metallb-l2-pool.yaml```
74
+
Create a YAML file accordingly, and deploy it: `kubectl apply -f metallb-l2-pool.yaml`
@@ -90,14 +101,17 @@ Port 7946 (TCP & UDP) must be allowed between the nodes. In addition, before ins
90
101
```YAML
91
102
apiVersion: v1
92
103
kind: Namespace
104
+
93
105
metadata:
94
106
name: web
95
107
---
96
108
apiVersion: apps/v1
97
109
kind: Deployment
110
+
98
111
metadata:
99
112
name: web-server
100
113
namespace: web
114
+
101
115
spec:
102
116
selector:
103
117
matchLabels:
@@ -115,9 +129,11 @@ Port 7946 (TCP & UDP) must be allowed between the nodes. In addition, before ins
115
129
---
116
130
apiVersion: v1
117
131
kind: Service
132
+
118
133
metadata:
119
134
name: web-server-service
120
135
namespace: web
136
+
121
137
spec:
122
138
selector:
123
139
app: web
@@ -130,21 +146,21 @@ Port 7946 (TCP & UDP) must be allowed between the nodes. In addition, before ins
130
146
131
147
4. Check your LoadBalancer
132
148
133
-
Run the following command to see your LoadBalancer with the external-ip and port.
149
+
Run the following command to see your LoadBalancer with the external-ip and port.
134
150
135
-
```shell
136
-
kubectl get service -n web
137
-
```
151
+
```shell
152
+
kubectl get service -n web
153
+
```
138
154
139
155
5. Access your example application
140
156
141
-
If you used private IP addresses for MetalLB in the ConfigMap (in step 2), you should run the following command from the local network. Use the IP address from the previous step.
157
+
If you used private IP addresses for MetalLB in the ConfigMap (in step 2), you should run the following command from the local network. Use the IP address from the previous step.
142
158
143
-
```shell
144
-
curl <EXTERNAL-IP>
145
-
```
159
+
```shell
160
+
curl <EXTERNAL-IP>
161
+
```
146
162
147
-
If you are successful, you should see ```<html><body><h1>It works!</h1></body></html>```.
163
+
If you are successful, you should see `<html><body><h1>It works!</h1></body></html>`.
0 commit comments