From 0f51f912c07f116610898daa21dda198d82aa3a9 Mon Sep 17 00:00:00 2001 From: ycz008 Date: Fri, 15 Sep 2023 14:08:02 +0800 Subject: [PATCH] fix: mysql terminated --- .../mongo/{mongo-dev.yaml => mongo.yaml} | 65 ++++++++----------- dev-upgrade/mongo/storage.yaml | 8 --- qa-upgrade/mongo/mongo.yaml | 13 ++++ qa-upgrade/mysql/mysql.yaml | 13 ++++ 4 files changed, 52 insertions(+), 47 deletions(-) rename dev-upgrade/mongo/{mongo-dev.yaml => mongo.yaml} (51%) delete mode 100644 dev-upgrade/mongo/storage.yaml diff --git a/dev-upgrade/mongo/mongo-dev.yaml b/dev-upgrade/mongo/mongo.yaml similarity index 51% rename from dev-upgrade/mongo/mongo-dev.yaml rename to dev-upgrade/mongo/mongo.yaml index 5bb90df..98afb0d 100644 --- a/dev-upgrade/mongo/mongo-dev.yaml +++ b/dev-upgrade/mongo/mongo.yaml @@ -1,33 +1,3 @@ - ---- -apiVersion: v1 -kind: PersistentVolume -metadata: - name: mongo-dev-0 - labels: - type: local -spec: - storageClassName: local-mongo - 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: @@ -43,6 +13,19 @@ spec: 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.6 @@ -57,15 +40,19 @@ spec: volumeMounts: - name: mongo-data mountPath: /data/db - volumeClaimTemplates: - - metadata: - name: mongo-data - spec: - accessModes: ['ReadWriteOnce'] - storageClassName: local-mongo - resources: - requests: - storage: 5Gi + volumes: + - name: mongo-data + hostPath: + path: /data/dev/mongo + affinity: + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: "kubernetes.io/hostname" + operator: In + values: + - bfs-k8snode-10-2-0-12.hetzner.base.beaconfireinc.com --- apiVersion: v1 diff --git a/dev-upgrade/mongo/storage.yaml b/dev-upgrade/mongo/storage.yaml deleted file mode 100644 index 5d453b4..0000000 --- a/dev-upgrade/mongo/storage.yaml +++ /dev/null @@ -1,8 +0,0 @@ ---- -apiVersion: storage.k8s.io/v1 -kind: StorageClass -metadata: - name: local-mongo -provisioner: kubernetes.io/no-provisioner -allowVolumeExpansion: true -volumeBindingMode: WaitForFirstConsumer \ No newline at end of file diff --git a/qa-upgrade/mongo/mongo.yaml b/qa-upgrade/mongo/mongo.yaml index 80a864e..1c2c28b 100644 --- a/qa-upgrade/mongo/mongo.yaml +++ b/qa-upgrade/mongo/mongo.yaml @@ -13,6 +13,19 @@ spec: 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.6 diff --git a/qa-upgrade/mysql/mysql.yaml b/qa-upgrade/mysql/mysql.yaml index 13ae489..4aabcc4 100644 --- a/qa-upgrade/mysql/mysql.yaml +++ b/qa-upgrade/mysql/mysql.yaml @@ -13,6 +13,19 @@ spec: labels: name: mysql 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: mysql image: mysql:8.0.33