Skip to content

Commit

Permalink
feat(charts/strichlistensystem): add chart
Browse files Browse the repository at this point in the history
  • Loading branch information
simonostendorf committed Oct 16, 2023
1 parent 5b8729a commit d78a457
Show file tree
Hide file tree
Showing 12 changed files with 424 additions and 2 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ The portals chart is located in the [`charts/portals`](./charts/portals/) folder

See more about the chart in the [README](./charts/portals/README.md) of the chart.

### Strichlistensystem

The strichlistensystem chart is located in the [`charts/strichlistensystem`](./charts/strichlistensystem/) folder. It contains our [tally system](github.com/fsr5-fhaachen/strichlistensystem).

See more about the chart in the [README](./charts/strichlistensystem/README.md) of the chart.

## Authors

👤 **Simon Ostendorf**
Expand Down
4 changes: 2 additions & 2 deletions charts/portals/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ This chart deploys the Portals application to a Kubernetes cluster.
You can install the chart with the following command:

```sh
helm repo add portals https://fsr5-fhaachen.github.io/portals/
helm upgrade --install portals portals/portals --namespace portals --create-namespace -f values.yaml
helm repo add fsr5-fhaachen https://fsr5-fhaachen.github.io/charts/
helm upgrade --install portals fsr5-fhaachen/portals --namespace portals --create-namespace -f values.yaml
```

## Database and Redis
Expand Down
11 changes: 11 additions & 0 deletions charts/strichlistensystem/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v2
name: strichlistensystem
description: Tally system for the first week of the Department of Electrical Engineering and Information Technology at FH Aachen - University of Applied Sciences.
type: application
version: 0.0.1
appVersion: "2.0.0"
home: github.com/fsr5-fhaachen/strichlistensystem
maintainers:
- name: fsr5-fhaachen
email: [email protected]
url: https://fsr5.de/
52 changes: 52 additions & 0 deletions charts/strichlistensystem/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Strichlistensystem Helm Chart

This chart deploys the Strichlistensystem application to a Kubernetes cluster.

## Install

You can install the chart with the following command:

```sh
helm repo add fsr5-fhaachen https://fsr5-fhaachen.github.io/charts/
helm upgrade --install strichlistensystem fsr5-fhaachen/strichlistensystem --namespace strichlistensystem --create-namespace -f values.yaml
```

## Database and Redis

The chart does not install a database or redis. You have to install them yourself.

You could use the [postgresql operator](https://cloudnative-pg.io/) and [redis operator](https://ot-container-kit.github.io/redis-operator/) for kubernetes.

If you want a deployment example, view [our deployment guide](https://github.com/fsr5-fhaachen/portals/blob/main/deploy/README.md) inside the portals repo. (This guide is written for portals but can be adapted for the strichlistensystem because they are both laravel applications installed via helm.)

## Values

You can find the default values in the [values.yaml](values.yaml) file.

You can override the default values but there are some values that need to be changed. The (minimum) required values are:

```yaml
environment:
APP_NAME: Gerolstein FB5
APP_KEY: # insert app key here
APP_URL: https://strichlistensystem.fsr5.de
APP_VPN_IP: # insert vpn ip here
CSV_EXPORT_PW: password # insert secret password here
DB_CONNECTION: pgsql
DB_HOST: # insert db host here
DB_PORT: "5432"
DB_DATABASE: postgres
DB_USERNAME: postgres
DB_PASSWORD: # insert db password here
REDIS_HOST: # insert redis host here
REDIS_PASSWORD: # insert redis password here
REDIS_PORT: "6379"
ingress:
enabled: true
className: "nginx"
annotations:
cert-manager.io/issuer: "letsencrypt-prod"
hosts:
- strichlistensystem.fsr5.de
tls: true
```
13 changes: 13 additions & 0 deletions charts/strichlistensystem/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Thank you for installing {{ .Chart.Name }}.

Your release is named {{ .Release.Name }}.

{{- if .Values.ingress.enabled }}
You can access your site on your configured domain by visiting {{ index .Values.ingress.hosts 0 }}.
{{- else }}
You can access your site by port-forwarding to the service: "kubectl port-forward -n {{ .Release.Namespace }} svc/{{ include "strichlistensystem.fullname" . }} 8000:8000"
{{- end }}



Learn more about portals at https://github.com/fsr5-fhaachen/strichlistensystem.
51 changes: 51 additions & 0 deletions charts/strichlistensystem/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "strichlistensystem.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 "strichlistensystem.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 "strichlistensystem.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "strichlistensystem.labels" -}}
helm.sh/chart: {{ include "strichlistensystem.chart" . }}
{{ include "strichlistensystem.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "strichlistensystem.selectorLabels" -}}
app.kubernetes.io/name: {{ include "strichlistensystem.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
59 changes: 59 additions & 0 deletions charts/strichlistensystem/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "strichlistensystem.fullname" . }}
labels:
{{- include "strichlistensystem.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "strichlistensystem.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "strichlistensystem.selectorLabels" . | nindent 8 }}
spec:
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 8000
protocol: TCP
{{- if not .Values.disableLivenessProbe }}
livenessProbe:
httpGet:
path: /
port: http
{{- end }}
{{- if not .Values.disableReadinessProbe }}
readinessProbe:
httpGet:
path: /
port: http
{{- end }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
env:
{{- range $key, $value := .Values.environment }}
- name: {{ $key }}
value: {{ $value | quote }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
20 changes: 20 additions & 0 deletions charts/strichlistensystem/templates/hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{{- if .Values.hpa.enabled }}
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "strichlistensystem.fullname" . }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "strichlistensystem.fullname" . }}
minReplicas: {{ .Values.hpa.minReplicas }}
maxReplicas: {{ .Values.hpa.maxReplicas }}
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ .Values.hpa.averageCPUUtilization }}
{{- end }}
54 changes: 54 additions & 0 deletions charts/strichlistensystem/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "strichlistensystem.fullname" . -}}
{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.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: {{ $fullName }}
labels:
{{- include "strichlistensystem.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.ingress.className }}
{{- end }}
{{- if .Values.ingress.tls }}
tls:
- hosts:
{{- range .Values.ingress.hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ $fullName }}-ingress-tls
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ . | quote }}
http:
paths:
- path: /
pathType: Prefix
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ $fullName }}
port:
number: 8000
{{- else }}
serviceName: {{ $fullName }}
servicePort: 8000
{{- end }}
{{- end }}
{{- end }}
59 changes: 59 additions & 0 deletions charts/strichlistensystem/templates/seed-job.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{{- if or .Values.migrateJob.onInstall .Values.migrateJob.onUpgrade -}}
apiVersion: batch/v1
kind: Job
metadata:
name: {{ include "strichlistensystem.fullname" . }}-migrate-job
labels:
{{- include "strichlistensystem.labels" . | nindent 4 }}
annotations:
helm.sh/hook: {{ if .Values.migrateJob.onInstall }}pre-install{{ end }}{{ if and .Values.migrateJob.onInstall .Values.migrateJob.onUpgrade }},{{ end }}{{ if .Values.migrateJob.onUpgrade }}pre-upgrade{{ end }}
helm.sh/hook-weight: "1"
helm.sh/hook-delete-policy: hook-succeeded
spec:
template:
spec:
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
env:
{{- range $key, $value := .Values.environment }}
- name: {{ $key }}
value: {{ $value | quote }}
{{- end }}
{{- if .Values.migrateJob.seed }}
command: ["php", "artisan", "migrate:fresh", "--seed", "--no-interaction", "--force"]
{{- else }}
command: ["php", "artisan", "migrate", "--no-interaction", "--force"]
{{- end }}
{{- if or (ne .Values.migrateJob.tutorsCsvConfigMapName "") (ne .Values.migrateJob.studentsCsvConfigMapName "") }}
volumeMounts:
{{- if ne .Values.migrateJob.tutorsCsvConfigMapName "" }}
- name: tutors-csv
mountPath: /var/www/html/database/seeders/tutors.csv
subPath: tutors.csv
{{- end }}
{{- if ne .Values.migrateJob.studentsCsvConfigMapName "" }}
- name: students-csv
mountPath: /var/www/html/database/seeders/students.csv
subPath: students.csv
{{- end }}
{{- end }}
{{- if or (ne .Values.migrateJob.tutorsCsvConfigMapName "") (ne .Values.migrateJob.studentsCsvConfigMapName "") }}
volumes:
{{- if ne .Values.migrateJob.tutorsCsvConfigMapName "" }}
- name: tutors-csv
configMap:
name: {{ .Values.migrateJob.tutorsCsvConfigMapName }}
{{- end }}
{{- if ne .Values.migrateJob.studentsCsvConfigMapName "" }}
- name: students-csv
configMap:
name: {{ .Values.migrateJob.studentsCsvConfigMapName }}
{{- end }}
{{- end }}
restartPolicy: Never
backoffLimit: 1
{{- end }}
14 changes: 14 additions & 0 deletions charts/strichlistensystem/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "strichlistensystem.fullname" . }}
labels:
{{- include "strichlistensystem.labels" . | nindent 4 }}
spec:
ports:
- name: http
port: 8000
targetPort: http
protocol: TCP
selector:
{{- include "strichlistensystem.selectorLabels" . | nindent 4 }}
Loading

0 comments on commit d78a457

Please sign in to comment.