kubernetes 获取pod状态

#!/usr/bin/env python
# coding=utf-8
import os
from kubernetes import client, config
config_file='~/.kube/config'
#!/usr/bin/env python
# coding=utf-8
import os
from kubernetes import client, config
config.load_kube_config(config_file=config_file)  # 指定kubeconfig配置文件,config_file: Name of the kube-config file.
apps_api = client.AppsV1Api()  # 资源接口类实例化
i=0
for dp in apps_api.list_deployment_for_all_namespaces().items:
     a='dsp'
     #if (dp.metadata.namespace == a) and (dp.metadata.name == 'dsp-deployment-unit' or dp.metadata.name =='dsp-kernel'):
     #print  dp.status
     if dp.metadata.namespace == a:
       dp_arr=[]
       #print (dp.status.conditions)
       for i in range(len(dp.status.conditions)):
          #print i
          #if  dp.metadata.name

你可能感兴趣的:(kubernetes,进阶,kubernetes)