Install on Kubernetes
How to install RedisInsight on Kubernetes
This tutorial shows how to install RedisInsight on Kubernetes (K8s). This is an easy way to use RedisInsight with a Redis Enterprise K8s deployment.
Create the RedisInsight deployment and service
Below is an annotated YAML file that will create a RedisInsight deployment and a service in a K8s cluster.
- Create a new file named
redisinsight.yaml
with the content below.
# RedisInsight service with name 'redisinsight-service'
apiVersion: v1
kind: Service
metadata:
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: LoadBalancer
ports:
- port: 80
targetPort: 5540
selector:
app: redisinsight
---
# RedisInsight deployment with name 'redisinsight'
apiVersion: apps/v1
kind: Deployment
metadata:
name: redisinsight #deployment name
labels:
app: redisinsight #deployment label
spec:
replicas: 1 #a single replica pod
selector:
matchLabels:
app: redisinsight #which pods is the deployment managing, as defined by the pod template
template: #pod template
metadata:
labels:
app: redisinsight #label for pod/s
spec:
containers:
- name: redisinsight #Container name (DNS_LABEL, unique)
image: redis/redisinsight:latest #repo/image
imagePullPolicy: IfNotPresent #Installs the latest RedisInsight version
volumeMounts:
- name: redisinsight #Pod volumes to mount into the container's filesystem. Cannot be updated.
mountPath: /data
ports:
- containerPort: 5540 #exposed container port and protocol
protocol: TCP
volumes:
- name: redisinsight
emptyDir: {} # node-ephemeral volume https://kubernetes.io/docs/concepts/storage/volumes/#emptydir
- Create the RedisInsight deployment and service:
kubectl apply -f redisinsight.yaml
- Once the deployment and service are successfully applied and complete, access RedisInsight. This can be accomplished by using the
<external-ip>
of the service we created to reach RedisInsight.
$ kubectl get svc redisinsight-service
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
redisinsight-service <cluster-ip> <external-ip> 80:32143/TCP 1m
- If you are using minikube, run
minikube list
to list the service and access RedisInsight athttp://<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 | |
|-------------|----------------------|--------------|---------------------------------------------|
Create the RedisInsight deployment with persistant storage
Below is an annotated YAML file that will create a RedisInsight
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.
- Create a new file
redisinsight.yaml
with the content below.
# RedisInsight service with name 'redisinsight-service'
apiVersion: v1
kind: Service
metadata:
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: LoadBalancer
ports:
- port: 80
targetPort: 5540
selector:
app: redisinsight
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: redisinsight-pv-claim
labels:
app: redisinsight
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 2Gi
storageClassName: default
---
# RedisInsight deployment with name 'redisinsight'
apiVersion: apps/v1
kind: Deployment
metadata:
name: redisinsight #deployment name
labels:
app: redisinsight #deployment label
spec:
replicas: 1 #a single replica pod
strategy:
type: Recreate
selector:
matchLabels:
app: redisinsight #which pods is the deployment managing, as defined by the pod template
template: #pod template
metadata:
labels:
app: redisinsight #label for pod/s
spec:
volumes:
- name: redisinsight
persistentVolumeClaim:
claimName: redisinsight-pv-claim
initContainers:
- name: init
image: busybox
command:
- /bin/sh
- '-c'
- |
chown -R 1001 /data
resources: {}
volumeMounts:
- name: redisinsight
mountPath: /data
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
containers:
- name: redisinsight #Container name (DNS_LABEL, unique)
image: redis/redisinsight:latest #repo/image
imagePullPolicy: IfNotPresent #Always pull image
volumeMounts:
- name: redisinsight #Pod volumes to mount into the container's filesystem. Cannot be updated.
mountPath: /data
ports:
- containerPort: 5540 #exposed container port and protocol
protocol: TCP
- Create the RedisInsight deployment and service.
kubectl apply -f redisinsight.yaml
Create the RedisInsight deployment without a service.
Below is an annotated YAML file that will create a RedisInsight deployment in a K8s cluster.
- Create a new file redisinsight.yaml with the content below
apiVersion: apps/v1
kind: Deployment
metadata:
name: redisinsight #deployment name
labels:
app: redisinsight #deployment label
spec:
replicas: 1 #a single replica pod
selector:
matchLabels:
app: redisinsight #which pods is the deployment managing, as defined by the pod template
template: #pod template
metadata:
labels:
app: redisinsight #label for pod/s
spec:
containers:
- name: redisinsight #Container name (DNS_LABEL, unique)
image: redis/redisinsight:latest #repo/image
imagePullPolicy: IfNotPresent #Always pull image
env:
# 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_HOST
value: "0.0.0.0"
- name: RI_APP_PORT
value: "5540"
volumeMounts:
- name: redisinsight #Pod volumes to mount into the container's filesystem. Cannot be updated.
mountPath: /data
ports:
- containerPort: 5540 #exposed container port and protocol
protocol: TCP
livenessProbe:
httpGet:
path : /healthcheck/ # exposed RI endpoint for healthcheck
port: 5540 # exposed container port
initialDelaySeconds: 5 # number of seconds to wait after the container starts to perform liveness probe
periodSeconds: 5 # period in seconds after which liveness probe is performed
failureThreshold: 1 # number of liveness probe failures after which container restarts
volumes:
- name: redisinsight
emptyDir: {} # node-ephemeral volume https://kubernetes.io/docs/concepts/storage/volumes/#emptydir
- Create the RedisInsight deployment
kubectl apply -f redisinsight.yaml
- Once the deployment has been successfully applied and the deployment is complete, access RedisInsight. 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