Horizontal Pod Autoscaler

This generates a Horizontal Pod Autoscaler object.

Property Description
Resource type horizontal-pod-autoscaler
Account type None

Inputs

Values

Name Type Description
annotations map Annotations to add to the manifest.
labels map Labels to add to the manifest.
maxReplicas integer The maximum number of replicas to scale to. (Must be > minReplicas.)
minReplicas integer The minimum number of replicas to scale to. (Must be > 0.)
targetCPUUtilizationPercentage integer The percentage of the CPU resource limit to attempt to scale to. (Must be between 0 and 100.)

Secrets

None

Notes

The Driver will override any resource inputs provided if the Driver inputs are more conservativeFor example, the final maxReplicas value will be min(resource_inputs.maxReplicas, driver_inputs.maxReplicas). If the values are omitted, the resource inputs are used.

Example

Set the following environment variables for the CLI and API commands:

Variable Example Description
HUMANITEC_TOKEN my-token The authentication token for accessing the Humanitec API.
HUMANITEC_ORG my-org-id The unique identifier for the organization in Humanitec.

Use the command below for the interface of your choice to create a Resource Definition that adds a Horizontal Pod Autoscaler to Workloads that caps the maxReplicas at 2:

  1. Create a file defining the Resource Definition you want to create:
cat << EOF > hpa.yaml
apiVersion: entity.humanitec.io/v1b1
kind: Definition
metadata:
  id: hpa
entity:
  driver_type: humanitec/hpa
  name: Horizontal Pod Autoscaler
  type: horizontal-pod-autoscaler
  driver_inputs:
    values:
      maxReplicas: 2
  criteria:
  - env_type: development
EOF
  1. Use the humctl create command to create the Resource Definition in the Organization defined by your configured context:
humctl create -f hpa.yaml
rm hpa.yaml

curl https://api.humanitec.io/orgs/${HUMANITEC_ORG}/resources/defs \
  -X POST \
  -H "Authorization: Bearer ${HUMANITEC_TOKEN}" \
  -H "Content-Type: application/json" \
  --data-binary '
{
  "id": "hpa",
  "name": "Horizontal Pod Autoscaler",
  "type": "horizontal-pod-autoscaler",
  "driver_type": "humanitec/hpa",
  "driver_inputs": {
    "values": {
      "maxReplicas": 2
    }
  },
  "criteria": [
    {
      "env_type": "development"
    }
  ]
}'
Top