繁体   English   中英

使用 ansible 获取 k8s pod 列表

[英]Get list of k8s pod using ansible

想要使用 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'))"}

有没有其他方法可以获取 podd 详细信息

$ 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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM