turbot/kubernetes_insights

Query: cronjob_tree

Usage

powerpipe query kubernetes_insights.query.cronjob_tree

SQL

-- This cronjob
select
null as from_id,
uid as id,
name as title,
0 as depth,
'cronjob' as category
from
kubernetes_cronjob
where
uid = $1
-- jobs owned by the cronjob
union all
select
$1 as from_id,
uid as id,
name as title,
1 as depth,
'job' as category
from
kubernetes_job,
jsonb_array_elements(owner_references) as owner
where
owner ->> 'uid' = $1
-- Pods owned by the jobs
union all
select
pod_owner ->> 'uid' as from_id,
pod.uid as id,
pod.name as title,
2 as depth,
'pod' as category
from
kubernetes_job as j,
jsonb_array_elements(j.owner_references) as j_owner,
kubernetes_pod as pod,
jsonb_array_elements(pod.owner_references) as pod_owner
where
j_owner ->> 'uid' = $1
and pod_owner ->> 'uid' = j.uid
-- containers in Pods owned by the jobs
union all
select
pod.uid as from_id,
concat(pod.uid, '_', container ->> 'name') as id,
container ->> 'name' as title,
3 as depth,
'container' as category
from
kubernetes_job as j,
jsonb_array_elements(j.owner_references) as j_owner,
kubernetes_pod as pod,
jsonb_array_elements(pod.owner_references) as pod_owner,
jsonb_array_elements(pod.containers) as container
where
j_owner ->> 'uid' = $1
and pod_owner ->> 'uid' = j.uid

Params

ArgsNameDefaultDescriptionVariable
$1uid

    Dashboards

    The query is used in the dashboards: