Search code examples
kubernetesautoscalingkubernetes-podhpa

Can I autoscale Kind : Pod?


apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
 name: testingHPA

spec:
 scaleTargetRef:
   apiVersion: apps/v1beta1
   kind: Deployment
   name: my_app
 minReplicas: 3
 maxReplicas: 5
 targetCPUUtilizationPercentage: 85

Above is the normal hpa.yaml structure, is it possible to use kind as a pod and auto scale it ??


Solution

  • As already pointed by others, it is not possible to set Pod as the Kind object as the target resource for an HPA.

    The document describes HPA as:

    The Horizontal Pod Autoscaler automatically scales the number of Pods in a replication controller, deployment, replica set or stateful set based on observed CPU utilization (or, with custom metrics support, on some other application-provided metrics). Note that Horizontal Pod Autoscaling does not apply to objects that can't be scaled, for example, DaemonSets.

    The document also described how the algorithm is implemented at the backend as:

    desiredReplicas = ceil[currentReplicas * ( currentMetricValue / desiredMetricValue )]
    

    and since the Pod resource does not have the replicas field as part of its spec therefore we can conclude that the same is not supported for auto scaling using the HPA.