diff --git a/helm-charts/core/ci/build/values.yaml b/helm-charts/core/ci/build/values.yaml index 866bf5971ff..18360c76caf 100644 --- a/helm-charts/core/ci/build/values.yaml +++ b/helm-charts/core/ci/build/values.yaml @@ -71,6 +71,14 @@ multiCluster: # 兜底策略, 为空则不用兜底 defaultNamespace: "" +# 构建机资源配置变量 +buildResource: + publicDocker: + enabled: false + k8sBuild: + enabled: true + defaultValue: KUBERNETES + # 内部数据源配置 mysql: image: diff --git a/helm-charts/core/ci/templates/init/init.sql.yaml b/helm-charts/core/ci/templates/init/init.sql.yaml index 5f04d61611c..41ec7ce09b5 100644 --- a/helm-charts/core/ci/templates/init/init.sql.yaml +++ b/helm-charts/core/ci/templates/init/init.sql.yaml @@ -44,6 +44,6 @@ spec: - | for SQL in *.sql; do mysql -u{{- include "bkci.mysqlUsername" . }} -p{{- include "bkci.mysqlPassword" . }} -h{{ $mysqlData._0 }} -P{{ $mysqlData._1 }}< $SQL; done ; echo 'DELETE FROM devops_ci_store.T_CONTAINER WHERE ID = "d51a712508c011e99792fa163e50f2b5";'|mysql -u{{- include "bkci.mysqlUsername" . }} -p{{- include "bkci.mysqlPassword" . }} -h{{ $mysqlData._0 }} -P{{ $mysqlData._1 }} - echo 'update devops_ci_store.T_BUSINESS_CONFIG set CONFIG_VALUE="KUBERNETES" WHERE BUSINESS_VALUE="LINUX" AND FEATURE="defaultBuildType";'|mysql -u{{- include "bkci.mysqlUsername" . }} -p{{- include "bkci.mysqlPassword" . }} -h{{ $mysqlData._0 }} -P{{ $mysqlData._1 }} + echo 'update devops_ci_store.T_BUSINESS_CONFIG set CONFIG_VALUE="{{ .Values.buildResource.defaultValue }}" WHERE BUSINESS_VALUE="LINUX" AND FEATURE="defaultBuildType";'|mysql -u{{- include "bkci.mysqlUsername" . }} -p{{- include "bkci.mysqlPassword" . }} -h{{ $mysqlData._0 }} -P{{ $mysqlData._1 }} restartPolicy: OnFailure {{- end -}} diff --git a/helm-charts/core/ci/templates/store/deployment.yaml b/helm-charts/core/ci/templates/store/deployment.yaml index 84f054d22f2..836b8309b06 100644 --- a/helm-charts/core/ci/templates/store/deployment.yaml +++ b/helm-charts/core/ci/templates/store/deployment.yaml @@ -75,6 +75,10 @@ spec: value: {{ .Chart.Name }} - name: MULTI_CLUSTER value: {{ .Values.multiCluster.enabled | quote }} + - name: ENABLE_PUBLIC_DOCKER + value: {{ .Values.buildResource.publicDocker.enabled | quote }} + - name: ENABLE_K8S_BUILD + value: {{ .Values.buildResource.k8sBuild.enabled | quote }} - name: DEFAULT_NAMESPACE value: {{ .Values.multiCluster.defaultNamespace }} - name: POD_NAME @@ -95,19 +99,19 @@ spec: httpGet: path: /management/health/livenessState port: http - initialDelaySeconds: 200 + initialDelaySeconds: 90 periodSeconds: 15 timeoutSeconds: 10 - failureThreshold: 20 + failureThreshold: 30 successThreshold: 1 readinessProbe: httpGet: path: /management/health/readinessState port: http - initialDelaySeconds: 200 + initialDelaySeconds: 90 periodSeconds: 15 timeoutSeconds: 10 - failureThreshold: 20 + failureThreshold: 30 successThreshold: 1 volumeMounts: - mountPath: /data/workspace/store/jvm diff --git a/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/type/BuildType.kt b/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/type/BuildType.kt index 75d3d77e746..17eb549ab82 100644 --- a/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/type/BuildType.kt +++ b/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/type/BuildType.kt @@ -43,9 +43,9 @@ enum class BuildType( KUBERNETES( "Kubernetes构建资源", listOf(OS.LINUX), - KubernetesUtils.inContainer(), - KubernetesUtils.inContainer(), - KubernetesUtils.inContainer() + KubernetesUtils.enableK8sBuild(), + KubernetesUtils.enableK8sBuild(), + KubernetesUtils.enableK8sBuild() ), IDC("公共:Docker on IDC CVM", listOf(OS.LINUX), true, false, false), PUBLIC_DEVCLOUD("公共:Docker on DevCloud", listOf(OS.LINUX), true, false, false), @@ -59,9 +59,9 @@ enum class BuildType( DOCKER( "Docker公共构建机", listOf(OS.LINUX), - KubernetesUtils.notInContainer(), - KubernetesUtils.notInContainer(), - KubernetesUtils.notInContainer() + KubernetesUtils.enablePublicDocker(), + KubernetesUtils.enablePublicDocker(), + KubernetesUtils.enablePublicDocker() ), STREAM("stream", listOf(OS.LINUX), false, false, false), AGENT_LESS("无编译环境", listOf(OS.LINUX), false, false, false) diff --git a/src/backend/ci/core/common/common-service/src/main/kotlin/com/tencent/devops/common/service/utils/KubernetesUtils.kt b/src/backend/ci/core/common/common-service/src/main/kotlin/com/tencent/devops/common/service/utils/KubernetesUtils.kt index 9bef681d2cb..a81f55c8698 100644 --- a/src/backend/ci/core/common/common-service/src/main/kotlin/com/tencent/devops/common/service/utils/KubernetesUtils.kt +++ b/src/backend/ci/core/common/common-service/src/main/kotlin/com/tencent/devops/common/service/utils/KubernetesUtils.kt @@ -9,6 +9,19 @@ object KubernetesUtils { private val chartName = System.getenv("CHART_NAME") private val multiCluster = BooleanUtils.toBoolean(System.getenv("MULTI_CLUSTER")) private val defaultNamespace = System.getenv("DEFAULT_NAMESPACE") + private val enablePublicDocker = + BooleanUtils.toBoolean(StringUtils.defaultIfBlank(System.getenv("ENABLE_PUBLIC_DOCKER"), "true")) + private val enableK8sBuild = + BooleanUtils.toBoolean(StringUtils.defaultIfBlank(System.getenv("ENABLE_K8S_BUILD"), "false")) + + /** + * 是否开启docker公共构建机 + */ + fun enablePublicDocker() = enablePublicDocker + /** + * 是否开启k8s构建机 + */ + fun enableK8sBuild() = enableK8sBuild /** * 服务是否在容器中