Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/326.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
kubernetes python客户端在使用watch.stream方法运行时挂起_Python_Python 3.x_Kubernetes - Fatal编程技术网

kubernetes python客户端在使用watch.stream方法运行时挂起

kubernetes python客户端在使用watch.stream方法运行时挂起,python,python-3.x,kubernetes,Python,Python 3.x,Kubernetes,我正在尝试使用kubernetes python客户端(版本9.0)观看kubernetes资源类的pods,但几分钟后观看k8s资源时,watch.stream()方法似乎被挂起 v1=client.CoreV1Api() w=手表。手表() 对于w.stream中的资源(v1.list\u namespaced\u pod): 剂量测定(资源) 我怎样才能一直关注kebernetes吊舱呢?您可能正在点击此按钮,如本文所述,您可以尝试以下方法: from kubernetes import

我正在尝试使用kubernetes python客户端(版本9.0)观看kubernetes资源类的pods,但几分钟后观看k8s资源时,watch.stream()方法似乎被挂起

v1=client.CoreV1Api()
w=手表。手表()
对于w.stream中的资源(v1.list\u namespaced\u pod):
剂量测定(资源)

我怎样才能一直关注kebernetes吊舱呢?您可能正在点击此按钮,如本文所述,您可以尝试以下方法:

from kubernetes import client, config, watch
from urllib3.exceptions import ProtocolError
config.load_kube_config()
api_instance = client.CoreV1Api()
while True:
  w = watch.Watch()
  try:
    for event in w.stream(api_instance.list_namespaced_pod, namespace="default"):
      print("Event: %s %s %s" % (event['type'],event['object'].kind, event['object'].metadata.name))
  except ProtocolError:
    print("watchPodEvents ProtocolError, continuing..")

希望有帮助

thx,但是
虽然True
循环不起作用,可能是防火墙切断了连接,我要重新部署kubernetes客户端,防火墙切断了连接