-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmongo.yaml
More file actions
126 lines (126 loc) · 4.3 KB
/
Copy pathmongo.yaml
File metadata and controls
126 lines (126 loc) · 4.3 KB
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: mongo
namespace: default
labels:
app: mongo
spec:
serviceName: mongodb-service
replicas: 3
selector:
matchLabels:
app: mongo
template:
metadata:
labels:
app: mongo
spec:
terminationGracePeriodSeconds: 10
containers:
- name: mongo
image: mongo:6.0
resources:
limits:
memory: "512Mi"
cpu: "500m"
# env:
# - name: MONGO_INITDB_ROOT_USERNAME
# valueFrom:
# secretKeyRef:
# name: mongo-secret
# key: MONGO_USER
# - name: MONGO_INITDB_ROOT_PASSWORD
# valueFrom:
# secretKeyRef:
# name: mongo-secret
# key: MONGO_PASS
# - name: STATEFULSET_NAME
# valueFrom:
# fieldRef:
# fieldPath: metadata.name
command:
- mongod
- "--bind_ip_all"
# - "--keyFile"
# - "/etc/mongo/mongo-keyfile"
- "--replSet"
- anya-rs
# command:
# - "bash"
# - "-c"
# #the default cache size guidance is: "50% of RAM minus 1 GB, or 256 MB"
# # Which is why the wired tiger cache size is this way. This assumes 2gb of memory
# # on the host machine. The plan is to change 0.25 to a calculated value
# # by passing an environment variable that contains the host machines memory
# # and automatically "personalizing" mongo to the machine its running on
# - |
# mongod --wiredTigerCacheSizeGB 0.25 --bind_ip_all \
# --keyFile /etc/mongo/mongo-keyfile \
# --replSet anya-rs \
# --fork --logpath /var/log/mongod.log \
# &&
# if [ $STATEFULSET_NAME == "mongo-0" ];
# then
# initiated=0
# replica_exists=false
# while [ "$replica_exists" != true ]
# do
# # Need to check to make sure that the other pods are currently up
# initiated=`mongosh --quiet --eval 'rs.initiate({_id: "anya-rs", version: 1, members: [
# { _id: 0, host : "mongo-0.mongodb-service:27017" },
# { _id: 1, host : "mongo-1.mongodb-service:27017" },
# { _id: 2, host : "mongo-2.mongodb-service:27017" }
# ]})["ok"]'`;
# replica_exists=`mongosh --quiet --eval 'db.isMaster()["ismaster"]'`;
# # Shit we need to check rs status i think instead
# echo "Replica exists: " $replica_exists;
# sleep 2
# done
# # If everything else is workign then we need to create an admin user
# mongosh --eval "db.getSiblingDB('admin').createUser({
# user : \"$MONGO_USER\",
# pwd : \"$MONGO_PASSWORD\",
# roles: [ { role: 'root', db: 'admin' } ]
# });"
# echo "STATEFULSET_NAME: $STATEFULSET_NAME \n MACHINE_MEMORY: $MACHINE_MEMORY";
# fi
ports:
- containerPort: 27017
name: mongo
volumeMounts:
# - name: mongo-config
# mountPath: /etc/mongo/mongo-config.yaml
# subPath: mongo-config.yaml
- name: mongo-pvc
mountPath: /data/db
# - name: mongo-keyfile
# mountPath: /etc/mongo/mongo-keyfile
# subPath: mongo-keyfile
restartPolicy: Always
# volumes:
# - name: mongo-config
# configMap:
# name: mongo-config
# items:
# - key: mongo-config.yaml
# path: mongo-config.yaml
# - name: mongo-pvc
# persistentVolumeClaim:
# claimName: mongo-pvc
# - name: mongo-keyfile
# secret:
# secretName: mongo-keyfile
# defaultMode: 256
# items:
# - key: mongo-keyfile
# path: mongo-keyfile
volumeClaimTemplates:
- metadata:
name: mongo-pvc
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 1Gi
storageClassName: gp2