#!/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}')