Skip to main content

Kubernetes Cloud Query

Background

The Run Kubernetes Cloud Query Action performs Steampipe queries on K8s resources with a powerful and simple PostgreSQL syntax.

For example, listing all k8s jobs can be done simply:

select
name,
namespace,
active,
succeeded,
failed,
completions,
start_time,
completion_time,
age(coalesce(completion_time, current_timestamp), start_time) as duration,
active_deadline_seconds,
parallelism,
selector,
labels,
annotations
from
kubernetes_job;

List only the active jobs:

select
name,
namespace,
start_time,
age(coalesce(completion_time, current_timestamp), start_time) as duration,
active,
succeeded,
failed
from
kubernetes_job
where active > 0;

A query to list all container statuses:

select
namespace,
name as pod_name,
phase,
cs ->> 'name' as container_name,
cs ->> 'image' as image,
cs ->> 'ready' as ready,
cs_state as state,
cs ->> 'started' as started,
cs ->> 'restartCount' as restarts
from
kubernetes_pod,
jsonb_array_elements(container_statuses) as cs,
jsonb_object_keys(cs -> 'state') as cs_state
order by
namespace,
name,
container_name;

A full description of all existing tables and official examples are provided here:

info

Blink's supported Steampipe version is: v0.15.0.

Action Parameters

ParameterDescription
SQL statementThe SQL statement we wish to use to query the resource.
Output formatRepresentation of the output result. The possible options are "Table", "CSV" or "JSON".

RunKubernetesCloudQuery