Merge "feat(pipeline): enables images value override"
This commit is contained in:
commit
f0be23a0f8
@ -5,37 +5,37 @@ metadata:
|
|||||||
data:
|
data:
|
||||||
cluster.json: |
|
cluster.json: |
|
||||||
{
|
{
|
||||||
"use_existing_cluster": "true"
|
"use_existing_cluster": "true"
|
||||||
}
|
}
|
||||||
image.json: |
|
image.json: |
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"build_from_source": false,
|
"build_from_source": false,
|
||||||
"image_name": "mongodb-sharded",
|
"image_name": "mongodb-sharded",
|
||||||
"project": "mongodb",
|
"project": "mongodb",
|
||||||
"repo": "mongodb-sharded",
|
"repo": "mongodb-sharded",
|
||||||
"tag": "4.4.3",
|
"tag": "4.4.3",
|
||||||
"image_fullname": "mongodb/mongodb-sharded:4.4.3",
|
"image_fullname": "mongodb/mongodb-sharded:4.4.3",
|
||||||
"path": "",
|
"path": "",
|
||||||
"build": {
|
"build": {
|
||||||
"repo": "docker.io/bitnami/mongodb-sharded",
|
"repo": "docker.io/bitnami/mongodb-sharded",
|
||||||
"tag": "4.4.3-debian-10-r44"
|
"tag": "4.4.3-debian-10-r44"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"build_from_source": true,
|
"build_from_source": true,
|
||||||
"image_name": "mongodb",
|
"image_name": "mongodb",
|
||||||
"project": "mongodb",
|
"project": "mongodb",
|
||||||
"repo": "mongodb",
|
"repo": "mongodb",
|
||||||
"tag": "1.built",
|
"tag": "1.built",
|
||||||
"image_fullname": "mongodb/mongodb:1.0",
|
"image_fullname": "mongodb/mongodb:1.0",
|
||||||
"path": "tools/gate/jarvis/5G-SA-core/mongodb/images/mongodb",
|
"path": "tools/gate/jarvis/5G-SA-core/mongodb/images/mongodb",
|
||||||
"build": {
|
"build": {
|
||||||
"repo": "https://review.opendev.org/airship/charts",
|
"repo": "https://review.opendev.org/airship/charts",
|
||||||
"target_loc": "/src/checkout/mongodb",
|
"target_loc": "/src/checkout/mongodb",
|
||||||
"refspec": "master",
|
"refspec": "master",
|
||||||
"version": "refs/changes/*:refs/changes/*"
|
"version": "refs/changes/*:refs/changes/*"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
chart.json: |
|
chart.json: |
|
||||||
@ -54,13 +54,18 @@ data:
|
|||||||
},
|
},
|
||||||
"namespace": "development-pipeline",
|
"namespace": "development-pipeline",
|
||||||
"release_name": "mongodb-bitnami",
|
"release_name": "mongodb-bitnami",
|
||||||
"images": {
|
"sources": {
|
||||||
"applications": {
|
"image_map": {
|
||||||
"mongodb-sharded": {
|
"tag": ["releases", "image", "tag"],
|
||||||
"tag": "1.0",
|
"tmp_name": ["releases", "image", "repository"],
|
||||||
"name": "mongodb",
|
"tmp_repo": ["releases", "image", "registry"]
|
||||||
"repo": "mongodb"
|
}
|
||||||
}
|
},
|
||||||
|
"releases": {
|
||||||
|
"image": {
|
||||||
|
"registry": "docker.io",
|
||||||
|
"repository": "bitnami/mongodb-sharded",
|
||||||
|
"tag": "4.4.3-debian-10-r44"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -78,12 +83,21 @@ data:
|
|||||||
},
|
},
|
||||||
"namespace": "development-pipeline",
|
"namespace": "development-pipeline",
|
||||||
"release_name": "mongodb",
|
"release_name": "mongodb",
|
||||||
"images": {
|
"sources": {
|
||||||
"applications": {
|
"image_map": {
|
||||||
"mongodb": {
|
"tag": ["releases", "images", "applications", "mongodb", "tag"],
|
||||||
"tag": "1.0",
|
"tmp_name": ["releases", "images", "applications", "mongodb", "name"],
|
||||||
"name": "mongodb",
|
"tmp_repo": ["releases", "images", "applications", "mongodb", "repo"]
|
||||||
"repo": "mongodb"
|
}
|
||||||
|
},
|
||||||
|
"releases": {
|
||||||
|
"images": {
|
||||||
|
"applications": {
|
||||||
|
"mongodb": {
|
||||||
|
"tag": "1.0",
|
||||||
|
"name": "mongodb",
|
||||||
|
"repo": "mongodb"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -97,15 +111,15 @@ data:
|
|||||||
"noproxy": "",
|
"noproxy": "",
|
||||||
"enabled": false
|
"enabled": false
|
||||||
},
|
},
|
||||||
"chart_registry_url": "harbor-core.jarvis.local/chartrepo",
|
"chart_registry_url": "harbor-core.jarvis.local/chartrepo",
|
||||||
"chart_repository": "jarvis-harbor",
|
"chart_repository": "jarvis-harbor",
|
||||||
"docker_registry": "harbor-core.jarvis.local",
|
"docker_registry": "harbor-core.jarvis.local",
|
||||||
"harbor_secret_mounted_path": "/workspace/helm-creds",
|
"harbor_secret_mounted_path": "/workspace/helm-creds",
|
||||||
"clone_async_batch_size": 20,
|
"clone_async_batch_size": 20,
|
||||||
"chart_async_batch_size": 20,
|
"chart_async_batch_size": 20,
|
||||||
"image_async_batch_size": 2
|
"image_async_batch_size": 2
|
||||||
}
|
}
|
||||||
cleanup.json: |
|
cleanup.json: |
|
||||||
{
|
{
|
||||||
"remove_artifacts": "true"
|
"remove_artifacts": "true"
|
||||||
}
|
}
|
||||||
|
@ -23,13 +23,22 @@ spec:
|
|||||||
script: |
|
script: |
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
update-ca-certificates
|
update-ca-certificates
|
||||||
ansible-playbook -vvv {{ $.Values.tasks.functional.functionalPlaybook }} -i hosts -e '{"stage":"deploy"}' -e @"$(workspaces.development_pipeline_data.path)/default.json" -e @"$(workspaces.development_pipeline_data.path)/cluster.json" -e 'loop_source="$(workspaces.development_pipeline_data.path)/chart.json"'
|
ansible-playbook -vvv {{ $.Values.tasks.functional.functionalPlaybook }} -i hosts \
|
||||||
|
-e '{"stage":"deploy"}' \
|
||||||
|
-e @"$(workspaces.development_pipeline_data.path)/default.json" \
|
||||||
|
-e @"$(workspaces.development_pipeline_data.path)/cluster.json" \
|
||||||
|
-e 'loop_source="$(workspaces.development_pipeline_data.path)/chart.json"' \
|
||||||
|
-e 'datapath="$(workspaces.development_pipeline_data.path)"'
|
||||||
|
|
||||||
- name: run-helm-tests
|
- name: run-helm-tests
|
||||||
image: {{ $.Values.tasks.functional.functionalTestImage }}
|
image: {{ $.Values.tasks.functional.functionalTestImage }}
|
||||||
script: |
|
script: |
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
ansible-playbook -vvv {{ $.Values.tasks.functional.functionalPlaybook }} -i hosts -e '{"stage":"test"}' -e @"$(workspaces.development_pipeline_data.path)/default.json" -e @"$(workspaces.development_pipeline_data.path)/cluster.json" -e 'loop_source="$(workspaces.development_pipeline_data.path)/chart.json"'
|
ansible-playbook -vvv {{ $.Values.tasks.functional.functionalPlaybook }} -i hosts \
|
||||||
|
-e '{"stage":"test"}' \
|
||||||
|
-e @"$(workspaces.development_pipeline_data.path)/default.json" \
|
||||||
|
-e @"$(workspaces.development_pipeline_data.path)/cluster.json" \
|
||||||
|
-e 'loop_source="$(workspaces.development_pipeline_data.path)/chart.json"'
|
||||||
volumes:
|
volumes:
|
||||||
- name: helm-publish-creds
|
- name: helm-publish-creds
|
||||||
secret:
|
secret:
|
||||||
|
@ -21,6 +21,7 @@ RUN apt-get update ;\
|
|||||||
ca-certificates \
|
ca-certificates \
|
||||||
gnupg-agent \
|
gnupg-agent \
|
||||||
software-properties-common \
|
software-properties-common \
|
||||||
|
moreutils \
|
||||||
gettext-base ;\
|
gettext-base ;\
|
||||||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - ;\
|
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - ;\
|
||||||
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" ;\
|
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" ;\
|
||||||
|
@ -6,9 +6,36 @@
|
|||||||
when: ("{{ stage }}" == "deploy")
|
when: ("{{ stage }}" == "deploy")
|
||||||
block:
|
block:
|
||||||
#Deploy CNF
|
#Deploy CNF
|
||||||
|
|
||||||
- name: Deploy charts
|
- name: Deploy charts
|
||||||
shell: helm upgrade --install --kubeconfig="{{ cluster_kubeconfig_path }}/kubeconfig" "{{ chart.release_name }}" "{{ chart.project }}-staging/{{ chart.chart_name }}" --version="{{ chart.version }}" --namespace="{{ chart.namespace }}"
|
shell: |
|
||||||
|
set -xe ;
|
||||||
|
CHARTNAME={{ chart.chart_name }} ;
|
||||||
|
REPO={{ docker_registry }} ;
|
||||||
|
NAME={{ chart.project }}-staging/{{ chart.chart_name }} ;
|
||||||
|
|
||||||
|
jq -c --arg c $CHARTNAME --arg v $REPO 'map(if .repo == $c then .["tmp_repo"] = $v else . end)' {{ datapath }}/image.json | sponge {{ datapath }}/image.json ;
|
||||||
|
jq -c --arg c $CHARTNAME --arg v $NAME 'map(if .repo == $c then .["tmp_name"] = $v else . end)' {{ datapath }}/image.json | sponge {{ datapath }}/image.json ;
|
||||||
|
|
||||||
|
M=$(jq -c --arg c $CHARTNAME 'map(select(.chart_name == $c)) | first | .sources.image_map' {{ datapath }}/chart.json) ;
|
||||||
|
if [ "$M" != "null" ] && [ -n "$M" ] ; then \
|
||||||
|
echo $M | jq -r 'keys[]' | while IFS= read -r k; do \
|
||||||
|
v=$(echo $M | jq -c --arg k $k '.[$k]') ;\
|
||||||
|
filter=".$k" ;\
|
||||||
|
value=$(jq -c --arg c $CHARTNAME 'map(select(.image_name == $c)) | first' {{ datapath}}/image.json | jq -r $filter) ;\
|
||||||
|
jq -r --arg c $CHARTNAME --argjson k $v --arg v $value 'map(if .chart_name == $c then getpath($k) = $v else . end)' {{ datapath }}/chart.json | sponge {{ datapath }}/chart.json ;\
|
||||||
|
done ; \
|
||||||
|
fi ;
|
||||||
|
jq -c --arg c $CHARTNAME 'map(select(.chart_name == $c)) | first | .releases' \
|
||||||
|
{{ datapath }}/chart.json > {{ datapath }}/{{ chart.chart_name }}-overrides.json ;
|
||||||
|
cat {{ datapath }}/{{ chart.chart_name }}-overrides.json ;
|
||||||
|
helm upgrade --install \
|
||||||
|
--kubeconfig="{{ cluster_kubeconfig_path }}/kubeconfig" \
|
||||||
|
"{{ chart.release_name }}" "{{ chart.project }}-staging/{{ chart.chart_name }}" \
|
||||||
|
--version="{{ chart.version }}" \
|
||||||
|
--values="{{ datapath }}/{{ chart.chart_name }}-overrides.json" \
|
||||||
|
--namespace="{{ chart.namespace }}"
|
||||||
|
args:
|
||||||
|
executable: /bin/bash
|
||||||
loop: "{{ charts }}"
|
loop: "{{ charts }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
loop_var: "chart"
|
loop_var: "chart"
|
||||||
|
Loading…
Reference in New Issue
Block a user