Skip to content

Instantly share code, notes, and snippets.

@zakkg3
Created September 5, 2019 15:45
Show Gist options
  • Save zakkg3/8c4f6b5e015d1229bf0643156b30ecdc to your computer and use it in GitHub Desktop.
Save zakkg3/8c4f6b5e015d1229bf0643156b30ecdc to your computer and use it in GitHub Desktop.
#!/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}')
@alikhanxgrid
Copy link

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment