-
Notifications
You must be signed in to change notification settings - Fork 505
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8392 from stubenhuang/issue-init-plugin-8338
feat: 容器化部署时自动上传插件到应用商店 #8338
- Loading branch information
Showing
7 changed files
with
116 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
helm-charts/core/ci/templates/configmap/monitoring-configmap.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#monitoring configmap | ||
{{ if .Values.configmap.enabled -}} | ||
kind: ConfigMap | ||
apiVersion: v1 | ||
metadata: | ||
name: {{ include "bkci.names.fullname" . }}-monitoring | ||
labels: {{- include "bkci.labels.standard" . | nindent 4 }} | ||
app.kubernetes.io/component: monitoring | ||
{{- if .Values.commonLabels }} | ||
{{- include "common.tplvalues.render" (dict "value" .Values.commonLabels "context" $) | nindent 4 }} | ||
{{- end }} | ||
{{- if .Values.commonAnnotations }} | ||
annotations: {{- include "common.tplvalues.render" (dict "value" .Values.commonAnnotations "context" $) | nindent 4 }} | ||
{{- end }} | ||
data: | ||
application.yml: |- | ||
{{- include "bkci.monitoring.yaml" . | nindent 4 -}} | ||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# 初始化商店插件 | ||
{{ if .Values.init.plugin.enabled }} | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: {{ include "bkci.names.fullname" . }}-init-plugin | ||
labels: {{- include "bkci.labels.standard" . | nindent 4 }} | ||
app.kubernetes.io/component: init-plugin | ||
annotations: | ||
"helm.sh/hook": post-install,post-upgrade | ||
"helm.sh/hook-weight": "0" | ||
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded | ||
spec: | ||
template: | ||
metadata: | ||
labels: {{- include "bkci.labels.standard" . | nindent 8 }} | ||
app.kubernetes.io/component: init-plugin | ||
spec: | ||
containers: | ||
- name: init-plugin | ||
image: {{ include "common.images.image" ( dict "imageRoot" .Values.backendImage "global" $) }} | ||
imagePullPolicy: {{ .Values.backendImage.pullPolicy }} | ||
workingDir: /data/workspace/ | ||
{{ $mysqlData := split ":" (include "bkci.mysqlAddr" .) }} | ||
command: | ||
- "/bin/bash" | ||
- "-c" | ||
- | | ||
services="store artifactory" | ||
for service in $services | ||
do | ||
until curl --connect-timeout 3 -m 1 -s "http://{{ include "bkci.names.fullname" . }}-$service.{{ .Release.Namespace }}.svc.cluster.local" > nohup | ||
do | ||
echo "waiting for {{ include "bkci.names.fullname" . }}-$service"; | ||
sleep 2; | ||
done | ||
echo "{{ include "bkci.names.fullname" . }}-$service is available"; | ||
done | ||
touch atom.sql | ||
touch atom.redis | ||
{{ range .Values.init.plugin.atoms }} | ||
atom_code={{ .code }} | ||
check_atom_url=http://{{ include "bkci.names.fullname" $ }}-store.{{ $.Release.Namespace }}.svc.cluster.local/api/service/pipeline/atom/codes/$atom_code/versions/1.0.0 | ||
check_atom_response=$(curl -s $check_atom_url) | ||
if [ -z $(echo $check_atom_response | grep -o "atomCode") ]; then | ||
atom_url={{ .url }} | ||
atom_file=${atom_code}.zip | ||
curl -s $atom_url -o $atom_file -L | ||
if [ $? -eq 0 ]; then | ||
curl "http://{{ include "bkci.names.fullname" $ }}-store.{{ $.Release.Namespace }}.svc.cluster.local/api/op/pipeline/atom/deploy" -H "X-DEVOPS-UID: admin" -F atomCode=$atom_code -F file=@$atom_file | ||
fi | ||
else | ||
echo "atomCode exists" | ||
fi | ||
echo 'UPDATE devops_ci_store.T_ATOM SET DEFAULT_FLAG=true WHERE ATOM_CODE="$atom_code"' >> atom.sql | ||
echo 'SADD STORE_PUBLIC_FLAG_KEY:ATOM $atom_code' >> atom.redis | ||
{{ end }} | ||
mysql -u{{- include "bkci.mysqlUsername" . }} -p{{- include "bkci.mysqlPassword" . }} -h{{ $mysqlData._0 }} -P{{ $mysqlData._1 }} < atom.sql | ||
redis-cli -h {{ include "bkci.redisHost" . }} -a {{ include "bkci.redisPassword" . }} -p {{ include "bkci.redisPort" . }} < atom.redis | ||
restartPolicy: OnFailure | ||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.