Skip to main content
NetApp container solutions
简体中文版经机器翻译而成,仅供参考。如与英语版出现任何冲突,应以英语版为准。

配置:集群管理任务

贡献者 banum-netapp kevin-hoke

Red Hat OpenShift 集群管理员执行以下任务:

  1. 以集群管理员身份登录 Red Hat OpenShift 集群。

  2. 创建两个项目,分别对应不同的工程。

oc create namespace project-1
oc create namespace project-2
  1. 为 project-1 创建开发人员角色。

cat << EOF | oc create -f -
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  namespace: project-1
  name: developer-project-1
rules:
  - verbs:
      - '*'
    apiGroups:
      - apps
      - batch
      - autoscaling
      - extensions
      - networking.k8s.io
      - policy
      - apps.openshift.io
      - build.openshift.io
      - image.openshift.io
      - ingress.operator.openshift.io
      - route.openshift.io
      - snapshot.storage.k8s.io
      - template.openshift.io
    resources:
      - '*'
  - verbs:
      - '*'
    apiGroups:
      - ''
    resources:
      - bindings
      - configmaps
      - endpoints
      - events
      - persistentvolumeclaims
      - pods
      - pods/log
      - pods/attach
      - podtemplates
      - replicationcontrollers
      - services
      - limitranges
      - namespaces
      - componentstatuses
      - nodes
  - verbs:
      - '*'
    apiGroups:
      - trident.netapp.io
    resources:
      - tridentsnapshots
EOF
备注 本节提供的角色定义仅仅是一个示例。必须根据最终用户的要求来定义开发人员的角色。
  1. 同样,为 project-2 创建开发人员角色。

  2. 所有 OpenShift 和NetApp存储资源通常由存储管理员管理。存储管理员的访问权限由安装Trident时创建的 trident 操作员角色控制。除此之外,存储管理员还需要访问 ResourceQuotas 来控制存储的消耗方式。

  3. 创建一个用于管理集群中所有项目的 ResourceQuotas 的角色,并将其附加到存储管理员。

cat << EOF | oc create -f -
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: resource-quotas-role
rules:
  - verbs:
      - '*'
    apiGroups:
      - ''
    resources:
      - resourcequotas
  - verbs:
      - '*'
    apiGroups:
      - quota.openshift.io
    resources:
      - '*'
EOF
  1. 确保集群与组织的身份提供者集成,并且用户组与集群组同步。以下示例显示身份提供者已与集群集成并与用户组同步。

$ oc get groups
NAME                        USERS
ocp-netapp-storage-admins   ocp-netapp-storage-admin
ocp-project-1               ocp-project-1-user
ocp-project-2               ocp-project-2-user
  1. 为存储管理员配置 ClusterRoleBindings。

cat << EOF | oc create -f -
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: netapp-storage-admin-trident-operator
subjects:
  - kind: Group
    apiGroup: rbac.authorization.k8s.io
    name: ocp-netapp-storage-admins
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: trident-operator
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: netapp-storage-admin-resource-quotas-cr
subjects:
  - kind: Group
    apiGroup: rbac.authorization.k8s.io
    name: ocp-netapp-storage-admins
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: resource-quotas-role
EOF
备注 对于存储管理员,必须绑定两个角色:trident-operator 和 resource-quotas。
  1. 为开发者创建 RoleBindings,将developer-project-1 角色绑定到 project-1 中对应的组(ocp-project-1)。

cat << EOF | oc create -f -
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: project-1-developer
  namespace: project-1
subjects:
  - kind: Group
    apiGroup: rbac.authorization.k8s.io
    name: ocp-project-1
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: developer-project-1
EOF
  1. 同样的,在project-2中为开发者创建RoleBindings,将开发者角色绑定到对应的用户组。