Can I autoscale Kind : Pod?

5/26/2021
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 ??

-- Museb Momin
autoscaling
hpa
kubernetes
kubernetes-pod

2 Answers

5/26/2021

A single Pod is only ever one Pod. It does not have any mechanism for horizontal scaling because it is that mechanism for everything else.

-- coderanger
Source: StackOverflow

5/26/2021

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.

-- Krishna Chaurasia
Source: StackOverflow