Created
September 5, 2019 15:45
-
-
Save zakkg3/8c4f6b5e015d1229bf0643156b30ecdc to your computer and use it in GitHub Desktop.
This file contains 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/local/bin/python3 | |
from kubernetes import client, config | |
import sys | |
config.load_kube_config() | |
def print_help(): | |
print('I need the namespace(s) as an argument') | |
if len(sys.argv) <= 1: | |
print (f'bad arguments: {str(sys.argv[1:])}') | |
print_help() | |
exit(1) | |
namespaces = sys.argv[1:] | |
v1 = client.CoreV1Api() | |
print ('Pods with Persistant Volume Cliams | namespace | pod | pvc') | |
for n in namespaces: | |
ret = v1.list_namespaced_pod(n,watch=False) | |
for i in ret.items: | |
for v in i.spec.volumes: | |
if v.persistent_volume_claim: | |
print (f'{n} | {i.metadata.name} | {v.persistent_volume_claim.claim_name}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks