How to setup pod autoscaler on GCP GKE based on value from other server?

145 views Asked by At

Here is my problem:

I have running Deployment workload on GCP GKE. I also have running database server outside GCP which has a public IP. I would like implement pod autoscaler based on value obtained from database on db server. I do not exactly know how to do it in best way.

My solution right now, but I have not implemented it yet: use HorizontalPodAutoscaler (HPA) and use external metric (or custom?). Create a Python script on db server which will be run SQL cmd and obtain specific value and send this value as log to Cloud Logging. Then, create a log-based metric in Cloud Monitoring and use this metric in HPA workload on GCP GKE. Python script will be executed via cron on db server.

What do you think about this solution? It seems to be quite complicated but I do not have much experience in DevOps/Cloud field and I do not know if it is the best solution to this problem. Maybe there is a simpler solution which involves less steps?

I would be grateful for any help.

1

There are 1 answers

0
Aditya Ch On

Custom metrics can be used to autoscale the pod. Your thought process is right. Please find the below link to streamline your thought process.

https://cloud.google.com/kubernetes-engine/docs/tutorials/autoscaling-metrics#custom-metric

https://cloud.google.com/kubernetes-engine/docs/how-to/horizontal-pod-autoscaling#custom-or-external-metric