-
Notifications
You must be signed in to change notification settings - Fork 0
/
mongo.yaml
54 lines (54 loc) · 1.41 KB
/
mongo.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: mongo
spec:
serviceName: "mongo"
replicas: 1
selector:
matchLabels:
role: mongo
template:
metadata:
labels:
role: mongo
environment: test
spec:
terminationGracePeriodSeconds: 10
containers:
- name: mongo
image: mongo
command:
- /bin/sh
- -c
- >
mongod --replSet rs1 --bind_ip 0.0.0.0
# lifecycle:
# postStart:
# exec:
# command:
# - /bin/sh
# - -c
# - >
# sleep 4;
# if [ "$HOSTNAME" = "mongo-0" ]; then
# mongo --eval 'rs.initiate();';
# sleep 6;
# mongo --eval 'db = db.getSiblingDB("admin"); db.createUser({ user: "admin", pwd: "superpuper", roles: [{ role: "root", db: "admin" }]});';
# fi;
ports:
- containerPort: 27017
volumeMounts:
- name: mongo-key
mountPath: "/etc/secrets-volume"
readOnly: true
- name: mongo-pvc
mountPath: /data/db
volumes:
- name: mongo-key
secret:
defaultMode: 256
secretName: mongo-key
- name: mongo-pvc
persistentVolumeClaim:
claimName: mongo-pvc