feat: Continuous helm polling to update database
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
dcb3decbd3
commit
a5e3c79d10
@ -54,6 +54,43 @@ data:
|
|||||||
<script src="script.js"></script>
|
<script src="script.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
update.sh: |
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
while getopts u: flag
|
||||||
|
do
|
||||||
|
case "${flag}" in
|
||||||
|
u) URL=${OPTARG};;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
[ $(curl -kLs -w "%{http_code}" -o /dev/null https://$URL) != 200 ] && {
|
||||||
|
echo 'Could not connect to' $URL
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '['$(date "+%Y-%m-%d %H:%M:%S")'] Started polling helm releases with 60 second interval'
|
||||||
|
|
||||||
|
while sleep 60;
|
||||||
|
do
|
||||||
|
echo '['$(date "+%Y-%m-%d %H:%M:%S")']' $(curl -ks https://$URL/components | jq length) 'known releases in database'
|
||||||
|
|
||||||
|
echo -n $(helm list --all-namespaces --output json | jq -c '.[]') | while IFS= read -r release;
|
||||||
|
do
|
||||||
|
APP_NAME=$(echo $release | jq -r '.name')
|
||||||
|
APP_ID=$(curl -ks https://$URL/components?name=$APP_NAME | jq -r '.[0].id')
|
||||||
|
|
||||||
|
# Release is not yet in database
|
||||||
|
[ "$APP_ID" == null ] && {
|
||||||
|
curl -ks -X POST https://$URL/components -H 'Content-Type: application/json' --data "$release"
|
||||||
|
}
|
||||||
|
# Release is already in database
|
||||||
|
[ "$APP_ID" != null ] && {
|
||||||
|
curl -ks -X PATCH https://$URL/components/$APP_ID -H 'Content-Type: application/json' --data "$release"
|
||||||
|
}
|
||||||
|
done
|
||||||
|
|
||||||
|
done
|
||||||
db.json: |
|
db.json: |
|
||||||
{{ include "common.tplvalues.render" ( dict "value" .Values.jsonServer.seedData.configInline "context" $) | indent 4 }}
|
{{ include "common.tplvalues.render" ( dict "value" .Values.jsonServer.seedData.configInline "context" $) | indent 4 }}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
@ -62,7 +62,12 @@ spec:
|
|||||||
command:
|
command:
|
||||||
- /bin/sh
|
- /bin/sh
|
||||||
- -c
|
- -c
|
||||||
- sleep infinity
|
- "/opt/update.sh -u {{ .Values.sidecar.targetUrl }}"
|
||||||
|
volumeMounts:
|
||||||
|
- name: {{ .Release.Name }}-configmap
|
||||||
|
mountPath: /opt/update.sh
|
||||||
|
subPath: update.sh
|
||||||
|
defaultMode: 0744
|
||||||
volumes:
|
volumes:
|
||||||
- name: {{ .Release.Name }}-configmap
|
- name: {{ .Release.Name }}-configmap
|
||||||
configMap:
|
configMap:
|
||||||
|
@ -13,6 +13,7 @@ jsonServer:
|
|||||||
tag: {{ image_tag }}
|
tag: {{ image_tag }}
|
||||||
|
|
||||||
sidecar:
|
sidecar:
|
||||||
|
targetUrl: metadata.example.org
|
||||||
image:
|
image:
|
||||||
repository: bv11-cr01.bessems.eu/library/json-server
|
repository: bv11-cr01.bessems.eu/library/json-server
|
||||||
pullPolicy: IfNotPresent
|
pullPolicy: IfNotPresent
|
||||||
|
Loading…
Reference in New Issue
Block a user