-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzadig-mongo.yml
146 lines (141 loc) · 3.19 KB
/
zadig-mongo.yml
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# 单节点mongodb,pvc持久化数据,带mongo-exporter
# 创建管理员和授权
# use admin
# db.createUser({user:'root',pwd:'klg2go',roles:[{role:'root',db:'admin'}]})
# db.auth('root','root');
# 配置文件开启认证
# 在mongo.conf添加auth=true
---
# PVC
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: zadig-mongo
namespace: zadig
spec:
storageClassName: managed-nfs-storage
accessModes:
- ReadWriteMany
resources:
requests:
storage: 5Gi
---
# ConfigMap
apiVersion: v1
kind: ConfigMap
metadata:
name: zadig-mongodb
namespace: zadig
data:
mongodb.conf: |
dbpath=/data/mongodb
logpath=/data/mongodb/mongodb.log
pidfilepath=/data/mongodb/master.pid
directoryperdb=true
logappend=true
bind_ip=0.0.0.0
port=27017
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: zadig-mongodb
namespace: zadig
spec:
replicas: 1
selector:
matchLabels:
app: zadig-mongodb
template:
metadata:
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "9104"
labels:
app: zadig-mongodb
spec:
containers:
- name: zadig-mongodb
image: mongo:4.2
command:
- sh
- -c
- "exec mongod -f /etc/mongod.conf"
ports:
- containerPort: 27017
resources:
limits:
cpu: 1000m
memory: 512Mi
requests:
cpu: 1000m
memory: 512Mi
livenessProbe:
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 3
tcpSocket:
port: 27017
readinessProbe:
initialDelaySeconds: 10
periodSeconds: 10
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 3
tcpSocket:
port: 27017
volumeMounts:
- name: data
mountPath: /data/mongodb/
- name: config
mountPath: /etc/mongod.conf
subPath: mongodb.conf
# - name: localtime
# readOnly: true
# mountPath: /etc/localtime
- name: mongo-exporter
image: noenv/mongo-exporter:latest
args:
[
"--web.listen-address=:9104",
"--mongodb.uri",
"mongodb://zadig-mongodb:27017",
]
resources:
requests:
cpu: 100m
memory: 100Mi
ports:
- containerPort: 9104
volumes:
- name: data
persistentVolumeClaim:
claimName: zadig-mongodb
- name: config
configMap:
name: zadig-mongodb
# - name: localtime
# hostPath:
# type: File
# path: /etc/localtime
---
# Service
apiVersion: v1
kind: Service
metadata:
name: zadig-mongodb
namespace: zadig
spec:
type: ClusterIP
ports:
- name: zadig-mongodb
port: 27017
protocol: TCP
targetPort: 27017
- name: prom
port: 9104
targetPort: 9104
selector:
app: zadig-mongodb