Kubernetes Deep Dive Room

Sign Up Free or Log In to participate!

Hi Nigel, I’ve got a storage question.

What are the advantages of having a database inside a K8 cluster? If I’ve got it right, after the storage class, in case of the pod with MySQL dies, I will loose the database (yes, the db file system will still be on the volume) and spinning up a new pod with another instance of DB I don’t see how can I use the previous DB instance file system, still on the volume (if reclaim policy was not delete). As I can see things now, in case of a new DB instance, I start from scratch, the old data id pretty much gone. Wouldn’t be easier to use the DB as a managed service somewhere in the cloud? And even if the load dictates to spin up a new DB instance, for a read replica, the new instance will not be able to use the old instance file system, to start from the same point, it will be empty. Can you clear this topic for me, please?

1 Answers

Hello Andrei, 
Maybe I can clarify a bit from my own perspective. 

Here you are basically asking two questions: 

1. Isn’t it better/easier to use a managed DB service instead of running your DB in kubernetes? 

2. Can a new pod claim an existing orphaned/unclaimed volume (if the reclaim policy is not delete)? 

Here are my answers: 

1. Everything solution in IT comes with a compromise. Yes, running your DB in a managed DB service is probably EASIER, but that doesn’t mean that it’s always possible/best solution. 

  • What if you already have a k8s cluster with spare nodes and you don’t want to spend additional charges on a managed db service when you can run your db for free. 

  • What if you don’t want to setup networking between your cluster and a managed db. 

  • What if you are not on the cloud and you are running kubernetes in your DC and have no access to cloud. 

2. The answer to this question is a DEFINITE YES. That’s the whole point of separating volumes from pods/processes. Think of volumes as your hard disk on your pc and pods as a process on your desktop. You can start/terminate/fail a process, but the disk is there and the process knows where to find what it needs each time. Pods can die for a various reason, but k8s control plane can bring it back on and as soon as it comes back on, it can attempt to reclaim the volume, again depending on the arch of your service/deployment.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?