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
This adds a simple controller that will watch for services of type LoadBalancer
and try to allocated addresses from the specified IPv4 and/or IPv6 ranges.
It's assumed that kube-router (or another network controller) will announce the addresses.
As the controller uses leases for leader election and updates the service status new
RBAC permissions are required.
The load balancer allocator controller looks for services with the type LoadBalancer and tries to allocate addresses for it if needed.
6
+
The controller doesn't enable any announcement of the addresses by default, so `--advertise-loadbalancer-ip` should be set to true and BGP peers configured.
7
+
8
+
## Load balancer classes
9
+
10
+
By default the controller allocates addresses for all LoadBalancer services with the where `loadBalancerClass` is empty or set to one of "default" or "kube-router".
11
+
If `--loadbalancer-default-class` is set to false, the controller will only handle services with the class set to "kube-router".
12
+
13
+
## RBAC permissions
14
+
15
+
The controller needs some extra permissions to get, create and update leases for leader election and to update services with allocated addresses.
16
+
17
+
Example permissions:
18
+
```yaml
19
+
kind: ClusterRole
20
+
apiVersion: rbac.authorization.k8s.io/v1
21
+
metadata:
22
+
name: kube-router
23
+
namespace: kube-system
24
+
rules:
25
+
- apiGroups:
26
+
- "coordination.k8s.io"
27
+
resources:
28
+
- leases
29
+
verbs:
30
+
- get
31
+
- create
32
+
- update
33
+
- apiGroups:
34
+
- ""
35
+
resources:
36
+
- services/status
37
+
verbs:
38
+
- update
39
+
```
40
+
41
+
## Environment variables
42
+
43
+
The controller uses the environment variable `POD_NAME` as the identify for the lease used for leader election.
44
+
Using the kubernetes downward api to set `POD_NAME` to the pod name the lease identify will match the current leader.
45
+
```yaml
46
+
---
47
+
apiVersion: apps/v1
48
+
kind: DaemonSet
49
+
metadata:
50
+
labels:
51
+
k8s-app: kube-router
52
+
tier: node
53
+
name: kube-router
54
+
namespace: kube-system
55
+
spec:
56
+
...
57
+
template:
58
+
metadata:
59
+
....
60
+
spec:
61
+
...
62
+
env:
63
+
- name: POD_NAME
64
+
valueFrom:
65
+
fieldRef:
66
+
fieldPath: metadata.name
67
+
...
68
+
```
69
+
70
+
The environment variable `POD_NAMESPACE` can also be specified to set the namespace used for the lease.
71
+
By default the namespace is looked up from within the pod using `/var/run/secrets/kubernetes.io/serviceaccount/namespace`.
72
+
73
+
## Running outside kubernetes
74
+
75
+
When running the controller outside a pod, both `POD_NAME` and `POD_NAMESPACE` must set for the controller to work.
76
+
`POD_NAME`should be unique per instance, so using for example the hostname of the machine might be a good idea.
77
+
`POD_NAMESPACE`must be the same across all instances running in the same cluster.
78
+
79
+
## Notes
80
+
81
+
It's not possible to specify the addresses for the load balancer services. A externalIP service can be used instead.
0 commit comments