Control: Deployment containers argument event qps should be less than 5
Description
This check ensures that the container in the Deployment has argument event qps set to less than 5.
Usage
Run the control in your terminal:
powerpipe control run kubernetes_compliance.control.deployment_container_argument_event_qps_less_than_5
Snapshot and share results via Turbot Pipes:
powerpipe loginpowerpipe control run kubernetes_compliance.control.deployment_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_deployment, 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 deployment_name , coalesce(context_name, '') as context_name, namespace, source_type, coalesce(path || ':' || start_line || '-' || end_line, '') as pathfrom kubernetes_deployment, jsonb_array_elements(template -> 'spec' -> 'containers') as c left join container_list as l on c ->> 'name' = l.container_name;