2023-06-01 19:28:28 +08:00
|
|
|
---
|
|
|
|
apiVersion: apps/v1
|
|
|
|
kind: StatefulSet
|
|
|
|
metadata:
|
|
|
|
name: mongo
|
|
|
|
spec:
|
|
|
|
replicas: 1
|
|
|
|
serviceName: mongo
|
|
|
|
selector:
|
|
|
|
matchLabels:
|
|
|
|
app: mongo
|
|
|
|
template:
|
|
|
|
metadata:
|
|
|
|
labels:
|
|
|
|
app: mongo
|
|
|
|
spec:
|
|
|
|
containers:
|
|
|
|
- name: mongo
|
|
|
|
image: mongo:6.0.6
|
|
|
|
imagePullPolicy: IfNotPresent
|
|
|
|
env:
|
|
|
|
- name: MONGO_INITDB_ROOT_USERNAME
|
|
|
|
value: root
|
|
|
|
- name: MONGO_INITDB_ROOT_PASSWORD
|
2023-06-06 15:03:50 +08:00
|
|
|
value: 'root@123'
|
2023-06-01 19:28:28 +08:00
|
|
|
ports:
|
|
|
|
- containerPort: 27017
|
|
|
|
volumeMounts:
|
|
|
|
- name: mongo-data
|
|
|
|
mountPath: /data/db
|
|
|
|
volumeClaimTemplates:
|
|
|
|
- metadata:
|
|
|
|
name: mongo-data
|
|
|
|
spec:
|
|
|
|
accessModes: ['ReadWriteOnce']
|
|
|
|
storageClassName: "local-mongo"
|
|
|
|
resources:
|
|
|
|
requests:
|
|
|
|
storage: 5Gi
|
|
|
|
|
|
|
|
---
|
|
|
|
apiVersion: v1
|
|
|
|
kind: Service
|
|
|
|
metadata:
|
|
|
|
name: mongo
|
|
|
|
spec:
|
|
|
|
selector:
|
|
|
|
app: mongo
|
|
|
|
ports:
|
|
|
|
- name: mongo
|
|
|
|
protocol: TCP
|
|
|
|
port: 27017
|
|
|
|
targetPort: 27017
|
|
|
|
nodePort: 30018
|
|
|
|
type: NodePort
|