2018-04-24 10:19:11 +00:00
|
|
|
# Role Based Access Control (RBAC)
|
2017-05-22 21:12:23 +00:00
|
|
|
|
|
|
|
## Overview
|
|
|
|
|
2021-11-28 21:11:22 +00:00
|
|
|
This example applies to ingress-nginx-controllers being deployed in an environment with RBAC enabled.
|
2017-05-22 21:12:23 +00:00
|
|
|
|
|
|
|
Role Based Access Control is comprised of four layers:
|
|
|
|
|
2017-10-13 13:55:03 +00:00
|
|
|
1. `ClusterRole` - permissions assigned to a role that apply to an entire cluster
|
|
|
|
2. `ClusterRoleBinding` - binding a ClusterRole to a specific account
|
|
|
|
3. `Role` - permissions assigned to a role that apply to a specific namespace
|
|
|
|
4. `RoleBinding` - binding a Role to a specific account
|
2017-05-22 21:12:23 +00:00
|
|
|
|
2021-11-28 21:11:22 +00:00
|
|
|
In order for RBAC to be applied to an ingress-nginx-controller, that controller
|
2017-05-22 21:12:23 +00:00
|
|
|
should be assigned to a `ServiceAccount`. That `ServiceAccount` should be
|
2021-11-28 21:11:22 +00:00
|
|
|
bound to the `Role`s and `ClusterRole`s defined for the ingress-nginx-controller.
|
2017-05-22 21:12:23 +00:00
|
|
|
|
|
|
|
## Service Accounts created in this example
|
|
|
|
|
2021-11-28 21:11:22 +00:00
|
|
|
One ServiceAccount is created in this example, `ingress-nginx`.
|
2017-05-22 21:12:23 +00:00
|
|
|
|
|
|
|
## Permissions Granted in this example
|
|
|
|
|
|
|
|
There are two sets of permissions defined in this example. Cluster-wide
|
2021-11-28 21:11:22 +00:00
|
|
|
permissions defined by the `ClusterRole` named `ingress-nginx`, and
|
|
|
|
namespace specific permissions defined by the `Role` named `ingress-nginx`.
|
2017-05-22 21:12:23 +00:00
|
|
|
|
|
|
|
### Cluster Permissions
|
|
|
|
|
2021-11-28 21:11:22 +00:00
|
|
|
These permissions are granted in order for the ingress-nginx-controller to be
|
2017-05-22 21:12:23 +00:00
|
|
|
able to function as an ingress across the cluster. These permissions are
|
2021-11-28 21:11:22 +00:00
|
|
|
granted to the ClusterRole named `ingress-nginx`
|
2017-05-22 21:12:23 +00:00
|
|
|
|
|
|
|
* `configmaps`, `endpoints`, `nodes`, `pods`, `secrets`: list, watch
|
2017-06-01 11:47:16 +00:00
|
|
|
* `nodes`: get
|
2017-05-22 21:12:23 +00:00
|
|
|
* `services`, `ingresses`: get, list, watch
|
|
|
|
* `events`: create, patch
|
|
|
|
* `ingresses/status`: update
|
|
|
|
|
|
|
|
### Namespace Permissions
|
|
|
|
|
2021-11-28 21:11:22 +00:00
|
|
|
These permissions are granted specific to the ingress-nginx namespace. These
|
|
|
|
permissions are granted to the Role named `ingress-nginx`
|
2017-05-22 21:12:23 +00:00
|
|
|
|
|
|
|
* `configmaps`, `pods`, `secrets`: get
|
2018-02-24 13:31:22 +00:00
|
|
|
* `endpoints`: get
|
2017-05-22 21:12:23 +00:00
|
|
|
|
2021-11-28 21:11:22 +00:00
|
|
|
Furthermore to support leader-election, the ingress-nginx-controller needs to
|
2017-06-01 11:47:16 +00:00
|
|
|
have access to a `configmap` using the resourceName `ingress-controller-leader-nginx`
|
|
|
|
|
2017-06-03 09:24:35 +00:00
|
|
|
> Note that resourceNames can NOT be used to limit requests using the “create”
|
|
|
|
> verb because authorizers only have access to information that can be obtained
|
|
|
|
> from the request URL, method, and headers (resource names in a “create” request
|
|
|
|
> are part of the request body).
|
|
|
|
|
|
|
|
* `configmaps`: get, update (for resourceName `ingress-controller-leader-nginx`)
|
|
|
|
* `configmaps`: create
|
2017-06-01 11:47:16 +00:00
|
|
|
|
|
|
|
This resourceName is the concatenation of the `election-id` and the
|
2017-08-16 21:46:45 +00:00
|
|
|
`ingress-class` as defined by the ingress-controller, which defaults to:
|
2017-06-01 11:47:16 +00:00
|
|
|
|
|
|
|
* `election-id`: `ingress-controller-leader`
|
|
|
|
* `ingress-class`: `nginx`
|
|
|
|
* `resourceName` : `<election-id>-<ingress-class>`
|
|
|
|
|
|
|
|
Please adapt accordingly if you overwrite either parameter when launching the
|
2021-11-28 21:11:22 +00:00
|
|
|
ingress-nginx-controller.
|
2017-06-01 11:47:16 +00:00
|
|
|
|
2017-05-22 21:12:23 +00:00
|
|
|
### Bindings
|
|
|
|
|
2021-11-28 21:11:22 +00:00
|
|
|
The ServiceAccount `ingress-nginx` is bound to the Role
|
|
|
|
`ingress-nginx` and the ClusterRole `ingress-nginx`.
|
2017-05-22 21:12:23 +00:00
|
|
|
|
|
|
|
The serviceAccountName associated with the containers in the deployment must
|
2017-10-13 13:55:03 +00:00
|
|
|
match the serviceAccount. The namespace references in the Deployment metadata,
|
2021-11-28 21:11:22 +00:00
|
|
|
container arguments, and POD_NAMESPACE should be in the ingress-nginx namespace.
|