Skip to content

Commit 2e2058d

Browse files
committed
update README, examples and RBAC to include leader election
1 parent 8f69d74 commit 2e2058d

File tree

4 files changed

+39
-1
lines changed

4 files changed

+39
-1
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ It is necessary to create a new service account and give it enough privileges to
4848
for i in $(find deploy/kubernetes -name '*.yaml'); do kubectl create -f $i; done
4949
```
5050

51+
### Running with Leader Election
52+
53+
If you want to run external-snapshotter with higher availability, you can enable resource based leader election. To enable this, set the following flags:
54+
```bash
55+
--leader-election=true
56+
```
57+
5158
## Testing
5259

5360
Running Unit Tests:

deploy/kubernetes/rbac-external-provisioner.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ roleRef:
5959
apiGroup: rbac.authorization.k8s.io
6060

6161
---
62-
# Provisioner must be able to work with endpoints in current namespace
62+
# Provisioner must be able to work with endpoints and leases in current namespace
6363
# if (and only if) leadership election is enabled
6464
kind: Role
6565
apiVersion: rbac.authorization.k8s.io/v1
@@ -71,6 +71,9 @@ rules:
7171
- apiGroups: [""]
7272
resources: ["endpoints"]
7373
verbs: ["get", "watch", "list", "delete", "update", "create"]
74+
- apiGroups: ["coordination.k8s.io"]
75+
resources: ["leases"]
76+
verbs: ["get", "watch", "list", "delete", "update", "create"]
7477

7578
---
7679
kind: RoleBinding

deploy/kubernetes/rbac.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,30 @@ roleRef:
6363
# change the name also here if the ClusterRole gets renamed
6464
name: external-snapshotter-runner
6565
apiGroup: rbac.authorization.k8s.io
66+
67+
---
68+
kind: Role
69+
apiVersion: rbac.authorization.k8s.io/v1
70+
metadata:
71+
namespace: default # TODO: replace with the namespace you want for your sidecar
72+
name: external-snapshotter-leaderelection
73+
rules:
74+
- apiGroups: ["coordination.k8s.io"]
75+
resources: ["leases"]
76+
verbs: ["get", "watch", "list", "delete", "update", "create"]
77+
78+
---
79+
kind: RoleBinding
80+
apiVersion: rbac.authorization.k8s.io/v1
81+
metadata:
82+
name: external-snapshotter-leaderelection
83+
namespace: default # TODO: replace with the namespace you want for your sidecar
84+
subjects:
85+
- kind: ServiceAccount
86+
name: csi-snapshotter
87+
namespace: default # TODO: replace with the namespace you want for your sidecar
88+
roleRef:
89+
kind: Role
90+
name: external-snapshotter-leaderelection
91+
apiGroup: rbac.authorization.k8s.io
92+

deploy/kubernetes/setup-csi-snapshotter.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ spec:
8989
args:
9090
- "--csi-address=$(ADDRESS)"
9191
- "--connection-timeout=15s"
92+
- "--leader-election=false"
9293
env:
9394
- name: ADDRESS
9495
value: /csi/csi.sock

0 commit comments

Comments
 (0)