Skip to content

Commit 9e699c9

Browse files
committed
chore(mongo): update mongo docker images
1 parent fbc05e1 commit 9e699c9

File tree

3 files changed

+350
-1
lines changed

3 files changed

+350
-1
lines changed
Lines changed: 214 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
---
2+
version: '2'
3+
4+
services:
5+
mongod:
6+
image: ${MONGO_VERSION}
7+
stdin_open: true
8+
tty: true
9+
volumes_from:
10+
- mongod-config
11+
- mongod-data
12+
labels:
13+
{{- if ne .Values.MONGOD_HOST_LABEL ""}}
14+
io.rancher.scheduler.affinity:host_label: ${MONGOD_HOST_LABEL}
15+
{{- end}}
16+
io.rancher.container.pull_image: always
17+
io.rancher.container.hostname_override: container_name
18+
io.rancher.scheduler.affinity:container_label_ne: io.rancher.stack_service.name=$${stack_name}/$${service_name}
19+
io.rancher.sidekicks: mongod-config, mongod-data
20+
environment:
21+
RS_NAME: '${MONGOD_RS_NAME}'
22+
MONGO_INITDB_ROOT_USERNAME: '${MONGO_INITDB_ROOT_USERNAME}'
23+
MONGO_INITDB_ROOT_PASSWORD: '${MONGO_INITDB_ROOT_PASSWORD}'
24+
{{- if and (eq .Values.MONGOS_ENABLED "true") (ne .Values.MONGOD_PORT "")}}
25+
ports:
26+
- '${MONGOD_PORT}:27017'
27+
{{- end}}
28+
entrypoint: /opt/rancher/bin/entrypoint-mongod.sh
29+
30+
mongod-config:
31+
image: lgatica/mongo-config
32+
stdin_open: true
33+
tty: true
34+
volumes:
35+
- /run/secrets
36+
- /opt/rancher/bin
37+
environment:
38+
MONGODB_KEYFILE_SECRET: '${MONGODB_KEYFILE}'
39+
labels:
40+
{{- if ne .Values.MONGOD_HOST_LABEL ""}}
41+
io.rancher.scheduler.affinity:host_label: ${MONGOD_HOST_LABEL}
42+
{{- end}}
43+
io.rancher.container.pull_image: always
44+
io.rancher.container.hostname_override: container_name
45+
io.rancher.container.start_once: 'true'
46+
47+
{{- if .Values.MONGOD_VOLUME_PATH}}
48+
mongod-data:
49+
image: busybox
50+
labels:
51+
{{- if ne .Values.MONGOD_HOST_LABEL ""}}
52+
io.rancher.scheduler.affinity:host_label: ${MONGOD_HOST_LABEL}
53+
{{- end}}
54+
io.rancher.container.hostname_override: container_name
55+
io.rancher.container.start_once: 'true'
56+
volumes:
57+
- {{.Values.MONGOD_VOLUME_PATH}}:/data/db
58+
entrypoint: /bin/true
59+
{{- end}}
60+
61+
{{- if eq .Values.ARBITER_ENABLED "true"}}
62+
arbiter:
63+
image: ${MONGO_VERSION}
64+
stdin_open: true
65+
tty: true
66+
volumes_from:
67+
- arbiter-config
68+
- arbiter-data
69+
labels:
70+
{{- if ne .Values.ARBITER_HOST_LABEL ""}}
71+
io.rancher.scheduler.affinity:host_label: ${ARBITER_HOST_LABEL}
72+
{{- end}}
73+
io.rancher.container.pull_image: always
74+
io.rancher.container.hostname_override: container_name
75+
io.rancher.sidekicks: arbiter-config, arbiter-data
76+
environment:
77+
RS_NAME: '${MONGOD_RS_NAME}'
78+
MONGO_INITDB_ROOT_USERNAME: '${MONGO_INITDB_ROOT_USERNAME}'
79+
MONGO_INITDB_ROOT_PASSWORD: '${MONGO_INITDB_ROOT_PASSWORD}'
80+
entrypoint: /opt/rancher/bin/entrypoint-arbiter.sh
81+
depends_on:
82+
- mongod
83+
84+
arbiter-config:
85+
image: lgatica/mongo-config
86+
stdin_open: true
87+
tty: true
88+
volumes:
89+
- /run/secrets
90+
- /opt/rancher/bin
91+
environment:
92+
MONGODB_KEYFILE_SECRET: '${MONGODB_KEYFILE}'
93+
labels:
94+
{{- if ne .Values.ARBITER_HOST_LABEL ""}}
95+
io.rancher.scheduler.affinity:host_label: ${ARBITER_HOST_LABEL}
96+
{{- end}}
97+
io.rancher.container.pull_image: always
98+
io.rancher.container.hostname_override: container_name
99+
io.rancher.container.start_once: 'true'
100+
101+
{{- if .Values.ARBITER_VOLUME_PATH}}
102+
arbiter-data:
103+
image: busybox
104+
labels:
105+
{{- if ne .Values.ARBITER_HOST_LABEL ""}}
106+
io.rancher.scheduler.affinity:host_label: ${ARBITER_HOST_LABEL}
107+
{{- end}}
108+
io.rancher.container.hostname_override: container_name
109+
io.rancher.container.start_once: 'true'
110+
volumes:
111+
- {{.Values.ARBITER_VOLUME_PATH}}:/data/db
112+
entrypoint: /bin/true
113+
{{- end}}
114+
{{- end}}
115+
116+
{{- if eq .Values.CONFIGSVR_ENABLED "true"}}
117+
configsvr:
118+
image: ${MONGO_VERSION}
119+
stdin_open: true
120+
tty: true
121+
volumes_from:
122+
- configsvr-config
123+
- configsvr-data
124+
labels:
125+
{{- if ne .Values.CONFIGSVR_HOST_LABEL ""}}
126+
io.rancher.scheduler.affinity:host_label: ${CONFIGSVR_HOST_LABEL}
127+
{{- end}}
128+
io.rancher.container.pull_image: always
129+
io.rancher.scheduler.affinity:container_label_ne: io.rancher.stack_service.name=$${stack_name}/$${service_name}
130+
io.rancher.container.hostname_override: container_name
131+
io.rancher.sidekicks: configsvr-config, configsvr-data
132+
environment:
133+
RS_NAME: '${CONFIGSVR_RS_NAME}'
134+
MONGO_INITDB_ROOT_USERNAME: '${MONGO_INITDB_ROOT_USERNAME}'
135+
MONGO_INITDB_ROOT_PASSWORD: '${MONGO_INITDB_ROOT_PASSWORD}'
136+
entrypoint: /opt/rancher/bin/entrypoint-configsvr.sh
137+
138+
configsvr-config:
139+
image: lgatica/mongo-config
140+
stdin_open: true
141+
tty: true
142+
volumes:
143+
- /run/secrets
144+
- /opt/rancher/bin
145+
environment:
146+
MONGODB_KEYFILE_SECRET: '${MONGODB_KEYFILE}'
147+
labels:
148+
{{- if ne .Values.CONFIGSVR_HOST_LABEL ""}}
149+
io.rancher.scheduler.affinity:host_label: ${CONFIGSVR_HOST_LABEL}
150+
{{- end}}
151+
io.rancher.container.pull_image: always
152+
io.rancher.container.hostname_override: container_name
153+
io.rancher.container.start_once: 'true'
154+
155+
{{- if .Values.CONFIGSVR_VOLUME_PATH}}
156+
configsvr-data:
157+
image: busybox
158+
labels:
159+
{{- if ne .Values.CONFIGSVR_HOST_LABEL ""}}
160+
io.rancher.scheduler.affinity:host_label: ${CONFIGSVR_HOST_LABEL}
161+
{{- end}}
162+
io.rancher.container.hostname_override: container_name
163+
io.rancher.container.start_once: 'true'
164+
volumes:
165+
- {{.Values.CONFIGSVR_VOLUME_PATH}}:/data/db
166+
entrypoint: /bin/true
167+
{{- end}}
168+
{{- end}}
169+
170+
{{- if eq .Values.MONGOS_ENABLED "true"}}
171+
mongos:
172+
image: ${MONGO_VERSION}
173+
stdin_open: true
174+
tty: true
175+
volumes_from:
176+
- mongos-config
177+
ports:
178+
- '${MONGOS_PORT}:27017'
179+
environment:
180+
MONGOD_RS_NAME: '${MONGOD_RS_NAME}'
181+
CONFIGSVR_RS_NAME: '${CONFIGSVR_RS_NAME}'
182+
MONGODB_DBNAME: '${MONGODB_DBNAME}'
183+
MONGO_INITDB_ROOT_USERNAME: '${MONGO_INITDB_ROOT_USERNAME}'
184+
MONGO_INITDB_ROOT_PASSWORD: '${MONGO_INITDB_ROOT_PASSWORD}'
185+
labels:
186+
{{- if ne .Values.MONGOS_HOST_LABEL ""}}
187+
io.rancher.scheduler.affinity:host_label: ${MONGOS_HOST_LABEL}
188+
{{- end}}
189+
io.rancher.container.pull_image: always
190+
io.rancher.scheduler.affinity:container_label_ne: io.rancher.stack_service.name=$${stack_name}/$${service_name}
191+
io.rancher.container.hostname_override: container_name
192+
io.rancher.sidekicks: mongos-config
193+
entrypoint: /opt/rancher/bin/entrypoint-mongos.sh
194+
depends_on:
195+
- mongod
196+
- configsvr
197+
198+
mongos-config:
199+
image: lgatica/mongo-config
200+
stdin_open: true
201+
tty: true
202+
volumes:
203+
- /run/secrets
204+
- /opt/rancher/bin
205+
environment:
206+
MONGODB_KEYFILE_SECRET: '${MONGODB_KEYFILE}'
207+
labels:
208+
{{- if ne .Values.MONGOS_HOST_LABEL ""}}
209+
io.rancher.scheduler.affinity:host_label: ${MONGOS_HOST_LABEL}
210+
{{- end}}
211+
io.rancher.container.pull_image: always
212+
io.rancher.container.hostname_override: container_name
213+
io.rancher.container.start_once: 'true'
214+
{{- end}}
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
---
2+
.catalog:
3+
name: "MongoDB Sharded"
4+
version: "v1.0.1"
5+
description: |
6+
MongoDB Sharded Cluster
7+
questions:
8+
- variable: MONGO_VERSION
9+
label: "MongoDB version"
10+
type: enum
11+
options:
12+
- mongo:3.6.1
13+
- mongo:3.4.10
14+
- mongo:3.2.18
15+
default: mongo:3.6.1
16+
required: true
17+
- variable: MONGODB_KEYFILE
18+
label: "MongoDB Keyfile"
19+
type: multiline
20+
required: true
21+
description: |
22+
Set a random strong passphrase. Generate with: openssl rand -base64 756
23+
- variable: MONGO_INITDB_ROOT_USERNAME
24+
label: "Username for admin user (Optional)"
25+
type: string
26+
default: "admin"
27+
required: false
28+
- variable: MONGO_INITDB_ROOT_PASSWORD
29+
label: "Password for admin user"
30+
type: password
31+
required: true
32+
- variable: MONGODB_DBNAME
33+
label: "Database name (Optional)"
34+
type: string
35+
required: false
36+
- variable: MONGOS_PORT
37+
label: "Mongos port"
38+
type: int
39+
required: true
40+
default: "27017"
41+
- variable: MONGOD_PORT
42+
label: "Mongod port (Optional)"
43+
type: int
44+
required: false
45+
- variable: "ARBITER_ENABLED"
46+
label: "Enable Arbiter"
47+
description: "Enable Arbiter for Mongod ReplicaSet."
48+
type: boolean
49+
required: true
50+
default: true
51+
- variable: "CONFIGSVR_ENABLED"
52+
label: "Enable Configsvr"
53+
description: "Enable Configsvr for Sharded."
54+
type: boolean
55+
required: true
56+
default: true
57+
- variable: "MONGOS_ENABLED"
58+
label: "Enable Mongos"
59+
description: "Enable Mongos for Sharded."
60+
type: boolean
61+
required: true
62+
default: true
63+
- variable: "MONGOD_SCALE"
64+
label: "Mongod Scale"
65+
description: |
66+
Number of Mongod nodes to launch. Only one node is scheduled to each
67+
host. Recommended 2.
68+
type: int
69+
required: true
70+
default: 2
71+
- variable: "CONFIGSVR_SCALE"
72+
label: "Configsvr Scale"
73+
description: |
74+
Number of Configsvr nodes to launch. Only one node is scheduled to each
75+
host. Recommended 3.
76+
type: int
77+
required: true
78+
default: 3
79+
- variable: MONGOD_RS_NAME
80+
label: "Mongod ReplicaSet name"
81+
type: string
82+
required: true
83+
default: "rs1"
84+
- variable: CONFIGSVR_RS_NAME
85+
label: "Configsvr ReplicaSet name"
86+
type: string
87+
required: true
88+
default: "configsvr_rs1"
89+
- variable: MONGOD_HOST_LABEL
90+
label: "Host label for mongod nodes (Optional)"
91+
type: string
92+
required: false
93+
- variable: ARBITER_HOST_LABEL
94+
label: "Host label for arbiter nodes (Optional)"
95+
type: string
96+
required: false
97+
- variable: CONFIGSVR_HOST_LABEL
98+
label: "Host label for configsvr nodes (Optional)"
99+
type: string
100+
required: false
101+
- variable: MONGOS_HOST_LABEL
102+
label: "Host label for mongos nodes (Optional)"
103+
type: string
104+
required: false
105+
- variable: MONGOD_VOLUME_PATH
106+
label: Volume path of mongod nodes (Optional)
107+
description: To store the mongod data.
108+
type: string
109+
required: false
110+
- variable: ARBITER_VOLUME_PATH
111+
label: Volume path of arbiter nodes (Optional)
112+
description: To store the arbiter data.
113+
type: string
114+
required: false
115+
- variable: CONFIGSVR_VOLUME_PATH
116+
label: Volume path of configsvr nodes (Optional)
117+
description: To store the configsvr data.
118+
type: string
119+
required: false
120+
121+
version: '2'
122+
services:
123+
mongod:
124+
scale: ${MONGOD_SCALE}
125+
start_on_create: true
126+
retain_ip: true
127+
configsvr:
128+
scale: ${CONFIGSVR_SCALE}
129+
start_on_create: true
130+
retain_ip: true
131+
mongos:
132+
scale: 1
133+
start_on_create: true
134+
retain_ip: true

templates/mongodb/config.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
---
12
name: MongoDB Sharded
23
description: |
34
MongoDB Sharded Cluster
4-
version: v1.0.0
5+
version: v1.0.1
56
category: Databases
67
maintainer: Leonardo Gatica <[email protected]>
78
projectURL: http://github.com/lgaticaq/mongo-sharded-rancher

0 commit comments

Comments
 (0)