turbot/kubernetes
steampipe plugin install kubernetes

Table: kubernetes_horizontal_pod_autoscaler - Query Kubernetes Horizontal Pod Autoscalers using SQL

A Kubernetes Horizontal Pod Autoscaler automatically scales the number of pods in a replication controller, deployment, replica set, or stateful set based on observed CPU utilization. It is designed to maintain a specified amount of CPU utilization across the pods, irrespective of the load. The Horizontal Pod Autoscaler is implemented as a Kubernetes API resource and a controller.

Table Usage Guide

The kubernetes_horizontal_pod_autoscaler table provides insights into Horizontal Pod Autoscalers within a Kubernetes cluster. As a Kubernetes administrator or DevOps engineer, explore autoscaler-specific details through this table, including the current and desired number of replicas, target CPU utilization, and associated metadata. Utilize it to monitor the performance and efficiency of the autoscalers, ensuring that your applications are scaling correctly and efficiently under varying load conditions.

Examples

Basic Info

Explore the configuration of your Kubernetes horizontal pod autoscaler to determine its current and desired replica settings. This will help you understand how your system is scaling and whether it is operating within your set parameters.

select
name,
namespace,
min_replicas,
max_replicas,
current_replicas,
desired_replicas
from
kubernetes_horizontal_pod_autoscaler;
The PostgreSQL query provided does not use any PostgreSQL - specific functions,
data types,
or JSON functions.Therefore,
the query can be used in SQLite without any changes.Here is the SQLite equivalent: ` ` ` sql
select
name,
namespace,
min_replicas,
max_replicas,
current_replicas,
desired_replicas
from
kubernetes_horizontal_pod_autoscaler;
### Get list of HPA metrics configurations
Explore the configurations of your Horizontal Pod Autoscalers (HPA) to understand their current and desired replica settings. This can help you assess the efficiency of your current setup and identify areas for potential optimization.
```sql+postgres
select
name,
namespace,
min_replicas,
max_replicas,
current_replicas,
desired_replicas,
jsonb_array_elements(metrics) as metrics,
jsonb_array_elements(current_metrics) as current_metrics,
conditions
from
kubernetes_horizontal_pod_autoscaler;
select
name,
namespace,
min_replicas,
max_replicas,
current_replicas,
desired_replicas,
metrics,
current_metrics,
conditions
from
kubernetes_horizontal_pod_autoscaler,
json_each(metrics),
json_each(current_metrics);

List manifest resources

Explore which Kubernetes horizontal pod autoscalers have a defined path. This helps in understanding the autoscaling configuration for the pods and aids in optimizing resource usage within your Kubernetes environment.

select
name,
namespace,
min_replicas,
max_replicas,
current_replicas,
desired_replicas,
path
from
kubernetes_horizontal_pod_autoscaler
where
path is not null;
select
name,
namespace,
min_replicas,
max_replicas,
current_replicas,
desired_replicas,
path
from
kubernetes_horizontal_pod_autoscaler
where
path is not null;

Schema for kubernetes_horizontal_pod_autoscaler

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.
conditionsjsonbConditions is the set of conditions required for this autoscaler to scale its target and indicates whether or not those conditions are met.
context_nametextKubectl config context name.
creation_timestamptimestamp with time zoneCreationTimestamp is a timestamp representing the server time when this object was created.
current_metricsjsonbCurrentMetrics is the last read state of the metrics used by this autoscaler.
current_replicasbigintThe current number of replicas of pods managed by this autoscaler.
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.
desired_replicasbigintThe desired number of replicas of pods managed by this autoscaler.
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.
last_scale_timetimestamp with time zoneThe last time the HorizontalPodAutoscaler scaled the number of pods used by the autoscaler to control how often the number of pods is changed.
max_replicasbigintThe Upper limit for the number of pods that can be set by the autoscaler. It cannot be smaller than MinReplicas.
metricsjsonbMetrics contains the specifications for which to use to calculate the desired replica count (the maximum replica count across all metrics will be used). The desired replica count is calculated multiplying the ratio between the target value and the current value by the current number of pods.
min_replicasbigintMinReplicas is the lower limit for the number of replicas to which the autoscaler can scale down. It defaults to 1 pod. MinReplicas is allowed to be 0 if the alpha feature gate HPAScaleToZero is enabled and at least one Object or External metric is configured.
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 by this autoscaler.
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.
resource_versiontextAn opaque value that represents the internal version of this object that can be used by clients to determine when objects have changed.
scale_down_behaviorjsonbBehavior configures the scaling behavior of the target in both Up and Down directions (scaleUp and scaleDown fields respectively). If not set, the default value is to allow to scale down to minReplicas pods, with a 300 second stabilization window (i.e., the highest recommendation for the last 300sec is used).
scale_target_refjsonbScaleTargetRef points to the target resource to scale, and is used to the pods for which metrics should be collected, as well as to actually change the replica count.
scale_up_behaviorjsonbBehavior configures the scaling behavior of the target in both Up and Down directions (scaleUp and scaleDown fields respectively). If not set, the default value is the higher of: * increase no more than 4 pods per 60 seconds * double the number of pods per 60 seconds.
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.
titletextTitle of the resource.
uidtextUID is the unique in time and space value for this object.

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_horizontal_pod_autoscaler