turbot/kubernetes_compliance

Query: statefulset_container_argument_event_qps_less_than_5

Usage

powerpipe query kubernetes_compliance.query.statefulset_container_argument_event_qps_less_than_5

Steampipe Tables

SQL

with container_list as (
select
c ->> 'name' as container_name,
trim('"' from split_part(co::text, '=', 2))::integer as value
from
kubernetes_stateful_set as p,
jsonb_array_elements(template -> 'spec' -> 'containers') as c,
jsonb_array_elements(c -> 'command') as co
where
(co)::text LIKE '%event-qps=%'
)
select
coalesce(uid, concat(path, ':', start_line)) as resource,
case
when (c -> 'command') is null or not ((c -> 'command') @> '["kubelet"]') then 'ok'
when l.container_name is null then 'ok'
when l.container_name is not null and (c -> 'command') @> '["kubelet"]' and coalesce((l.value)::int, 0) > 5 then 'alarm'
else 'ok'
end as status,
case
when (c -> 'command') is null then c ->> 'name' || ' command not defined.'
when not ((c -> 'command') @> '["kubelet"]') then c ->> 'name' || ' kubelet not defined.'
when l.container_name is null then c ->> 'name' || ' event-qps is not set.'
else c ->> 'name' || ' event-qps is set to ' || l.value || '.'
end as reason,
name as stateful_set_name
, coalesce(context_name, '') as context_name, namespace, source_type, coalesce(path || ':' || start_line || '-' || end_line, '') as path
from
kubernetes_stateful_set,
jsonb_array_elements(template -> 'spec' -> 'containers') as c
left join container_list as l on c ->> 'name' = l.container_name;

Controls

The query is being used by the following controls: