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_replicasfrom 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: ` ` ` sqlselect name, namespace, min_replicas, max_replicas, current_replicas, desired_replicasfrom kubernetes_horizontal_pod_autoscaler;
### Get list of HPA metrics configurationsExplore 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+postgresselect name, namespace, min_replicas, max_replicas, current_replicas, desired_replicas, jsonb_array_elements(metrics) as metrics, jsonb_array_elements(current_metrics) as current_metrics, conditionsfrom kubernetes_horizontal_pod_autoscaler;
select name, namespace, min_replicas, max_replicas, current_replicas, desired_replicas, metrics, current_metrics, conditionsfrom 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, pathfrom kubernetes_horizontal_pod_autoscalerwhere path is not null;
select name, namespace, min_replicas, max_replicas, current_replicas, desired_replicas, pathfrom kubernetes_horizontal_pod_autoscalerwhere path is not null;
Schema for kubernetes_horizontal_pod_autoscaler
Name | Type | Operators | Description |
---|---|---|---|
_ctx | jsonb | Steampipe context in JSON form. | |
annotations | jsonb | Annotations is an unstructured key value map stored with a resource that may be set by external tools to store and retrieve arbitrary metadata. | |
conditions | jsonb | Conditions is the set of conditions required for this autoscaler to scale its target and indicates whether or not those conditions are met. | |
context_name | text | Kubectl config context name. | |
creation_timestamp | timestamp with time zone | CreationTimestamp is a timestamp representing the server time when this object was created. | |
current_metrics | jsonb | CurrentMetrics is the last read state of the metrics used by this autoscaler. | |
current_replicas | bigint | The current number of replicas of pods managed by this autoscaler. | |
deletion_grace_period_seconds | bigint | Number 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_timestamp | timestamp with time zone | DeletionTimestamp is RFC 3339 date and time at which this resource will be deleted. | |
desired_replicas | bigint | The desired number of replicas of pods managed by this autoscaler. | |
end_line | bigint | The path to the manifest file. | |
finalizers | jsonb | Must 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_name | text | GenerateName is an optional prefix, used by the server, to generate a unique name ONLY IF the Name field has not been provided. | |
generation | bigint | A sequence number representing a specific generation of the desired state. | |
labels | jsonb | Map 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_time | timestamp with time zone | The last time the HorizontalPodAutoscaler scaled the number of pods used by the autoscaler to control how often the number of pods is changed. | |
max_replicas | bigint | The Upper limit for the number of pods that can be set by the autoscaler. It cannot be smaller than MinReplicas. | |
metrics | jsonb | Metrics 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_replicas | bigint | MinReplicas 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. | |
name | text | Name of the object. Name must be unique within a namespace. | |
namespace | text | Namespace defines the space within which each name must be unique. | |
observed_generation | bigint | The most recent generation observed by this autoscaler. | |
owner_references | jsonb | List 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. | |
path | text | The path to the manifest file. | |
resource_version | text | An opaque value that represents the internal version of this object that can be used by clients to determine when objects have changed. | |
scale_down_behavior | jsonb | Behavior 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_ref | jsonb | ScaleTargetRef 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_behavior | jsonb | Behavior 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_type | text | The 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_name | text | Steampipe connection name. | |
sp_ctx | jsonb | Steampipe context in JSON form. | |
start_line | bigint | The path to the manifest file. | |
tags | jsonb | A map of tags for the resource. This includes both labels and annotations. | |
title | text | Title of the resource. | |
uid | text | UID 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