turbot/kubernetes_compliance

Query: job_container_image_pull_policy_always

Usage

powerpipe query kubernetes_compliance.query.job_container_image_pull_policy_always

Steampipe Tables

SQL

select
coalesce(uid, concat(path, ':', start_line)) as resource,
case
when c ->> 'image' is null
or c ->> 'image' = '' then 'alarm'
when c ->> 'imagePullPolicy' is null
and (
select
(
regexp_matches(c ->> 'image', '(?:[^\s\/]+\/)?([^\s:]+):?([^\s]*)')
) [ 2 ]
) not in ('latest', '') then 'alarm'
when c ->> 'imagePullPolicy' <> 'Always' then 'alarm'
else 'ok'
end as status,
case
when c ->> 'image' is null
or c ->> 'image' = '' then c ->> 'name' || ' no image specified.'
when c ->> 'imagePullPolicy' is null
and (
select
(
regexp_matches(c ->> 'image', '(?:[^\s\/]+\/)?([^\s:]+):?([^\s]*)')
) [ 2 ]
) not in ('latest', '') then c ->> 'name' || ' image pull policy is not specified.'
when c ->> 'imagePullPolicy' <> 'Always' then c ->> 'name' || ' image pull policy is not set to ''Always''.'
else c ->> 'name' || ' image pull policy is set to ''Always''.'
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;

Controls

The query is being used by the following controls: