2021-07-08 05:12:24 +08:00
|
|
|
apiVersion: v1
|
|
|
|
kind: Service
|
|
|
|
metadata:
|
|
|
|
name: mongo
|
|
|
|
labels:
|
|
|
|
name: mongo
|
|
|
|
spec:
|
|
|
|
ports:
|
|
|
|
- port: 27017
|
|
|
|
targetPort: 27017
|
|
|
|
clusterIP: None
|
|
|
|
selector:
|
|
|
|
role: mongo
|
|
|
|
---
|
|
|
|
apiVersion: apps/v1
|
|
|
|
kind: StatefulSet
|
|
|
|
metadata:
|
|
|
|
name: mongo
|
|
|
|
spec:
|
|
|
|
serviceName: "mongo"
|
|
|
|
replicas: 1
|
|
|
|
selector:
|
|
|
|
matchLabels:
|
|
|
|
role: mongo
|
|
|
|
template:
|
|
|
|
metadata:
|
|
|
|
labels:
|
|
|
|
app: mongo
|
|
|
|
role: mongo
|
|
|
|
spec:
|
|
|
|
containers:
|
|
|
|
- name: mongo
|
|
|
|
image: mongo
|
|
|
|
env:
|
|
|
|
- name: MONGO_INITDB_ROOT_USERNAME
|
|
|
|
value: mongoadmin
|
|
|
|
- name: MONGO_INITDB_ROOT_PASSWORD
|
|
|
|
value: mongopass
|
|
|
|
securityContext:
|
|
|
|
privileged: true
|
|
|
|
volumeMounts:
|
|
|
|
- name: mongovol
|
|
|
|
mountPath: /data/db
|
|
|
|
volumes:
|
|
|
|
- name: mongovol
|
|
|
|
persistentVolumeClaim:
|
2021-07-16 03:27:34 +08:00
|
|
|
claimName: mongodb-pvc
|
2021-07-08 05:12:24 +08:00
|
|
|
---
|
|
|
|
apiVersion: v1
|
|
|
|
kind: PersistentVolumeClaim
|
|
|
|
metadata:
|
2021-07-16 03:27:34 +08:00
|
|
|
name: mongodb-pvc
|
2021-07-08 05:12:24 +08:00
|
|
|
spec:
|
|
|
|
accessModes:
|
|
|
|
- ReadWriteOnce
|
|
|
|
resources:
|
|
|
|
requests:
|
|
|
|
storage: 7Gi
|
2021-07-16 03:27:34 +08:00
|
|
|
storageClassName: microk8s-hostpath
|