Add helm chart

This commit is contained in:
Thor77 2022-06-06 14:09:32 +02:00
parent 9e5d0f2586
commit eff1b2c373
No known key found for this signature in database
GPG Key ID: 5051E71B46AA669A
10 changed files with 198 additions and 84 deletions

23
chart/.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/

6
chart/Chart.yaml Normal file
View File

@ -0,0 +1,6 @@
apiVersion: v2
name: turniere-frontend
description: turnie.re frontend
type: application
version: 0.1.0
appVersion: "latest"

View File

@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "chart.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 "chart.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 "chart.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Common labels
*/}}
{{- define "chart.labels" -}}
helm.sh/chart: {{ include "chart.chart" . }}
{{ include "chart.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
{{/*
Selector labels
*/}}
{{- define "chart.selectorLabels" -}}
app.kubernetes.io/name: {{ include "chart.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{/*
Create the name of the service account to use
*/}}
{{- define "chart.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "chart.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

View File

@ -0,0 +1,51 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "chart.fullname" . }}
labels:
{{- include "chart.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "chart.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "chart.selectorLabels" . | nindent 8 }}
spec:
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 80
protocol: TCP
env:
- name: TURNIERE_API_URL
value: "{{ .Values.turniere.backend }}"
readinessProbe:
httpGet:
path: /
port: http
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}

View File

@ -0,0 +1,19 @@
{{- $fullName := include "chart.fullname" . -}}
---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
name: {{ $fullName }}
spec:
entryPoints:
- websecure
routes:
{{ range $host := .Values.ingress.hosts }}
- match: Host(`{{ $host }}`)
kind: Rule
services:
- name: {{ $fullName }}
port: {{ $.Values.service.port }}
{{ end }}
tls:
certResolver: leresolver

View File

@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "chart.fullname" . }}
labels:
{{- include "chart.labels" . | nindent 4 }}
spec:
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "chart.selectorLabels" . | nindent 4 }}

23
chart/values.yaml Normal file
View File

@ -0,0 +1,23 @@
replicaCount: 1
image:
repository: registry.gitlab.com/turniere/turniere-frontend/production/commits
pullPolicy: IfNotPresent
tag: ""
podAnnotations: {}
securityContext: {}
# runAsNonRoot: true
# runAsUser: 1000
service:
port: 8080
ingress:
hosts: []
resources: {}
turniere:
backend: ""

View File

@ -1,25 +0,0 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: frontend-deployment
namespace: turniere-frontend
labels:
app: turniere-frontend
spec:
replicas: 1
selector:
matchLabels:
app: turniere-frontend
template:
metadata:
labels:
app: turniere-frontend
spec:
containers:
- name: frontend-container
image: registry.gitlab.com/turniere/turniere-frontend:<%= current_sha %>
ports:
- containerPort: 80
env:
- name: TURNIERE_API_URL
value: 'https://api01.turnie.re'

View File

@ -1,13 +0,0 @@
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: gitlab-deploy-rb
namespace: turniere-frontend
subjects:
- kind: ServiceAccount
name: gitlab-deploy
namespace: gitlab
roleRef:
kind: ClusterRole
name: gitlab-deploy-role
apiGroup: rbac.authorization.k8s.io

View File

@ -1,46 +0,0 @@
apiVersion: v1
kind: Service
metadata:
name: frontend-service
namespace: turniere-frontend
spec:
selector:
app: turniere-frontend
ports:
- name: http
port: 80
targetPort: 80
---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
name: frontend-ingress-http
namespace: turniere-frontend
spec:
entryPoints:
- http
routes:
- match: Host(`frontend01.turnie.re`) || Host(`turnie.re`)
kind: Rule
services:
- name: frontend-service
port: 80
middlewares:
- name: redirect
---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
name: frontend-ingress-https
namespace: turniere-frontend
spec:
entryPoints:
- https
routes:
- match: Host(`frontend01.turnie.re`) || Host(`turnie.re`)
kind: Rule
services:
- name: frontend-service
port: 80
tls:
certResolver: default