Skip to content

Commit c137b48

Browse files
committed
feat(rancher): remove haproxy
Add sentinel port and nodes
1 parent d3a9c96 commit c137b48

File tree

2 files changed

+210
-0
lines changed

2 files changed

+210
-0
lines changed
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
version: '2'
2+
3+
services:
4+
redis:
5+
image: ${REDIS_VERSION}
6+
environment:
7+
REDIS_PASSWORD: '${REDIS_PASSWORD}'
8+
ports:
9+
- ${REDIS_PORT}:6379/tcp
10+
stdin_open: true
11+
tty: true
12+
labels:
13+
{{- if ne .Values.REDIS_SERVER_HOST_LABEL ""}}
14+
io.rancher.scheduler.affinity:host_label: ${REDIS_SERVER_HOST_LABEL}
15+
{{- end}}
16+
io.rancher.container.pull_image: always
17+
io.rancher.sidekicks: redis-config{{- if ne .Values.REDIS_VOLUME_PATH ""}}, redis-data{{- end}}
18+
io.rancher.scheduler.affinity:container_label_ne: io.rancher.stack_service.name=$${stack_name}/$${service_name}
19+
io.rancher.container.hostname_override: container_name
20+
volumes_from:
21+
- redis-config
22+
{{- if ne .Values.REDIS_VOLUME_PATH ""}}
23+
- redis-data
24+
{{- end}}
25+
entrypoint: /opt/redis/scripts/server-entrypoint.sh
26+
command:
27+
- "redis-server"
28+
- "/usr/local/etc/redis/redis.conf"
29+
30+
sentinel:
31+
image: ${REDIS_VERSION}
32+
environment:
33+
REDIS_PASSWORD: '${REDIS_PASSWORD}'
34+
SENTINEL_QUORUM: '${SENTINEL_QUORUM}'
35+
SENTINEL_DOWN_AFTER: '${SENTINEL_DOWN_AFTER}'
36+
SENTINEL_FAILOVER: '${SENTINEL_FAILOVER}'
37+
ports:
38+
- ${SENTINEL_PORT}:26379/tcp
39+
stdin_open: true
40+
tty: true
41+
labels:
42+
io.rancher.container.pull_image: always
43+
{{- if ne .Values.REDIS_SENTINEL_HOST_LABEL ""}}
44+
io.rancher.scheduler.affinity:host_label: ${REDIS_SENTINEL_HOST_LABEL}
45+
{{- end}}
46+
io.rancher.sidekicks: sentinel-config{{- if ne .Values.SENTINEL_VOLUME_PATH ""}}, sentinel-data{{- end}}
47+
io.rancher.scheduler.affinity:container_label_ne: io.rancher.stack_service.name=$${stack_name}/$${service_name}
48+
io.rancher.container.hostname_override: container_name
49+
volumes_from:
50+
- sentinel-config
51+
{{- if ne .Values.SENTINEL_VOLUME_PATH ""}}
52+
- sentinel-data
53+
{{- end}}
54+
entrypoint: /opt/redis/scripts/sentinel-entrypoint.sh
55+
command:
56+
- "redis-server"
57+
- "/usr/local/etc/redis/sentinel.conf"
58+
- "--sentinel"
59+
60+
redis-config:
61+
image: lgatica/redis-config:1
62+
environment:
63+
REDIS_PASSWORD: '${REDIS_PASSWORD}'
64+
stdin_open: true
65+
tty: true
66+
volumes:
67+
- /usr/local/etc/redis
68+
- /opt/redis/scripts
69+
labels:
70+
{{- if ne .Values.REDIS_SERVER_HOST_LABEL ""}}
71+
io.rancher.scheduler.affinity:host_label: ${REDIS_SERVER_HOST_LABEL}
72+
{{- end}}
73+
io.rancher.container.pull_image: always
74+
io.rancher.container.hostname_override: container_name
75+
io.rancher.container.start_once: 'true'
76+
entrypoint: /bin/true
77+
78+
sentinel-config:
79+
image: lgatica/redis-config:2
80+
environment:
81+
REDIS_PASSWORD: '${REDIS_PASSWORD}'
82+
stdin_open: true
83+
tty: true
84+
volumes:
85+
- /usr/local/etc/redis
86+
- /opt/redis/scripts
87+
labels:
88+
{{- if ne .Values.REDIS_SENTINEL_HOST_LABEL ""}}
89+
io.rancher.scheduler.affinity:host_label: ${REDIS_SENTINEL_HOST_LABEL}
90+
{{- end}}
91+
io.rancher.container.pull_image: always
92+
io.rancher.container.hostname_override: container_name
93+
io.rancher.container.start_once: 'true'
94+
entrypoint: /bin/true
95+
96+
{{- if .Values.REDIS_VOLUME_PATH}}
97+
redis-data:
98+
image: busybox
99+
labels:
100+
{{- if ne .Values.REDIS_SERVER_HOST_LABEL ""}}
101+
io.rancher.scheduler.affinity:host_label: ${REDIS_SERVER_HOST_LABEL}
102+
{{- end}}
103+
io.rancher.container.hostname_override: container_name
104+
io.rancher.container.start_once: 'true'
105+
volumes:
106+
- {{.Values.REDIS_VOLUME_PATH}}:/data
107+
entrypoint: /bin/true
108+
{{- end}}
109+
110+
{{- if .Values.SENTINEL_VOLUME_PATH}}
111+
sentinel-data:
112+
image: busybox
113+
labels:
114+
{{- if ne .Values.REDIS_SENTINEL_HOST_LABEL ""}}
115+
io.rancher.scheduler.affinity:host_label: ${REDIS_SENTINEL_HOST_LABEL}
116+
{{- end}}
117+
io.rancher.container.hostname_override: container_name
118+
io.rancher.container.start_once: 'true'
119+
volumes:
120+
- {{.Values.SENTINEL_VOLUME_PATH}}:/data
121+
entrypoint: /bin/true
122+
{{- end}}
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
---
2+
.catalog:
3+
name: "Redis Cluster"
4+
version: "v2.0.0"
5+
description: |
6+
Redis Sentinel Cluster
7+
questions:
8+
- variable: REDIS_VERSION
9+
label: "Redis version"
10+
type: enum
11+
options:
12+
- redis:4-alpine
13+
- redis:3-alpine
14+
default: redis:4-alpine
15+
required: true
16+
- variable: REDIS_PASSWORD
17+
label: "Redis auth password"
18+
type: password
19+
required: true
20+
- variable: REDIS_NODES
21+
label: Number of redis nodes
22+
description: Number of Redis server nodes to launch.
23+
type: int
24+
default: 1
25+
required: true
26+
- variable: SENTINEL_NODES
27+
label: Number of sentinel nodes
28+
description: Number of Sentinel nodes to launch.
29+
type: int
30+
default: 1
31+
required: true
32+
- variable: REDIS_PORT
33+
label: "Redis port"
34+
type: int
35+
default: 6379
36+
required: true
37+
- variable: SENTINEL_PORT
38+
label: "Sentinel port"
39+
type: int
40+
default: 26379
41+
required: true
42+
- variable: REDIS_SERVER_HOST_LABEL
43+
label: "Host label for redis server node (Optional)"
44+
type: string
45+
required: false
46+
- variable: REDIS_SENTINEL_HOST_LABEL
47+
label: "Host label for sentinel (Optional)"
48+
type: string
49+
required: false
50+
- variable: SENTINEL_QUORUM
51+
label: Sentinel quorum
52+
description: |
53+
The number of Sentinel processes that need to detect an error condition in order for a master to be flagged as ODOWN
54+
type: int
55+
default: 2
56+
required: true
57+
- variable: SENTINEL_DOWN_AFTER
58+
label: Sentinel down-after-milliseconds
59+
description: |
60+
The time in milliseconds an instance should not be reachable for a Sentinel starting to think it is down.
61+
type: int
62+
default: 1000
63+
required: true
64+
- variable: SENTINEL_FAILOVER
65+
label: Sentinel failover-timeout
66+
description: The time to failover the same master again.
67+
type: int
68+
default: 1000
69+
required: true
70+
- variable: REDIS_VOLUME_PATH
71+
label: Volume Name of server nodes (Optional)
72+
description: To store the redis data.
73+
type: string
74+
required: false
75+
- variable: SENTINEL_VOLUME_PATH
76+
label: Volume Name of sentinel nodes (Optional)
77+
description: To store the sentinel data.
78+
type: string
79+
required: false
80+
81+
version: '2'
82+
services:
83+
sentinel:
84+
scale: ${SENTINEL_NODES}
85+
retain_ip: true
86+
redis:
87+
scale: ${REDIS_NODES}
88+
retain_ip: true

0 commit comments

Comments
 (0)