-2

I have a need to run two services within a container/POD ...

1. An App
2. Redis - the App uses it

Is it possible, say by making the Redis a Sidecar?

Shashank V
  • 10,007
  • 2
  • 25
  • 41
Naga Vijayapuram
  • 845
  • 7
  • 11
  • 1
    Are you sure that you want an redis instance per app instance? Shouldn't all app instances use the same redis-data? – Jonas Jan 26 '20 at 17:43

2 Answers2

1

you just need to make a two-container pod, something like this:

    containers:
  - name: 1st
    image: redis
...
  - name: 2nd
    image: app
Alex
  • 2,342
  • 1
  • 18
  • 30
0

You can make it if you want to tie the lifecycle of redis with single instance of your app. You just need to create a pod with multiple containers. You can access redis on localhost from your app if they are running in same pod.

https://kubernetes.io/docs/tasks/access-application-cluster/communicate-containers-same-pod-shared-volume/#creating-a-pod-that-runs-two-containers

apiVersion: v1
kind: Pod
metadata:
  name: two-containers
spec:
  containers:
  - name: app
    image: myapp
  - name: redis
    image: redis

Your question sounds more like an XY problem. Why not make redis as a separate pod and access it via a service? That way you can scale your app independently.

Shashank V
  • 10,007
  • 2
  • 25
  • 41