【Chaos Mesh官方文档】Manage User Permissions

本文介绍了如何在ChaosMesh中管理用户权限,包括创建不同角色的用户账户、绑定权限、管理令牌以及启用或禁用权限认证。ChaosMesh使用Kubernetes的原生RBAC来控制用户角色和权限。用户需要有特定的权限才能创建、查看、更新和删除混沌实验。详细步骤包括选择权限范围、用户角色,生成RBAC配置,并通过kubectl应用配置文件创建用户账户和绑定权限。
摘要由CSDN通过智能技术生成

This document describes how to manage user permissions in Chaos Mesh, including creating user account of different roles, binding permissions for users, managing tokens, and enable or disable permission authentication.

Chaos Mesh uses the native RBAC features in Kubernetes to manage user roles and permissions. To create, view and manage Chaos experiments, users need to have the corresponding permissions in the apiGroups of chaos-mesh.org to customize resources of Chaos experiments.

note

If Chaos Mesh is installed using Helm, permission authentication is enabled by default. For production environments and other scenarios with high security requirements, it is recommended to keep the permission authentication feature enabled. If you just want to give Chaos Mesh a try and quickly create Chaos experiments without enabling the permission authentication feature, you can refer to Enable or disable permission authentication to learn how to disable the feature.

Create user accounts and bind permissions

You can create user accounts and bind permissions directly through the Chaos Mesh Dashboard interface. When you access the Dashboard, a login window pops up. Click the link Click here to generate:

 

After you click the link, another window pops up as follows:

 

The steps to create user accounts and bind permissions are as follows. You need to perform the first three of the following steps in the pop-up window:

  1. Choose the permission scope

    If you want to give the account the appropriate permissions for all Chaos experiments in Kubernetes, check the Cluster scoped box. If you specify a namespace in the Namespace dropdown option box, the account only has permissions in that specified namespace.

  2. Choose the user role

    Currently, Chaos Mesh provides the following user roles:

    • Manager, who has all permissions to create, view, update, and delete Chaos experiments.
    • Viewer, who has only the view permission for Chaos experiments.
  3. Generate RBAC configurations

    After determining the permission scope and user role of the created account, the Dashboard shows the corresponding RBAC configuration on the pop-up window page. For example, the RBAC configurations for a manager account in the namespace default looks like this:

    kind: ServiceAccount
    apiVersion: v1
    metadata:
      namespace: default
      name: account-default-manager-vfmot
    
    ---
    kind: Role
    apiVersion: rbac.authorization.k8s.io/v1
    metadata:
      namespace: default
      name: role-default-manager-vfmot
    rules:
    - apiGroups: [""]
      resources: ["pods", "namespaces"]
      verbs: ["get", "watch", "list"]
    - apiGroups:
      - chaos-mesh.org
      resources: [ "*" ]
      verbs: ["get", "list", "watch", "create", "delete", "patch", "update"]
    
     ---
    apiVersion: rbac.authorization.k8s.io/v1
    kind: RoleBinding
    metadata:
      name: bind-default-manager-vfmot
      namespace: default
    subjects:
    - kind: ServiceAccount
      name: account-default-manager-vfmot
      namespace: default
    roleRef:
      kind: Role
      name: role-default-manager-vfmot
      apiGroup: rbac.authorization.k8s.io
    
  • Click COPY in the upper right corner of the configuration section in the pop-up window to copy the RBAC configuration and then save the content as rbac.yaml locally.

  • Create the user account and bind permissions

    Run the following command in your terminal:

    kubectl apply -f rbac.yaml
    

Generate the token

Copy the command shown in the third step on the Token generator page and run the command in your terminal. The following is an example command:

kubectl describe -n default secrets account-default-manager-vfmot

The output is as follows:

Name:         account-default-manager-vfmot-token-n4tg8
Namespace:    default
Labels:       <none>
Annotations:  kubernetes.io/service-account.name: account-default-manager-vfmot
              kubernetes.io/service-account.uid: b71b3bf4-cd5e-4efb-8bf6-ff9a55fd7e07

Type:  kubernetes.io/service-account-token

Data
====
ca.crt:     1111 bytes
namespace:  7 bytes
token:      eyJhbG...
  1. Copy the token data in the above output and use it for the next step to log in.

  2. Sign in to Chaos Mesh with the user account you have created

    Close the Token generator window and return to the login window. Enter the token that you have got from the previous step in the Token input box and enter a meaningful name for the token in the Name input box. It is recommended to use a name consisting of the permission scope and the user role, such as default-manager. Once you finish filling these two input boxes, click Submit to log in:

note

  • You need to ensure that the local user who executes kubectl has permissions for the cluster so that this user can create user accounts, bind permission for other users, and generate tokens.

  • If you have not deployed Chaos Mesh Dashboard, you can also generate RBAC configurations by yourself, then use kubectl to create user accounts and bind permissions.

Logout Token

If you need to replace a token with another, click the Settings button shown in the left side bar on the Dashboard web page:

On the most top of the page, you can see the Logout button. Click the button to log out the current token.

Enable or disable permission authentication

If Chaos Mesh is installed using Helm, the permission authentication feature is enabled by default.For production environments and other scenarios with high security requirements, it is recommended to keep the permission authentication feature enabled.If you just want to give Chaos Mesh a try and quickly create Chaos experiments with the permission authentication feature disabled, you can set --set dashboard.securityMode=false in a Helm command. The command is as follows:

helm upgrade chaos-mesh chaos-mesh/chaos-mesh --namespace=chaos-testing --version 2.1.5 --set dashboard.securityMode=false

If you want to enable the permission authentication feature again, then reset --set dashboard.securityMode=true in a Helm command.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值