turbot/kubernetes
steampipe plugin install kubernetes

Table: kubernetes_stateful_set - Query Kubernetes Stateful Sets using SQL

A Kubernetes Stateful Set is a workload API object that manages stateful applications. It is used to manage applications which require one or more of the following: stable, unique network identifiers, stable, persistent storage, and ordered, graceful deployment and scaling. Stateful Sets are valuable for applications that require stable network identity or stable storage, like databases.

Table Usage Guide

The kubernetes_stateful_set table provides insights into the stateful applications running in a Kubernetes environment. As a DevOps engineer, explore details of these applications through this table, including network identifiers, persistent storage, and deployment details. Utilize it to manage and monitor stateful applications, such as databases, that require stable network identity or persistent storage.

Examples

Basic Info - kubectl get statefulsets --all-namespaces columns

Explore the organization and status of your Kubernetes stateful sets by identifying their names, associated services, and the number of replicas. This query also allows you to assess the age of these sets, helping you manage system resources and plan for updates or decommissioning.

select
name,
namespace,
service_name,
replicas,
age(current_timestamp, creation_timestamp)
from
kubernetes_stateful_set
order by
namespace,
name;
select
name,
namespace,
service_name,
replicas,
strftime('%s', 'now') - strftime('%s', creation_timestamp) as age
from
kubernetes_stateful_set
order by
namespace,
name;

List stateful sets that require manual update when the object's configuration is changed

Explore which stateful sets in your Kubernetes environment require manual updates whenever there are changes in the object's configuration. This is useful for ensuring optimal management and timely updates of stateful sets, particularly those with an 'OnDelete' update strategy.

select
name,
namespace,
service_name,
update_strategy ->> 'type' as update_strategy_type
from
kubernetes_stateful_set
where
update_strategy ->> 'type' = 'OnDelete';
select
name,
namespace,
service_name,
json_extract(update_strategy, '$.type') as update_strategy_type
from
kubernetes_stateful_set
where
json_extract(update_strategy, '$.type') = 'OnDelete';

List manifest resources

Explore which stateful applications in your Kubernetes cluster have specified storage configurations. This can help you understand how your persistent data is managed and identify any potential issues with data persistence.

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

Control examples

Schema for kubernetes_stateful_set

NameTypeOperatorsDescription
_ctxjsonbSteampipe context in JSON form.
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 statefulset.
collision_countbigintThe count of hash collisions for the StatefulSet.
conditionsjsonbRepresents the latest available observations of a stateful set'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.
current_replicasbigintThe number of Pods created by the StatefulSet controller from the StatefulSet version indicated by currentRevision.
current_revisiontextIndicates the version of the StatefulSet used to generate Pods in the sequence [0,currentReplicas).
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.
nametextName of the object. Name must be unique within a namespace.
namespacetextNamespace defines the space within which each name must be unique.
observed_generationbigintThe most recent generation observed for this StatefulSet.
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.
pod_management_policytextPolicy that controls how pods are created during initial scale up, when replacing pods on nodes, or when scaling down.
ready_replicasbigintThe number of Pods created by the StatefulSet controller that have a Ready Condition.
replicasbigintThe desired number of replicas of the given Template.
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 maximum number of revisions that will be maintained in the StatefulSet's revision history.
service_nametextThe name of the service that governs this StatefulSet.
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.
sp_connection_nametextSteampipe connection name.
sp_ctxjsonbSteampipe context in JSON form.
start_linebigintThe path to the manifest file.
tagsjsonbA map of tags for the resource. This includes both labels and annotations.
templatejsonbTemplate is the object that describes the pod that will be created if insufficient replicas are detected.
titletextTitle of the resource.
uidtextUID is the unique in time and space value for this object.
update_revisiontextIndicates the version of the StatefulSet used to generate Pods in the sequence [replicas-updatedReplicas,replicas).
update_strategyjsonbIndicates the StatefulSetUpdateStrategy that will be employed to update Pods in the StatefulSet when a revision is made to Template.
updated_replicasbigintThe number of Pods created by the StatefulSet controller from the StatefulSet version indicated by updateRevision.

Export

This table is available as a standalone Exporter CLI. Steampipe exporters are stand-alone binaries that allow you to extract data using Steampipe plugins without a database.

You can download the tarball for your platform from the Releases page, but it is simplest to install them with the steampipe_export_installer.sh script:

/bin/sh -c "$(curl -fsSL https://steampipe.io/install/export.sh)" -- kubernetes

You can pass the configuration to the command with the --config argument:

steampipe_export_kubernetes --config '<your_config>' kubernetes_stateful_set