turbot/kubernetes_insights

Query: persistent_volumes_for_pod

Usage

powerpipe query kubernetes_insights.query.persistent_volumes_for_pod

SQL

select
distinct pv.uid as uid
from
kubernetes_pod as p,
jsonb_array_elements(volumes) as v
left join kubernetes_persistent_volume as pv
on v -> 'persistentVolumeClaim' ->> 'claimName' = pv.claim_ref ->> 'name'
where
pv.uid is not null
and v ->> 'name' in
(select
v ->> 'name'
from kubernetes_pod,
jsonb_array_elements(containers) as c,
jsonb_array_elements(c -> 'volumeMounts') as v)
and p.context_name = pv.context_name
and p.uid = $1;