Я предполагаю, что у вас есть файл kubeconfig
под ~/.kube/config
from kubernetes import client, config
from kubernetes.client.rest import ApiException
from pprint import pprint
config.load_kube_config()
v1 = client.CoreV1Api()
namespace = 'default'
try:
api_response = v1.list_namespaced_pod(namespace)
pprint(api_response.items[0].metadata.creation_timestamp)
except ApiException as e:
print("Exception when calling CoreV1Api->list_namespaced_pod: %s\n" % e)
Он возвращает tzut c, который вам нужно будет проанализировать.
$ python3 get_pods.py
datetime.datetime(2020, 5, 25, 16, 2, 39, tzinfo=tzutc())