From 3ad6fa80d45a31eb101f90c6b596efad6076502f Mon Sep 17 00:00:00 2001 From: Jan Weitz Date: Thu, 1 Jun 2017 13:47:16 +0200 Subject: [PATCH] Fix #798 - RBAC for leader election Using gcr.io/google_containers/nginx-ingress-controller:0.9.0-beta.7 the nginx-controller needs to handle leader-election via configmaps. To perform the leader-election the nginx-controller needs to have the appropiate RBAC permissions. Previously to this fix, the following errors occured: - cannot get configmaps in the namespace "NAMESPACE_PLACEHOLDER". (get configmaps ingress-controller-leader-nginx) - initially creating leader election record: User "system:serviceaccount:NAMESPACE_PLACEHOLDER" cannot create configmaps in the namespace "NAMESPACE_PLACEHOLDER". (post configmaps) --- examples/rbac/nginx/README.md | 15 +++++++++++++++ .../rbac/nginx/nginx-ingress-controller-rbac.yml | 14 ++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/examples/rbac/nginx/README.md b/examples/rbac/nginx/README.md index dd9042d59..3fee21b69 100644 --- a/examples/rbac/nginx/README.md +++ b/examples/rbac/nginx/README.md @@ -49,6 +49,21 @@ permissions are granted to the Role named `nginx-ingress-role` * `configmaps`, `pods`, `secrets`: get * `endpoints`: create, get, update +Furthermore to support leader-election, the nginx-ingress-controller needs to +have access to a `configmap` using the resourceName `ingress-controller-leader-nginx` + +* `configmaps`: create, get, update (for resourceName `ingress-controller-leader-nginx`) + +This resourceName is the concatenation of the `election-id` and the +`ingress-class` as defined by the ingress-controller, which default to: + +* `election-id`: `ingress-controller-leader` +* `ingress-class`: `nginx` +* `resourceName` : `-` + +Please adapt accordingly if you overwrite either parameter when launching the +nginx-ingress-controller. + ### Bindings The ServiceAccount `nginx-ingress-serviceaccount` is bound to the Role diff --git a/examples/rbac/nginx/nginx-ingress-controller-rbac.yml b/examples/rbac/nginx/nginx-ingress-controller-rbac.yml index fbe50f7ae..87f97b58d 100644 --- a/examples/rbac/nginx/nginx-ingress-controller-rbac.yml +++ b/examples/rbac/nginx/nginx-ingress-controller-rbac.yml @@ -69,6 +69,20 @@ rules: - secrets verbs: - get + - apiGroups: + - "" + resources: + - configmaps + resourceNames: + # Defaults to "-" + # Here: "-" + # This has to be adapted if you change either parameter + # when launching the nginx-ingress-controller. + - "ingress-controller-leader-nginx" + verbs: + - create + - get + - update - apiGroups: - "" resources: