kubesphere-multi-tenant-management
它能做什么
这个技能帮助 AI 智能体在 KubeSphere 中设置租户,包括用户、工作区、项目和角色绑定。适合在共享集群中管理谁可以访问什么的管理员。
适用场景
- ✓当你需要为 KubeSphere 添加一名拥有基本角色的新用户时。
- ✓当新团队需要一个带有合适成员的工作区或项目时。
- ✓当你想以所需的最低级别授予某人项目访问权限时。
技能链接
https://github.com/kubesphere/kubesphere/blob/master/skills/kubesphere-multi-tenant-management/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请为 Maria 添加一个普通用户,并以普通成员的身份邀请她加入市场部工作区。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会创建或读取用户、工作区或项目,然后绑定对应的内置角色。它从最低访问级别开始,只有在你要求时才会提高权限。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
KubeSphere Multi-Tenant Management
Security Guidelines
Never use kubectl edit/delete - Do NOT use
kubectl edit,kubectl delete, or similar commands to modify or delete workspaces, projects, users, roles, or role bindings. These operations are sensitive and should be performed via KubeSphere Console with proper approval workflow.Never perform delete operations via API - Do NOT delete users, workspaces, projects, roles, or role bindings via API. These operations must be performed manually via KubeSphere Console with proper approval workflow. Only use this skill for creating and querying resources.
Never create custom roles - Do NOT create custom roles (Role, WorkspaceRole, GlobalRole). Only use built-in roles provided by KubeSphere. If custom permissions are needed, instruct the user to configure them via KubeSphere Console.
Default to least privilege - When creating users or assigning permissions, always use the minimum required access level:
- New user creation: default to
platform-regular(not platform-admin) - Inviting user to workspace: default to
<workspace-name>-regular(not admin) - Inviting user to project: default to
viewer(not admin) - Only escalate permissions when explicitly requested
- New user creation: default to
Core Concepts
Workspace
The top-level organizational unit in KubeSphere, representing a team, department, or business unit. A workspace can contain multiple projects and serves as the basic boundary for resource grouping and access control. Workspaces can span multiple clusters, enabling centralized management of resources distributed across different clusters.
Project
KubeSphere's enhanced Kubernetes namespace, representing a specific application, environment, or workload within a workspace. Each project maps to a separate namespace.
User & Role
- User: KubeSphere account entity, can be platform admin, workspace member, or project member
- Role: Permission set defined in KubeSphere's three-tier RBAC:
Project Roles (roles.iam.kubesphere.io):
admin: Full access to all resourcesoperator: Create/update/delete resources, cannot manage rolesviewer: Read-only access
Workspace Roles (WorkspaceRole, workspaceroles.iam.kubesphere.io):
<workspace-name>-admin: Full access to workspace and all projects<workspace-name>-regular: Limited workspace access<workspace-name>-self-provisioner: Create projects in workspace<workspace-name>-viewer: Read-only access to workspace
Platform Roles (GlobalRole, globalroles.iam.kubesphere.io):
platform-admin: Full access to all resourcesplatform-regular: Limited platform accessplatform-self-provisioner: Can create workspaces
Role Binding (KubeSphere API endpoints, binds roles to Users):
- Project-level:
/namespacemembersAPI, bindsroles.iam.kubesphere.ioto User - Workspace-level:
/workspacemembersAPI, bindsworkspaceroles.iam.kubesphere.ioto User - Platform-level:
/users/<username>API, bindsglobalroles.iam.kubesphere.ioto User via annotation
Step-by-Step Guide
Prerequisites
Set up authentication using the provided CLI tool. First, navigate to the scripts directory:
# Navigate to the skill's scripts directory
# Example path (replace with your actual kubesphere-skills location):
cd ~/kubesphere-skills/core/kubesphere-core/scripts
# Install required Python package
pip install requests
# Set host endpoint (optional, defaults to http://ks-apiserver.kubesphere-system)
export KUBESPHERE_HOST="http://<kubesphere-host>"
# Login to get token (token will be cached)
python ks_api.py --login --username admin --password <your-password>
# Token is cached in ~/.kubesphere_token and auto-refreshed
# Optional: Clear cached token
python ks_api.py --clear-cache
1. Create Workspace
Required parameters:
workspace-name: Name for the workspace (maps tometadata.name)manager: Workspace manager (maps tospec.template.spec.manager, default to current login user)creator: Creator name (maps tometadata.annotations["kubesphere.io/creator"])clusters: List of cluster names to host this workspace (maps tospec.placement.clusters)
# Create workspace via Python CLI
python ks_api.py POST /kapis/tenant.kubesphere.io/v1beta1/workspacetemplates '{
"apiVersion": "iam.kubesphere.io/v1beta1",
"kind": "WorkspaceTemplate",
"metadata": {
"name": "<workspace-name>",
"annotation
常见问题
智能体能删除用户或项目吗?
不能。该技能说明删除操作必须在 KubeSphere 控制台中手动完成。
它能创建自定义角色吗?
不能。它只使用内置角色,自定义角色应在控制台中设置。
默认的访问级别是什么?
默认是最低访问级别,例如新用户为普通用户,项目为查看者。
详情
作者的原始描述
KubeSphere multi-tenant management Skill. Use when user requests to create users, workspaces, projects, or assign roles/permissions. Supports user lifecycle management, workspace configuration, project creation, role binding. Do not perform any delete operations, do not create custom roles.
repo: kubesphere/kubesphere
热度
- GitHub 星标
- 17k
- 排名
- #10777
- 许可证
- —
- 更新时间
- 2026/7/14
评论
- …
同一仓库的更多技能
frontend-forge-fe-operations
17k帮你的智能体在 KubeSphere 中管理 FrontendExtension 资源,包括构建、发布和调试。
frontend-forge-fi-operations
17k帮你的智能体在 KubeSphere 中创建、更新、启用、禁用和检查 FrontendIntegration 资源及 frontend-forge 扩展。
frontend-integration-yaml
17k帮你的智能体为一个菜单及其一个或多个页面,创建可直接提交的 FrontendIntegration YAML。
kubeeye
17k帮你的智能体安装 KubeEye,设置集群巡检规则和计划,并阅读巡检报告。