turbot/kubernetes

GitHub
steampipe plugin install kubernetessteampipe plugin install kubernetes

Table: kubernetes_deployment

A Deployment provides declarative updates for Pods and ReplicaSets.

You describe a desired state in a Deployment, and the Deployment Controller changes the actual state to the desired state at a controlled rate. You can define Deployments to create new ReplicaSets, or to remove existing Deployments and adopt all their resources with new Deployments.

Examples

Basic Info

select
name,
namespace,
status_replicas,
ready_replicas,
updated_replicas,
available_replicas,
unavailable_replicas,
age(current_timestamp, creation_timestamp)
from
kubernetes_deployment
order by
namespace,
name;

Configuration Info

select
name,
paused,
generate_name,
generation,
revision_history_limit,
replicas,
strategy,
selector
from
kubernetes_deployment;

Container Images used in Deployments

select
name as deployment_name,
namespace,
c ->> 'name' as container_name,
c ->> 'image' as image
from
kubernetes_deployment,
jsonb_array_elements(template -> 'spec' -> 'containers') as c
order by
namespace,
name;

List pods for a deployment

select
pod.namespace,
d.name as deployment_name,
rs.name as replicaset_name,
pod.name as pod_name,
pod.phase,
age(current_timestamp, pod.creation_timestamp),
pod.pod_ip,
pod.node_name
from
kubernetes_pod as pod,
jsonb_array_elements(pod.owner_references) as pod_owner,
kubernetes_replicaset as rs,
jsonb_array_elements(rs.owner_references) as rs_owner,
kubernetes_deployment as d
where
pod_owner ->> 'kind' = 'ReplicaSet'
and rs.uid = pod_owner ->> 'uid'
and rs_owner ->> 'uid' = d.uid
and d.name = 'frontend'
order by
pod.namespace,
d.name,
rs.name,
pod.name;

List Pods with access to the to the host process ID, IPC, or network namespace

select
namespace,
name,
template -> 'spec' ->> 'hostPID' as hostPID,
template -> 'spec' ->> 'hostIPC' as hostIPC,
template -> 'spec' ->> 'hostNetwork' as hostNetwork
from
kubernetes_deployment
where
template -> 'spec' ->> 'hostPID' = 'true'
or template -> 'spec' ->> 'hostIPC' = 'true'
or template -> 'spec' ->> 'hostNetwork' = 'true';

List manifest resources

select
name,
namespace,
replicas,
path
from
kubernetes_deployment
where
path is not null
order by
namespace,
name;

Query examples

.inspect kubernetes_deployment

Kubernetes Deployment enables declarative updates for Pods and ReplicaSets.

NameTypeDescription
_ctxjsonbSteampipe context in JSON form, e.g. connection_name.
annotationsjsonbAnnotations is an unstructured key value map stored with a resource that may be set by external tools to store and retrieve arbitrary metadata.
available_replicasbigintTotal number of available pods (ready for at least minReadySeconds) targeted by this deployment.
collision_countbigintCount of hash collisions for the Deployment. The Deployment controller uses this field as a collision avoidance mechanism when it needs to create the name for the newest ReplicaSet.
conditionsjsonbRepresents the latest available observations of a deployment's current state.
context_nametextKubectl config context name.
creation_timestamptimestamp with time zoneCreationTimestamp is a timestamp representing the server time when this object was created.
deletion_grace_period_secondsbigintNumber of seconds allowed for this object to gracefully terminate before it will be removed from the system. Only set when deletionTimestamp is also set.
deletion_timestamptimestamp with time zoneDeletionTimestamp is RFC 3339 date and time at which this resource will be deleted.
end_linebigintThe path to the manifest file.
finalizersjsonbMust be empty before the object is deleted from the registry. Each entry is an identifier for the responsible component that will remove the entry from the list. If the deletionTimestamp of the object is non-nil, entries in this list can only be removed.
generate_nametextGenerateName is an optional prefix, used by the server, to generate a unique name ONLY IF the Name field has not been provided.
generationbigintA sequence number representing a specific generation of the desired state.
labelsjsonbMap of string keys and values that can be used to organize and categorize (scope and select) objects. May match selectors of replication controllers and services.
min_ready_secondsbigintMinimum number of seconds for which a newly created pod should be ready without any of its container crashing, for it to be considered available. Defaults to 0.
nametextName of the object. Name must be unique within a namespace.
namespacetextNamespace defines the space within which each name must be unique.
observed_generationbigintThe generation observed by the deployment controller.
owner_referencesjsonbList of objects depended by this object. If ALL objects in the list have been deleted, this object will be garbage collected. If this object is managed by a controller, then an entry in this list will point to this controller, with the controller field set to true. There cannot be more than one managing controller.
pathtextThe path to the manifest file.
pausedbooleanIndicates that the deployment is paused.
progress_deadline_secondsbigintThe maximum time in seconds for a deployment to make progress before it is considered to be failed.
ready_replicasbigintTotal number of ready pods targeted by this deployment.
replicasbigintNumber of desired pods. Defaults to 1.
resource_versiontextAn opaque value that represents the internal version of this object that can be used by clients to determine when objects have changed.
revision_history_limitbigintThe number of old ReplicaSets to retain to allow rollback.
selectorjsonbLabel selector for pods. A label selector is a label query over a set of resources.
selector_querytextA query string representation of the selector.
source_typetextThe source of the resource. Possible values are: deployed and manifest. If the resource is fetched from the spec file the value will be manifest.
start_linebigintThe path to the manifest file.
status_replicasbigintTotal number of non-terminated pods targeted by this deployment (their labels match the selector).
strategyjsonbThe deployment strategy to use to replace existing pods with new ones.
tagsjsonbA map of tags for the resource. This includes both labels and annotations.
templatejsonbTemplate describes the pods that will be created.
titletextTitle of the resource.
uidtextUID is the unique in time and space value for this object.
unavailable_replicasbigintTotal number of unavailable pods targeted by this deployment.
updated_replicasbigintTotal number of non-terminated pods targeted by this deployment that have the desired template spec.