From 8a97852955747a6212e9cb4543399e15f884002d Mon Sep 17 00:00:00 2001 From: David Collom Date: Fri, 22 Apr 2022 19:43:53 +0100 Subject: [PATCH] feat: Controller Leader Election (#1883) * Issue 1565: Controller Leader Election Signed-off-by: David Collom * Fix up RBAC Signed-off-by: David Collom * Adding coordination/leases to install/namespace-install Signed-off-by: David Collom * Fix up rbac Signed-off-by: David Collom * Adding additional RBAC for Events Signed-off-by: David Collom --- controllers/cmd/start.go | 2 ++ .../rbac/argo-events-cluster-role.yaml | 19 +++++++++++++++++++ manifests/install.yaml | 19 +++++++++++++++++++ manifests/namespace-install.yaml | 19 +++++++++++++++++++ .../rbac/argo-events-role.yaml | 19 +++++++++++++++++++ 5 files changed, 78 insertions(+) diff --git a/controllers/cmd/start.go b/controllers/cmd/start.go index 9f6a68edab..fc699dfc73 100644 --- a/controllers/cmd/start.go +++ b/controllers/cmd/start.go @@ -46,6 +46,8 @@ func Start(namespaced bool, managedNamespace string) { opts := ctrl.Options{ MetricsBindAddress: fmt.Sprintf(":%d", common.ControllerMetricsPort), HealthProbeBindAddress: ":8081", + LeaderElection: true, + LeaderElectionID: "argo-events-controller", } if namespaced { opts.Namespace = managedNamespace diff --git a/manifests/cluster-install/rbac/argo-events-cluster-role.yaml b/manifests/cluster-install/rbac/argo-events-cluster-role.yaml index 0f75111f66..e8f5edca2c 100644 --- a/manifests/cluster-install/rbac/argo-events-cluster-role.yaml +++ b/manifests/cluster-install/rbac/argo-events-cluster-role.yaml @@ -3,6 +3,25 @@ kind: ClusterRole metadata: name: argo-events-role rules: + - apiGroups: + - "" + resources: + - "events" + verbs: + - "create" + - "patch" + - apiGroups: + - coordination.k8s.io + resources: + - leases + verbs: + - get + - list + - watch + - create + - update + - patch + - delete - apiGroups: - argoproj.io verbs: diff --git a/manifests/install.yaml b/manifests/install.yaml index dbb737de4e..f38882676f 100644 --- a/manifests/install.yaml +++ b/manifests/install.yaml @@ -211,6 +211,25 @@ kind: ClusterRole metadata: name: argo-events-role rules: +- apiGroups: + - "" + resources: + - events + verbs: + - create + - patch +- apiGroups: + - coordination.k8s.io + resources: + - leases + verbs: + - get + - list + - watch + - create + - update + - patch + - delete - apiGroups: - argoproj.io resources: diff --git a/manifests/namespace-install.yaml b/manifests/namespace-install.yaml index d34fdbacd4..4b6c461bbb 100644 --- a/manifests/namespace-install.yaml +++ b/manifests/namespace-install.yaml @@ -130,6 +130,25 @@ metadata: name: argo-events-role namespace: argo-events rules: +- apiGroups: + - "" + resources: + - events + verbs: + - create + - patch +- apiGroups: + - coordination.k8s.io + resources: + - leases + verbs: + - get + - list + - watch + - create + - update + - patch + - delete - apiGroups: - argoproj.io resources: diff --git a/manifests/namespace-install/rbac/argo-events-role.yaml b/manifests/namespace-install/rbac/argo-events-role.yaml index aa79885438..a5b35931dd 100644 --- a/manifests/namespace-install/rbac/argo-events-role.yaml +++ b/manifests/namespace-install/rbac/argo-events-role.yaml @@ -3,6 +3,25 @@ kind: Role metadata: name: argo-events-role rules: + - apiGroups: + - "" + resources: + - "events" + verbs: + - "create" + - "patch" + - apiGroups: + - coordination.k8s.io + resources: + - leases + verbs: + - get + - list + - watch + - create + - update + - patch + - delete - apiGroups: - argoproj.io verbs: