Как создать пользователя? | 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 |
Что, если два ClusterAuthorizationRules подходят для одного пользователя? | What if there are two ClusterAuthorizationRules matching to a single user? |
Представьте, что пользователь | 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 |
yaml rbac.deckhouse.io/aggregate-to-all-as: manager | Then there are selectors that implement aggregation: |
Далее указаны селекторы, именно они реализуют агрегацию: |
|
| 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 |
yaml rbac.deckhouse.io/kind: manage module: user-authn | This way, your role will combine permissions of the |
Таким образом роль получает права от подсистем | 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. |
Например, в кластере появился новый кластерный (пример для manage-роли) CRD-объект — MySuperResource, и нужно дополнить собственную роль из примера выше правами на взаимодействие с этим ресурсом. | First, you have to add a new selector to the role: |
Первым делом нужно дополнить роль новым селектором: | yaml rbac.deckhouse.io/kind: manage rbac.deckhouse.io/aggregate-to-custom-as: manager |
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 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:
| 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: labels: rbac.deckhouse.io/aggregate-to-custom-as: manager rbac.deckhouse.io/kind: manage name: custom:manage:permission:mycustom:superresource:view rules:
|
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. |
Роль дополнит своими правами роль подсистемы, дав права на просмотр нового объекта. | Notes: |
Особенности: |
|
| Extending the existing manage subsystem roles |
Расширение существующих manage subsystem-ролей | To extend an existing role, follow the procedure outlined in the section above. Be sure to change the labels and the role name! |
Если необходимо расширить существующую роль, нужно выполнить те же шаги, что и в пункте выше, но изменив лейблы и название роли. | 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:
|
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:
| This way, the new role will extend the |
Таким образом новая роль расширит роль | Extending manage subsystem roles and adding a new namespace |
Расширение manage subsystem-ролей с добавлением нового пространства имён | 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: |
Если необходимо добавить новое пространство имён (для создания в нём use-роли с помощью хука), потребуется добавить лишь один лейбл: | yaml “rbac.deckhouse.io/namespace”: namespace |
yaml “rbac.deckhouse.io/namespace”: namespace | This label instructs the hook to create a use role in this namespace: |
Этот лейбл сообщает хуку, что в этом пространстве имён нужно создать use-роль: | 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:
|
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:
| The hook monitors |
Хук мониторит | Extending the existing use roles |
Расширение существующих use-ролей | 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-роль вместо manage-роли. Разница лишь в лейблах и имени: | 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:
|
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:
| This role will be added to the |
Эта роль дополнит роль |