Compare commits
19 Commits
Author | SHA1 | Date | |
---|---|---|---|
15daa960c2 | |||
105bc71e9c | |||
a6d6e91ffa | |||
e8822fc8da | |||
fa2c72cb68 | |||
2725f36017 | |||
0af8f2ac5e | |||
6270499efe | |||
44ac6b484d | |||
6f07cc8d87 | |||
a5e3c79d10 | |||
dcb3decbd3 | |||
3c141a2d40 | |||
0999fdf705 | |||
6c71c5f364 | |||
c551a242c7 | |||
ec36309d8d | |||
93ff24ac73 | |||
614fda9b7d |
14
.drone.yml
14
.drone.yml
@ -48,7 +48,7 @@ steps:
|
|||||||
pull: always
|
pull: always
|
||||||
commands:
|
commands:
|
||||||
- |
|
- |
|
||||||
export IMAGE_TAG=$(cat .version 2> /dev/null) && [ -n "$IMAGE_TAG" ] || (echo 'No release tag - exiting'; exit 0)
|
export VALID_TAG=$(cat .version 2> /dev/null) && [ -n "$VALID_TAG" ] || (echo 'No release tag - exiting'; exit 0)
|
||||||
- |
|
- |
|
||||||
wget https://github.com/jqlang/jq/releases/download/jq-1.6/jq-linux64 -qO /bin/jq
|
wget https://github.com/jqlang/jq/releases/download/jq-1.6/jq-linux64 -qO /bin/jq
|
||||||
chmod +x /bin/jq
|
chmod +x /bin/jq
|
||||||
@ -59,7 +59,7 @@ steps:
|
|||||||
--dockerfile=Dockerfile \
|
--dockerfile=Dockerfile \
|
||||||
--context=dir://. \
|
--context=dir://. \
|
||||||
--destination=bv11-cr01.bessems.eu/library/json-server:latest \
|
--destination=bv11-cr01.bessems.eu/library/json-server:latest \
|
||||||
--destination=bv11-cr01.bessems.eu/library/json-server:$IMAGE_TAG
|
--destination=bv11-cr01.bessems.eu/library/json-server:$VALID_TAG
|
||||||
environment:
|
environment:
|
||||||
HARBOR_USERNAME:
|
HARBOR_USERNAME:
|
||||||
from_secret: harbor_username
|
from_secret: harbor_username
|
||||||
@ -73,7 +73,7 @@ steps:
|
|||||||
pull: always
|
pull: always
|
||||||
commands:
|
commands:
|
||||||
- |
|
- |
|
||||||
export IMAGE_TAG=$(cat .version 2> /dev/null) && [ -n "$IMAGE_TAG" ] || (echo 'No release tag - exiting'; exit 0)
|
export VALID_TAG=$(cat .version 2> /dev/null) && [ -n "$VALID_TAG" ] || (echo 'No release tag - exiting'; exit 0)
|
||||||
- |
|
- |
|
||||||
wget https://github.com/jqlang/jq/releases/download/jq-1.6/jq-linux64 -qO /bin/jq
|
wget https://github.com/jqlang/jq/releases/download/jq-1.6/jq-linux64 -qO /bin/jq
|
||||||
chmod +x /bin/jq
|
chmod +x /bin/jq
|
||||||
@ -84,7 +84,7 @@ steps:
|
|||||||
--dockerfile=Dockerfile \
|
--dockerfile=Dockerfile \
|
||||||
--context=dir://. \
|
--context=dir://. \
|
||||||
--destination=docker.io/djpbessems/json-server:latest \
|
--destination=docker.io/djpbessems/json-server:latest \
|
||||||
--destination=docker.io/djpbessems/json-server:$IMAGE_TAG
|
--destination=docker.io/djpbessems/json-server:$VALID_TAG
|
||||||
environment:
|
environment:
|
||||||
DOCKER_USERNAME:
|
DOCKER_USERNAME:
|
||||||
from_secret: docker_username
|
from_secret: docker_username
|
||||||
@ -98,9 +98,9 @@ steps:
|
|||||||
pull: always
|
pull: always
|
||||||
commands:
|
commands:
|
||||||
- |
|
- |
|
||||||
export CHART_VERSION=$(cat .version 2> /dev/null) && [ -n "$CHART_VERSION" ] || (echo 'No release tag - exiting'; exit 0)
|
export VALID_TAG=$(cat .version 2> /dev/null) && [ -n "$VALID_TAG" ] || (echo 'No release tag - exiting'; exit 0)
|
||||||
sed -i 's/{{ chart_version }}/'$CHART_VERSION'/g' charts/json-server/Chart.yaml
|
sed -i 's/{{ chart_version }}/'$VALID_TAG'/g' charts/json-server/Chart.yaml
|
||||||
sed -i 's/tag: latest/tag: '$CHART_VERSION'/g' charts/json-server/values.yaml
|
sed -i 's/{{ image_tag }}/'$VALID_TAG'/g' charts/json-server/values.yaml
|
||||||
- |
|
- |
|
||||||
helm package ./charts/json-server
|
helm package ./charts/json-server
|
||||||
- |
|
- |
|
||||||
|
52
CHANGELOG.md
52
CHANGELOG.md
@ -1,3 +1,55 @@
|
|||||||
|
## [0.8.2](https://code.spamasaurus.com/djpbessems/ContainerImage.JSONServer/compare/v0.8.1...v0.8.2) (2023-07-16)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* Remove race condition when testing target url ([105bc71](https://code.spamasaurus.com/djpbessems/ContainerImage.JSONServer/commit/105bc71e9c16ebf9afa5a4027d1131f311a76c5e))
|
||||||
|
* Set filemode per key ([a6d6e91](https://code.spamasaurus.com/djpbessems/ContainerImage.JSONServer/commit/a6d6e91ffadd13650c0ce44d0c43e96dea3c6711))
|
||||||
|
|
||||||
|
## [0.8.1](https://code.spamasaurus.com/djpbessems/ContainerImage.JSONServer/compare/v0.8.0...v0.8.1) (2023-07-14)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* Add missing dependency ([6270499](https://code.spamasaurus.com/djpbessems/ContainerImage.JSONServer/commit/6270499efecb8ae1474f1ce29c8f4003da3916df))
|
||||||
|
* Fix linebreak ([fa2c72c](https://code.spamasaurus.com/djpbessems/ContainerImage.JSONServer/commit/fa2c72cb68254dd0e27f12220f8056b9223223ed))
|
||||||
|
* Refactor update script for bash interpreter ([2725f36](https://code.spamasaurus.com/djpbessems/ContainerImage.JSONServer/commit/2725f360179b3dab1d77d5f429b2f60d4aabcd4a))
|
||||||
|
* Workaround for set locale warning ([0af8f2a](https://code.spamasaurus.com/djpbessems/ContainerImage.JSONServer/commit/0af8f2ac5ea0f8453fdb7120aeb7eff15aa88e42))
|
||||||
|
|
||||||
|
# [0.8.0](https://code.spamasaurus.com/djpbessems/ContainerImage.JSONServer/compare/v0.7.3...v0.8.0) (2023-07-14)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* Fix linebreak ([6f07cc8](https://code.spamasaurus.com/djpbessems/ContainerImage.JSONServer/commit/6f07cc8d876d49be0a798772b62f93b09efba110))
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* Continuous helm polling to update database ([a5e3c79](https://code.spamasaurus.com/djpbessems/ContainerImage.JSONServer/commit/a5e3c79d10a378336e5a6af267f7d28997cd9a8c))
|
||||||
|
* Rebase sidecar container image ([dcb3dec](https://code.spamasaurus.com/djpbessems/ContainerImage.JSONServer/commit/dcb3decbd3d4e1507aba351f11cd4a148822b06b))
|
||||||
|
|
||||||
|
## [0.7.3](https://code.spamasaurus.com/djpbessems/ContainerImage.JSONServer/compare/v0.7.2...v0.7.3) (2023-07-14)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* Missing period in chart template ([0999fdf](https://code.spamasaurus.com/djpbessems/ContainerImage.JSONServer/commit/0999fdf7051d6e8a2161333980bd1aedd9f180ef))
|
||||||
|
|
||||||
|
## [0.7.2](https://code.spamasaurus.com/djpbessems/ContainerImage.JSONServer/compare/v0.7.1...v0.7.2) (2023-07-14)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* Adhere to naming convention in templates ([c551a24](https://code.spamasaurus.com/djpbessems/ContainerImage.JSONServer/commit/c551a242c7a49a445da68ba6e1e5966eeb5ce7d7))
|
||||||
|
|
||||||
|
## [0.7.1](https://code.spamasaurus.com/djpbessems/ContainerImage.JSONServer/compare/v0.7.0...v0.7.1) (2023-07-14)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* Adhere to naming convention in values.yaml ([614fda9](https://code.spamasaurus.com/djpbessems/ContainerImage.JSONServer/commit/614fda9b7d284862bd84a1eab62ba8144f798199))
|
||||||
|
|
||||||
# [0.7.0](https://code.spamasaurus.com/djpbessems/ContainerImage.JSONServer/compare/v0.6.0...v0.7.0) (2023-07-14)
|
# [0.7.0](https://code.spamasaurus.com/djpbessems/ContainerImage.JSONServer/compare/v0.6.0...v0.7.0) (2023-07-14)
|
||||||
|
|
||||||
|
|
||||||
|
29
Dockerfile
29
Dockerfile
@ -1,8 +1,31 @@
|
|||||||
FROM node:lts-slim AS build
|
FROM alpine:latest AS download
|
||||||
|
|
||||||
RUN npm install -g --omit=optional --omit=dev \
|
RUN apk --update add --no-cache \
|
||||||
|
curl \
|
||||||
|
jq && \
|
||||||
|
curl -L https://api.github.com/repos/helm/helm/releases/latest | \
|
||||||
|
jq -r '.tag_name' | \
|
||||||
|
xargs -I {} curl -L -o /tmp/helm.tar.gz https://get.helm.sh/helm-{}-linux-amd64.tar.gz && \
|
||||||
|
tar -xzf /tmp/helm.tar.gz --strip-components=1 -C /tmp
|
||||||
|
|
||||||
|
FROM node:lts-slim
|
||||||
|
|
||||||
|
COPY --from=download /tmp/helm /usr/bin/helm
|
||||||
|
|
||||||
|
ENV LANG en_US.UTF-8
|
||||||
|
ENV LANGUAGE en_US:en
|
||||||
|
ENV LC_ALL en_US.UTF-8
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get upgrade -y && apt-get install -y --no-install-recommends \
|
||||||
|
curl \
|
||||||
|
jq \
|
||||||
|
locales && \
|
||||||
|
sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && \
|
||||||
|
locale-gen && \
|
||||||
|
npm install -g --omit=optional --omit=dev \
|
||||||
json-server && \
|
json-server && \
|
||||||
npm cache clean --force
|
npm cache clean --force && \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
COPY init/entrypoint.sh /opt/entrypoint.sh
|
COPY init/entrypoint.sh /opt/entrypoint.sh
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ metadata:
|
|||||||
subjects:
|
subjects:
|
||||||
- kind: ServiceAccount
|
- kind: ServiceAccount
|
||||||
name: {{ include "json-server.serviceAccountName" . }}
|
name: {{ include "json-server.serviceAccountName" . }}
|
||||||
namespace: {{ Release.Namespace }}
|
namespace: {{ .Release.Namespace }}
|
||||||
roleRef:
|
roleRef:
|
||||||
kind: ClusterRole
|
kind: ClusterRole
|
||||||
name: {{ .Release.Name }}-clusterrole
|
name: {{ .Release.Name }}-clusterrole
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{{- if not .Values.json-server.seedData.existingConfigMap }}
|
{{- if not .Values.jsonServer.seedData.existingConfigMap }}
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: ConfigMap
|
kind: ConfigMap
|
||||||
metadata:
|
metadata:
|
||||||
@ -54,6 +54,43 @@ data:
|
|||||||
<script src="script.js"></script>
|
<script src="script.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
update.sh: |
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
while getopts u: flag
|
||||||
|
do
|
||||||
|
case "${flag}" in
|
||||||
|
u) URL=${OPTARG};;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
[[ $(getent hosts $URL) ]] || {
|
||||||
|
echo 'Could not resolve' $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'
|
||||||
|
|
||||||
|
for entry in $(helm list --all-namespaces --output json | jq -r '.[] | @base64'); do
|
||||||
|
RELEASE=$(echo $entry | base64 -d)
|
||||||
|
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" -o /dev/null
|
||||||
|
}
|
||||||
|
# Release is already in database
|
||||||
|
[ "$APP_ID" != null ] && {
|
||||||
|
curl -ks -X PATCH https://$URL/components/$APP_ID -H 'Content-Type: application/json' --data "$RELEASE" -o /dev/null
|
||||||
|
}
|
||||||
|
done
|
||||||
|
|
||||||
|
done
|
||||||
db.json: |
|
db.json: |
|
||||||
{{ include "common.tplvalues.render" ( dict "value" .Values.json-server.seedData.configInline "context" $) | indent 4 }}
|
{{ include "common.tplvalues.render" ( dict "value" .Values.jsonServer.seedData.configInline "context" $) | indent 4 }}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
@ -29,8 +29,8 @@ spec:
|
|||||||
- name: {{ .Chart.Name }}
|
- name: {{ .Chart.Name }}
|
||||||
securityContext:
|
securityContext:
|
||||||
{{- toYaml .Values.securityContext | nindent 12 }}
|
{{- toYaml .Values.securityContext | nindent 12 }}
|
||||||
image: "{{ .Values.json-server.image.repository }}:{{ .Values.json-server.image.tag | default .Chart.AppVersion }}"
|
image: "{{ .Values.jsonServer.image.repository }}:{{ .Values.jsonServer.image.tag | default .Chart.AppVersion }}"
|
||||||
imagePullPolicy: {{ .Values.json-server.image.pullPolicy }}
|
imagePullPolicy: {{ .Values.jsonServer.image.pullPolicy }}
|
||||||
ports:
|
ports:
|
||||||
- name: http
|
- name: http
|
||||||
containerPort: {{ .Values.service.port }}
|
containerPort: {{ .Values.service.port }}
|
||||||
@ -60,13 +60,25 @@ spec:
|
|||||||
resources:
|
resources:
|
||||||
{{- toYaml .Values.resources | nindent 12 }}
|
{{- toYaml .Values.resources | nindent 12 }}
|
||||||
command:
|
command:
|
||||||
- /bin/sh
|
- /bin/bash
|
||||||
- -c
|
- -c
|
||||||
- sleep infinity
|
- "/opt/update.sh -u {{ .Values.sidecar.targetUrl }}"
|
||||||
|
volumeMounts:
|
||||||
|
- name: {{ .Release.Name }}-configmap
|
||||||
|
mountPath: /opt/update.sh
|
||||||
|
subPath: update.sh
|
||||||
volumes:
|
volumes:
|
||||||
- name: {{ .Release.Name }}-configmap
|
- name: {{ .Release.Name }}-configmap
|
||||||
configMap:
|
configMap:
|
||||||
name: {{ .Release.Name }}-configmap
|
name: {{ .Release.Name }}-configmap
|
||||||
|
items:
|
||||||
|
- key: db.json
|
||||||
|
path: db.json
|
||||||
|
- key: index.html
|
||||||
|
path: index.html
|
||||||
|
- key: update.sh
|
||||||
|
path: update.sh
|
||||||
|
mode: 0744
|
||||||
{{- with .Values.nodeSelector }}
|
{{- with .Values.nodeSelector }}
|
||||||
nodeSelector:
|
nodeSelector:
|
||||||
{{- toYaml . | nindent 8 }}
|
{{- toYaml . | nindent 8 }}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# Default values for json-server.
|
# Default values for json-server.
|
||||||
|
|
||||||
json-server:
|
jsonServer:
|
||||||
seedData:
|
seedData:
|
||||||
# Not implemented yet
|
# Not implemented yet
|
||||||
# existingConfigMap: ""
|
# existingConfigMap: ""
|
||||||
@ -10,13 +10,15 @@ json-server:
|
|||||||
repository: bv11-cr01.bessems.eu/library/json-server
|
repository: bv11-cr01.bessems.eu/library/json-server
|
||||||
pullPolicy: IfNotPresent
|
pullPolicy: IfNotPresent
|
||||||
# Overrides the image tag whose default is the chart appVersion.
|
# Overrides the image tag whose default is the chart appVersion.
|
||||||
tag: latest
|
tag: {{ image_tag }}
|
||||||
|
|
||||||
sidecar:
|
sidecar:
|
||||||
|
targetUrl: metadata.example.org
|
||||||
image:
|
image:
|
||||||
repository: alpine/helm
|
repository: bv11-cr01.bessems.eu/library/json-server
|
||||||
pullPolicy: IfNotPresent
|
pullPolicy: IfNotPresent
|
||||||
tag: 3.12.1
|
# Overrides the image tag whose default is the chart appVersion.
|
||||||
|
tag: {{ image_tag }}
|
||||||
|
|
||||||
replicaCount: 1
|
replicaCount: 1
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user