Is it possible to Autoscale other Kinds than Kind : Deployment in Kubernetes?

5/28/2021

I want to use kind other than Deployment for Autoscaling in Kubernetes is it possible ? the reason I don't want to use kind:Deployment is the restart policy, as per as k8s documentation the only valid field for restart policy is "Always", and If put "Never" I am getting an error.

In my scenario I have a external monitoring UI which I use to shutdown the service if required, but now what happening is the pods are terminating and new pod are getting created. What should I do ? please note that I can not run it as kind:Pod as I want to auto-scale the services and Autoscaling of Kind:Pod is not valid !

Please share your suggestions and view on this ! thanks in advance.

-- Museb Momin
autoscaling
deployment
hpa
kubernetes
kubernetes-pod

1 Answer

5/28/2021

HPA can be used with the following resources: ReplicationController, Deployment, ReplicaSet or StatefulSet. However HPA doesn't support scaling to 0.

There are some serverless frameworks that support scalability to zero in kubernetes such as Knative and Keda.

Your use case sounds much simpler though, as you're looking to scale to zero based on a manual action. You can achieve this by setting the number of replicas of your deployment to 0.

kubectl scale --replicas=0 deployment/{deploymentName}

And then if you want to re-activate the service then increase the replicas back again.

kubectl scale --replicas=1 deployment/{deploymentName}
-- Yayotrón
Source: StackOverflow