From 4004d9330dbd886cae8deeb2a57ac6a7b22765c5 Mon Sep 17 00:00:00 2001 From: jsonwan Date: Fri, 3 Nov 2023 20:37:59 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E5=AE=B9=E5=99=A8=E5=8C=96Values?= =?UTF-8?q?=E6=9A=B4=E9=9C=B2=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1=E7=8B=AC?= =?UTF-8?q?=E7=AB=8BDB=E7=AD=89=E7=94=9F=E4=BA=A7=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E9=9C=80=E8=A6=81=E7=9A=84=E9=85=8D=E7=BD=AE=E9=A1=B9=20#2551?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 暴露相关配置项 --- .../crontab/JobCrontabBootApplication.java | 3 +- .../crontab/config/JobQuartzProperties.java | 96 ------------------- .../bk/job/crontab/config/QuartzConfig.java | 46 +-------- .../crontab/metrics/CronMetricsConstants.java | 12 --- .../crontab/metrics/MeasureServiceImpl.java | 60 ------------ .../kubernetes/charts/bk-job/VALUES_LOG.md | 16 ++++ .../charts/bk-job/templates/_helpers.tpl | 28 +++++- .../templates/job-analysis/configmap.yaml | 6 +- .../templates/job-assemble/configmap.yaml | 36 +------ .../templates/job-assemble/deployment.yaml | 10 ++ .../templates/job-crontab/configmap.yaml | 36 +------ .../templates/job-crontab/deployment.yaml | 12 +++ .../templates/job-execute/configmap.yaml | 12 +-- .../bk-job/templates/secret-crontabDB.yaml | 17 ++++ .../kubernetes/charts/bk-job/values.yaml | 81 ++++++++++++++-- ...#job#job-assemble#application-assemble.yml | 20 +--- .../#etc#job#job-crontab#job-crontab.yml | 18 ---- 17 files changed, 170 insertions(+), 339 deletions(-) delete mode 100644 src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/config/JobQuartzProperties.java delete mode 100644 src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/metrics/MeasureServiceImpl.java create mode 100644 support-files/kubernetes/charts/bk-job/templates/secret-crontabDB.yaml diff --git a/src/backend/job-crontab/boot-job-crontab/src/main/java/com/tencent/bk/job/crontab/JobCrontabBootApplication.java b/src/backend/job-crontab/boot-job-crontab/src/main/java/com/tencent/bk/job/crontab/JobCrontabBootApplication.java index 27b80376d8..83ef24e270 100644 --- a/src/backend/job-crontab/boot-job-crontab/src/main/java/com/tencent/bk/job/crontab/JobCrontabBootApplication.java +++ b/src/backend/job-crontab/boot-job-crontab/src/main/java/com/tencent/bk/job/crontab/JobCrontabBootApplication.java @@ -26,7 +26,6 @@ import com.tencent.bk.job.common.service.boot.JobBootApplication; import com.tencent.bk.job.common.service.feature.config.FeatureToggleConfig; -import com.tencent.bk.job.crontab.config.JobQuartzProperties; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.availability.ApplicationAvailabilityAutoConfiguration; import org.springframework.boot.autoconfigure.jooq.JooqAutoConfiguration; @@ -38,7 +37,7 @@ "com.tencent.bk.job.crontab"}, exclude = {JooqAutoConfiguration.class, ApplicationAvailabilityAutoConfiguration.class}) @EnableFeignClients(basePackages = {"com.tencent.bk.job.manage.api", "com.tencent.bk.job.execute.api"}) -@EnableConfigurationProperties({FeatureToggleConfig.class, JobQuartzProperties.class}) +@EnableConfigurationProperties({FeatureToggleConfig.class}) public class JobCrontabBootApplication { public static void main(String[] args) { diff --git a/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/config/JobQuartzProperties.java b/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/config/JobQuartzProperties.java deleted file mode 100644 index 1a920e27c2..0000000000 --- a/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/config/JobQuartzProperties.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Tencent is pleased to support the open source community by making BK-JOB蓝鲸智云作业平台 available. - * - * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. - * - * BK-JOB蓝鲸智云作业平台 is licensed under the MIT License. - * - * License for BK-JOB蓝鲸智云作业平台: - * -------------------------------------------------------------------- - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated - * documentation files (the "Software"), to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and - * to permit persons to whom the Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all copies or substantial portions of - * the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO - * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -package com.tencent.bk.job.crontab.config; - -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Profile; -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; - -/** - * Job 扩展的 quartz 配置 - */ -@Data -@Profile("!test") -@ConfigurationProperties(prefix = "spring.quartz") -public class JobQuartzProperties { - /** - * 线程池配置 - */ - private ThreadPool threadPool = new ThreadPool(); - - /** - * Scheduler 配置 - */ - private Scheduler scheduler = new Scheduler(); - - public JobQuartzProperties() { - - } - - /** - * 执行定时任务的线程池配置,配置参考 ThreadPoolTaskExecutor - * - * @see ThreadPoolTaskExecutor - */ - @Data - public static class ThreadPool { - private String threadNamePrefix; - - private int threadPriority = 5; - - private boolean daemon = false; - - private String threadGroupName; - - private int corePoolSize = 10; - - private int maxPoolSize = Integer.MAX_VALUE; - - private int keepAliveSeconds = 60; - - private int queueCapacity = Integer.MAX_VALUE; - - private boolean allowCoreThreadTimeOut = false; - - private boolean waitForTasksToCompleteOnShutdown = false; - - private int awaitTerminationSeconds = 0; - } - - @Data - public static class Scheduler { - - private String schedulerName; - - private String applicationContextSchedulerContextKey = "applicationContext"; - - private boolean overwriteExistingJobs = true; - - private boolean autoStartup = true; - - private int startupDelay = 5; - } -} diff --git a/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/config/QuartzConfig.java b/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/config/QuartzConfig.java index ba0c19b5de..576deab605 100644 --- a/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/config/QuartzConfig.java +++ b/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/config/QuartzConfig.java @@ -24,14 +24,11 @@ package com.tencent.bk.job.crontab.config; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.autoconfigure.quartz.SchedulerFactoryBeanCustomizer; -import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Profile; -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import javax.sql.DataSource; @@ -40,54 +37,15 @@ */ @Configuration @Profile("!test") -@EnableConfigurationProperties({JobQuartzProperties.class}) public class QuartzConfig { - private final JobQuartzProperties jobQuartzProperties; - - @Autowired - public QuartzConfig(JobQuartzProperties quartzProperties) { - this.jobQuartzProperties = quartzProperties; - } - - @Bean("quartzTaskExecutor") - public ThreadPoolTaskExecutor quartzTaskExecutor() { - JobQuartzProperties.ThreadPool threadPoolConfig = jobQuartzProperties.getThreadPool(); - ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor(); - threadPoolTaskExecutor.setThreadNamePrefix(threadPoolConfig.getThreadNamePrefix()); - threadPoolTaskExecutor.setThreadGroupName(threadPoolConfig.getThreadGroupName()); - threadPoolTaskExecutor.setDaemon(threadPoolConfig.isDaemon()); - threadPoolTaskExecutor.setThreadPriority(threadPoolConfig.getThreadPriority()); - threadPoolTaskExecutor.setCorePoolSize(threadPoolConfig.getCorePoolSize()); - threadPoolTaskExecutor.setMaxPoolSize(threadPoolConfig.getMaxPoolSize()); - threadPoolTaskExecutor.setQueueCapacity(threadPoolConfig.getQueueCapacity()); - threadPoolTaskExecutor.setKeepAliveSeconds(threadPoolConfig.getKeepAliveSeconds()); - threadPoolTaskExecutor.setAllowCoreThreadTimeOut(threadPoolConfig.isAllowCoreThreadTimeOut()); - threadPoolTaskExecutor.setWaitForTasksToCompleteOnShutdown( - threadPoolConfig.isWaitForTasksToCompleteOnShutdown()); - threadPoolTaskExecutor.setAwaitTerminationSeconds( - threadPoolConfig.getAwaitTerminationSeconds()); - - return threadPoolTaskExecutor; - } - @Bean public SchedulerFactoryBeanCustomizer schedulerFactoryBeanCustomizer( - @Qualifier("quartzTaskExecutor") ThreadPoolTaskExecutor quartzTaskExecutor, @Qualifier("job-crontab-data-source") DataSource dataSource) { return schedulerFactoryBean -> { - // 自定义taskExecutor - schedulerFactoryBean.setTaskExecutor(quartzTaskExecutor); - - // 自定义scheduler - schedulerFactoryBean.setSchedulerName(jobQuartzProperties.getScheduler().getSchedulerName()); - schedulerFactoryBean.setApplicationContextSchedulerContextKey( - jobQuartzProperties.getScheduler().getApplicationContextSchedulerContextKey()); - schedulerFactoryBean.setOverwriteExistingJobs(jobQuartzProperties.getScheduler().isOverwriteExistingJobs()); - schedulerFactoryBean.setAutoStartup(jobQuartzProperties.getScheduler().isAutoStartup()); - schedulerFactoryBean.setStartupDelay(jobQuartzProperties.getScheduler().getStartupDelay()); + schedulerFactoryBean.setOverwriteExistingJobs(true); + schedulerFactoryBean.setStartupDelay(10); schedulerFactoryBean.setDataSource(dataSource); }; - } } diff --git a/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/metrics/CronMetricsConstants.java b/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/metrics/CronMetricsConstants.java index c1711f3807..d019f7b54f 100644 --- a/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/metrics/CronMetricsConstants.java +++ b/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/metrics/CronMetricsConstants.java @@ -25,20 +25,8 @@ package com.tencent.bk.job.crontab.metrics; public class CronMetricsConstants { - /** - * Quartz工作线程池线程数 - */ - public static final String NAME_CRON_QUARTZ_TASK_EXECUTOR_POOL_SIZE = "cron.quartz.task.executor.pool.size"; - /** - * Quartz工作线程池队列大小 - */ - public static final String NAME_CRON_QUARTZ_TASK_EXECUTOR_QUEUE_SIZE = "cron.quartz.task.executor.queue.size"; /** * 定时任务调度延迟指标 */ public static final String NAME_JOB_CRON_SCHEDULE_DELAY = "job.cron.schedule.delay"; - - public static final String TAG_KEY_MODULE = "module"; - - public static final String TAG_VALUE_MODULE_CRON = "cron"; } diff --git a/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/metrics/MeasureServiceImpl.java b/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/metrics/MeasureServiceImpl.java deleted file mode 100644 index ba93f41094..0000000000 --- a/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/metrics/MeasureServiceImpl.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Tencent is pleased to support the open source community by making BK-JOB蓝鲸智云作业平台 available. - * - * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. - * - * BK-JOB蓝鲸智云作业平台 is licensed under the MIT License. - * - * License for BK-JOB蓝鲸智云作业平台: - * -------------------------------------------------------------------- - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated - * documentation files (the "Software"), to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and - * to permit persons to whom the Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all copies or substantial portions of - * the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO - * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -package com.tencent.bk.job.crontab.metrics; - -import io.micrometer.core.instrument.MeterRegistry; -import io.micrometer.core.instrument.Tag; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Profile; -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; -import org.springframework.stereotype.Service; - -import java.util.Collections; - -@Slf4j -@Service("jobCrontabMeasureService") -@Profile("!test") -public class MeasureServiceImpl { - - @Autowired - public MeasureServiceImpl(MeterRegistry meterRegistry, ThreadPoolTaskExecutor quartzTaskExecutor) { - // 同步线程池监控:Agent状态 - meterRegistry.gauge( - CronMetricsConstants.NAME_CRON_QUARTZ_TASK_EXECUTOR_POOL_SIZE, - Collections.singletonList(Tag.of(CronMetricsConstants.TAG_KEY_MODULE, - CronMetricsConstants.TAG_VALUE_MODULE_CRON)), - quartzTaskExecutor, - taskExecutor -> taskExecutor.getThreadPoolExecutor().getPoolSize() - ); - meterRegistry.gauge( - CronMetricsConstants.NAME_CRON_QUARTZ_TASK_EXECUTOR_QUEUE_SIZE, - Collections.singletonList(Tag.of(CronMetricsConstants.TAG_KEY_MODULE, - CronMetricsConstants.TAG_VALUE_MODULE_CRON)), - quartzTaskExecutor, - taskExecutor -> taskExecutor.getThreadPoolExecutor().getQueue().size() - ); - } -} diff --git a/support-files/kubernetes/charts/bk-job/VALUES_LOG.md b/support-files/kubernetes/charts/bk-job/VALUES_LOG.md index 75face451f..acf862ab16 100644 --- a/support-files/kubernetes/charts/bk-job/VALUES_LOG.md +++ b/support-files/kubernetes/charts/bk-job/VALUES_LOG.md @@ -1,5 +1,21 @@ # chart values 更新日志 +## 0.5.4 +1. 增加定时任务服务独立数据库配置(若不配置该项则使用与其他服务共用的公共数据库),默认无需配置 + +```yaml +## job-crontab定时任务配置 +crontabConfig: + # 定时任务服务独立数据库配置,若不配置该项则使用与其他服务共用的公共数据库 + database: + host: "" + port: 3306 + connection: + properties: ?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull + username: "job" + password: "job" +``` + ## 0.5.3 1. 增加操作审计相关配置 diff --git a/support-files/kubernetes/charts/bk-job/templates/_helpers.tpl b/support-files/kubernetes/charts/bk-job/templates/_helpers.tpl index 4be1194408..ac4a6a5d24 100644 --- a/support-files/kubernetes/charts/bk-job/templates/_helpers.tpl +++ b/support-files/kubernetes/charts/bk-job/templates/_helpers.tpl @@ -669,7 +669,6 @@ Return the Archive MariaDB secret name {{ printf "%s-%s" (include "job.fullname" .) "archive-mariadb" }} {{- end -}} - {{/* Return the storage PVC name */}} @@ -683,3 +682,30 @@ Return the job pod terminationGracePeriodSeconds {{- define "job.podTerminationGracePeriodSeconds" -}} terminationGracePeriodSeconds: {{ .Values.podTerminationGracePeriodSeconds }} {{- end -}} + +{{/* +Return the Crontab DB secret name +*/}} +{{- define "job.crontabdb.secretName" -}} +{{ printf "%s-%s" (include "job.fullname" .) "crontab-db" }} +{{- end -}} + + +{{/* +Return the job crontab database config +*/}} +{{- define "job.crontab.databaseConfig" -}} +{{- if .Values.crontabConfig.database.host -}} +jdbc-url: {{ include "job.jdbcMysqlScheme" . }}://{{- .Values.crontabConfig.database.host }}:{{- .Values.crontabConfig.database.port }}/job_crontab{{- .Values.crontabConfig.database.connection.properties }} +username: {{ .Values.crontabConfig.database.username }} +password: ${crontab-db-password} +{{- else -}} +jdbc-url: {{ include "job.jdbcMysqlScheme" . }}://{{- include "job.mariadb.host" . }}:{{- include "job.mariadb.port" . }}/job_crontab{{ include "job.mariadb.connection.properties" . }} +username: {{ include "job.mariadb.username" . }} + {{- if .Values.externalMariaDB.existingPasswordSecret }} +password: {{ .Values.externalMariaDB.existingPasswordKey | default "mariadb-password" | printf "${%s}" }} + {{- else }} +password: ${mariadb-password} + {{- end }} +{{- end }} +{{- end -}} diff --git a/support-files/kubernetes/charts/bk-job/templates/job-analysis/configmap.yaml b/support-files/kubernetes/charts/bk-job/templates/job-analysis/configmap.yaml index 59e80c3f32..57bdfb6529 100644 --- a/support-files/kubernetes/charts/bk-job/templates/job-analysis/configmap.yaml +++ b/support-files/kubernetes/charts/bk-job/templates/job-analysis/configmap.yaml @@ -62,11 +62,7 @@ data: max-file-size: 5GB max-request-size: 5GB feign: - client: - config: - default: - connectTimeout: 5000 - readTimeout: 300000 + {{- toYaml .Values.analysisConfig.feign | nindent 6 }} server: port: {{ .Values.analysisConfig.containerPort }} {{- end }} diff --git a/support-files/kubernetes/charts/bk-job/templates/job-assemble/configmap.yaml b/support-files/kubernetes/charts/bk-job/templates/job-assemble/configmap.yaml index f3a34b5e31..3f2e58e01c 100644 --- a/support-files/kubernetes/charts/bk-job/templates/job-assemble/configmap.yaml +++ b/support-files/kubernetes/charts/bk-job/templates/job-assemble/configmap.yaml @@ -188,13 +188,7 @@ data: job-crontab: driver-class-name: {{ include "job.jdbcMysqlDriverClass" . }} type: com.zaxxer.hikari.HikariDataSource - jdbc-url: {{ include "job.jdbcMysqlScheme" . }}://{{- include "job.mariadb.host" . }}:{{- include "job.mariadb.port" . }}/job_crontab{{ include "job.mariadb.connection.properties" . }} - username: {{ include "job.mariadb.username" . }} - {{ if .Values.externalMariaDB.existingPasswordSecret }} - password: {{ .Values.externalMariaDB.existingPasswordKey | default "mariadb-password" | printf "${%s}" }} - {{- else -}} - password: ${mariadb-password} - {{- end }} + {{- include "job.crontab.databaseConfig" . | nindent 10 }} maximum-pool-size: 100 minimum-idle: 20 idle-timeout: 600000 @@ -278,24 +272,6 @@ data: jdbc: # 是否自动使用 SQL 初始化 Quartz 表结构。这里设置成 never ,手动创建表结构 initialize-schema: never - thread-pool: - thread-name-prefix: QuartzThreadPoolTaskExecutor- - thread-priority: 5 - daemon: false - thread-group-name: QuartzThreadPoolTaskExecutorGroup - core-pool-size: 150 - max-pool-size: 300 - keep-alive-seconds: 60 - queue-capacity: 150 - allow-core-thread-timeout: false - waitfor-tasks-tocomplete-onshutdown: true - await-termination-seconds: 900 - scheduler: - scheduler-name: quartz-scheduler - application-context-scheduler-contextkey: applicationContext - overwrite-existing-jobs: true - auto-startup: true - startup-delay: 10 properties: org: quartz: @@ -319,20 +295,16 @@ data: # 调度器实例编号自动生成 instanceId: AUTO skipUpdateCheck: true - batchTriggerAcquisitionMaxCount: 50 + batchTriggerAcquisitionMaxCount: {{ .Values.crontabConfig.quartz.scheduler.batchTriggerAcquisitionMaxCount }} threadPool: class: org.quartz.simpl.SimpleThreadPool - threadCount: 300 + threadCount: {{ .Values.crontabConfig.quartz.threadPool.threadCount }} ## 其他框架组件配置 ## server: port: {{ .Values.assembleConfig.containerPort }} feign: - client: - config: - default: - connectTimeout: 5000 - readTimeout: 20000 + {{- toYaml .Values.assembleConfig.feign | nindent 6 }} ## Job 配置 ## job: diff --git a/support-files/kubernetes/charts/bk-job/templates/job-assemble/deployment.yaml b/support-files/kubernetes/charts/bk-job/templates/job-assemble/deployment.yaml index 3bca51a6f8..89ea827f0e 100644 --- a/support-files/kubernetes/charts/bk-job/templates/job-assemble/deployment.yaml +++ b/support-files/kubernetes/charts/bk-job/templates/job-assemble/deployment.yaml @@ -123,6 +123,11 @@ spec: resources: {{- toYaml .Values.assembleConfig.resources | nindent 12 }} volumeMounts: + {{- if .Values.crontabConfig.database.host }} + - name: crontabdb + mountPath: /etc/secrets/crontabdb + readOnly: true + {{- end }} - name: distribute-volume mountPath: {{ .Values.fileDistribute.hostPath }} - name: job-storage @@ -144,6 +149,11 @@ spec: readOnly: true terminationGracePeriodSeconds: 120 volumes: + {{- if .Values.crontabConfig.database.host }} + - name: crontabdb + secret: + secretName: {{ include "job.crontabdb.secretName" . }} + {{- end }} - name: distribute-volume hostPath: path: {{ .Values.fileDistribute.hostPath }} diff --git a/support-files/kubernetes/charts/bk-job/templates/job-crontab/configmap.yaml b/support-files/kubernetes/charts/bk-job/templates/job-crontab/configmap.yaml index 9ffee567ea..05ebef3ff0 100644 --- a/support-files/kubernetes/charts/bk-job/templates/job-crontab/configmap.yaml +++ b/support-files/kubernetes/charts/bk-job/templates/job-crontab/configmap.yaml @@ -35,13 +35,7 @@ data: job-crontab: driver-class-name: {{ include "job.jdbcMysqlDriverClass" . }} type: com.zaxxer.hikari.HikariDataSource - jdbc-url: {{ include "job.jdbcMysqlScheme" . }}://{{- include "job.mariadb.host" . }}:{{- include "job.mariadb.port" . }}/job_crontab{{ include "job.mariadb.connection.properties" . }} - username: {{ include "job.mariadb.username" . }} - {{ if .Values.externalMariaDB.existingPasswordSecret }} - password: {{ .Values.externalMariaDB.existingPasswordKey | default "mariadb-password" | printf "${%s}" }} - {{- else -}} - password: ${mariadb-password} - {{- end }} + {{- include "job.crontab.databaseConfig" . | nindent 10 }} maximum-pool-size: 20 minimum-idle: 5 idle-timeout: 600000 @@ -63,24 +57,6 @@ data: jdbc: # 是否自动使用 SQL 初始化 Quartz 表结构。这里设置成 never ,手动创建表结构 initialize-schema: never - thread-pool: - thread-name-prefix: QuartzThreadPoolTaskExecutor- - thread-priority: 5 - daemon: false - thread-group-name: QuartzThreadPoolTaskExecutorGroup - core-pool-size: 150 - max-pool-size: 300 - keep-alive-seconds: 60 - queue-capacity: 150 - allow-core-thread-timeout: false - waitfor-tasks-tocomplete-onshutdown: true - await-termination-seconds: 900 - scheduler: - scheduler-name: quartz-scheduler - application-context-scheduler-contextkey: applicationContext - overwrite-existing-jobs: true - auto-startup: true - startup-delay: 10 properties: org: quartz: @@ -104,21 +80,17 @@ data: # 调度器实例编号自动生成 instanceId: AUTO skipUpdateCheck: true - batchTriggerAcquisitionMaxCount: 50 + batchTriggerAcquisitionMaxCount: {{ .Values.crontabConfig.quartz.scheduler.batchTriggerAcquisitionMaxCount }} threadPool: class: org.quartz.simpl.SimpleThreadPool - threadCount: 300 + threadCount: {{ .Values.crontabConfig.quartz.threadPool.threadCount }} ribbon: ReadTimeout: 120000 ConnectTimeout: 10000 eureka: enabled: false feign: - client: - config: - default: - connectTimeout: 5000 - readTimeout: 20000 + {{- toYaml .Values.crontabConfig.feign | nindent 6 }} job: crontab: notification-policy: diff --git a/support-files/kubernetes/charts/bk-job/templates/job-crontab/deployment.yaml b/support-files/kubernetes/charts/bk-job/templates/job-crontab/deployment.yaml index 1fe9ee2481..3dc18c647e 100644 --- a/support-files/kubernetes/charts/bk-job/templates/job-crontab/deployment.yaml +++ b/support-files/kubernetes/charts/bk-job/templates/job-crontab/deployment.yaml @@ -102,9 +102,15 @@ spec: resources: {{- toYaml .Values.crontabConfig.resources | nindent 12 }} volumeMounts: + {{- if .Values.crontabConfig.database.host }} + - name: crontabdb + mountPath: /etc/secrets/crontabdb + readOnly: true + {{- else }} - name: mariadb mountPath: /etc/secrets/mariadb readOnly: true + {{- end }} - name: rabbitmq mountPath: /etc/secrets/rabbitmq readOnly: true @@ -112,9 +118,15 @@ spec: mountPath: /etc/secrets/redis readOnly: true volumes: + {{- if .Values.crontabConfig.database.host }} + - name: crontabdb + secret: + secretName: {{ include "job.crontabdb.secretName" . }} + {{- else }} - name: mariadb secret: secretName: {{ include "job.mariadb.secretName" . }} + {{- end }} - name: rabbitmq secret: secretName: {{ include "job.rabbitmq.secretName" . }} diff --git a/support-files/kubernetes/charts/bk-job/templates/job-execute/configmap.yaml b/support-files/kubernetes/charts/bk-job/templates/job-execute/configmap.yaml index d7e2bab595..61f3c12cbd 100644 --- a/support-files/kubernetes/charts/bk-job/templates/job-execute/configmap.yaml +++ b/support-files/kubernetes/charts/bk-job/templates/job-execute/configmap.yaml @@ -188,17 +188,7 @@ data: server: port: {{ .Values.executeConfig.containerPort }} feign: - client: - config: - default: - connectTimeout: 5000 - readTimeout: 20000 - sync: - connectTimeout: 5000 - readTimeout: 30000 - log: - connectTimeout: 5000 - readTimeout: 30000 + {{- toYaml .Values.executeConfig.feign | nindent 6 }} job: execute: log-export: diff --git a/support-files/kubernetes/charts/bk-job/templates/secret-crontabDB.yaml b/support-files/kubernetes/charts/bk-job/templates/secret-crontabDB.yaml new file mode 100644 index 0000000000..203c9ffd8b --- /dev/null +++ b/support-files/kubernetes/charts/bk-job/templates/secret-crontabDB.yaml @@ -0,0 +1,17 @@ +{{- if .Values.crontabConfig.database.host }} +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "job.crontabdb.secretName" . }} + labels: {{- include "common.labels.standard" . | nindent 4 }} + {{- if .Values.commonLabels }} + {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }} + {{- end }} + namespace: {{ .Release.Namespace }} + {{- if .Values.commonAnnotations }} + annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }} + {{- end }} +type: Opaque +data: + crontab-db-password: {{ .Values.crontabConfig.database.password | b64enc | quote }} +{{- end }} diff --git a/support-files/kubernetes/charts/bk-job/values.yaml b/support-files/kubernetes/charts/bk-job/values.yaml index 173242505e..6334ff5961 100644 --- a/support-files/kubernetes/charts/bk-job/values.yaml +++ b/support-files/kubernetes/charts/bk-job/values.yaml @@ -885,7 +885,17 @@ executeConfig: port: 80 # 运行时JVM参数 jvmOptions: "-Xms512m -Xmx512m -XX:NewRatio=1 -XX:SurvivorRatio=8" - + # Feign相关配置块 + feign: + # 客户端配置 + client: + config: + # 默认Client实例配置 + default: + # 连接超时,单位:毫秒 + connectTimeout: 5000 + # 读取超时,单位:毫秒 + readTimeout: 20000 ## job-crontab定时任务配置 crontabConfig: @@ -931,6 +941,12 @@ crontabConfig: maxReplicas: 5 targetCPU: 50 targetMemory: 50 + service: + port: 80 + type: ClusterIP + containerPort: 19805 + # 运行时JVM参数 + jvmOptions: "-Xms256m -Xmx256m -XX:NewRatio=1 -XX:SurvivorRatio=8" # 连续启动失败通知策略:默认 从第一次失败开始,连续失败每5次通知第一次 begin = 1;frequency = 5;totalTimes = -1 notificationPolicy: failed: @@ -941,12 +957,41 @@ crontabConfig: frequency: 5 # 通知次数:默认 -1 - 不限制通知次数, 0 - 不通知, 1 - 只通知1次, total: -1 - containerPort: 19805 - service: - port: 80 - type: ClusterIP - # 运行时JVM参数 - jvmOptions: "-Xms256m -Xmx256m -XX:NewRatio=1 -XX:SurvivorRatio=8" + # 定时任务服务独立数据库配置,若不配置该项则使用与其他服务共用的公共数据库 + database: + host: "" + port: 3306 + connection: + properties: ?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull + username: "job" + password: "job" + # Quartz相关配置 + quartz: + # 调度器配置 + scheduler: + # 单次获取触发任务量的最大值 + batchTriggerAcquisitionMaxCount: 50 + # 线程池配置 + threadPool: + # 用于执行触发任务的线程池工作线程数量 + threadCount: 50 + # Feign相关配置块 + feign: + # Http类型的客户端配置 + httpclient: + # 最大连接数 + maxConnections: 300 + # 单个路由地址的最大连接数 + maxConnectionsPerRoute: 300 + # 客户端配置 + client: + config: + # 默认Client实例配置 + default: + # 连接超时,单位:毫秒 + connectTimeout: 5000 + # 读取超时,单位:毫秒 + readTimeout: 20000 ## job-logsvr日志服务配置 logsvrConfig: @@ -1129,6 +1174,17 @@ analysisConfig: type: ClusterIP # 运行时JVM参数 jvmOptions: "-Xms256m -Xmx256m -XX:NewRatio=1 -XX:SurvivorRatio=8" + # Feign相关配置块 + feign: + # 客户端配置 + client: + config: + # 默认Client实例配置 + default: + # 连接超时,单位:毫秒 + connectTimeout: 5000 + # 读取超时,单位:毫秒 + readTimeout: 300000 ## job-file-gateway文件网关服务配置 fileGatewayConfig: @@ -1514,6 +1570,17 @@ assembleConfig: port: 80 # 运行时JVM参数 jvmOptions: "-Xms512m -Xmx1024m -XX:NewRatio=1 -XX:SurvivorRatio=8" + # Feign相关配置块 + feign: + # 客户端配置 + client: + config: + # 默认Client实例配置 + default: + # 连接超时,单位:毫秒 + connectTimeout: 5000 + # 读取超时,单位:毫秒 + readTimeout: 300000 # pod删除时等待优雅关闭的最大时间,单位为秒(超出后强制删除) podTerminationGracePeriodSeconds: 40 diff --git a/support-files/templates/#etc#job#job-assemble#application-assemble.yml b/support-files/templates/#etc#job#job-assemble#application-assemble.yml index 0fa7083692..895a7daac8 100644 --- a/support-files/templates/#etc#job#job-assemble#application-assemble.yml +++ b/support-files/templates/#etc#job#job-assemble#application-assemble.yml @@ -269,24 +269,6 @@ spring: jdbc: # 是否自动使用 SQL 初始化 Quartz 表结构。这里设置成 never ,手动创建表结构 initialize-schema: never - thread-pool: - thread-name-prefix: QuartzThreadPoolTaskExecutor- - thread-priority: 5 - daemon: false - thread-group-name: QuartzThreadPoolTaskExecutorGroup - core-pool-size: 150 - max-pool-size: 300 - keep-alive-seconds: 60 - queue-capacity: 150 - allow-core-thread-timeout: false - waitfor-tasks-tocomplete-onshutdown: true - await-termination-seconds: 900 - scheduler: - scheduler-name: quartz-scheduler - application-context-scheduler-contextkey: applicationContext - overwrite-existing-jobs: true - auto-startup: true - startup-delay: 10 properties: org: quartz: @@ -313,7 +295,7 @@ spring: batchTriggerAcquisitionMaxCount: 50 threadPool: class: org.quartz.simpl.SimpleThreadPool - threadCount: 300 + threadCount: 50 ## 其他框架组件配置 ## server: diff --git a/support-files/templates/#etc#job#job-crontab#job-crontab.yml b/support-files/templates/#etc#job#job-crontab#job-crontab.yml index a4afe4aaf4..ddd97d5125 100644 --- a/support-files/templates/#etc#job#job-crontab#job-crontab.yml +++ b/support-files/templates/#etc#job#job-crontab#job-crontab.yml @@ -65,24 +65,6 @@ spring: jdbc: # 是否自动使用 SQL 初始化 Quartz 表结构。这里设置成 never ,手动创建表结构 initialize-schema: never - thread-pool: - thread-name-prefix: QuartzThreadPoolTaskExecutor- - thread-priority: 5 - daemon: false - thread-group-name: QuartzThreadPoolTaskExecutorGroup - core-pool-size: 150 - max-pool-size: 300 - keep-alive-seconds: 60 - queue-capacity: 150 - allow-core-thread-timeout: false - waitfor-tasks-tocomplete-onshutdown: true - await-termination-seconds: 900 - scheduler: - scheduler-name: quartz-scheduler - application-context-scheduler-contextkey: applicationContext - overwrite-existing-jobs: true - auto-startup: true - startup-delay: 10 properties: org: quartz: