Skip to content

Commit 74ab69e

Browse files
committed
fix(volumes): change volumes to path
Rename services
1 parent 9624f32 commit 74ab69e

File tree

2 files changed

+59
-51
lines changed

2 files changed

+59
-51
lines changed

templates/redis/0/docker-compose.yml.tpl

Lines changed: 48 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: '2'
22

33
services:
4-
redis-server:
4+
redis:
55
image: ${REDIS_VERSION}
66
environment:
77
REDIS_PASSWORD: '${REDIS_PASSWORD}'
@@ -12,17 +12,20 @@ services:
1212
io.rancher.scheduler.affinity:host_label: ${REDIS_SERVER_HOST_LABEL}
1313
{{- end}}
1414
io.rancher.container.pull_image: always
15-
io.rancher.sidekicks: redis-server-config
15+
io.rancher.sidekicks: redis-config{{- if ne .Values.REDIS_VOLUME_PATH ""}}, redis-data{{- end}}
1616
io.rancher.scheduler.affinity:container_label_ne: io.rancher.stack_service.name=$${stack_name}/$${service_name}
1717
io.rancher.container.hostname_override: container_name
1818
volumes_from:
19-
- redis-server-config
19+
- redis-config
20+
{{- if ne .Values.REDIS_VOLUME_PATH ""}}
21+
- redis-data
22+
{{- end}}
2023
entrypoint: /opt/redis/scripts/server-entrypoint.sh
2124
command:
2225
- "redis-server"
2326
- "/usr/local/etc/redis/redis.conf"
2427

25-
redis-sentinel:
28+
sentinel:
2629
image: ${REDIS_VERSION}
2730
environment:
2831
REDIS_PASSWORD: '${REDIS_PASSWORD}'
@@ -36,17 +39,20 @@ services:
3639
{{- if ne .Values.REDIS_SENTINEL_HOST_LABEL ""}}
3740
io.rancher.scheduler.affinity:host_label: ${REDIS_SENTINEL_HOST_LABEL}
3841
{{- end}}
39-
io.rancher.sidekicks: redis-sentinel-config
42+
io.rancher.sidekicks: sentinel-config{{- if ne .Values.SENTINEL_VOLUME_PATH ""}}, sentinel-data{{- end}}
4043
io.rancher.container.hostname_override: container_name
4144
volumes_from:
42-
- redis-sentinel-config
45+
- sentinel-config
46+
{{- if ne .Values.SENTINEL_VOLUME_PATH ""}}
47+
- sentinel-data
48+
{{- end}}
4349
entrypoint: /opt/redis/scripts/sentinel-entrypoint.sh
4450
command:
4551
- "redis-server"
4652
- "/usr/local/etc/redis/sentinel.conf"
4753
- "--sentinel"
4854

49-
haproxy:
55+
redis-lb:
5056
image: rancher/lb-service-haproxy:v0.7.9
5157
ports:
5258
- ${REDIS_HAPROXY_PORT}:6379/tcp
@@ -57,7 +63,7 @@ services:
5763
io.rancher.container.agent.role: environmentAdmin
5864
io.rancher.container.create_agent: 'true'
5965

60-
redis-server-config:
66+
redis-config:
6167
image: lgatica/redis-config
6268
environment:
6369
REDIS_PASSWORD: '${REDIS_PASSWORD}'
@@ -66,12 +72,16 @@ services:
6672
volumes:
6773
- /usr/local/etc/redis
6874
- /opt/redis/scripts
69-
- redis-server:/data
7075
labels:
76+
{{- if ne .Values.REDIS_SERVER_HOST_LABEL ""}}
77+
io.rancher.scheduler.affinity:host_label: ${REDIS_SERVER_HOST_LABEL}
78+
{{- end}}
7179
io.rancher.container.pull_image: always
7280
io.rancher.container.hostname_override: container_name
7381
io.rancher.container.start_once: 'true'
74-
redis-sentinel-config:
82+
entrypoint: /bin/true
83+
84+
sentinel-config:
7585
image: lgatica/redis-config
7686
environment:
7787
REDIS_PASSWORD: '${REDIS_PASSWORD}'
@@ -80,27 +90,39 @@ services:
8090
volumes:
8191
- /usr/local/etc/redis
8292
- /opt/redis/scripts
83-
- redis-sentinel:/data
8493
labels:
94+
{{- if ne .Values.REDIS_SENTINEL_HOST_LABEL ""}}
95+
io.rancher.scheduler.affinity:host_label: ${REDIS_SENTINEL_HOST_LABEL}
96+
{{- end}}
8597
io.rancher.container.pull_image: always
8698
io.rancher.container.hostname_override: container_name
8799
io.rancher.container.start_once: 'true'
100+
entrypoint: /bin/true
88101

89-
{{- if or (.Values.REDIS_VOLUME_NAME) (.Values.SENTINEL_VOLUME_NAME)}}
90-
volumes:
91-
{{- if .Values.REDIS_VOLUME_NAME}}
92-
{{.Values.REDIS_VOLUME_NAME}}:
93-
external: true
94-
{{- if .Values.STORAGE_DRIVER}}
95-
driver: {{.Values.STORAGE_DRIVER}}
96-
{{- end}}
102+
{{- if .Values.REDIS_VOLUME_PATH}}
103+
redis-data:
104+
image: busybox
105+
labels:
106+
{{- if ne .Values.REDIS_SERVER_HOST_LABEL ""}}
107+
io.rancher.scheduler.affinity:host_label: ${REDIS_SERVER_HOST_LABEL}
108+
{{- end}}
109+
io.rancher.container.hostname_override: container_name
110+
io.rancher.container.start_once: 'true'
111+
volumes:
112+
- {{.Values.REDIS_VOLUME_PATH}}:/data
113+
entrypoint: /bin/true
97114
{{- end}}
98115

99-
{{- if .Values.SENTINEL_VOLUME_NAME}}
100-
{{.Values.SENTINEL_VOLUME_NAME}}:
101-
external: true
102-
{{- if .Values.STORAGE_DRIVER}}
103-
driver: {{.Values.STORAGE_DRIVER}}
104-
{{- end}}
116+
{{- if .Values.SENTINEL_VOLUME_PATH}}
117+
sentinel-data:
118+
image: busybox
119+
labels:
120+
{{- if ne .Values.REDIS_SENTINEL_HOST_LABEL ""}}
121+
io.rancher.scheduler.affinity:host_label: ${REDIS_SENTINEL_HOST_LABEL}
122+
{{- end}}
123+
io.rancher.container.hostname_override: container_name
124+
io.rancher.container.start_once: 'true'
125+
volumes:
126+
- {{.Values.SENTINEL_VOLUME_PATH}}:/data
127+
entrypoint: /bin/true
105128
{{- end}}
106-
{{- end }}

templates/redis/0/rancher-compose.yml

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -55,43 +55,29 @@
5555
type: int
5656
default: 1000
5757
required: true
58-
- variable: REDIS_VOLUME_NAME
58+
- variable: REDIS_VOLUME_PATH
5959
label: Volume Name of server nodes (Optional)
60-
description: |
61-
To store the redis data.
62-
By default this will be a (host scoped) named Docker volume. See "Persistent Storage Driver" for other options.
60+
description: To store the redis data.
6361
type: string
6462
required: false
65-
- variable: SENTINEL_VOLUME_NAME
63+
- variable: SENTINEL_VOLUME_PATH
6664
label: Volume Name of sentinel nodes (Optional)
67-
description: |
68-
To store the sentinel data.
69-
By default this will be a (host scoped) named Docker volume. See "Persistent Storage Driver" for other options.
65+
description: To store the sentinel data.
7066
type: string
7167
required: false
72-
- variable: STORAGE_DRIVER
73-
label: Volume Storage Driver (Optional)
74-
description: |
75-
To use a stack scoped volume backed by a persistent storage service, select the name
76-
of an existing storage driver (see `Infrastructure -> Storage`). This also requires "Volume Name" to be set.
77-
type: enum
78-
options:
79-
- local
80-
- rancher-nfs
81-
required: false
8268

8369
version: '2'
8470
services:
85-
redis-sentinel:
71+
sentinel:
8672
scale: 1
87-
start_on_create: true
88-
haproxy:
73+
retain_ip: true
74+
redis-lb:
8975
scale: 1
90-
start_on_create: true
76+
retain_ip: true
9177
lb_config:
9278
certs: []
9379
config: |-
94-
backend redis-server
80+
backend redis
9581
option tcplog
9682
option tcp-check
9783
tcp-check send AUTH\ ${REDIS_PASSWORD}\r\n
@@ -105,7 +91,7 @@ services:
10591
port_rules:
10692
- priority: 1
10793
protocol: tcp
108-
service: redis-server
94+
service: redis
10995
source_port: ${REDIS_HAPROXY_PORT}
11096
target_port: 6379
11197
health_check:
@@ -117,6 +103,6 @@ services:
117103
interval: 2000
118104
strategy: recreate
119105
reinitializing_timeout: 60000
120-
redis-server:
106+
redis:
121107
scale: ${REDIS_NODES}
122108
retain_ip: true

0 commit comments

Comments
 (0)