initial commit of functioning opening tracking

This commit is contained in:
Sheldan
2024-01-06 23:29:25 +01:00
parent b72c68dfe5
commit 45e7982330
176 changed files with 37635 additions and 0 deletions

23
ci/gw2-tools/.helmignore Normal file
View File

@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/

8
ci/gw2-tools/Chart.yaml Normal file
View File

@@ -0,0 +1,8 @@
apiVersion: v2
name: gw2-tools
description: A Helm chart for Kubernetes
type: application
version: 0.0.1

View File

@@ -0,0 +1,7 @@
liquibase.secureParsing=false
liquibase.liquibaseSchemaName={{ .Values.db.schemaName }}
liquibase.command.defaultSchemaName={{ .Values.db.schemaName }}
liquibase.command.password={{ .Values.dbCredentials.password }}
liquibase.command.username={{ .Values.dbCredentials.userName }}
driver=org.postgresql.Driver
liquibase.command.url=jdbc:postgresql://{{ $.Values.dbCredentials.host }}:{{ $.Values.dbCredentials.port }}/{{ $.Values.dbCredentials.name }}

View File

@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "gw2Tools.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "gw2Tools.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "gw2Tools.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Common labels
*/}}
{{- define "gw2Tools.labels" -}}
helm.sh/chart: {{ include "gw2Tools.chart" . }}
{{ include "gw2Tools.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
{{/*
Selector labels
*/}}
{{- define "gw2Tools.selectorLabels" -}}
app.kubernetes.io/name: {{ include "gw2Tools.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{/*
Create the name of the service account to use
*/}}
{{- define "gw2Tools.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "gw2Tools.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

View File

@@ -0,0 +1,102 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: backend
labels:
app: backend
spec:
{{- if not .Values.backend.autoscaling.enabled }}
replicas: {{ .Values.backend.replicaCount }}
{{- end }}
selector:
matchLabels:
app: backend
template:
metadata:
{{- with .Values.backend.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
app: backend
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "gw2Tools.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.backend.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.backend.securityContext | nindent 12 }}
image: "{{ .Values.backend.image.repository }}/{{ .Values.backend.image.image }}:{{ .Values.backend.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.backend.image.pullPolicy }}
env:
- name: DB_PASS
valueFrom:
secretKeyRef:
name: db-credentials
key: dbPassword
- name: DB_HOST
valueFrom:
secretKeyRef:
name: db-credentials
key: dbHost
- name: DB_PORT
valueFrom:
secretKeyRef:
name: db-credentials
key: dbPort
- name: DB_USER
valueFrom:
secretKeyRef:
name: db-credentials
key: dbUser
- name: DB_NAME
valueFrom:
secretKeyRef:
name: db-credentials
key: dbName
{{- range $key, $value := .Values.backend.propertyConfig }}
- name: {{ $key | quote }}
value: {{ $value | quote}}
{{- end }}
ports:
- name: http
containerPort: {{ .Values.backend.service.port }}
protocol: TCP
{{- if .Values.backend.debug.enabled }}
- name: debug
containerPort: {{ .Values.backend.debug.port }}
protocol: TCP
{{- end }}
readinessProbe:
httpGet:
path: /health-check
port: {{ .Values.backend.service.port }}
initialDelaySeconds: {{ $.Values.backend.readinessProbe.initialDelaySeconds }}
periodSeconds: {{ $.Values.backend.readinessProbe.periodSeconds }}
failureThreshold: {{ $.Values.backend.readinessProbe.failureThreshold }}
livenessProbe:
httpGet:
path: /health-check
port: {{ .Values.backend.service.port }}
initialDelaySeconds: {{ $.Values.backend.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ $.Values.backend.livenessProbe.periodSeconds }}
failureThreshold: {{ $.Values.backend.livenessProbe.failureThreshold }}
resources:
{{- toYaml .Values.backend.resources | nindent 12 }}
{{- with .Values.backend.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.backend.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.backend.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}

View File

@@ -0,0 +1,28 @@
{{- if .Values.backend.autoscaling.enabled }}
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: backend
labels:
{{- include "gw2Tools.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: backend
minReplicas: {{ .Values.backend.autoscaling.minReplicas }}
maxReplicas: {{ .Values.backend.autoscaling.maxReplicas }}
metrics:
{{- if .Values.backend.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
targetAverageUtilization: {{ .Values.backend.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.backend.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
targetAverageUtilization: {{ .Values.backend.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}

View File

@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ .Values.backend.service.name }}
labels:
{{- include "gw2Tools.labels" . | nindent 4 }}
spec:
type: {{ .Values.backend.service.type }}
ports:
- port: {{ .Values.backend.service.port }}
targetPort: {{ .Values.backend.service.port }}
protocol: TCP
name: http
selector:
app: backend

View File

@@ -0,0 +1,38 @@
{{- if .Values.cacheJob.enabled -}}
apiVersion: batch/v1
kind: CronJob
metadata:
name: cache-job
spec:
schedule: {{ .Values.cacheJob.cronExpression | quote }}
jobTemplate:
spec:
template:
spec:
containers:
- name: item-cache
image: {{ .Values.cacheJob.image.repository }}{{ .Values.cacheJob.image.image }}:{{ .Values.cacheJob.image.tag }}
imagePullPolicy: IfNotPresent
command:
- /bin/sh
- -c
- curl -X POST "${BACKEND_HOST}:${BACKEND_PORT}/item-cache"
env:
- name: BACKEND_HOST
value: "{{ .Values.backend.service.name }}.{{ .Release.Namespace }}.svc.cluster.local"
- name: BACKEND_PORT
value: "{{ .Values.backend.service.port }}"
- name: currency-cache
image: {{ .Values.cacheJob.image.repository }}{{ .Values.cacheJob.image.image }}:{{ .Values.cacheJob.image.tag }}
imagePullPolicy: IfNotPresent
command:
- /bin/sh
- -c
- curl -X POST "${BACKEND_HOST}:${BACKEND_PORT}/currency-cache"
env:
- name: BACKEND_HOST
value: "{{ .Values.backend.service.name }}.{{ .Release.Namespace }}.svc.cluster.local"
- name: BACKEND_PORT
value: "{{ .Values.backend.service.port }}"
restartPolicy: Never
{{- end }}

View File

@@ -0,0 +1,44 @@
{{- if .Values.dbDeployment.enabled -}}
apiVersion: batch/v1
kind: Job
metadata:
name: db-config-deployment-job
annotations:
"helm.sh/hook": pre-upgrade,pre-install
"helm.sh/hook-weight": "-5"
"helm.sh/hook-delete-policy": hook-succeeded
spec:
template:
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: db-config-deployment-job
image: "{{ $.Values.dbDeployment.image.repository }}/{{ $.Values.dbDeployment.image.image }}:{{ $.Values.dbDeployment.image.tag | default .Chart.AppVersion}}"
imagePullPolicy: {{ $.Values.dbDeployment.image.pullPolicy }}
args:
- "--changelog-file=changeLog.xml"
- "--defaultsFile=/liquibase/config/liquibase.properties"
- "update"
volumeMounts:
- mountPath: "/liquibase/config/"
name: liquibase-config
readOnly: true
restartPolicy: Never
volumes:
- name: liquibase-config
secret:
secretName: liquibase-config
backoffLimit: 4
---
apiVersion: v1
kind: Secret
metadata:
name: liquibase-config
data:
liquibase.properties: {{ (tpl (.Files.Get "configuration/db/liquibase.properties") . ) | b64enc }}
{{- end }}

View File

@@ -0,0 +1,13 @@
apiVersion: v1
kind: Secret
metadata:
name: db-credentials
annotations:
"helm.sh/hook": pre-upgrade,pre-install
"helm.sh/hook-weight": "-6"
data:
dbPassword: {{ $.Values.dbCredentials.password | b64enc }} # b64enc is needed, because a stringData secret field cannot hold numeric values
dbUser: {{ $.Values.dbCredentials.userName | b64enc }}
dbHost: {{ $.Values.dbCredentials.host | b64enc }}
dbPort: {{ $.Values.dbCredentials.port | b64enc }}
dbName: {{ $.Values.dbCredentials.name | b64enc }}

View File

@@ -0,0 +1,72 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: frontend
labels:
app: frontend
spec:
{{- if not .Values.frontend.autoscaling.enabled }}
replicas: {{ .Values.frontend.replicaCount }}
{{- end }}
selector:
matchLabels:
app: frontend
template:
metadata:
{{- with .Values.frontend.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
app: frontend
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "gw2Tools.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.frontend.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.frontend.securityContext | nindent 12 }}
image: "{{ .Values.frontend.image.repository }}/{{ .Values.frontend.image.image }}:{{ .Values.frontend.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.frontend.image.pullPolicy }}
env:
- name: BACKEND_HOST
value: "{{ .Values.backend.service.name }}.{{ .Release.Namespace }}.svc.cluster.local"
- name: BACKEND_PORT
value: "{{ .Values.backend.service.port }}"
ports:
- name: http
containerPort: {{ .Values.frontend.service.port }}
protocol: TCP
livenessProbe:
httpGet:
path: /health
port: {{ .Values.frontend.service.port }}
initialDelaySeconds: {{ $.Values.frontend.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ $.Values.frontend.livenessProbe.periodSeconds }}
failureThreshold: {{ $.Values.frontend.livenessProbe.failureThreshold }}
readinessProbe:
httpGet:
path: /health
port: {{ .Values.frontend.service.port }}
initialDelaySeconds: {{ $.Values.frontend.readinessProbe.initialDelaySeconds }}
periodSeconds: {{ $.Values.frontend.readinessProbe.periodSeconds }}
failureThreshold: {{ $.Values.frontend.readinessProbe.failureThreshold }}
resources:
{{- toYaml .Values.frontend.resources | nindent 12 }}
{{- with .Values.frontend.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.frontend.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.frontend.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}

View File

@@ -0,0 +1,56 @@
{{- if .Values.frontend.ingress.enabled -}}
{{- $fullName := include "gw2Tools.fullname" . -}}
{{- $svcPort := .Values.frontend.service.port -}}
{{- $servicePort := .Values.frontend.service.port -}}
{{- $serviceName := .Values.frontend.service.name -}}
{{- $ingressPath := .Values.frontend.ingress.path -}}
{{- $ingressPathType := .Values.frontend.ingress.pathType -}}
{{- $extraPaths := .Values.frontend.ingress.extraPaths -}}
{{- if and .Values.frontend.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.frontend.ingress.annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .Values.frontend.ingress.annotations "kubernetes.io/ingress.class" .Values.frontend.ingress.className}}
{{- end }}
{{- end }}
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: frontend-ingress
labels:
{{- include "gw2Tools.labels" . | nindent 4 }}
{{- with .Values.frontend.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and .Values.frontend.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.frontend.ingress.className }}
{{- end }}
{{- with .Values.frontend.ingress.tls }}
tls:
{{- tpl (toYaml .) $ | nindent 4 }}
{{- end }}
rules:
{{- if .Values.frontend.ingress.hosts }}
{{- range .Values.frontend.ingress.hosts }}
- host: {{ tpl . $ }}
http:
paths:
{{- with $extraPaths }}
{{- toYaml . | nindent 10 }}
{{- end }}
- path: {{ $ingressPath }}
pathType: {{ $ingressPathType }}
backend:
service:
name: {{ $serviceName }}
port:
number: {{ $servicePort }}
{{- end }}
{{- end -}}
{{- end }}

View File

@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ .Values.frontend.service.name }}
labels:
{{- include "gw2Tools.labels" . | nindent 4 }}
spec:
type: {{ .Values.frontend.service.type }}
ports:
- port: {{ .Values.frontend.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
app: frontend

View File

@@ -0,0 +1,12 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "gw2Tools.serviceAccountName" . }}
labels:
{{- include "gw2Tools.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}

175
ci/gw2-tools/values.yaml Normal file
View File

@@ -0,0 +1,175 @@
# Default values for gw2-tools.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
backend:
image:
repository: harbor.sheldan.dev/gw2
pullPolicy: Always
image: gw2-tools-backend
# Overrides the image tag whose default is the chart appVersion.
tag: 0.0.1
debug:
enabled: true
port: 5005
service:
type: ClusterIP
port: 8080
name: backend-service
nodeSelector: {}
tolerations: []
affinity: {}
resources:
podAnnotations: {}
podSecurityContext: {}
# fsGroup: 2000
securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000
ingress:
enabled: false
annotations: {}
labels: {}
path: /
pathType: Prefix
hosts:
extraPaths: []
tls: []
replicaCount: 1
autoscaling:
enabled: false
minReplicas: 1
maxReplicas: 100
targetCPUUtilizationPercentage: 80
# targetMemoryUtilizationPercentage: 80
livenessProbe:
initialDelaySeconds: 20
periodSeconds: 5
failureThreshold: 3
readinessProbe:
initialDelaySeconds: 20
periodSeconds: 5
failureThreshold: 3
propertyConfig:
hikariPoolSize: 3
dbDeployment:
enabled: true
image:
repository: harbor.sheldan.dev/gw2
image: gw2-tools-database
tag: 0.0.1
pullPolicy: Always
cacheJob:
enabled: true
image:
repository:
pullPolicy: Always
image: curlimages/curl
tag: 8.5.0
cronExpression: "@weekly"
dbCredentials:
password:
userName:
host:
port:
name:
db:
schemaName: gw2
frontend:
image:
repository: harbor.sheldan.dev/gw2
pullPolicy: IfNotPresent
image: gw2-tools-frontend
# Overrides the image tag whose default is the chart appVersion.
tag: 0.0.1
port: 8080
service:
type: ClusterIP
port: 8080
name: frontend
nodeSelector: {}
livenessProbe:
initialDelaySeconds: 2
periodSeconds: 5
failureThreshold: 3
readinessProbe:
initialDelaySeconds: 2
periodSeconds: 5
failureThreshold: 3
tolerations: []
affinity: {}
resources:
podAnnotations: {}
podSecurityContext: {}
# fsGroup: 2000
securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000
ingress:
enabled: false
annotations: {}
labels: {}
path: /
pathType: Prefix
hosts:
extraPaths: []
tls: []
replicaCount: 1
autoscaling:
enabled: false
minReplicas: 1
maxReplicas: 100
targetCPUUtilizationPercentage: 80
# targetMemoryUtilizationPercentage: 80
imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""
serviceAccount:
# Specifies whether a service account should be created
create: true
# Annotations to add to the service account
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: ""