turbot/steampipe-mod-kubernetes-compliance

Control: Replication Controller containers argument event qps should be less than 5

Description

This check ensures that the container in the Replication Controller has argument event qps set to less than 5.

Usage

Run the control in your terminal:

powerpipe control run kubernetes_compliance.control.replication_controller_container_argument_event_qps_less_than_5

Snapshot and share results via Turbot Pipes:

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

SQL

This control uses a named query:

with container_list as (
select
c ->> 'name' as container_name,
trim('"' from split_part(co::text, '=', 2))::integer as value
from
kubernetes_replication_controller 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 replication_controller_name
, coalesce(context_name, '') as context_name, namespace, source_type, coalesce(path || ':' || start_line || '-' || end_line, '') as path
from
kubernetes_replication_controller,
jsonb_array_elements(template -> 'spec' -> 'containers') as c
left join container_list as l on c ->> 'name' = l.container_name;

Tags