-
Notifications
You must be signed in to change notification settings - Fork 1
/
mongo.yaml
102 lines (102 loc) · 3.11 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: mongo
namespace: mongo
spec:
#podManagementPolicy: Parallel
replicas: 2
selector:
matchLabels:
role: mongo
serviceName: mongo
template:
metadata:
labels:
role: mongo
spec:
serviceAccountName: mongo-account
terminationGracePeriodSeconds: 30
nodeSelector:
agentpool: mongodb
containers:
- image: mongo:4.2
name: mongo
command: ["/bin/sh","-c"]
args: ["/home/mongodb/mongo-data-dir-permission.sh && docker-entrypoint.sh mongod --replSet=rs0 --dbpath=/var/lib/mongodb --bind_ip=0.0.0.0 --keyFile=/var/lib/mongoKey/mongo.key"]
env:
- name: MONGO_INITDB_ROOT_USERNAME
value: root
- name: MONGO_DATA_DIR
value: /var/lib/mongodb
- name: MONGO_INITDB_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: mongosecret
key: mongoRootPassword
- name: SECOND_USER_DB_PASSWORD
valueFrom:
secretKeyRef:
name: mongosecret
key: initDbPassword
ports:
- containerPort: 27017
resources:
limits:
memory: 14000Mi
cpu: 6000m
requests:
memory: 8000Mi
cpu: 4000m
volumeMounts:
- mountPath: /var/lib/mongodb
name: mongo-pvc
- name: mongoinit
mountPath: /docker-entrypoint-initdb.d
- name: mongopost
mountPath: /home/mongodb
- name: mongokey
mountPath: /var/lib/mongoKeyTemp
- name: mongo-sidecar
image: cvallance/mongo-k8s-sidecar:latest
env:
- name: MONGO_SIDECAR_POD_LABELS
value: "role=mongo"
- name: KUBE_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: KUBERNETES_MONGO_SERVICE_NAME
value: mongo
- name: MONGODB_USERNAME
value: root
- name: MONGODB_DATABASE
value: admin
- name: MONGODB_PASSWORD
valueFrom:
secretKeyRef:
name: mongosecret
key: mongoRootPassword
volumes:
- name: "mongoinit"
configMap:
name: "mongo-init"
defaultMode: 0755
- name: "mongopost"
configMap:
name: "mongo-scripts"
defaultMode: 0755
- name: "mongokey"
configMap:
name: "mongo-key"
defaultMode: 0755
volumeClaimTemplates:
- metadata:
name: mongo-pvc
spec:
accessModes:
- ReadWriteOnce
storageClassName: mongodb
resources:
requests:
storage: 20Gi