Files
jenkins-pipeline/k8s_yaml/config/apex-user/apex-user-rbac.yaml
2025-11-20 14:51:44 +08:00

37 lines
1.3 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 创建 ServiceAccount放在命名空间
apiVersion: v1
kind: ServiceAccount
metadata:
name: apex-user
namespace: apex-evaluation # 明确 ServiceAccount 所在的命名空间(必填)
---
# 为 apex-evaluation 命名空间创建 Role仅允许操作 apex-evaluation 下的资源)
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: apex-user-role # Role 名称
namespace: apex-evaluation # 绑定到 apex-evaluation 命名空间
rules:
- apiGroups: ["", "apps", "extensions", "batch", "networking.k8s.io"]
resources: ["pods", "pods/log", "statefulsets", "deployments", daemonsets, "services", "configmaps", "secrets", "events", "replicasets"]
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
- apiGroups: ["metrics.k8s.io"]
resources: ["pods","nodes"]
verbs: ["get","list","watch"]
---
# 将 apex-evaluation 命名空间的 Role 绑定到 ServiceAccount
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: apex-user-binding
namespace: apex-evaluation # 与 Role 同命名空间
subjects:
- kind: ServiceAccount
name: apex-user
namespace: apex-evaluation # 注意:这里是 SA 所在的命名空间
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: apex-user-role # 绑定的 Role 名称,与上方 Role 一致