From 73f0a052ef1b1b3144d8f1fe2630cc0ae730750a Mon Sep 17 00:00:00 2001 From: ycz008 Date: Mon, 10 Jul 2023 18:07:26 +0800 Subject: [PATCH] add mongodb --- dev-upgrade/mongo/mongo-dev.yaml | 94 ++++++++++++++++++++++++++++ dev-upgrade/mongo/mongo-release.yaml | 94 ++++++++++++++++++++++++++++ 2 files changed, 188 insertions(+) create mode 100644 dev-upgrade/mongo/mongo-dev.yaml create mode 100644 dev-upgrade/mongo/mongo-release.yaml diff --git a/dev-upgrade/mongo/mongo-dev.yaml b/dev-upgrade/mongo/mongo-dev.yaml new file mode 100644 index 0000000..e594aba --- /dev/null +++ b/dev-upgrade/mongo/mongo-dev.yaml @@ -0,0 +1,94 @@ + +--- +apiVersion: storage.k8s.io/v1 +kind: StorageClass +metadata: + name: mongo-dev +provisioner: kubernetes.io/no-provisioner +allowVolumeExpansion: true +volumeBindingMode: WaitForFirstConsumer + +--- +apiVersion: v1 +kind: PersistentVolume +metadata: + name: mongo-dev-0 + labels: + type: local +spec: + storageClassName: mongo-dev + capacity: + storage: 10Gi + accessModes: + - ReadWriteOnce + local: + path: /data/dev/mongo + nodeAffinity: + required: + nodeSelectorTerms: + - matchExpressions: + - key: app.kubernetes.io/name + operator: In + values: + - trainer + - key: kubernetes.io/hostname + operator: In + values: + - bfs-k8snode-10-2-0-12.hetzner.base.beaconfireinc.com + +--- +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 + value: 'root@123' + ports: + - containerPort: 27017 + volumeMounts: + - name: mongo-data + mountPath: /data/db + volumeClaimTemplates: + - metadata: + name: mongo-data + spec: + accessModes: ['ReadWriteOnce'] + storageClassName: "mongo-dev" + 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 + diff --git a/dev-upgrade/mongo/mongo-release.yaml b/dev-upgrade/mongo/mongo-release.yaml new file mode 100644 index 0000000..c2c35b4 --- /dev/null +++ b/dev-upgrade/mongo/mongo-release.yaml @@ -0,0 +1,94 @@ + +--- +apiVersion: storage.k8s.io/v1 +kind: StorageClass +metadata: + name: mongo-release +provisioner: kubernetes.io/no-provisioner +allowVolumeExpansion: true +volumeBindingMode: WaitForFirstConsumer + +--- +apiVersion: v1 +kind: PersistentVolume +metadata: + name: mongo-release-0 + labels: + type: local +spec: + storageClassName: mongo-release + capacity: + storage: 10Gi + accessModes: + - ReadWriteOnce + local: + path: /data/release/mongo + nodeAffinity: + required: + nodeSelectorTerms: + - matchExpressions: + - key: app.kubernetes.io/name + operator: In + values: + - trainer + - key: kubernetes.io/hostname + operator: In + values: + - bfs-k8snode-10-2-0-13.hetzner.base.beaconfireinc.com + +--- +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 + value: 'root@123' + ports: + - containerPort: 27017 + volumeMounts: + - name: mongo-data + mountPath: /data/db + volumeClaimTemplates: + - metadata: + name: mongo-data + spec: + accessModes: ['ReadWriteOnce'] + storageClassName: "mongo-release" + 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 +