我正在制作一个自定义 REDIS StatefulSet yaml。到目前为止,我已经成功部署了应用程序,但是 REDIS SLAVE 有问题。它找不到主人,我没有猜测DNS配置错误的原因。
我的 StatefulSet 看起来像这样:
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
和一个看起来像这样的无头服务:
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
当我这样做时,nslookup redis-server-headless
我可以找到 IP 地址,但是当我尝试时,ping redis-server-0.redis-server-headless
或者ping redis-server-0.redis-server
我收到错误的地址错误消息。
我错过了什么?