27 Commits

Author SHA1 Message Date
15daa960c2 chore(release): 0.8.2 [skip ci]
## [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](105bc71e9c))
* Set filemode per key ([a6d6e91](a6d6e91ffa))
2023-07-16 09:48:56 +00:00
105bc71e9c fix: Remove race condition when testing target url
All checks were successful
continuous-integration/drone/push Build is passing
2023-07-16 11:46:17 +02:00
a6d6e91ffa fix: Set filemode per key 2023-07-16 11:45:19 +02:00
e8822fc8da chore(release): 0.8.1 [skip ci]
## [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](6270499efe))
* Fix linebreak ([fa2c72c](fa2c72cb68))
* Refactor update script for bash interpreter ([2725f36](2725f36017))
* Workaround for set locale warning ([0af8f2a](0af8f2ac5e))
2023-07-14 13:29:52 +00:00
fa2c72cb68 fix: Fix linebreak
All checks were successful
continuous-integration/drone/push Build is passing
2023-07-14 15:27:18 +02:00
2725f36017 fix: Refactor update script for bash interpreter
Some checks failed
continuous-integration/drone/push Build is failing
2023-07-14 15:25:42 +02:00
0af8f2ac5e fix: Workaround for set locale warning 2023-07-14 15:25:00 +02:00
6270499efe fix: Add missing dependency 2023-07-14 14:57:31 +02:00
44ac6b484d chore(release): 0.8.0 [skip ci]
# [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](6f07cc8d87))

### Features

* Continuous helm polling to update database ([a5e3c79](a5e3c79d10))
* Rebase sidecar container image ([dcb3dec](dcb3decbd3))
2023-07-14 11:44:02 +00:00
6f07cc8d87 fix: Fix linebreak
All checks were successful
continuous-integration/drone/push Build is passing
2023-07-14 13:41:25 +02:00
a5e3c79d10 feat: Continuous helm polling to update database
Some checks failed
continuous-integration/drone/push Build is failing
2023-07-14 13:39:28 +02:00
dcb3decbd3 feat: Rebase sidecar container image 2023-07-14 13:39:10 +02:00
3c141a2d40 chore(release): 0.7.3 [skip ci]
## [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](0999fdf705))
2023-07-14 08:45:47 +00:00
0999fdf705 fix: Missing period in chart template
All checks were successful
continuous-integration/drone/push Build is passing
2023-07-14 10:43:47 +02:00
6c71c5f364 chore(release): 0.7.2 [skip ci]
## [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](c551a242c7))
2023-07-14 08:42:11 +00:00
c551a242c7 fix: Adhere to naming convention in templates
All checks were successful
continuous-integration/drone/push Build is passing
2023-07-14 10:40:08 +02:00
ec36309d8d chore(release): 0.7.1 [skip ci]
## [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](614fda9b7d))
2023-07-14 08:39:28 +00:00
93ff24ac73 Merge branch 'main' of https://code.spamasaurus.com/djpbessems/ContainerImage.JSONServer into main
All checks were successful
continuous-integration/drone/push Build is passing
2023-07-14 10:37:21 +02:00
614fda9b7d fix: Adhere to naming convention in values.yaml 2023-07-14 10:37:10 +02:00
78b8d6872a chore(release): 0.7.0 [skip ci]
# [0.7.0](https://code.spamasaurus.com/djpbessems/ContainerImage.JSONServer/compare/v0.6.0...v0.7.0) (2023-07-14)

### Features

* Add sidecar for continuous polling ([806757a](806757a913))
2023-07-14 08:24:10 +00:00
d09d09e526 build: Group shell commands to avoid unintended exit
All checks were successful
continuous-integration/drone/push Build is passing
2023-07-14 10:22:06 +02:00
806757a913 feat: Add sidecar for continuous polling
All checks were successful
continuous-integration/drone/push Build is passing
2023-07-14 10:15:55 +02:00
d40f35a2d6 build: Debug exit behaviour #2
All checks were successful
continuous-integration/drone/push Build is passing
2023-07-13 10:45:25 +02:00
c61bc4fc8d build: Debug exit behaviour
Some checks reported errors
continuous-integration/drone/push Build encountered an error
2023-07-13 10:42:53 +02:00
cbd981cf19 build: Revert using export and refactor to gracefully exit on an empty value
Some checks reported errors
continuous-integration/drone/push Build encountered an error
2023-07-13 10:33:33 +02:00
f4457a1275 build: Add graceful exit if semantic release does not create a new version
Some checks failed
continuous-integration/drone/push Build is failing
2023-07-13 09:17:42 +02:00
377885f802 build: Create and upload changelog file
Some checks failed
continuous-integration/drone/push Build is failing
2023-07-12 12:22:42 +02:00
10 changed files with 219 additions and 27 deletions

View File

@ -47,19 +47,19 @@ steps:
image: gcr.io/kaniko-project/executor:debug
pull: always
commands:
- |
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
chmod +x /bin/jq
- |
/bin/jq '.auths["https://bv11-cr01.bessems.eu/v2/"].auth="'"$(echo -n $HARBOR_USERNAME':'$HARBOR_PASSWORD | base64)"'"' --null-input > /kaniko/.docker/config.json
- |
export IMAGE_TAG=$(cat .version)
- |
/kaniko/executor \
--dockerfile=Dockerfile \
--context=dir://. \
--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:
HARBOR_USERNAME:
from_secret: harbor_username
@ -72,11 +72,11 @@ steps:
image: gcr.io/kaniko-project/executor:debug
pull: always
commands:
- |
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
chmod +x /bin/jq
- |
export IMAGE_TAG=$(cat .version)
- |
/bin/jq '.auths["https://index.docker.io/v1/"].auth="'"$(echo -n $DOCKER_USERNAME':'$DOCKER_PASSWORD | base64)"'"' --null-input > /kaniko/.docker/config.json
- |
@ -84,7 +84,7 @@ steps:
--dockerfile=Dockerfile \
--context=dir://. \
--destination=docker.io/djpbessems/json-server:latest \
--destination=docker.io/djpbessems/json-server:$IMAGE_TAG
--destination=docker.io/djpbessems/json-server:$VALID_TAG
environment:
DOCKER_USERNAME:
from_secret: docker_username
@ -98,9 +98,9 @@ steps:
pull: always
commands:
- |
export CHART_VERSION=$(cat .version)
sed -i 's/{{ chart_version }}/'$CHART_VERSION'/g' charts/json-server/Chart.yaml
sed -i 's/tag: latest/tag: '$CHART_VERSION'/g' charts/json-server/values.yaml
export VALID_TAG=$(cat .version 2> /dev/null) && [ -n "$VALID_TAG" ] || (echo 'No release tag - exiting'; exit 0)
sed -i 's/{{ chart_version }}/'$VALID_TAG'/g' charts/json-server/Chart.yaml
sed -i 's/{{ image_tag }}/'$VALID_TAG'/g' charts/json-server/values.yaml
- |
helm package ./charts/json-server
- |
@ -128,6 +128,8 @@ steps:
image: bv11-cr01.bessems.eu/proxy/library/node:20-slim
pull: always
commands:
- |
export VALID_TAG=$(cat .version 2> /dev/null) && [ -n "$VALID_TAG" ] || (echo 'No release tag - exiting'; exit 0)
- |
apt-get update
- |
@ -137,6 +139,7 @@ steps:
- |
npm install \
semantic-release \
@semantic-release/changelog \
@semantic-release/commit-analyzer \
@semantic-release/git \
@semantic-release/release-notes-generator
@ -146,7 +149,7 @@ steps:
npx semantic-release \
--branches ${DRONE_BRANCH} \
--tag-format "v\$${version}" \
--plugins @semantic-release/commit-analyzer,@semantic-release/release-notes-generator,@semantic-release/git
--plugins @semantic-release/commit-analyzer,@semantic-release/release-notes-generator,@semantic-release/changelog,@semantic-release/git
environment:
GIT_APIKEY:
from_secret: git_apikey

58
CHANGELOG.md Normal file
View File

@ -0,0 +1,58 @@
## [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)
### Features
* Add sidecar for continuous polling ([806757a](https://code.spamasaurus.com/djpbessems/ContainerImage.JSONServer/commit/806757a9135341d919b31d4183a84e3870c24f3f))

View File

@ -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 && \
npm cache clean --force
npm cache clean --force && \
rm -rf /var/lib/apt/lists/*
COPY init/entrypoint.sh /opt/entrypoint.sh

View File

@ -0,0 +1,8 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ .Release.Name }}-clusterrole
rules:
- apiGroups: [""]
resources: ["secrets"]
verbs: ["get", "list"]

View File

@ -0,0 +1,12 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ .Release.Name }}-clusterrolebinding
subjects:
- kind: ServiceAccount
name: {{ include "json-server.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
roleRef:
kind: ClusterRole
name: {{ .Release.Name }}-clusterrole
apiGroup: rbac.authorization.k8s.io

View File

@ -1,4 +1,4 @@
{{- if not .Values.seedData.existingConfigMap }}
{{- if not .Values.jsonServer.seedData.existingConfigMap }}
apiVersion: v1
kind: ConfigMap
metadata:
@ -54,6 +54,43 @@ data:
<script src="script.js"></script>
</body>
</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: |
{{ include "common.tplvalues.render" ( dict "value" .Values.seedData.configInline "context" $) | indent 4 }}
{{ include "common.tplvalues.render" ( dict "value" .Values.jsonServer.seedData.configInline "context" $) | indent 4 }}
{{- end -}}

View File

@ -29,8 +29,8 @@ spec:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
image: "{{ .Values.jsonServer.image.repository }}:{{ .Values.jsonServer.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.jsonServer.image.pullPolicy }}
ports:
- name: http
containerPort: {{ .Values.service.port }}
@ -52,10 +52,33 @@ spec:
- name: {{ .Release.Name }}-configmap
mountPath: /usr/local/lib/node_modules/json-server/public/index.html
subPath: index.html
- name: {{ .Chart.Name }}-sidecar
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.sidecar.image.repository }}:{{ .Values.sidecar.image.tag }}"
imagePullPolicy: {{ .Values.sidecar.image.pullPolicy }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
command:
- /bin/bash
- -c
- "/opt/update.sh -u {{ .Values.sidecar.targetUrl }}"
volumeMounts:
- name: {{ .Release.Name }}-configmap
mountPath: /opt/update.sh
subPath: update.sh
volumes:
- name: {{ .Release.Name }}-configmap
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 }}
nodeSelector:
{{- toYaml . | nindent 8 }}

View File

@ -1,18 +1,27 @@
# Default values for json-server.
seedData:
# Not implemented yet
# existingConfigMap: ""
configInline: {}
jsonServer:
seedData:
# Not implemented yet
# existingConfigMap: ""
configInline: {}
image:
repository: bv11-cr01.bessems.eu/library/json-server
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: {{ image_tag }}
sidecar:
targetUrl: metadata.example.org
image:
repository: bv11-cr01.bessems.eu/library/json-server
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: {{ image_tag }}
replicaCount: 1
image:
repository: bv11-cr01.bessems.eu/library/json-server
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: latest
imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""

18
package-lock.json generated
View File

@ -5,6 +5,7 @@
"packages": {
"": {
"dependencies": {
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/commit-analyzer": "^10.0.1",
"@semantic-release/exec": "^6.0.3",
"@semantic-release/git": "^10.0.1",
@ -287,6 +288,23 @@
"node": ">=12"
}
},
"node_modules/@semantic-release/changelog": {
"version": "6.0.3",
"resolved": "https://registry.npmjs.org/@semantic-release/changelog/-/changelog-6.0.3.tgz",
"integrity": "sha512-dZuR5qByyfe3Y03TpmCvAxCyTnp7r5XwtHRf/8vD9EAn4ZWbavUX8adMtXYzE86EVh0gyLA7lm5yW4IV30XUag==",
"dependencies": {
"@semantic-release/error": "^3.0.0",
"aggregate-error": "^3.0.0",
"fs-extra": "^11.0.0",
"lodash": "^4.17.4"
},
"engines": {
"node": ">=14.17"
},
"peerDependencies": {
"semantic-release": ">=18.0.0"
}
},
"node_modules/@semantic-release/commit-analyzer": {
"version": "10.0.1",
"resolved": "https://registry.npmjs.org/@semantic-release/commit-analyzer/-/commit-analyzer-10.0.1.tgz",

View File

@ -1,5 +1,6 @@
{
"dependencies": {
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/commit-analyzer": "^10.0.1",
"@semantic-release/exec": "^6.0.3",
"@semantic-release/git": "^10.0.1",