Created
January 10, 2018 02:22
-
-
Save srkiNZ84/3c8412067840df5b08c28a47f2d6fb77 to your computer and use it in GitHub Desktop.
Python script to list Kubernetes deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
from kubernetes import client, config | |
# Configs can be set in Configuration class directly or using helper utility | |
config.load_kube_config(context="foobar") | |
#v1 = client.CoreV1Api() | |
v1 = client.AppsV1beta1Api() | |
print("Listing deployments with their IPs:") | |
ret = v1.list_deployment_for_all_namespaces(watch=False) | |
for i in ret.items: | |
print("\n%s\n" % (i.spec.template.spec.containers[0].image)) | |
print("%s\t%s\t%s\t%s" % (i.status, i.metadata.namespace,\ | |
i.metadata.name, i.metadata.labels.get('version',"None"))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment