I'm crafting a custom REDIS StatefulSet yaml. So far i've succedded in deploying the application but that is something wrong with the REDIS SLAVE. It cant find the master, and i'm not guessing the reason why the DNS configuration is wrong.
My StatefulSet looks like this:
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: redis-server
namespace: scm
labels:
app.k8s/name: redis
app.k8s/instance: server
spec:
replicas: 3
serviceName: redis-server
selector:
matchLabels:
app.k8s/name: redis
app.k8s/instance: server
template:
metadata:
labels:
app.k8s/name: redis
app.k8s/instance: server
spec:
containers:
- name: redis-server
image: redis:6.0.9-alpine
imagePullPolicy: IfNotPresent
command: ["redis-server", "/data/conf/redis.conf"]
ports:
- name: redis
containerPort: 6379
and a headless service that looks like:
apiVersion: v1
kind: Service
metadata:
name: redis-server-headless
namespace: scm
labels:
app.k8s/name: redis
app.k8s/instance: server
app.k8s/part-of: gitlab
spec:
type: ClusterIP
clusterIP: None
publishNotReadyAddresses: true
ports:
- name: server
port: 6379
protocol: TCP
targetPort: redis
selector:
app.k8s/name: redis
app.k8s/instance: server
When i do a nslookup redis-server-headless
i can find the IP addresses but when i try to ping redis-server-0.redis-server-headless
or ping redis-server-0.redis-server
i get a bad address error message.
What am i missing?
Your serviceName
of of redis statefuleset should be redis-server-headless
.