(self, pod_list)
return pod_tags_by_pvc
Return a map, e.g.
            {
                "<kube_namespace>/<persistentvolumeclaim>": [<list_of_pod_tags>],
                "<kube_namespace1>/<persistentvolumeclaim1>": [<list_of_pod_tags1>],
            }
        that can be used to add pod tags to associated volume metrics
Return a map, e.g.
            {
                "<kube_namespace>/<persistentvolumeclaim>": [<list_of_pod_tags>],
                "<kube_namespace1>/<persistentvolumeclaim1>": [<list_of_pod_tags1>],
            }
        that can be used to add pod tags to associated volume metrics
Return a map e . g . { <kube_namespace > / <persistentvolumeclaim > : [ <list_of_pod_tags > ] <kube_namespace1 > / <persistentvolumeclaim1 > : [ <list_of_pod_tags1 > ] } that can be used to add pod tags to associated volume metrics
def _create_pod_tags_by_pvc(self, pod_list):
        """
        Return a map, e.g.
            {
                "<kube_namespace>/<persistentvolumeclaim>": [<list_of_pod_tags>],
                "<kube_namespace1>/<persistentvolumeclaim1>": [<list_of_pod_tags1>],
            }
        that can be used to add pod tags to associated volume metrics
        """
        pod_tags_by_pvc = defaultdict(set)
        pods = pod_list.get('items', [])
        for pod in pods:
            # get kubernetes namespace of PVC
            kube_ns = pod.get('metadata', {}).get('namespace')
            if not kube_ns:
                continue

            # get volumes
            volumes = pod.get('spec', {}).get('volumes')
            if not volumes:
                continue

            # get pod id
            pod_id = pod.get('metadata', {}).get('uid')
            if not pod_id:
                self.log.debug('skipping pod with no uid')
                continue

            # get tags from tagger
            tags = tagger.tag('kubernetes_pod_uid://%s' % pod_id, tagger.ORCHESTRATOR) or None
            if not tags:
                continue

            # remove tags that don't apply to PVCs
            for excluded_tag in self.VOLUME_TAG_KEYS_TO_EXCLUDE:
                tags = [t for t in tags if not t.startswith(excluded_tag + ':')]

            # get PVC
            for v in volumes:
                pvc_name = v.get('persistentVolumeClaim', {}).get('claimName')
                if pvc_name:
                    pod_tags_by_pvc['{}/{}'.format(kube_ns, pvc_name)].update(tags)

        return pod_tags_by_pvc
def _create_pod_tags_by_pvc ( self , pod_list ) : pod_tags_by_pvc = defaultdict ( set ) pods = pod_list . get ( 'items' , [ ] ) for pod in pods : # get kubernetes namespace of PVC kube_ns = pod . get ( 'metadata' , { } ) . get ( 'namespace' ) if not kube_ns : continue # get volumes volumes = pod . get ( 'spec' , { } ) . get ( 'volumes' ) if not volumes : continue # get pod id pod_id = pod . get ( 'metadata' , { } ) . get ( 'uid' ) if not pod_id : self . log . debug ( 'skipping pod with no uid' ) continue # get tags from tagger tags = tagger . tag ( 'kubernetes_pod_uid://%s' % pod_id , tagger . ORCHESTRATOR ) or None if not tags : continue # remove tags that don't apply to PVCs for excluded_tag in self . VOLUME_TAG_KEYS_TO_EXCLUDE : tags = [ t for t in tags if not t . startswith ( excluded_tag + ':' ) ] # get PVC for v in volumes : pvc_name = v . get ( 'persistentVolumeClaim' , { } ) . get ( 'claimName' ) if pvc_name : pod_tags_by_pvc [ '{}/{}' . format ( kube_ns , pvc_name ) ] . update ( tags ) return pod_tags_by_pvc