skip to Main Content

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?

2

Answers


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

        containers:
      - name: 1st
        image: redis
    ...
      - name: 2nd
        image: app
    
    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search