Is it possible to scale up pods in expectance of high traffic in Kubernetes?

4/24/2021

So, we are thinking about switching our production server to Kubernetes. Right now, it's not really professional as it's only one single nginx instance. 99% of the time our server needs to handle about 30 requests a minute, which it easily manages to do. On specific times, that we exactly know of in before, there can be 2000 Users on the same second expecting a service. That is obviously way too much for it and last time it often returned a 502. Kubernetes Autoscaling seems like a good approach for that. The only problem is that we need the extra containers at that specific time, not 30 seconds after.

So is there a way to "manually" scale? Like telling to Kubernetes to prepare 4 containers at exactly 8 PM MESZ e.g.?

-- crimbler2
docker
horizontal-pod-autoscaling
kubernetes
nginx
server

1 Answer

4/24/2021

There are a number of way to autoscale Pods in Kubernetes.

Horizontal Pod Autoscaler

You can use an Horizontal Pod Autoscaler to scale up Pods reactively, based on metrics. You can also use custom metrics.

Manually adjust number of replicas

You can also manually set the number of replicas: in the Deployment. This can be done declaratively by changing the manifest, or imperatively by using kubectl:

kubectl scale deployment my-app --replicas=5

Use a CronJob to adjust the number of replicas

You can also use a Kubernetes CronJob with a kubectl-image that does the command above to scale up number of replicas at a specific time.

Use Knative Serving Autoscaler to autoscale per request

When using Knative Serving, you can use the Knative Service Autoscaler to scale up based on the number of requests.

-- Jonas
Source: StackOverflow