We will create an example service within Kubernetes, to show you how you can connect to services, and use them to architect your code. Redis (https://redis.io) is a super-flexible data store that you may already be familiar with, and it is easy to use from both Python and Node.js.
Redis is already available as a container, and it is easily found on the Docker Hub (https://hub.docker.com/) as a container image. There are several options available, with the relevant tags listed on the Docker Hub web page:
We can use this image with the kubectl run
command to create a deployment, and then with the kubectl expose
command to create a service to map to the Pods within the deployment:
kubectl run redis --image=docker.io/redis:alpine
We will create a deployment named redis
, and through that deployment download the image and start running it. We can see the Pod operational:
kubectl get pods
NAME READY STATUS RESTARTS AGE
flask-1908233635-d6stj 1/1...