OpenShift:如何非交互式编辑SCC? [英] Openshift: how to edit scc non-interactively?

查看:104
本文介绍了OpenShift:如何非交互式编辑SCC?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试openshift/minishift,发现自己必须跑步:

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

oc edit scc privileged

并添加:

- system:serviceaccount:default:router

所以我可以露出豆荚.有没有办法在脚本中做到这一点?

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

我知道oc adm有一些用于策略操纵的命令,但我不知道如何添加此行.

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

推荐答案

您可以使用oc patch命令并使用json类型来实现.下面的代码段将在第0个元素之前向数组添加一个新项目.您可以使用伪造的"bla"值等进行尝试.

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"}]'

--type=json会将提供的补丁解释为 jsonpatch 操作.不幸的是,oc patch --help没有提供有关json补丁类型的任何示例.幸运的是,可以在kubernetes文档中找到示例用法: kubectl补丁

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

这篇关于OpenShift:如何非交互式编辑SCC?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆