feat: Add sidecar for continuous polling
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Danny Bessems 2023-07-14 10:15:55 +02:00
parent d40f35a2d6
commit 806757a913
6 changed files with 56 additions and 18 deletions

View File

@ -48,7 +48,7 @@ steps:
pull: always pull: always
commands: commands:
- | - |
export IMAGE_TAG=$(cat .version) && [ -n "$IMAGE_TAG" ] || echo 'No release tag - exiting'; exit 0 export IMAGE_TAG=$(cat .version 2> /dev/null) && [ -n "$IMAGE_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
@ -73,7 +73,7 @@ steps:
pull: always pull: always
commands: commands:
- | - |
export IMAGE_TAG=$(cat .version) && [ -n "$IMAGE_TAG" ] || echo 'No release tag - exiting'; exit 0 export IMAGE_TAG=$(cat .version 2> /dev/null) && [ -n "$IMAGE_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
@ -98,7 +98,7 @@ steps:
pull: always pull: always
commands: commands:
- | - |
export CHART_VERSION=$(cat .version) && [ -n "$CHART_VERSION" ] || echo 'No release tag - exiting'; exit 0 export CHART_VERSION=$(cat .version 2> /dev/null) && [ -n "$CHART_VERSION" ] || 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 }}/'$CHART_VERSION'/g' charts/json-server/Chart.yaml
sed -i 's/tag: latest/tag: '$CHART_VERSION'/g' charts/json-server/values.yaml sed -i 's/tag: latest/tag: '$CHART_VERSION'/g' charts/json-server/values.yaml
- | - |
@ -129,7 +129,7 @@ steps:
pull: always pull: always
commands: commands:
- | - |
export VALID_TAG=$(cat .version) && [ -n "$VALID_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
- | - |
apt-get update apt-get update
- | - |

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.json-server.seedData.existingConfigMap }}
apiVersion: v1 apiVersion: v1
kind: ConfigMap kind: ConfigMap
metadata: metadata:
@ -55,5 +55,5 @@ data:
</body> </body>
</html> </html>
db.json: | db.json: |
{{ include "common.tplvalues.render" ( dict "value" .Values.seedData.configInline "context" $) | indent 4 }} {{ include "common.tplvalues.render" ( dict "value" .Values.json-server.seedData.configInline "context" $) | indent 4 }}
{{- end -}} {{- end -}}

View File

@ -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.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" image: "{{ .Values.json-server.image.repository }}:{{ .Values.json-server.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }} imagePullPolicy: {{ .Values.json-server.image.pullPolicy }}
ports: ports:
- name: http - name: http
containerPort: {{ .Values.service.port }} containerPort: {{ .Values.service.port }}
@ -52,6 +52,17 @@ spec:
- name: {{ .Release.Name }}-configmap - name: {{ .Release.Name }}-configmap
mountPath: /usr/local/lib/node_modules/json-server/public/index.html mountPath: /usr/local/lib/node_modules/json-server/public/index.html
subPath: 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/sh
- -c
- sleep infinity
volumes: volumes:
- name: {{ .Release.Name }}-configmap - name: {{ .Release.Name }}-configmap
configMap: configMap:

View File

@ -1,18 +1,25 @@
# Default values for json-server. # Default values for json-server.
seedData: json-server:
# Not implemented yet seedData:
# existingConfigMap: "" # Not implemented yet
configInline: {} # existingConfigMap: ""
configInline: {}
image:
repository: bv11-cr01.bessems.eu/library/json-server
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: latest
sidecar:
image:
repository: alpine/helm
pullPolicy: IfNotPresent
tag: 3.12.1
replicaCount: 1 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: [] imagePullSecrets: []
nameOverride: "" nameOverride: ""
fullnameOverride: "" fullnameOverride: ""