How do I create a user? | Как создать пользователя? |
How do I limit user rights to specific namespaces? | Как ограничить права пользователю конкретными пространствами имён? |
To limit a user’s rights to specific namespaces in the experimental role-based model, use | Чтобы ограничить права пользователя конкретными пространствами имён в экспериментальной ролевой модели, используйте в |
In the current role-based model, use the | В текущей ролевой модули используйте параметры |
What if there are two ClusterAuthorizationRules matching to a single user? | Что, если два ClusterAuthorizationRules подходят для одного пользователя? |
Imagine that the user | Представьте, что пользователь |
yaml apiVersion: deckhouse.io/v1 kind: ClusterAuthorizationRule metadata: name: jane spec: subjects:
| yaml apiVersion: deckhouse.io/v1 kind: ClusterAuthorizationRule metadata: name: jane spec: subjects:
|
|
|
Because
| Так как для
|
|
|
How do I extend a role or create a new one? | Как расширить роли или создать новую? |
The experimental role model is based on the aggregation principle; it compiles smaller roles into larger ones, thus providing easy ways to enhance the model with custom roles. | Экспериментальная ролевая модель построена на принципе агрегации, она собирает более мелкие роли в более обширные, тем самым предоставляя лёгкие способы расширения модели собственными ролями. |
Creating a new role subsystem | Создание новой роли подсистемы |
Suppose that the current subsystems do not fit the role distribution in the company. You need to create a new subsystem
that includes roles from the | Предположим, что текущие подсистемы не подходят под ролевое распределение в компании и требуется создать новую подсистему,
которая будет включать в себя роли из подсистемы |
To meet this need, create the following role: | Для решения этой задачи создайте следующую роль: |
yaml apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: custom:manage:mycustom:manager labels: rbac.deckhouse.io/use-role: admin rbac.deckhouse.io/kind: manage rbac.deckhouse.io/level: subsystem rbac.deckhouse.io/subsystem: custom rbac.deckhouse.io/aggregate-to-all-as: manager aggregationRule: clusterRoleSelectors:
| yaml apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: custom:manage:mycustom:manager labels: rbac.deckhouse.io/use-role: admin rbac.deckhouse.io/kind: manage rbac.deckhouse.io/level: subsystem rbac.deckhouse.io/subsystem: custom rbac.deckhouse.io/aggregate-to-all-as: manager aggregationRule: clusterRoleSelectors:
|
The labels for the new role listed at the top suggest that: | В начале указаны лейблы для новой роли: |
|
|
yaml rbac.deckhouse.io/use-role: admin | yaml rbac.deckhouse.io/use-role: admin |
|
|
yaml rbac.deckhouse.io/kind: manage | yaml rbac.deckhouse.io/kind: manage |
|
|
yaml rbac.deckhouse.io/level: subsystem |
|
| yaml rbac.deckhouse.io/level: subsystem |
yaml rbac.deckhouse.io/subsystem: custom |
|
| yaml rbac.deckhouse.io/subsystem: custom |
yaml rbac.deckhouse.io/aggregate-to-all-as: manager |
|
Then there are selectors that implement aggregation: | yaml rbac.deckhouse.io/aggregate-to-all-as: manager |
| Далее указаны селекторы, именно они реализуют агрегацию: |
yaml rbac.deckhouse.io/kind: manage rbac.deckhouse.io/aggregate-to-deckhouse-as: manager |
|
| yaml rbac.deckhouse.io/kind: manage rbac.deckhouse.io/aggregate-to-deckhouse-as: manager |
yaml rbac.deckhouse.io/kind: manage module: user-authn |
|
This way, your role will combine permissions of the | yaml rbac.deckhouse.io/kind: manage module: user-authn |
Notes: | Таким образом роль получает права от подсистем |
| Особенности: |
Extending the custom role |
|
Suppose a new cluster CRD object, MySuperResource, has been created in the cluster (a manage role example), and you need to extend the custom role from the example above to include the permissions to interact with this resource. | Расширение пользовательской роли |
First, you have to add a new selector to the role: | Например, в кластере появился новый кластерный (пример для manage-роли) CRD-объект — MySuperResource, и нужно дополнить собственную роль из примера выше правами на взаимодействие с этим ресурсом. |
yaml rbac.deckhouse.io/kind: manage rbac.deckhouse.io/aggregate-to-custom-as: manager | Первым делом нужно дополнить роль новым селектором: |
This selector would enable roles to be aggregated to a new subsystem by specifying this label. After adding the new selector, the role will look as follows: | yaml rbac.deckhouse.io/kind: manage rbac.deckhouse.io/aggregate-to-custom-as: manager |
yaml apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: custom:manage:mycustom:manager labels: rbac.deckhouse.io/use-role: admin rbac.deckhouse.io/kind: manage rbac.deckhouse.io/level: subsystem rbac.deckhouse.io/subsystem: custom rbac.deckhouse.io/aggregate-to-all-as: manager aggregationRule: clusterRoleSelectors:
| Этот селектор позволит агрегировать роли к новой подсистеме через указание этого лейбла. После добавления нового селектора роль будет выглядеть так: |
Next, you need to create a new role and define permissions for the new resource, e. g., the read-only permission: | yaml apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: custom:manage:mycustom:manager labels: rbac.deckhouse.io/use-role: admin rbac.deckhouse.io/kind: manage rbac.deckhouse.io/level: subsystem rbac.deckhouse.io/subsystem: custom rbac.deckhouse.io/aggregate-to-all-as: manager aggregationRule: clusterRoleSelectors:
|
yaml apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: rbac.deckhouse.io/aggregate-to-custom-as: manager rbac.deckhouse.io/kind: manage name: custom:manage:permission:mycustom:superresource:view rules:
| Далее нужно создать новую роль, в которой следует определить права для нового ресурса. Например, только чтение: |
The role will update the subsystem role to include its rights, so that the role bearer will be able to view the new object. | yaml apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: rbac.deckhouse.io/aggregate-to-custom-as: manager rbac.deckhouse.io/kind: manage name: custom:manage:permission:mycustom:superresource:view rules:
|
Notes: | Роль дополнит своими правами роль подсистемы, дав права на просмотр нового объекта. |
| Особенности: |
Extending the existing manage subsystem roles |
|
To extend an existing role, follow the procedure outlined in the section above. Be sure to change the labels and the role name! | Расширение существующих manage subsystem-ролей |
For example, here’s how you can extend the manager role from the | Если необходимо расширить существующую роль, нужно выполнить те же шаги, что и в пункте выше, но изменив лейблы и название роли. |
yaml apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: rbac.deckhouse.io/aggregate-to-deckhouse-as: manager rbac.deckhouse.io/kind: manage name: custom:manage:permission:mycustom:superresource:view rules:
| Пример для расширения роли менеджера из подсистемы |
This way, the new role will extend the | yaml apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: rbac.deckhouse.io/aggregate-to-deckhouse-as: manager rbac.deckhouse.io/kind: manage name: custom:manage:permission:mycustommodule:superresource:view rules:
|
Extending manage subsystem roles and adding a new namespace | Таким образом новая роль расширит роль |
If you need to create a new namespace (to create a use role in it by the hook), you only need to add one label: | Расширение manage subsystem-ролей с добавлением нового пространства имён |
yaml “rbac.deckhouse.io/namespace”: namespace | Если необходимо добавить новое пространство имён (для создания в нём use-роли с помощью хука), потребуется добавить лишь один лейбл: |
This label instructs the hook to create a use role in this namespace: | yaml “rbac.deckhouse.io/namespace”: namespace |
yaml apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: rbac.deckhouse.io/aggregate-to-deckhouse-as: manager rbac.deckhouse.io/kind: manage rbac.deckhouse.io/namespace: namespace name: custom:manage:permission:mycustom:superresource:view rules:
| Этот лейбл сообщает хуку, что в этом пространстве имён нужно создать use-роль: |
The hook monitors | yaml apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: rbac.deckhouse.io/aggregate-to-deckhouse-as: manager rbac.deckhouse.io/kind: manage rbac.deckhouse.io/namespace: namespace name: custom:manage:permission:mycustom:superresource:view rules:
|
Extending the existing use roles | Хук мониторит |
If the resource belongs to a namespace, you need to extend the use role instead of the manage role. The only difference is the labels and the name: | Расширение существующих use-ролей |
yaml apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: rbac.deckhouse.io/aggregate-to-kubernetes-as: user rbac.deckhouse.io/kind: use name: custom:use:capability:mycustom:superresource:view rules:
| Если ресурс принадлежит пространству имён, необходимо расширить use-роль вместо manage-роли. Разница лишь в лейблах и имени: |
This role will be added to the | yaml apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: rbac.deckhouse.io/aggregate-to-kubernetes-as: user rbac.deckhouse.io/kind: use name: custom:use:capability:mycustom:superresource:view rules:
|
Эта роль дополнит роль |