Skip to content

Commit

Permalink
Merge pull request #7880 from stubenhuang/issue-docker-config-7856
Browse files Browse the repository at this point in the history
feat: 公共构建机支持可配置 #7856
  • Loading branch information
irwinsun authored Oct 28, 2022
2 parents 56c01c7 + 1461f8d commit 133cea4
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 11 deletions.
8 changes: 8 additions & 0 deletions helm-charts/core/ci/build/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ multiCluster:
# 兜底策略, 为空则不用兜底
defaultNamespace: ""

# 构建机资源配置变量
buildResource:
publicDocker:
enabled: false
k8sBuild:
enabled: true
defaultValue: KUBERNETES

# 内部数据源配置
mysql:
image:
Expand Down
2 changes: 1 addition & 1 deletion helm-charts/core/ci/templates/init/init.sql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}
12 changes: 8 additions & 4 deletions helm-charts/core/ci/templates/store/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
* 服务是否在容器中
Expand Down

0 comments on commit 133cea4

Please sign in to comment.