turbot/gcp_insights

Query: compute_instances_for_kubernetes_cluster

Usage

powerpipe query gcp_insights.query.compute_instances_for_kubernetes_cluster

SQL

select
i.id::text || '/' || i.project as instance_id
from
gcp_kubernetes_node_pool p,
gcp_compute_instance_group g,
gcp_kubernetes_cluster c,
jsonb_array_elements_text(p.instance_group_urls) ig,
jsonb_array_elements(g.instances) g_ins,
gcp_compute_instance i
where
p.cluster_name = c.name
and c.project = p.project
and split_part(ig, 'instanceGroupManagers/', 2) = g.name
and g.project = p.project
and i.self_link = (g_ins ->> 'instance')
and c.id = split_part($1, '/', 1);