Skip to content

Commit

Permalink
feat: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
simonostendorf committed Aug 29, 2023
0 parents commit 00d3ba3
Show file tree
Hide file tree
Showing 9 changed files with 322 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/release-chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Release Helm Chart

on:
push:
branches:
- main

jobs:
release:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Install Helm
uses: azure/setup-helm@v3
- name: Run chart-releaser
uses: helm/[email protected]
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
with:
version: v1.6.0
6 changes: 6 additions & 0 deletions charts/portals/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
name: portals
description: Portals is a group allocation tool for the first week of the Department of Electrical Engineering and Information Technology at the FH Aachen - University of Applied Sciences.
type: application
version: 0.0.1
appVersion: "2.1.0"
44 changes: 44 additions & 0 deletions charts/portals/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Portals Helm Chart

This chart deploys the Portals application to a Kubernetes cluster.

## Install

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
```

## 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: Erstiwoche FB5
APP_KEY: # insert app key here
APP_URL: https://portals.fsr5.de
TUTOR_PASSWORD: password # insert secret password here
ADMIN_PASSWORD: admin # 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:
- portals.fsr5.de
tls: true
```
51 changes: 51 additions & 0 deletions charts/portals/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "portals.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 "portals.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 "portals.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

{{/*
Selector labels
*/}}
{{- define "portals.selectorLabels" -}}
app.kubernetes.io/name: {{ include "portals.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
53 changes: 53 additions & 0 deletions charts/portals/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "portals.fullname" . }}
labels:
{{- include "portals.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "portals.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "portals.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
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
port: http
resources:
{{- toYaml .Values.resources | nindent 12 }}
envFrom:
- secretRef:
name: {{ include "portals.fullname" . }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
54 changes: 54 additions & 0 deletions charts/portals/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "portals.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 "portals.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 }}
10 changes: 10 additions & 0 deletions charts/portals/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ include "portals.fullname" . }}
labels:
{{- include "portals.labels" . | nindent 4 }}
{{- with .Values.environment }}
stringData:
{{- toYaml . | nindent 2 }}
{{- end }}
14 changes: 14 additions & 0 deletions charts/portals/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "portals.fullname" . }}
labels:
{{- include "portals.labels" . | nindent 4 }}
spec:
ports:
- name: http
port: 8000
targetPort: http
protocol: TCP
selector:
{{- include "portals.selectorLabels" . | nindent 4 }}
61 changes: 61 additions & 0 deletions charts/portals/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
replicaCount: 1

nameOverride: ""
fullnameOverride: ""

podAnnotations: {}

image:
repository: ghcr.io/fsr5-fhaachen/portals
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: ""

environment:
APP_NAME: Erstiwoche FB5
APP_ENV: local
APP_KEY: # insert app key here
APP_DEBUG: "false"
APP_URL: https://portals.fsr5.de
TUTOR_PASSWORD: password # insert secret password here
ADMIN_PASSWORD: admin # 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
OCTANE_HTTPS: "true"
OCTANE_WORKERS: "4"
OCTANE_MAX_REQUESTS: "512"
WWWGROUP: "1000"
WWWUSER: "1000"
CACHE_DRIVER: redis
SESSION_DRIVER: redis
SESSION_LIFETIME: "120"
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:
- portals.fsr5.de
tls: true

resources: {}
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi

nodeSelector: {}

tolerations: []

affinity: {}

0 comments on commit 00d3ba3

Please sign in to comment.