turbot/kubernetes_insights

Query: roles_for_service_account

Usage

powerpipe query kubernetes_insights.query.roles_for_service_account

SQL

select
distinct r.uid as uid
from
kubernetes_service_account as a,
kubernetes_role as r,
kubernetes_role_binding as b,
jsonb_array_elements(subjects) as s
where
b.role_name = r.name
and s ->> 'kind' = 'ServiceAccount'
and s ->> 'name' = a.name
and a.context_name = r.context_name
and a.uid = $1;