亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Kubernetes 客戶端 python API 錯誤 401 - 未經授權

Kubernetes 客戶端 python API 錯誤 401 - 未經授權

慕碼人8056858 2023-08-22 17:22:05
我正在嘗試創建一個 Python 客戶端來連接并在 AKS 集群上的 pod 中執行命令,但是當嘗試連接時,我從客戶端收到消息錯誤 401 Unauthorized。有人在 API 中遇到過此問題嗎?API異常消息:kubernetes.client.rest.ApiException: (401)Reason: UnauthorizedHTTP response headers: HTTPHeaderDict({'Audit-Id': 'ba23c2b3-d65b-4200-b802-161300119860', 'Cache-Control': 'no-cache, private', 'Content-Type': 'application/json', 'Date': 'Mon, 21 Sep 2020 18:21:59 GMT', 'Content-Length': '129'})HTTP response body: {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"Unauthorized","reason":"Unauthorized","code":401}Python 客戶端 API Kubernetes    from __future__ import print_functionimport timeimport kubernetes.clientimport osfrom kubernetes.stream import streamfrom kubernetes.client.rest import ApiExceptionfrom pprint import pprintname = input("Insira o POD name cadastrado")namespace = input("namespace do POD cadastrado")NomeAtuador = input("Insira o nome do atuador a ser gerado o arquivo de configura??o")configuration = kubernetes.client.Configuration()#configuration.verify_ssl=False#configuration.assert_hostname = Falseconfiguration.api_key_prefix['authorization'] = 'Bearer'configuration.api_key['authorization'] = 'MYTOKEN'configuration.ssl_ca_cert= 'PATH TO CA.CRT'configuration.host = "HOST_IP:443"api_instance = kubernetes.client.CoreV1Api(    kubernetes.client.ApiClient(configuration))exec_command = [            '/etc/openvpn/setup/newClientCert.sh',            (NomeAtuador),             'xxxxxxx']resp = stream(api_instance.connect_post_namespaced_pod_exec(    (name), (namespace), command=exec_command,              stderr=True, stdin=True,              stdout=True, tty=True))print("Response: " + resp)我正在使用Python 3.8.2和Kubernetes
查看完整描述

1 回答

?
人到中年有點甜

TA貢獻1895條經驗 獲得超7個贊

為了解決我的問題,我將以下配置添加到集群配置中。

kubectl create clusterrolebinding serviceaccounts-cluster-admin \   --clusterrole=cluster-admin \   --group=system:serviceaccounts



查看完整回答
反對 回復 2023-08-22
  • 1 回答
  • 0 關注
  • 359 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號