Skip to content

Commit 5cbccea

Browse files
authored
Add controllers leader election documentation (#1890)
Add controllers leader election documentation By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 0c3a381 commit 5cbccea

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
---
2+
title: "Managing multiple instances of ACK with leader election"
3+
description: "Configure leader election for ACK controllers"
4+
draft: false
5+
menu:
6+
docs:
7+
parent: "getting-started"
8+
weight: 60
9+
toc: true
10+
---
11+
12+
In a Kubernetes cluster, you may want to run multiple instances of any ACK
13+
controller - configured for different accounts or regions, or for fail state
14+
rollover.
15+
However, to avoid conflicts and ensure proper resource management, it's necessary
16+
to designate one instance as the leader, which takes responsibility for executing
17+
certain operations while the other instances remain passive. In the event that
18+
the leader instance fails, [leader election][leader-election] ensures the seamless
19+
transition of leadership to another healthy instance.
20+
21+
By default, leader election is disabled in the ACK Helm charts. However, once
22+
enabled, you gain the flexibility to scale the default deployment of ACK controllers
23+
from a single replica (1) to a higher number.
24+
25+
## Enabling Leader Election for ACK Controllers
26+
27+
To enable leader election when installing an ACK controller, set the
28+
`leaderElection.enabled` to `true` in the helm chart `values.yaml` like:
29+
30+
```yaml
31+
leaderElection:
32+
enabled: true
33+
```
34+
35+
You also have the flexibility to scale the number of controller replicas. Edit
36+
the `deployment.replicas` configuration in the same `values.yaml` file and
37+
adjust it to your desired count, such as:
38+
39+
```yaml
40+
deployment:
41+
replicas: 3
42+
```
43+
44+
## Configuring Leader Election `Namespace`
45+
46+
The leader election namespace is a controller configuration setting that
47+
determines the namespace where controllers manage leader election. Under the
48+
hood it is used for storing `coordination.k8s.io/lease` objects, which help
49+
controllers reach consensus and choose a leader. If not specified, the system
50+
will use the namespace from the service account's configuration by default.
51+
52+
If you would like to set leader election namespace for your ACK controllers,
53+
you need to set `leaderElection.namespace`, like below:
54+
55+
```yaml
56+
leaderElection:
57+
enabled: true
58+
namespace: "ack-leader-election-ns"
59+
```
60+
61+
## Verifying Leader Election
62+
63+
To confirm that leader election is active, you can perform the following checks:
64+
65+
- **Log Messages**: Examine the logs of your ACK controller pods for any messages
66+
indicating the successful execution of leader election.
67+
- **`coordination.k8s.io/lease` Objects**: You can also inspect the
68+
`coordination.k8s.io/lease` objects within the configured leader election
69+
namespace. Using `kubectl` you can retrieve information about these objects,
70+
allowing you to verify leadership status.
71+
- **Kubernetes Events**: Another method is to monitor Kubernetes events related to your
72+
controllers. Execute `kubectl get events` to view events that might provide insights
73+
into leader election and controller behavior.
74+
75+
[leader-election]: https://kubernetes.io/docs/concepts/architecture/leases/#leader-election

0 commit comments

Comments
 (0)