Table: k8s_apps_daemon_sets

This table shows data for Kubernetes (K8s) Apps Daemon Sets.

The primary key for this table is uid.

Columns

NameType
_cq_iduuid
_cq_parent_iduuid
contextutf8
kindutf8
api_versionutf8
nameutf8
namespaceutf8
uid (PK)utf8
resource_versionutf8
generationint64
deletion_grace_period_secondsint64
labelsjson
annotationsjson
owner_referencesjson
finalizerslist<item: utf8, nullable>
spec_selectorjson
spec_templatejson
spec_update_strategyjson
spec_min_ready_secondsint64
spec_revision_history_limitint64
status_current_number_scheduledint64
status_number_misscheduledint64
status_desired_number_scheduledint64
status_number_readyint64
status_observed_generationint64
status_updated_number_scheduledint64
status_number_availableint64
status_number_unavailableint64
status_collision_countint64
status_conditionsjson

Example Queries

These SQL queries are sampled from CloudQuery policies and are compatible with PostgreSQL.

Daemonset enforces cpu limits

-- Join every row in the daemonset table with its json array of containers.
WITH
  daemonset_containers
    AS (
      SELECT
        uid, value AS container
      FROM
        k8s_apps_daemon_sets
        CROSS JOIN jsonb_array_elements(spec_template->'spec'->'containers')
            AS value
    )
SELECT
  uid AS resource_id,
  'Daemonset enforces cpu limits' AS title,
  context AS context,
  namespace AS namespace,
  name AS resource_name,
  CASE
  WHEN (
    SELECT
      count(*)
    FROM
      daemonset_containers
    WHERE
      daemonset_containers.uid = k8s_apps_daemon_sets.uid
      AND (
          daemonset_containers.container->'resources'->'limits'->>'cpu'
        ) IS NULL
  )
  > 0
  THEN 'fail'
  ELSE 'pass'
  END
    AS status
FROM
  k8s_apps_daemon_sets;

Daemonset enforces cpu requests

-- Join every row in the daemonset table with its json array of containers.
WITH
  daemonset_containers
    AS (
      SELECT
        uid, value AS container
      FROM
        k8s_apps_daemon_sets
        CROSS JOIN jsonb_array_elements(spec_template->'spec'->'containers')
            AS value
    )
SELECT
  uid AS resource_id,
  'Daemonset enforces cpu requests' AS title,
  context AS context,
  namespace AS namespace,
  name AS resource_name,
  CASE
  WHEN (
    SELECT
      count(*)
    FROM
      daemonset_containers
    WHERE
      daemonset_containers.uid = k8s_apps_daemon_sets.uid
      AND (
          daemonset_containers.container->'resources'->'requests'->>'cpu'
        ) IS NULL
  )
  > 0
  THEN 'fail'
  ELSE 'pass'
  END
    AS status
FROM
  k8s_apps_daemon_sets;

Daemonset enforces memory limits

-- Join every row in the daemonset table with its json array of containers.
WITH
  daemonset_containers
    AS (
      SELECT
        uid, value AS container
      FROM
        k8s_apps_daemon_sets
        CROSS JOIN jsonb_array_elements(spec_template->'spec'->'containers')
            AS value
    )
SELECT
  uid AS resource_id,
  'Daemonset enforces memory limits' AS title,
  context AS context,
  namespace AS namespace,
  name AS resource_name,
  CASE
  WHEN (
    SELECT
      count(*)
    FROM
      daemonset_containers
    WHERE
      daemonset_containers.uid = k8s_apps_daemon_sets.uid
      AND (
          daemonset_containers.container->'resources'->'limits'->>'memory'
        ) IS NULL
  )
  > 0
  THEN 'fail'
  ELSE 'pass'
  END
    AS status
FROM
  k8s_apps_daemon_sets;

Daemonset enforces memory requests

-- Join every row in the daemonset table with its json array of containers.
WITH
  daemonset_containers
    AS (
      SELECT
        uid, value AS container
      FROM
        k8s_apps_daemon_sets
        CROSS JOIN jsonb_array_elements(spec_template->'spec'->'containers')
            AS value
    )
SELECT
  uid AS resource_id,
  'Daemonset enforces memory requests' AS title,
  context AS context,
  namespace AS namespace,
  name AS resource_name,
  CASE
  WHEN (
    SELECT
      count(*)
    FROM
      daemonset_containers
    WHERE
      daemonset_containers.uid = k8s_apps_daemon_sets.uid
      AND (
          daemonset_containers.container->'resources'->'requests'->>'memory'
        ) IS NULL
  )
  > 0
  THEN 'fail'
  ELSE 'pass'
  END
    AS status
FROM
  k8s_apps_daemon_sets;

DaemonSet containers privileges disabled

WITH
  daemonset_containers
    AS (
      SELECT
        uid, value AS container
      FROM
        k8s_apps_daemon_sets
        CROSS JOIN jsonb_array_elements(spec_template->'spec'->'containers')
            AS value
    )
SELECT
  uid AS resource_id,
  'DaemonSet containers privileges disabled' AS title,
  context AS context,
  namespace AS namespace,
  name AS resource_name,
  CASE
  WHEN (
    SELECT
      count(*)
    FROM
      daemonset_containers
    WHERE
      daemonset_containers.uid = k8s_apps_daemon_sets.uid
      AND daemonset_containers.container->'securityContext'->>'privileged'
        = 'true'
  )
  > 0
  THEN 'fail'
  ELSE 'pass'
  END
    AS status
FROM
  k8s_apps_daemon_sets;

DaemonSet containers privilege escalation disabled

WITH
  daemonset_containers
    AS (
      SELECT
        uid, value AS container
      FROM
        k8s_apps_daemon_sets
        CROSS JOIN jsonb_array_elements(spec_template->'spec'->'containers')
            AS value
    )
SELECT
  uid AS resource_id,
  'DaemonSet containers privilege escalation disabled' AS title,
  context AS context,
  namespace AS namespace,
  name AS resource_name,
  CASE
  WHEN (
    SELECT
      count(*)
    FROM
      daemonset_containers
    WHERE
      daemonset_containers.uid = k8s_apps_daemon_sets.uid
      AND daemonset_containers.container->'securityContext'->>'allowPrivilegeEscalation'
        = 'true'
  )
  > 0
  THEN 'fail'
  ELSE 'pass'
  END
    AS status
FROM
  k8s_apps_daemon_sets;

Deamonset container hostNetwork disabled

SELECT
  uid AS resource_id,
  'Deamonset container hostNetwork disabled' AS title,
  context AS context,
  namespace AS namespace,
  name AS resource_name,
  CASE
  WHEN spec_template->'spec'->>'hostNetwork' = 'true' THEN 'fail'
  ELSE 'pass'
  END
    AS status
FROM
  k8s_apps_daemon_sets;

Deamonset containers HostPID and HostIPC sharing disabled

SELECT
  uid AS resource_id,
  'Deamonset containers HostPID and HostIPC sharing disabled' AS title,
  context AS context,
  namespace AS namespace,
  name AS resource_name,
  CASE
  WHEN spec_template->'spec'->>'hostPID' = 'true'
  OR spec_template->'spec'->>'hostIPC' = 'true'
  THEN 'fail'
  ELSE 'pass'
  END
    AS status
FROM
  k8s_apps_daemon_sets;

DeamonSet containers root file system is read-only

WITH
  daemonset_containers
    AS (
      SELECT
        uid, value AS container
      FROM
        k8s_apps_daemon_sets
        CROSS JOIN jsonb_array_elements(spec_template->'spec'->'containers')
            AS value
    )
SELECT
  uid AS resource_id,
  'DeamonSet containers root file system is read-only' AS title,
  context AS context,
  namespace AS namespace,
  name AS resource_name,
  CASE
  WHEN (
    SELECT
      count(*)
    FROM
      daemonset_containers
    WHERE
      daemonset_containers.uid = k8s_apps_daemon_sets.uid
      AND daemonset_containers.container->'securityContext'->>'readOnlyRootFilesystem'
        IS DISTINCT FROM 'true'
  )
  > 0
  THEN 'fail'
  ELSE 'pass'
  END
    AS status
FROM
  k8s_apps_daemon_sets;

DaemonSet containers to run as non-root

WITH
  daemonset_containers
    AS (
      SELECT
        uid, value AS container
      FROM
        k8s_apps_daemon_sets
        CROSS JOIN jsonb_array_elements(spec_template->'spec'->'containers')
            AS value
    )
SELECT
  uid AS resource_id,
  'DaemonSet containers to run as non-root' AS title,
  context AS context,
  namespace AS namespace,
  name AS resource_name,
  CASE
  WHEN (
    SELECT
      count(*)
    FROM
      daemonset_containers
    WHERE
      daemonset_containers.uid = k8s_apps_daemon_sets.uid
      AND daemonset_containers.container->'securityContext'->>'runAsNonRoot'
        IS DISTINCT FROM 'true'
  )
  > 0
  THEN 'fail'
  ELSE 'pass'
  END
    AS status
FROM
  k8s_apps_daemon_sets;