Я пытаюсь использовать Python API для kubernetes и не могу выполнить запрос.Я думаю, что конвейер мне не понятен.
Я выполняю следующие шаги: Клиент Python Kubernetes: проблема аутентификации
На удаленном сервере:
- Я настроил свою учетную запись службы и сгенерировал секрет, как описано в ссылке
- Я добавил токен в свой код
Я получаю отказ в соединении.
- Должен ли я импортировать какую-либо информацию из кластера на локального клиента?
- С портом все в порядке?
from kubernetes import client, config
def main():
configuration = client.Configuration()
configuration.host = "http://my_ip:8080"
configuration.api_key_prefix['authorization'] = "Bearer"
configuration.api_key['authorization'] = "my_token"
v1 = client.CoreV1Api()
print("Listing pods with their IPs:")
ret = v1.list_pod_for_all_namespaces(watch=False)
for i in ret.items:
print("%s\t%s\t%s" %
(i.status.pod_ip, i.metadata.namespace, i.metadata.name))
if __name__ == '__main__':
main()
Вывод:
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='xx.xx.xx.xx', port=8080): Max retries exceeded with url: /api/v1/pods?watch=False (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x1118e5668>: Failed to establish a new connection: [Errno 61] Connection refused'
Текущее представление конфигурации локального клиента kubectl:
apiVersion: v1
clusters: []
contexts: []
current-context: ""
kind: Config
preferences: {}
users: []