使用ansible获取k8s pod列表



希望使用ansible获取pod列表。下面是我的方法

# tasks file for elasticsearch_secure
- name: Fetch podd deatils
k8s_info:
kind: Pod
field_selectors:
- status.phase=Running
namespace: <ns>
register: pod_list
become: yes
delegate_to: localhost

连接超时

FAILED! => {"changed": false, "msg":
"Failed to get client due to HTTPSConnectionPool(host='<clusterip>', port=6443):
Max retries exceeded with url: /version
(Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x1081d5d00>:
Failed to establish a new connection: [Errno 60] Operation timed out'))"}

还有其他方法可以获得pod的详细信息吗

$ python --version
Python 2.7.16
$ pip3 list | grep openshift
openshift           0.11.2

请把你的建议塞在这里。

我也有同样的问题,这似乎是Python的kubernetes模块的问题:https://github.com/kubernetes-client/python/issues/1333

对我来说有效的是卸载kubernetesopenshift模块,并使用openshift==0.11.2的兼容版本重新安装它们:

# Uninstall kubernetes and openshift
$ pip3 uninstall -y openshift kubernetes
# This command also installs kubernetes
$ pip3 install -Iv openshift==0.11.2
# Installed versions
$ pip3 list | grep -e openshift -e kubernetes
kubernetes                 11.0.0
openshift                  0.11.2

最新更新