How to keep redis database pod running in kubernetes

437 views Asked by At

I created a pod which serve redis database and i want to leave it running when complete. Containers are meant to run to completion. Do i need to create and infinity loop which never ends ?

apiVersion: v1
kind: Pod
metadata:
  name: redis
spec:
  containers:
  - name: redis
    image: lfccncf/redis:latest
    command: [ "/bin/bash", "-c", "--" ]
    args: [ "while true; do sleep 30; done;" ]
2

There are 2 answers

0
Arghya Sadhu On BEST ANSWER

If the container has a process which keeps running then you don't need to use infinite loop. In this case the container will run the redis process.The dockerfile will have the RUN command to execute the process.

Also I suggest you use a standard redis image or a helm chart to deploy redis.

Here is guide on running PHP guestbook app with redis

0
Miffa Young On

it is no need

command: [ "/bin/bash", "-c", "--" ]
args: [ "while true; do sleep 30; done;" ]enter code here

delete it