From a1926917a094ae2117c2c4b22ceaec2b045baa8f Mon Sep 17 00:00:00 2001 From: ycz008 Date: Fri, 19 Apr 2024 11:46:33 +0800 Subject: [PATCH] add prod mongo --- prod-upgrade/mongo/mongo.yaml | 85 +++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 prod-upgrade/mongo/mongo.yaml diff --git a/prod-upgrade/mongo/mongo.yaml b/prod-upgrade/mongo/mongo.yaml new file mode 100644 index 0000000..2376434 --- /dev/null +++ b/prod-upgrade/mongo/mongo.yaml @@ -0,0 +1,85 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: mongo +spec: + replicas: 3 + serviceName: mongo + selector: + matchLabels: + app: mongo + template: + metadata: + labels: + app: mongo + spec: + initContainers: + - name: init + image: busybox + imagePullPolicy: IfNotPresent + command: + - sh + - -c + - | + sysctl -w net.ipv4.tcp_keepalive_time=300 + sysctl -w net.ipv4.tcp_keepalive_intvl=10 + sysctl -w net.ipv4.tcp_keepalive_probes=3 + securityContext: + privileged: true + containers: + - name: mongo + image: mongo:6.0 + command: + - --replSet "bfs-mongo-rs0" + imagePullPolicy: IfNotPresent + env: + - name: MONGO_INITDB_ROOT_USERNAME + valueFrom: + secretKeyRef: + name: mongo + key: initdb_root_username + - name: MONGO_INITDB_ROOT_PASSWORD + valueFrom: + secretKeyRef: + name: mongo + key: initdb_root_password + ports: + - containerPort: 27017 + volumeMounts: + - name: mongo-data + mountPath: /data/db + volumes: + - name: mongo-data + hostPath: + path: /data/mongodb/rs0 + affinity: + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: "app.kubernetes.io/component" + operator: In + values: + - mongo + tolerations: + - key: "app.kubernetes.io/component" + operator: "Equal" + value: "mongo" + effect: "NoSchedule" + +--- +apiVersion: v1 +kind: Service +metadata: + name: mongo +spec: + selector: + app: mongo + ports: + - name: mongo + protocol: TCP + port: 27017 + targetPort: 27017 + nodePort: 30018 + type: NodePort +