Reputation: 639
I want to create specific version of redis to be used as a cache. Task:
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
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"]
?Upvotes: 0
Views: 313
Reputation: 1083
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.
Upvotes: 0
Reputation: 44549
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.
Upvotes: 1