73 lines
2.2 KiB
YAML
73 lines
2.2 KiB
YAML
|
|
# 创建 ServiceAccount(放在 apex-evaluation 命名空间)
|
|||
|
|
apiVersion: v1
|
|||
|
|
kind: ServiceAccount
|
|||
|
|
metadata:
|
|||
|
|
name: apex-user
|
|||
|
|
namespace: apex-evaluation # 明确 ServiceAccount 所在的命名空间(必填)
|
|||
|
|
---
|
|||
|
|
# 创建 ServiceAccount(放在 sit 命名空间)
|
|||
|
|
apiVersion: v1
|
|||
|
|
kind: ServiceAccount
|
|||
|
|
metadata:
|
|||
|
|
name: apex-user
|
|||
|
|
namespace: sit # 在 sit 命名空间也创建相同的 ServiceAccount
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
# 为 apex-evaluation 命名空间创建 Role
|
|||
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
|||
|
|
kind: Role
|
|||
|
|
metadata:
|
|||
|
|
name: apex-user-role
|
|||
|
|
namespace: apex-evaluation
|
|||
|
|
rules:
|
|||
|
|
- apiGroups: ["", "apps", "extensions", "batch", "networking.k8s.io"]
|
|||
|
|
resources: ["pods", "pods/log", "pods/exec", "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"]
|
|||
|
|
---
|
|||
|
|
# 为 sit 命名空间创建 Role
|
|||
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
|||
|
|
kind: Role
|
|||
|
|
metadata:
|
|||
|
|
name: apex-user-role
|
|||
|
|
namespace: sit
|
|||
|
|
rules:
|
|||
|
|
- apiGroups: ["", "apps", "extensions", "batch", "networking.k8s.io"]
|
|||
|
|
resources: ["pods", "pods/log", "pods/exec", "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
|
|||
|
|
subjects:
|
|||
|
|
- kind: ServiceAccount
|
|||
|
|
name: apex-user
|
|||
|
|
namespace: apex-evaluation
|
|||
|
|
roleRef:
|
|||
|
|
apiGroup: rbac.authorization.k8s.io
|
|||
|
|
kind: Role
|
|||
|
|
name: apex-user-role
|
|||
|
|
---
|
|||
|
|
# 将 sit 命名空间的 Role 绑定到 ServiceAccount
|
|||
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
|||
|
|
kind: RoleBinding
|
|||
|
|
metadata:
|
|||
|
|
name: apex-user-binding
|
|||
|
|
namespace: sit
|
|||
|
|
subjects:
|
|||
|
|
- kind: ServiceAccount
|
|||
|
|
name: apex-user
|
|||
|
|
namespace: sit
|
|||
|
|
roleRef:
|
|||
|
|
apiGroup: rbac.authorization.k8s.io
|
|||
|
|
kind: Role
|
|||
|
|
name: apex-user-role
|