How to install Redis Insight on Kubernetes
| Redis Insight |
|---|
This tutorial shows how to install Redis Insight on Kubernetes (K8s). This is an easy way to use Redis Insight with a Redis Enterprise K8s deployment.
Below is an annotated YAML file that will create a Redis Insight deployment and a service in a K8s cluster.
redisinsight.yaml with the content below.# Redis Insight service with name 'redisinsight-service'apiVersion:v1kind:Servicemetadata:name:redisinsight-service # name should not be 'redisinsight'# since the service creates# environment variables that# conflicts with redisinsight# application's environment# variables `RI_APP_HOST` and# `RI_APP_PORT`spec:type:LoadBalancerports:- port:80targetPort:5540selector:app:redisinsight---# Redis Insight deployment with name 'redisinsight'apiVersion:apps/v1kind:Deploymentmetadata:name:redisinsight#deployment namelabels:app:redisinsight#deployment labelspec:replicas:1#a single replica podselector:matchLabels:app:redisinsight#which pods is the deployment managing, as defined by the pod templatetemplate:#pod templatemetadata:labels:app:redisinsight#label for pod/sspec:containers:- name:redisinsight#Container name (DNS_LABEL, unique)image:redis/redisinsight:latest#repo/imageimagePullPolicy:IfNotPresent#Installs the latest Redis Insight versionvolumeMounts:- name:redisinsight#Pod volumes to mount into the container's filesystem. Cannot be updated.mountPath:/dataports:- containerPort:5540#exposed container port and protocolprotocol:TCPvolumes:- name:redisinsightemptyDir:{}# node-ephemeral volume https://kubernetes.io/docs/concepts/storage/volumes/#emptydirkubectl apply -f redisinsight.yaml
<external-ip> of the service we created to reach Redis Insight.$ kubectl get svc redisinsight-service
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
redisinsight-service <cluster-ip> <external-ip> 80:32143/TCP 1m
minikube list to list the service and access Redis Insight at http://<minikube-ip>:<minikube-service-port>.$ minikube list
|-------------|----------------------|--------------|---------------------------------------------|
| NAMESPACE | NAME | TARGET PORT | URL |
|-------------|----------------------|--------------|---------------------------------------------|
| default | kubernetes | No node port | |
| default | redisinsight-service | 80 | http://<minikube-ip>:<minikubeservice-port> |
| kube-system | kube-dns | No node port | |
|-------------|----------------------|--------------|---------------------------------------------|
Below is an annotated YAML file that will create a Redis Insight
deployment in a K8s cluster. It will assign a peristent volume created from a volume claim template.
Write access to the container is configured in an init container. When using deployments
with persistent writeable volumes, it's best to set the strategy to Recreate. Otherwise you may find yourself
with two pods trying to use the same volume.
redisinsight.yaml with the content below.# Redis Insight service with name 'redisinsight-service'apiVersion:v1kind:Servicemetadata:name:redisinsight-service # name should not be 'redisinsight'# since the service creates# environment variables that# conflicts with redisinsight# application's environment# variables `RI_APP_HOST` and# `RI_APP_PORT`spec:type:LoadBalancerports:- port:80targetPort:5540selector:app:redisinsight---apiVersion:v1kind:PersistentVolumeClaimmetadata:name:redisinsight-pv-claimlabels:app:redisinsightspec:accessModes:- ReadWriteOnceresources:requests:storage:2GistorageClassName:default---# Redis Insight deployment with name 'redisinsight'apiVersion:apps/v1kind:Deploymentmetadata:name:redisinsight#deployment namelabels:app:redisinsight#deployment labelspec:replicas:1#a single replica podstrategy:type:Recreateselector:matchLabels:app:redisinsight#which pods is the deployment managing, as defined by the pod templatetemplate:#pod templatemetadata:labels:app:redisinsight#label for pod/sspec:volumes:- name:redisinsightpersistentVolumeClaim:claimName:redisinsight-pv-claiminitContainers:- name:initimage:busyboxcommand:- /bin/sh- '-c'- | chown -R 1000 /dataresources:{}volumeMounts:- name:redisinsightmountPath:/dataterminationMessagePath:/dev/termination-logterminationMessagePolicy:Filecontainers:- name:redisinsight#Container name (DNS_LABEL, unique)image:redis/redisinsight:latest#repo/imageimagePullPolicy:IfNotPresent#Always pull imagevolumeMounts:- name:redisinsight#Pod volumes to mount into the container's filesystem. Cannot be updated.mountPath:/dataports:- containerPort:5540#exposed container port and protocolprotocol:TCPkubectl apply -f redisinsight.yaml
Below is an annotated YAML file that will create a Redis Insight deployment in a K8s cluster.
apiVersion:apps/v1kind:Deploymentmetadata:name:redisinsight# deployment namelabels:app:redisinsight# deployment labelspec:replicas:1# a single replica podselector:matchLabels:app:redisinsight# which pods is the deployment managing, as defined by the pod templatetemplate:# pod templatemetadata:labels:app:redisinsight# label for pod/sspec:containers:- name:redisinsight# Container name (DNS_LABEL, unique)image:redis/redisinsight:latest# repo/imageimagePullPolicy:IfNotPresent# Always pull imageenv:# If there's a service named 'redisinsight' that exposes the# deployment, we manually set `RI_APP_HOST` and# `RI_APP_PORT` to override the service environment# variables.- name:RI_APP_HOSTvalue:"0.0.0.0"- name:RI_APP_PORTvalue:"5540"volumeMounts:- name:redisinsight# Pod volumes to mount into the container's filesystem. Cannot be updated.mountPath:/dataports:- containerPort:5540# exposed container port and protocolprotocol:TCPlivenessProbe:# Probe to check container healthhttpGet:path:/api/health/# exposed RI endpoint for healthcheckport:5540# exposed container portinitialDelaySeconds:5# number of seconds to wait after the container starts to perform liveness probeperiodSeconds:5# period in seconds after which liveness probe is performedfailureThreshold:1# number of liveness probe failures after which container restartsvolumes:- name:redisinsightemptyDir:{}# node-ephemeral volume https://kubernetes.io/docs/concepts/storage/volumes/#emptydirkubectl apply -f redisinsight.yaml
RI_APP_HOST and RI_APP_PORT environment variables to override the environment variables created by the service.Once the deployment has been successfully applied and the deployment is complete, access Redis Insight. This can be accomplished by exposing the deployment as a K8s Service or by using port forwarding, as in the example below:
kubectl port-forward deployment/redisinsight 5540
Open your browser and point to http://localhost:5540