turbot/steampipe-mod-kubernetes-compliance

Control: Job containers Kubernetes dashboard should not be deployed

Description

This check ensures that the container in the Job does not have Kubernetes dashboard deployed.

Usage

Run the control in your terminal:

powerpipe control run kubernetes_compliance.control.job_container_kubernetes_dashboard_not_deployed

Snapshot and share results via Turbot Pipes:

powerpipe login
powerpipe control run kubernetes_compliance.control.job_container_kubernetes_dashboard_not_deployed --share

SQL

This control uses a named query:

select
coalesce(uid, concat(path, ':', start_line)) as resource,
case
when c ->> 'image' is null or c ->> 'image' = '' then 'ok'
when not pg_typeof(c->>'image') = 'text'::regtype then 'alarm'
when c ->> 'image' = 'kubernetes-dashboard'
or c ->> 'image' = 'kubernetesui'
or labels ->> 'apps' = 'kubernetes-dashboard'
or labels ->> 'k8s-app' = 'kubernetes-dashboard' then 'alarm'
else 'ok'
end as status,
case
when c ->> 'image' is null or c ->> 'image' = '' then c ->> 'name' || ' no image specified.'
when not pg_typeof(c->>'image') = 'text'::regtype then c ->> 'name' || ' image invalid.'
when c ->> 'image' = 'kubernetes-dashboard'
or c ->> 'image' = 'kubernetesui'
or labels ->> 'apps' = 'kubernetes-dashboard'
or labels ->> 'k8s-app' = 'kubernetes-dashboard' then c ->> 'name' || ' kubernetes dashboard deployed.'
else c ->> 'name' || ' kubernetes dashboard not deployed.'
end as reason,
name as job_name
, coalesce(context_name, '') as context_name, namespace, source_type, coalesce(path || ':' || start_line || '-' || end_line, '') as path
from
kubernetes_job,
jsonb_array_elements(template -> 'spec' -> 'containers') as c;

Tags