Marvin
Marvin

Reputation: 429

how to deploy multiple redis (none cluster) pod with different persistent volume in kubernetes

I am going to deploy my golang application in multiple pods, and in the other hand deploy multiple redis node each one with its own persistent volume, mean each one has different data, as showing in the below, can you please let me know how I can achieve that with Kubernetes please ? I will have one deployment for the go app with 3 replica since they are stateless that part is easy, but for the redis I will also have another deployment with 3 replica, but how I should let the kuebernetes connect each pod with different PV ?

----------              ----------
| Go-app |  ----------- | Redis-1 |
----------              ----------
                            |__ PV-1

----------              ----------
| Go-app |  ----------- | Redis-2 |
----------              ----------
                            |__ PV-2

----------              ----------
| Go-app |  ----------- | Redis-3 |
----------              ----------
                            |__ PV-3

Upvotes: 0

Views: 1293

Answers (1)

sachin
sachin

Reputation: 1360

You can install bitnami redis helm chart for creating each redis pod with its own persistence storage.You can configure all properties in the helm chart. But in this case the application pod will not be mapped to redis like in the diagram.The chart installs a statefulset redis . You can access the redis node by redis.namespace.svc.cluster.local .

In general its better to seperate your application deployment and redis deployment for scalability and availability .

However your particular use case can be achieved by creating a StatefulSet where both in each pod there will be two containers:

  1. Your main application container
  2. Redis container (as a sidecar)

You can then specify persistent volume for each pod in the StatefulSet Yaml. Here the concept to achieve your case is a Sidecar pattern where supporting containers can be deployed with main container in the same pod.Though it is recommended to create pods containing only one container. In case of requirements where high availability and scalability is required you should run redis as a seperate deployment and not a sidecar.

Hope this helps.

Upvotes: 1

Related Questions