2

A Kubernetes cluster should not contain stateful services like databases because of scalability, recovery and operation of the storage. Would be the use of ceph be an alternative to this problem?

moinster
  • 133
  • 6

2 Answers2

1

A Kubernetes can contain stateful services. Some examples are Redis cache or CockroachDB - but they should be a distributed service.

Ceph is a storage solution alternative.

Jonas
  • 121,568
  • 97
  • 310
  • 388
  • Could you elaborate on what you mean with "distributed service" in a K8s context. Thank you! – Fritz Duchardt Jan 13 '21 at 10:03
  • @FritzDuchardt a distributed system, distributed service or distributed database consist of more than one node but appears to act as a single service for the user. – Jonas Jan 13 '21 at 10:06
0

In Kubernetes are objects called StatefulSets which are a workload APIs objects that maintains a sticky identity for each of the Pods to persistent volumes, so that you can reattach a volume to Pod that may be restarted on a different node. Such development is realy important to maintain state within a cluster, as an application like a database can now survive a Pod getting shut down. StatefulSets are mainly used with databases and clustered applications that have specific requirements. You can easy validate and modify them.

For example speaking abour scaling: With MySQL replication, you can scale your read query capacity by adding replicas. With StatefulSet, you can do this with a single command:

$ kubectl scale statefulset mysql  --replicas=5

Take a look: statefulset-database, Here you can find how to setup MySQL database using StatefulSet - mysql-statefulset.

Stateful applications are services that require backing storage and keeping state is critical to running the service. Databases such as MySQL, MongoDB, Postgres, and Cassandra are good examples. They need some form of persistent storage that will survive service restarts.

Speaking about Ceph. It is traditionally known for both object and block storage, but not for database storage. - read article: ceph-databases.

Take a look also on official documentation: statefulsets.

Malgorzata
  • 6,409
  • 1
  • 10
  • 27