skip to Main Content

I want to create specific version of redis to be used as a cache. Task:

  • Pod must run in web namespace
  • Pod name should be cache
  • Image name is lfccncf/redis with the 4.0-alpine tag
  • Expose port 6379
  • The pods need to be running after complete

This are my steps:

  • k create ns web
  • k -n web run cache --image=lfccncf/redis:4.0-alpine --port=6379 --dry-run=client-o yaml > pod1.yaml
  • vi pod1.yaml
  • pod looks like this
    enter image description here
  • k create -f pod1.yaml
    When the expose service name is not define is this right command to fully complete the task ?
    k expose pod cache --port=6379 --target-port=6379.
    Is it the best way to keep pod running using command like this command: ["/bin/sh", "-ec", "sleep 1000"] ?

2

Answers


  1. You should not use sleep to keep a redis pod running. As long as the redis process runs in the container the pod will be running.

    Login or Signup to reply.
  2. The best way to go about it is to take a stable helm chart from https://hub.helm.sh/charts/stable/redis-ha. Do a helm pull and modify the values as you need.
    Redis should be definde as a Statefulset for various reasons. You could also do a

    mkdir my-redis
    helm fetch --untar --untardir . 'stable/redis' #makes a directory called redis 
    helm template --output-dir './my-redis' './redis' #redis dir (local helm chart), export to my-redis dir
    

    then use Kustomise if you like.

    You will notice that a redis deployment definition is not so trivial when you see how much code there is in the stable chart.

    You can then expose it in various ways, but normally you need the access only within the cluster.
    If you need a fast way to test from outside the cluster or use it as a development environment check the official ways to do that.

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