kubernetes – 如何从OpenShift中的pod中获取命名空间?

栏目: 编程工具 · 发布时间: 6年前

内容简介:我想从pod中访问OpenShift和Kubernetes API,以查询和修改pod所属应用程序中的对象.在文档(问题是当我想要访问一个pod时,我需要知道我所在的命名空间:

我想从pod中访问OpenShift和Kubernetes API,以查询和修改pod所属应用程序中的对象.

在文档( https://docs.openshift.org/latest/dev_guide/service_accounts.html )中,我找到了关于如何访问api的描述:

$TOKEN="$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)"

$curl --cacert /var/run/secrets/kubernetes.io/serviceaccount/ca.crt \
"https://openshift.default.svc.cluster.local/oapi/v1/users/~" \
-H "Authorization: Bearer $TOKEN"

问题是当我想要访问一个pod时,我需要知道我所在的命名空间:

HTTPS://openshift.default.svc.cluster.local/oapi/v1/namespaces/${命名空间} /荚

到目前为止,我找到的唯一方法是将命名空间作为环境变量提交,但我不想要求用户输入该信息.


以上所述就是小编给大家介绍的《kubernetes – 如何从OpenShift中的pod中获取命名空间?》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

The Dream Machine

The Dream Machine

M. Mitchell Waldrop / Penguin Books / 2002-8 / USD 16.00

While most people may not be familiar with the name J. C. R. Licklider, he was the guiding spirit behind the greatest revolution of the modern era. At a time when most computers were big, ponderous ma......一起来看看 《The Dream Machine》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

SHA 加密
SHA 加密

SHA 加密工具

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具