HsinCC987 2025-03-26 09:00 采纳率: 17.6%
浏览 7

KubeSphere 如何新增 workspace 預設角色

KubeSphere Workspace 預設了四個角色,我想要新增一個我自己創的角色應用讓他變成 global 的,當我新增一個 workspace 時,這個角色就已經被寫入了(不需要每次都為單一 workspace 新增角色),請問我該怎麼做

  • 写回答

5条回答 默认 最新

  • 阿里嘎多学长 2025-03-26 09:00
    关注

    阿里嘎多学长整理AIGC生成,因移动端显示问题导致当前答案未能完全显示,请使用PC端查看更加详细的解答过程

    KubeSphere 如何新增 workspace 預設角色

    KubeSphere 提供了四個預設角色:admin、editor、viewer 和 auditor。要新增一個自定義的角色,可以使用 KubeSphere 的 Role-Based Access Control (RBAC) 功能。

    以下是步驟:

    1. 創建一個新的 Role:
    apiVersion: rbac.kubesphere.io/v1alpha1
    kind: Role
    metadata:
      name: my-new-role
      namespace: default
    rules:
      - apiGroups:
          - ""
        resources:
          - pods
        verbs:
          - get
          - list
    

    這個 Role 只允許訪問 pods 的 get 和 list 動作。

    1. 創建一個新的 ClusterRoleBinding:
    apiVersion: rbac.kubesphere.io/v1alpha1
    kind: ClusterRoleBinding
    metadata:
      name: my-new-role-binding
    roleRef:
      name: my-new-role
      kind: Role
    subjects:
      - kind: User
        name: <your-username>
        namespace: default
    

    這個 ClusterRoleBinding 將 my-new-role Role 绑定到你的 User 身份上。

    1. 將新的 Role 和 ClusterRoleBinding 部署到 KubeSphere:
    kubectl apply -f role.yaml
    kubectl apply -f clusterrolebinding.yaml
    
    1. 在創建新的 Workspace 時,KubeSphere 會自動將 my-new-role Role 則入到 Workspace 中。

    注意:這個步驟假設你已經有了 KubeSphere 的 ClusterAdmin 權限。如果你沒有這個權限,需要與 KubeSphere 的管理員聯繫以獲取適當的權限。

    希望這個解答能夠幫助你!

    评论

报告相同问题?

问题事件

  • 创建了问题 3月26日