2.4.6.3. ロールポリシーの例
ロールポリシーを適用して、クラスター内の特定のロールのルールおよびパーミッションを設定します。ロールの詳細は、「ロールベースのアクセス制御」を参照してください。ロールポリシーは以下の YAML ファイルのようになります。
apiVersion: policy.open-cluster-management.io/v1 kind: Policy metadata: name: policy-role namespace: open-cluster-management spec: complianceType: musthave remediationAction: inform namespaces: exclude: ["kube-*"] include: ["default"] role-templates: - apiVersion: open-cluster-management.io/v1/v1alpha1 # role must follow defined permissions metadata: namespace: "" # will be inferred name: operator-role-policy selector: matchLabels: dev: "true" complianceType: musthave # at this level, it means the role must exist with the rules that it must have the following rules: - complianceType: musthave # at this level, it means if the role exists the rule is a musthave policyRule: apiGroups: ["extensions", "apps"] resources: ["deployments"] verbs: ["get", "list", "watch", "create", "delete","patch"] - complianceType: "mustnothave" # at this level, it means if the role exists the rule is a mustnothave policyRule: apiGroups: ["core"] resources: ["secrets"] verbs: ["get", "list", "watch","delete", "create", "update", "patch"] ...
apiVersion: policy.open-cluster-management.io/v1
kind: Policy
metadata:
name: policy-role
namespace: open-cluster-management
spec:
complianceType: musthave
remediationAction: inform
namespaces:
exclude: ["kube-*"]
include: ["default"]
role-templates:
- apiVersion: open-cluster-management.io/v1/v1alpha1 # role must follow defined permissions
metadata:
namespace: "" # will be inferred
name: operator-role-policy
selector:
matchLabels:
dev: "true"
complianceType: musthave # at this level, it means the role must exist with the rules that it must have the following
rules:
- complianceType: musthave # at this level, it means if the role exists the rule is a musthave
policyRule:
apiGroups: ["extensions", "apps"]
resources: ["deployments"]
verbs: ["get", "list", "watch", "create", "delete","patch"]
- complianceType: "mustnothave" # at this level, it means if the role exists the rule is a mustnothave
policyRule:
apiGroups: ["core"]
resources: ["secrets"]
verbs: ["get", "list", "watch","delete", "create", "update", "patch"]
...
詳細は、「 ロールポリシーの管理 」を参照してください。コントローラーが監視するその他の設定ポリシーについては、「 Kubernetes 設定ポリシーコントローラー 」ページを参照してください。Red Hat Advanced Cluster Management RBAC の詳細は、「 ロールベースのアクセス制御 」を参照してください。