1 point by curious-devops 7 months ago flag hide 14 comments
postgresuser 7 months ago next
I'm curious to know the best practices for scaling PostgreSQL on Kubernetes. I've heard both good and bad things about it, so I'm excited to learn more!
k8spro 7 months ago next
One popular solution is to use a Kubernetes Operator like kubectl-horizon, which can help manage PostgreSQL replicas, backups, and auto-scaling.
dbaguru 7 months ago next
True, and you should also use something like Helm or Kustomize to manage your PostgreSQL deployment manifests for better maintainability.
cloudsme 7 months ago prev next
Have you considered using a managed service like Google SQL, AWS RDS or Azure Database for PostgreSQL? They have good PostgreSQL support and provide a more streamlined operations experience.
postgresuser 7 months ago next
@cloudSME I prefer a DIY approach, but still want something that's scalable and reliable. This is the main reason I'm asking about tips on doing this with Kubernetes.
devopsguru 7 months ago prev next
Partitioning your database horizontally using something like Citus can be very helpful with scalability. You could also consider sharding if you have many terabytes of data.
sqllover 7 months ago next
Citus sounds interesting! Could you elaborate more about how to partition using Citus on Kubernetes? Are there any gotchas?
devopsguru 7 months ago next
Absolutely! Check out Citus' Kubernetes documentation here: <https://docs.citusdata.com/en/latest/installation/kubernetes.html>. As for issues, you might run into storage driver incompatibilities or latency when accessing distributed tables through multiple nodes.
k8spro 7 months ago prev next
You should also make sure your Kubernetes cluster is highly available and horizontal pod autoscaling is enabled with adjusted thresholds. This will help ensure resources remain available during sudden scale events.
postgresuser 7 months ago next
@k8sPro Interesting! Regarding horiz. pod autoscaling, how would I know what scaling rules I should consider?
k8spro 7 months ago next
Metrics like the memory or CPU requests of your PostgreSQL nodes can give you an idea of when resource usage becomes an issue. Compare your current resources used with the limits you've set, and consider setting a threshold for autoscaling when resources approach limits.
perfmaster 7 months ago prev next
Several monitoring tools can aid with performance optimization: cAdvisor, kube-state-metrics, & Prometheus to name some. Don't forget to use persistent storage for PostgreSQL data and watch out for disk space when sharding!
securityexpert 7 months ago prev next
Security is a crucial aspect of your infrastructure. Encrypt data at rest and in transit, consider using an external secrets manager, and regularly review and follow CIS Kubernetes best practices.
postgresuser 7 months ago next
That's really helpful. I will definitely ensure that all these factors are taken care of. Thanks for all your suggestions!