问题描述
我需要使用 Python 将一些东西部署到 Openshift 集群(我已经被任何其他解决方案抢占了先机),所以我正在尝试使用 kubernetes
模块:
from kubernetes import client,config
configuration = client.Configuration()
configuration.username='admin'
configuration.password='redacted'
configuration.host='https://api.cluster.example.com:6443'
configuration.verify_ssl = False
v1 = client.CoreV1Api(client.apiclient(configuration))
ns = {}
ns['kind'] = 'Namespace'
ns['apiVersion'] = 'v1'
ns['Metadata'] = {}
ns['Metadata']['name'] = 'mynamespace'
v1.create_namespace(ns)
遗憾的是,v1 对象没有使用我提供的用户名/密码向集群进行身份验证:
kubernetes.client.rest.ApiException: (403)
Reason: Forbidden
HTTP response headers: HTTPHeaderDict({'Audit-Id': 'd59bb32d-a114-4b42-90ca-86c6315809d0',Cache-Control': 'no-cache,private','Content-Type': 'application/json','X-Content-Type-ptions': 'nosniff','X-Kubernetes-Pf-Flowschema-Uid': '58a1456a-ff43-47a6-9a08-4a682ad5a509',X-Kubernetes-Pf-Prioritylevel-Uid': 'efbe11a3-861b-46ec-8e4a-1eadb766e284','Date': 'Thu,21 Jan 2021 19:17:31 GMT','Content-Length': '273'})
HTTP response body: {"kind":"Status","apiVersion":"v1","Metadata":{},"status":"Failure","message":"namespaces is forbidden: User \"system:anonymous\" cannot create resource \"namespaces\" in API group \"\" at the cluster scope","reason":"Forbidden","details":{"kind":"namespaces"},"code":403}
我正在寻找一种在 OCP 集群上抛出配置 YAML 并让它坚持下去的方法...
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)