本文介紹 Kubernetes 支持數(shù)據(jù)庫等有狀態(tài)應(yīng)用的常見解決方案:StatefulSet。
在構(gòu)建機器學習向量管理層時窍育,我們面臨的一個重要問題:如何持久化數(shù)據(jù)以避免數(shù)據(jù)丟失铜犬?
在閱讀了許多數(shù)據(jù)庫企業(yè)發(fā)布的博客后竭沫,我們認為 StatefulSet[1] 是實現(xiàn)這個目標的可行方法。
我們研究了不同的數(shù)據(jù)庫,包括 Cockroach蚕礼、MySQL烟具、MongoDB、Cassandra奠蹬、PostgreSQL朝聋、Dgraph 和 Redis。我們還研究了 Kafka 和 Zookeeper囤躁,因為它們都需要持久化狀態(tài)冀痕。我們選擇這些數(shù)據(jù)庫是基于兩方面:
- 它們是業(yè)界廣泛使用的數(shù)據(jù)庫解決方案,并可以部署在 Kubernetes 上割以。其中一些是云原生數(shù)據(jù)庫金度,如 Cockroach。
- 這些有狀態(tài)應(yīng)用是不同類型的严沥,比如 MySQL 是關(guān)系型數(shù)據(jù)庫,MongoDB 是非關(guān)系型數(shù)據(jù)庫中姜。研究不同類型的數(shù)據(jù)庫讓我們對使用 StatefulSet 方案更加自信消玄。
下面列出了一些關(guān)于如何使用 StatefulSet 在 Kubernetes 中部署不同數(shù)據(jù)庫或有狀態(tài)應(yīng)用程序的文章。
Cockroach
- 3 ways to master stateful apps in Kubernetes[2]丢胚,
Kubernetes 有兩種方法管理狀態(tài):DaemonSet 和 StatefulSet翩瓜,但是 Cockroach 強烈建議使用 StatefulSet。
- How to Run CockroachDB on Kubernetes[3]Deploy a Local Cluster with Kubernetes[4]
MySQL
- Run a Replicated Stateful Application[5]
- Kubernetes StatefulSet — Example & Best Practices[6]
這篇文章介紹了使用 Kubernetes StatefulSet 部署 MySQL 的端到端流程携龟。
MongoDB
- Running MongoDB on Kubernetes with StatefulSets[7]
- How to Run MongoDB on Kubernetes[8]
Cassandra
- Deploying Cassandra with a StatefulSet[9]
PostgreSQL
- Deploying PostgreSQL as a StatefulSet in Kubernetes[10]
Dgraph[11]
Redis
- Deploying Redis Cluster on Kubernetes[12]
Kafka
- Set-up Kafka Cluster Using Kubernetes StatefulSet[13]
Zookeeper
- Running Zookeeper, A Distributed System Coordinator[14]
基于上述文章兔跌,我們將開始使用 StatefulSet,看看它是否能夠滿足我們的應(yīng)用場景峡蟋。
原文鏈接:https://medium.com/@junxie2/kubernetes-statefulset-for-db-applications-7fd186c6ccb9
參考引用
1.StatefulSet: https://kubernetes.io/zh-cn/docs/tutorials/stateful-application/basic-stateful-set/
2.3 ways to master stateful apps in Kubernetes:https://www.cockroachlabs.com/blog/kubernetes-orchestrate-sql-with-cockroachdb/
3.How to Run CockroachDB on Kubernetes:https://www.cockroachlabs.com/blog/running-cockroachdb-on-kubernetes/
4.Deploy a Local Cluster with Kubernetes:https://www.cockroachlabs.com/docs/stable/orchestrate-a-local-cluster-with-kubernetes.html
5.Run a Replicated Stateful Application:https://kubernetes.io/docs/tasks/run-application/run-replicated-stateful-application/
6.Kubernetes StatefulSet — Example & Best Practices:https://loft.sh/blog/kubernetes-statefulset-examples-and-best-practices/
7.Running MongoDB on Kubernetes with StatefulSets:https://kubernetes.io/blog/2017/01/running-mongodb-on-kubernetes-with-statefulsets/
8.How to Run MongoDB on Kubernetes:https://kubernetes.io/blog/2017/01/running-mongodb-on-kubernetes-with-statefulsets/
9.Deploying Cassandra with a StatefulSet:https://kubernetes.io/docs/tutorials/stateful-application/cassandra/
10.Deploying PostgreSQL as a StatefulSet in Kubernetes:https://www.bmc.com/blogs/kubernetes-postgresql/
11.Dgraph:https://dgraph.io/docs/deploy/kubernetes/
12.Deploying Redis Cluster on Kubernetes:https://www.containiq.com/post/deploy-redis-cluster-on-kubernetes
13.Set-up Kafka Cluster Using Kubernetes StatefulSet:https://medium.com/@knoldus/set-up-kafka-cluster-using-kubernetes-statefulset-30d73d25864b
14.Running Zookeeper, A Distributed System Coordinator:https://kubernetes.io/docs/tutorials/stateful-application/zookeeper/