【发布时间】:2020-06-04 21:18:06
【问题描述】:
我想在 google 函数中创建一个 python 脚本 - 删除给定的命名空间,
但是有两个问题 - 函数无法访问全局 kubeconfig 文件 - 我收到没有配置文件的错误
所以:
我创建了配置文件,将其上传到存储桶并尝试从KubeConfig() 的存储桶中使用它
这样:
storage_client = storage.Client()
bucket = storage_client.get_bucket("kyc-tfstate-staging")
blob=bucket.get_blob("storage/config2")
conf = KubeConfig(blob)
print(conf)
我得到了下一个输出:
kubeconfig.kubeconfig.KubeConfig object at 0x7feee1868a58
之后我尝试打印我拥有的所有命名空间:
v1 = kubernetes.client.CoreV1Api()
response = v1.list_namespace()
print(response)
我得到了下一个错误:
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', port=80): Max retries exceeded with url: /api/v1/namespaces (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fe49e098a90>: Failed to establish a new connection: [Errno 111] Connection refused',))
【问题讨论】:
标签: python kubernetes google-cloud-platform google-kubernetes-engine bucket