Jeff Saremi
Jeff Saremi

Reputation: 3014

OpenShift: Add SCC to Service Account in Yaml

Is there an equivalent for the following command in yaml? Using OpenShift 4.2 currently

oc adm policy add-scc-to-user <scc_name> <user_name>

Upvotes: 1

Views: 1987

Answers (2)

Gas
Gas

Reputation: 18030

This command creates rol ebinding (if you omit namespace it creates cluster role binding) :

$ oc adm policy add-scc-to-user anyuid -z default -n your-namespace
clusterrole.rbac.authorization.k8s.io/system:openshift:scc:anyuid added: "default"

You can do this by using the similar yaml
(this one is for default serviceAccount and anyuid scc, but should be similar for others):

kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: 'system:openshift:scc:anyuid'
  namespace: <your-namespace>
subjects:
  - kind: ServiceAccount
    name: default
    namespace: <your-namespace>
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: 'system:openshift:scc:anyuid'

Upvotes: 1

Oligzeev
Oligzeev

Reputation: 511

There's example of SCC. You have to add element to 'users' list, so you can export the SCC and re-apply modifyed object.

Upvotes: 1

Related Questions