diff --git a/support-files/kubernetes/charts/bk-job/templates/job-execute/deployment.yaml b/support-files/kubernetes/charts/bk-job/templates/job-execute/deployment.yaml index f20ee95d0f..e63b5fe09e 100644 --- a/support-files/kubernetes/charts/bk-job/templates/job-execute/deployment.yaml +++ b/support-files/kubernetes/charts/bk-job/templates/job-execute/deployment.yaml @@ -135,6 +135,7 @@ spec: - name: job-gse-tls-password mountPath: /etc/secrets readOnly: true + terminationGracePeriodSeconds: 120 volumes: - name: job-storage persistentVolumeClaim: diff --git a/support-files/kubernetes/images/backend/backend.Dockerfile b/support-files/kubernetes/images/backend/backend.Dockerfile index 7ee72f9c2c..57f954a312 100644 --- a/support-files/kubernetes/images/backend/backend.Dockerfile +++ b/support-files/kubernetes/images/backend/backend.Dockerfile @@ -7,11 +7,14 @@ ENV BK_JOB_HOME=/data/job/exec COPY ./ /data/job/exec/ RUN ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \ echo 'Asia/Shanghai' > /etc/timezone && \ - chmod +x /data/job/exec/startup.sh + chmod +x /data/job/exec/startup.sh && \ + chmod +x /data/job/exec/tini + ENV LANG en_US.utf8 ENV LANGUAGE en_US.utf8 ENV LC_ALL en_US.utf8 WORKDIR /data/job/exec -CMD /data/job/exec/startup.sh + +ENTRYPOINT ["./tini", "--", "/data/job/exec/startup.sh"] diff --git a/support-files/kubernetes/images/backend/startup.sh b/support-files/kubernetes/images/backend/startup.sh index defb1065d8..4e905f4708 100644 --- a/support-files/kubernetes/images/backend/startup.sh +++ b/support-files/kubernetes/images/backend/startup.sh @@ -53,7 +53,7 @@ if [[ "$OTEL_TRACE_ENABLED" == "true" ]];then fi fi -java -server \ +exec java -server \ $OTEL_OPTS \ -Dfile.encoding=UTF-8 \ -Djob.log.dir=$BK_JOB_LOG_BASE_DIR \ @@ -69,4 +69,5 @@ java -server \ -XX:ErrorFile=$BK_JOB_LOG_DIR/error_sys.log \ -Dspring.profiles.active=$BK_JOB_PROFILE \ $BK_JOB_JVM_OPTION \ - -jar /data/job/exec/$BK_JOB_JAR + -jar /data/job/exec/$BK_JOB_JAR \ + "$@" diff --git a/support-files/kubernetes/images/backend/tini b/support-files/kubernetes/images/backend/tini new file mode 100755 index 0000000000..86cb766c6b Binary files /dev/null and b/support-files/kubernetes/images/backend/tini differ diff --git a/support-files/kubernetes/images/build.sh b/support-files/kubernetes/images/build.sh index f8aa95def9..b7662bb08c 100755 --- a/support-files/kubernetes/images/build.sh +++ b/support-files/kubernetes/images/build.sh @@ -198,7 +198,7 @@ build_backend_module () { rm -rf tmp/* cp $BACKEND_DIR/release/$SERVICE-$VERSION.jar tmp/$SERVICE.jar cp $SUPPORT_FILES_DIR/javaagent/opentelemetry-javaagent.jar tmp/ - cp backend/startup.sh tmp/ + cp backend/startup.sh backend/tini tmp/ docker build -f backend/backend.Dockerfile -t $REGISTRY/$SERVICE:$VERSION tmp --network=host if [[ $PUSH -eq 1 ]] ; then docker push $REGISTRY/$SERVICE:$VERSION