云容器引擎 CCE-命名空间权限(Kubernetes RBAC授权):示例:授予集群管理员权限(cluster-admin)

时间:2024-05-31 08:37:53

示例:授予集群管理员权限(cluster-admin)

集群全部权限可以使用cluster-admin权限,cluster-admin包含集群所有资源的权限。

图5 授予集群管理员权限(cluster-admin)

如果使用kubectl查看可以看到创建了一个ClusterRoleBinding,将cluster-admin和cce-role-group这个用户组绑定了起来。

# kubectl get clusterrolebinding
NAME                                                              ROLE                           AGE
clusterrole_cluster-admin_group0c96fad22880f32a3f84c009862af6f7   ClusterRole/cluster-admin      61s

# kubectl get clusterrolebinding clusterrole_cluster-admin_group0c96fad22880f32a3f84c009862af6f7 -oyaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  annotations:
    CCE.com/ IAM : "true"
  creationTimestamp: "2021-06-23T09:15:22Z"
  name: clusterrole_cluster-admin_group0c96fad22880f32a3f84c009862af6f7
  resourceVersion: "36659058"
  selfLink: /apis/rbac.authorization.k8s.io/v1/clusterrolebindings/clusterrole_cluster-admin_group0c96fad22880f32a3f84c009862af6f7
  uid: d6cd43e9-b4ca-4b56-bc52-e36346fc1320
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
- apiGroup: rbac.authorization.k8s.io
  kind: Group
  name: 0c96fad22880f32a3f84c009862af6f7

使用被授予用户连接集群,如果能正常查询PV、StorageClass的信息,则说明权限配置正常。

# kubectl get pv
No resources found
# kubectl get sc
NAME                PROVISIONER                     RECLAIMPOLICY   VOLUMEBINDINGMODE      ALLOWVOLUMEEXPANSION   AGE
csi-disk            everest-csi-provisioner         Delete          Immediate              true                   75d
csi-disk-topology   everest-csi-provisioner         Delete          WaitForFirstConsumer   true                   75d
csi-nas             everest-csi-provisioner         Delete          Immediate              true                   75d
csi-obs             everest-csi-provisioner         Delete          Immediate              false                  75d
csi-sfsturbo        everest-csi-provisioner         Delete          Immediate              true                   75d
support.huaweicloud.com/usermanual-cce/cce_10_0189.html