Copy to ClipboardCopied!Toggle word wrapToggle overflow
たとえば、以下を実行して admin ロールを joe プロジェクトの alice ユーザーに追加できます。
oc adm policy add-role-to-user admin alice -n joe
$oc adm policy add-role-to-user admin alice -n joe
Copy to ClipboardCopied!Toggle word wrapToggle overflow
ヒント
または、以下の YAML を適用してユーザーにロールを追加できます。
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: admin-0
namespace: joe
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: admin
subjects:
- apiGroup: rbac.authorization.k8s.io
kind: User
name: alice
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:name: admin-0namespace: joe
roleRef:apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: admin
subjects:-apiGroup: rbac.authorization.k8s.io
kind: User
name: alice
Copy to ClipboardCopied!Toggle word wrapToggle overflow
出力でローカルロールバインディングを確認し、追加の内容を確認します。
oc describe rolebinding.rbac -n <project>
$oc describe rolebinding.rbac -n<project>
Copy to ClipboardCopied!Toggle word wrapToggle overflow
たとえば、joe プロジェクトのローカルロールバインディングを表示するには、以下を実行します。
oc describe rolebinding.rbac -n joe
$oc describe rolebinding.rbac -n joe
Copy to ClipboardCopied!Toggle word wrapToggle overflow
出力例
Name: admin
Labels: <none>
Annotations: <none>
Role:
Kind: ClusterRole
Name: admin
Subjects:
Kind Name Namespace
---- ---- ---------
User kube:admin
Name: admin-0
Labels: <none>
Annotations: <none>
Role:
Kind: ClusterRole
Name: admin
Subjects:
Kind Name Namespace
---- ---- ---------
User alice
Name: system:deployers
Labels: <none>
Annotations: openshift.io/description:
Allows deploymentconfigs in this namespace to rollout pods in
this namespace. It is auto-managed by a controller; remove
subjects to disa...
Role:
Kind: ClusterRole
Name: system:deployer
Subjects:
Kind Name Namespace
---- ---- ---------
ServiceAccount deployer joe
Name: system:image-builders
Labels: <none>
Annotations: openshift.io/description:
Allows builds in this namespace to push images to this
namespace. It is auto-managed by a controller; remove subjects
to disable.
Role:
Kind: ClusterRole
Name: system:image-builder
Subjects:
Kind Name Namespace
---- ---- ---------
ServiceAccount builder joe
Name: system:image-pullers
Labels: <none>
Annotations: openshift.io/description:
Allows all pods in this namespace to pull images from this
namespace. It is auto-managed by a controller; remove subjects
to disable.
Role:
Kind: ClusterRole
Name: system:image-puller
Subjects:
Kind Name Namespace
---- ---- ---------
Group system:serviceaccounts:joe
Name: admin
Labels: <none>
Annotations: <none>
Role:
Kind: ClusterRole
Name: admin
Subjects:
Kind Name Namespace
---- ---- ---------
User kube:admin
Name: admin-0
Labels: <none>
Annotations: <none>
Role:
Kind: ClusterRole
Name: admin
Subjects:
Kind Name Namespace
---- ---- ---------
User alice
1
Name: system:deployers
Labels: <none>
Annotations: openshift.io/description:
Allows deploymentconfigs in this namespace to rollout pods in
this namespace. It is auto-managed by a controller; remove
subjects to disa...
Role:
Kind: ClusterRole
Name: system:deployer
Subjects:
Kind Name Namespace
---- ---- ---------
ServiceAccount deployer joe
Name: system:image-builders
Labels: <none>
Annotations: openshift.io/description:
Allows builds in this namespace to push images to this
namespace. It is auto-managed by a controller; remove subjects
to disable.
Role:
Kind: ClusterRole
Name: system:image-builder
Subjects:
Kind Name Namespace
---- ---- ---------
ServiceAccount builder joe
Name: system:image-pullers
Labels: <none>
Annotations: openshift.io/description:
Allows all pods in this namespace to pull images from this
namespace. It is auto-managed by a controller; remove subjects
to disable.
Role:
Kind: ClusterRole
Name: system:image-puller
Subjects:
Kind Name Namespace
---- ---- ---------
Group system:serviceaccounts:joe
Copy to ClipboardCopied!Toggle word wrapToggle overflow