On my macOS (not using Minikube), I modeled a Kubernetes cluster after this , which means I completed this verbatim and in this order:
kubectl create -f ./redis/redis-service.yaml
kubectl create -f examples/storage/redis/redis-master.yaml
kubectl create -f examples/storage/redis/redis-sentinel-service.yaml
kubectl create -f examples/storage/redis/redis-controller.yaml
kubectl create -f examples/storage/redis/redis-sentinel-controller.yaml
kubectl scale rc redis
kubectl scale rc redis-sentinel
kubectl create -f web-deployment.yaml
The only difference in redis-proxy.yaml
I used the image image: kubernetes/redis-proxy
instead image: kubernetes/redis-proxy:v2
, because I could not pull out the latter.
These are the objects that I pass ioredis to create Redis instances (one for sessions and one for the main):
config.js
main: {
host: 'redis',
port: 6379,
db: 5
},
session: {
host: 'redis',
port: 6379,
db: 6
}
Error Logs:
In my web-3448218364-sf1q0
pod web client, I repeat this in the logs:
INFO: ctn/53 on web-3448218364-sf1q0: Connected to Redis event
WARN: ctn/53 on web-3448218364-sf1q0: Redis Connection Error: { [Error: read ECONNRESET] code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'read' }
INFO: ctn/53 on web-3448218364-sf1q0: Connected to Redis event
WARN: ctn/53 on web-3448218364-sf1q0: Redis Connection Error: { [Error: read ECONNRESET] code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'read' }
INFO: ctn/53 on web-3448218364-sf1q0: Connected to Redis event
WARN: ctn/53 on web-3448218364-sf1q0: Redis Connection Error: { [Error: read ECONNRESET] code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'read' }
WARN: ctn/53 on web-3448218364-sf1q0: Redis Connection Error: { [Error: connect ETIMEDOUT] errorno: 'ETIMEDOUT', code: 'ETIMEDOUT', syscall: 'connect' }
WARN: ctn/53 on web-3448218364-sf1q0: Redis Connection Error: { [Error: connect ETIMEDOUT] errorno: 'ETIMEDOUT', code: 'ETIMEDOUT', syscall: 'connect' }
WARN: ctn/53 on web-3448218364-sf1q0: Redis Connection Error: { [Error: connect ETIMEDOUT] errorno: 'ETIMEDOUT', code: 'ETIMEDOUT', syscall: 'connect' }
WARN: ctn/53 on web-3448218364-sf1q0: Redis Connection Error: { [Error: connect ETIMEDOUT] errorno: 'ETIMEDOUT', code: 'ETIMEDOUT', syscall: 'connect' }
INFO: ctn/53 on web-3448218364-sf1q0: Connected to Redis event
WARN: ctn/53 on web-3448218364-sf1q0: Redis Connection Error: { [Error: read ECONNRESET] code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'read' }
INFO: ctn/53 on web-3448218364-sf1q0: Connected to Redis event
In my Redis redis-proxy
pod, I repeat this in the logs:
Error connecting to read: dial tcp :0: connection refused
Cluster Information:
$ kubectl get svc
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes 10.91.240.1 <none> 443/TCP 2d
redis 10.91.251.170 <none> 6379/TCP 31m
redis-sentinel 10.91.250.118 <none> 26379/TCP 31m
web 10.91.240.16 <none> 80/TCP 31m
$ kubectl get po
NAME READY STATUS RESTARTS AGE
redis-2frd0 1/1 Running 0 34m
redis-master 2/2 Running 0 34m
redis-n4x6f 1/1 Running 0 34m
redis-proxy 1/1 Running 0 34m
redis-sentinel-k8tbl 1/1 Running 0 34m
redis-sentinel-kzd66 1/1 Running 0 34m
redis-sentinel-wlzsb 1/1 Running 0 34m
web-3448218364-sf1q0 1/1 Running 0 34m
$ kubectl get deploy
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
web 1 1 1 1 39m
1) Redis. redis-proxy
? , redis-service.yaml
:
apiVersion: v1
kind: Service
metadata:
name: redis
spec:
ports:
- port: 6379
targetPort: 6379
selector:
name: redis-proxy
role: proxy
, redis
6379, , . bash - web-3448218364-sf1q0
, printenv
REDIS_SERVICE_PORT=6379
REDIS_SERVICE_HOST=10.91.251.170
.
2) , dial tcp :0:
? Kubernetes "" " " redis
:
redis:6379 TCP
redis:0 TCP
0 TCP
? 0 TCP, , , , CLI kubectl get svc
.