forked from mjy8/MongoDB-in-Kubernetes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scalemongodbShards.yaml
108 lines (108 loc) · 2.75 KB
/
scalemongodbShards.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
103
104
105
106
107
108
apiVersion: v1
kind: Service
metadata:
name: mongodbshardservice2
labels:
name: mongoshard
spec:
ports:
- port: 27017
targetPort: 27017
clusterIP: None
selector:
role: mongoshard
---
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
name: mongodbshardstateful2
spec:
selector:
matchLabels:
role: mongoshard
serviceName: mongodbshardservice2
replicas: 1
updateStrategy:
type: RollingUpdate
template:
metadata:
labels:
role: mongoshard
replicaset: mongoshards2
spec:
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 50 #set to 100
podAffinityTerm:
labelSelector:
matchExpressions:
- key: replicaset
operator: In
values:
- mongoshards2
topologyKey: kubernetes.io/hostname
terminationGracePeriodSeconds: 10
containers:
- name: mongodshardcontainer
image: mongo:3.6.2
command:
- "numactl"
- "--interleave=all"
- "mongod"
- "--shardsvr"
- "--replSet"
- "mongoreplicaset2shard"
- "--bind_ip_all"
- "--port"
- "27017"
# - "--wiredTigerCacheSizeGB"
# - "0.5"
# - "--auth"
# - "--clusterAuthMode"
# - "keyFile" or can be "x509"
# - "--keyFile"
# - "keyfile path"
# - "--setParameter"
# - "authenticationMechanisms=SCRAM-SHA-1"
ports:
- containerPort: 27017
lifecycle:
#postStart:
#exec:
#command: ["/bin/sh", "-c", "rm -rfd /data/db/*"]
preStop:
exec:
command: ["/bin/sh", "-c", "rm -rfd /data/db/*"]
volumeMounts:
- name: mongodbshardpvc2
mountPath: /data/db
readinessProbe:
exec:
command:
- mongo
- --eval
- "db.getMongo()"
initialDelaySeconds: 30
periodSeconds: 20
timeoutSeconds: 120
failureThreshold: 6
livenessProbe:
exec:
command:
- mongo
- --eval
- "db.getMongo()"
initialDelaySeconds: 30
periodSeconds: 20
timeoutSeconds: 120
failureThreshold: 6
volumeClaimTemplates:
- metadata:
name: mongodbshardpvc2
spec:
accessModes: [ "ReadWriteOnce" ]
storageClassName: sharedfs
resources:
requests:
storage: 5Gi