Add k8s status output for 'deploy ps'
This commit is contained in:
parent
16753166c6
commit
ad437b2109
@ -212,8 +212,18 @@ class K8sDeployer(Deployer):
|
|||||||
def ps(self):
|
def ps(self):
|
||||||
self.connect_api()
|
self.connect_api()
|
||||||
# Call whatever API we need to get the running container list
|
# Call whatever API we need to get the running container list
|
||||||
pods = self.core_api.list_pod_for_all_namespaces(watch=False)
|
all_pods = self.core_api.list_pod_for_all_namespaces(watch=False)
|
||||||
|
pods = []
|
||||||
|
|
||||||
|
if all_pods.items:
|
||||||
|
for p in all_pods.items:
|
||||||
|
if self.cluster_info.app_name in p.metadata.name:
|
||||||
|
pods.append(p)
|
||||||
|
|
||||||
|
if not pods:
|
||||||
|
return []
|
||||||
|
|
||||||
|
ret = []
|
||||||
hostname = "?"
|
hostname = "?"
|
||||||
ip = "?"
|
ip = "?"
|
||||||
tls = "?"
|
tls = "?"
|
||||||
@ -235,23 +245,38 @@ class K8sDeployer(Deployer):
|
|||||||
except: # noqa: E722
|
except: # noqa: E722
|
||||||
pass
|
pass
|
||||||
|
|
||||||
print("Hostname:", hostname)
|
print("Ingress:")
|
||||||
print("IP:", ip)
|
print("\tHostname:", hostname)
|
||||||
print("TLS:", tls)
|
print("\tIP:", ip)
|
||||||
|
print("\tTLS:", tls)
|
||||||
print("")
|
print("")
|
||||||
|
print("Pod Status:")
|
||||||
|
|
||||||
ret = []
|
for i in pods:
|
||||||
if pods.items:
|
|
||||||
for i in pods.items:
|
|
||||||
if self.cluster_info.app_name in i.metadata.name:
|
if self.cluster_info.app_name in i.metadata.name:
|
||||||
|
if i.metadata.deletion_timestamp:
|
||||||
|
print(f"\t{i.metadata.name}: Terminating ({i.metadata.deletion_timestamp})")
|
||||||
|
else:
|
||||||
|
print(f"\t{i.metadata.name}: Running ({i.metadata.creation_timestamp})")
|
||||||
|
pod_ip = i.status.pod_ip
|
||||||
|
ports = AttrDict()
|
||||||
|
for c in i.spec.containers:
|
||||||
|
for p in c.ports:
|
||||||
|
ports[str(p.container_port)] = [AttrDict({
|
||||||
|
"HostIp": pod_ip,
|
||||||
|
"HostPort": p.container_port
|
||||||
|
})]
|
||||||
|
|
||||||
ret.append(AttrDict({
|
ret.append(AttrDict({
|
||||||
"id": i.metadata.name,
|
"id": i.metadata.name,
|
||||||
"name": i.metadata.name,
|
"name": i.metadata.name,
|
||||||
"namespace": i.metadata.namespace,
|
"namespace": i.metadata.namespace,
|
||||||
"network_settings": AttrDict({
|
"network_settings": AttrDict({
|
||||||
"ports": {}
|
"ports": ports
|
||||||
})
|
})
|
||||||
}))
|
}))
|
||||||
|
print("")
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def port(self, service, private_port):
|
def port(self, service, private_port):
|
||||||
|
Loading…
Reference in New Issue
Block a user