Running databases within container clusters seems, at first glance, to be more effort than it’s worth. Why use a system designed for stateless highly available microservices to manage persistent storage? Historically, production database systems were housed outside of container clusters, often with the help of dynamic storage. However, the data layer can also benefit from scalability and agility, and tools have been developed to make this easier. Additional benefits include fault tolerance and improved performance as smaller database parts reduce transaction time.
Kubernetes is the leading container orchestration tool, improving operational efficiency and system resilience. Kubernetes also has the benefit of being flexible and extensible through many software extensions. Sharing and persistence of the data layer has been challenging. In earlier distributions, data was temporary and could not be shared between pods. Kubernetes later introduced persistent volumes. Persistent volumes must be provisioned in advance and still require manual mounting of file systems. Storage classes overcame the second issue, by allowing nodes to request storage on the fly which is then mounted appropriately. The final piece of the puzzle is StatefulSets. StatefulSets are pod controllers which maintain persistent hostnames. Using these hostnames, persistent volumes can be mounted when pods fail and restart.
These features make it possible to run databases within pods, but the automation really comes in with Kubernetes operators. Operators take directives and implement actions, managing clusters on behalf of a user. The operators are then able to monitor and manage specific hardware, reducing human error but also improving resource management. Operators also ensure that databases survive pod failures, maintaining data integrity. (source)
With all these Kubernetes extensions, it becomes a question of which database technology is most suitable. Needless to say, distributed databases are best
This article is purposely trimmed, please visit the source to read the full article.
The post Kubernetes Gotchas: Lessons Learned appeared first on Software Engineering Daily.