是否有一个python API函数从kubernetes statfulsets读取标签?



我试图找到一个API函数来读取kubernetes statefulset中所有标签的键和值。谁能给我一个例子或文档如何做到这一点?

你看过这个库了吗?
https://github.com/kubernetes-client/python

使用上面的库,我要做的是实现你想要的:

from kubernetes import client, config
# Configs can be set in Configuration class directly or using helper utility
config.load_kube_config()
v1 = client.AppsV1Api()
print("Listing StatefulSets' labels:")
ret = v1.list_stateful_set_for_all_namespaces(watch=False)
for i in ret.items:
print(i.metadata.labels)

最新更新