I am using Redis-Sentinel Configuration along with redisinsight. I have three redis-sentinel so I created 3 services(Services and ExternalName Service for this.). I have 2 namespaces: redis, ingress-nginx. I created ingress controller in ingress-nginx namespace. Below are my yaml files.
ExternalName Service
apiVersion: v1
kind: Service
metadata:
name: redis-s0-external
namespace: ingress-nginx
spec:
type: ExternalName
externalName: redis-s0.redis.svc.cluster.local
---
apiVersion: v1
kind: Service
metadata:
name: redis-s1-external
namespace: ingress-nginx
spec:
type: ExternalName
externalName: redis-s1.redis.svc.cluster.local
---
apiVersion: v1
kind: Service
metadata:
name: redis-s2-external
namespace: ingress-nginx
spec:
type: ExternalName
externalName: redis-s2.redis.svc.cluster.local
Ingress-Controller
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: be-ingress
namespace: ingress-nginx
spec:
ingressClassName: nginx
rules:
- host: example.amazonaws.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: redisinsight-external
port:
number: 8001
- path: /redis0
pathType: Prefix
backend:
service:
name: redis-s0-external
port:
number: 26379
- path: /redis1
pathType: Prefix
backend:
service:
name: redis-s1-external
port:
number: 26379
- path: /redis2
pathType: Prefix
backend:
service:
name: redis-s2-external
port:
number: 26379
Redisinsight
apiVersion: v1
kind: Service
metadata:
name: redisinsight-service
namespace: redis
spec:
ports:
- protocol: TCP
name: redisinsight
port: 8001
targetPort: 8001
selector:
app: redisinsight
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: redisinsight-pv
spec:
capacity:
storage: 3Gi # Adjust the storage size as needed
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: gp2
hostPath:
path: /data/redisinsight-pv # Replace with the actual path on the host
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: redisinsight-pv-claim
labels:
app: redisinsight
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 2Gi
storageClassName: gp2
---
# RedisInsight deployment with name 'redisinsight'
apiVersion: apps/v1
kind: Deployment
metadata:
name: redisinsight #deployment name
namespace: redis
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: db
persistentVolumeClaim:
claimName: redisinsight-pv-claim
initContainers:
- name: init
image: busybox
command:
- /bin/sh
- '-c'
- |
chown -R 1001 /db
resources: {}
volumeMounts:
- name: db
mountPath: /db
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
containers:
- name: redisinsight #Container name (DNS_LABEL, unique)
image: redislabs/redisinsight:latest #repo/image
imagePullPolicy: IfNotPresent #Always pull image
volumeMounts:
- name: db #Pod volumes to mount into the container's filesystem. Cannot be updated.
mountPath: /db
ports:
- containerPort: 8001 #exposed container port and protocol
protocol: TCP
When : Ingress deployed in ingress-nginx namespace --> redisinsight working ; Ingress in redis namespace --> redis services working [not exactly working but getting some response in raw format on webpage].