-
-
Save edgarsandi/e577893b8ab785ca4e9a0d86fa497baa 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