From 6c628cf05c581fdc1c7fc140c4518ad860669745 Mon Sep 17 00:00:00 2001 From: liaozan <378024053@qq.com> Date: Tue, 20 Sep 2022 16:14:22 +0800 Subject: [PATCH] Add initContainers to make the required folder used for Jvm gc log --- Dockerfile | 2 +- k8s-deploy-template.yaml | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index f26137d..87fe085 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ COPY --from=builder app/application/ ./ RUN mkdir -p /data/logs -ENV JVM_OPTS='-XX:MaxRAMPercentage=90 -XX:+AlwaysPreTouch \ +ENV JVM_OPTS='-XX:MaxRAMPercentage=80 -XX:+AlwaysPreTouch \ -XX:+UseG1GC -Xlog:gc*:/data/logs/gc.log:time,uptime \ -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/data/heapdump.hprof \ -XX:-OmitStackTraceInFastThrow -XX:+PrintCommandLineFlags \ diff --git a/k8s-deploy-template.yaml b/k8s-deploy-template.yaml index e57729c..34c14af 100644 --- a/k8s-deploy-template.yaml +++ b/k8s-deploy-template.yaml @@ -25,6 +25,13 @@ spec: values: - ${NODE_POOL_ID} terminationGracePeriodSeconds: 30 + initContainers: + - name: ${APP_NAME}-init + image: busybox + command: [ 'mkdir', '-p', "/data/logs" ] + volumeMounts: + - name: ${APP_NAME}-volume + mountPath: /data containers: - name: ${APP_NAME} image: ${IMAGE} @@ -64,9 +71,9 @@ spec: periodSeconds: 10 volumeMounts: - name: ${APP_NAME}-volume - mountPath: / + mountPath: /data volumes: - name: ${APP_NAME}-volume - hostPath: - path: /data/share/pod/data/${APP_NAME} - type: DirectoryOrCreate \ No newline at end of file + - name: ${APP_NAME}-volume + hostPath: + path: /share/pod/data/${APP_NAME} + type: DirectoryOrCreate \ No newline at end of file -- GitLab