Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Openshift: how to edit scc non-interactively?

I am experimenting with openshift/minishift, I find myself having to run:

oc edit scc privileged

and add:

- system:serviceaccount:default:router

So I can expose the pods. Is there a way to do it in a script?

I know oc adm have some command for policy manipulation but I can't figure out how to add this line.

like image 860
Tiago Lopo Avatar asked Sep 01 '25 02:09

Tiago Lopo


1 Answers

You can achieve it using oc patch command and with type json. The snippet below will add a new item to array before 0th element. You can try it out with a fake "bla" value etc.

oc patch scc privileged --type=json -p '[{"op": "add", "path": "/users/0", "value":"system:serviceaccount:default:router"}]'

The --type=json will interpret the provided patch as jsonpatch operation. Unfortunately oc patch --help doesn't provide any example for json patch type. Luckily example usage can be found in kubernetes docs: kubectl patch

like image 107
Bartosz Bierkowski Avatar answered Sep 02 '25 23:09

Bartosz Bierkowski