Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #206

Merged
merged 3 commits into from
Nov 23, 2024
Merged

Dev #206

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions .github/workflows/HugoBuildAndDeploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,5 @@ jobs:
# Checkout the repository
- uses: actions/checkout@v3

- name: Find and Replace
uses: jacobtomlinson/gha-find-replace@v3
with:
find: "{{RUN_NUMBER}}"
replace: ${{ github.run_number }}
regex: false

# Deploy Kubernetes YAML
- run: kubectl apply -f ./deployment/Fachinformatiker-Prüfungsvorbereitung.yaml --kubeconfig ${{ steps.write_file.outputs.filePath }}
- run: helm upgrade --install fi-pv ./helm --kubeconfig ${{ steps.write_file.outputs.filePath }} --set runNumber=${{ github.run_number }}
21 changes: 20 additions & 1 deletion .github/workflows/HugoBuildDev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
extended: true

# Build the hugo repository
- run: hugo
- run: hugo -e development --baseURL "https://dev.fachinformatikerpruefungsvorbereitung.de"
working-directory: ./${{ env.NAME }}/

# Zip the Artifact for GitHubPages deployment
Expand Down Expand Up @@ -56,3 +56,22 @@ jobs:

- name: Push the image to dockerhub
run: docker push lnadev/${{ env.CONTAINER-NAME }}:dev

DeployContainer:
needs: ReleaseDEV
runs-on: ubuntu-latest

steps:
# Download Secure-File
- name: base64-to-file
id: write_file
uses: timheuer/[email protected]
with:
fileName: "custom-config"
encodedString: ${{ secrets.KUBECTL_CONFIG }}

# Checkout the repository
- uses: actions/checkout@v3

# Deploy Kubernetes YAML
- run: helm upgrade --install fi-pv-dev ./helm --kubeconfig ${{ steps.write_file.outputs.filePath }} --set runNumber=dev,domain=dev.fachinformatikerpruefungsvorbereitung.de,namespace=fi-pv-dev,production=false
23 changes: 23 additions & 0 deletions helm/.helmignore
Original file line number Diff line number Diff line change
@@ -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 changes: 6 additions & 0 deletions helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
name: fi-vorbereitung
description: A Helm chart for Kubernetes
type: application
version: 0.0.1
appVersion: 0.0.1
27 changes: 27 additions & 0 deletions helm/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: fi-pv-deployment
namespace: {{ .Values.namespace }}
spec:
selector:
matchLabels:
app: fi-pv
template:
metadata:
labels:
app: fi-pv
spec:
containers:
- name: fi-pv
image: lnadev/fi-pv:{{ .Values.runNumber }}
imagePullPolicy: Always
resources:
requests:
memory: "128Mi"
cpu: "50m"
limits:
memory: "128Mi"
ports:
- containerPort: 80
name: port-http
Original file line number Diff line number Diff line change
@@ -1,58 +1,20 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: fi-pv-deployment
spec:
selector:
matchLabels:
app: fi-pv
template:
metadata:
labels:
app: fi-pv
spec:
containers:
- name: fi-pv
image: lnadev/fi-pv:{{RUN_NUMBER}}
imagePullPolicy: Always
resources:
limits:
memory: "128Mi"
cpu: "500m"
ports:
- containerPort: 80
name: port-http

---
apiVersion: v1
kind: Service
metadata:
name: fi-pv-service
spec:
selector:
app: fi-pv
ports:
- port: 80
targetPort: port-http
name: http

---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: fi-pv-ingress
namespace: {{ .Values.namespace }}
annotations:
cert-manager.io/cluster-issuer: letsencrypt
traefik.ingress.kubernetes.io/router.entrypoints: websecure
traefik.ingress.kubernetes.io/router.middlewares: default-redirectscheme@kubernetescrd
traefik.ingress.kubernetes.io/router.middlewares: {{ .Values.namespace }}-redirectscheme@kubernetescrd
spec:
tls:
- hosts:
- "fachinformatikerpruefungsvorbereitung.de"
- "www.fachinformatikerpruefungsvorbereitung.de"
- "{{ .Values.domain }}"
- "www.{{ .Values.domain }}"
secretName: fi-pv-cert
rules:
- host: fachinformatikerpruefungsvorbereitung.de
- host: "{{ .Values.domain }}"
http:
paths:
- path: /
Expand All @@ -62,7 +24,7 @@ spec:
name: fi-pv-service
port:
number: 80
- host: www.fachinformatikerpruefungsvorbereitung.de
- host: www.{{ .Values.domain }}
http:
paths:
- path: /
Expand All @@ -74,22 +36,18 @@ spec:
number: 80

---
# Needed because of HTTP to HTTPS redirecting
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: fi-pv-redirection-ingress
name: fi-pv-ingress-http
namespace: {{ .Values.namespace }}
annotations:
cert-manager.io/cluster-issuer: letsencrypt
traefik.ingress.kubernetes.io/router.entrypoints: websecure
traefik.ingress.kubernetes.io/router.middlewares: default-redirectschemefipv@kubernetescrd
traefik.ingress.kubernetes.io/router.entrypoints: web
traefik.ingress.kubernetes.io/router.middlewares: default-redirectscheme@kubernetescrd
spec:
tls:
- hosts:
- "xn--fachinformatiker-prfungsvorbereitung-w0d.de"
- "fi.lna-dev.net"
secretName: fi-pv-cert-fipv
rules:
- host: xn--fachinformatiker-prfungsvorbereitung-w0d.de
- host: "{{ .Values.domain }}"
http:
paths:
- path: /
Expand All @@ -99,7 +57,7 @@ spec:
name: fi-pv-service
port:
number: 80
- host: fi.lna-dev.net
- host: www.{{ .Values.domain }}
http:
paths:
- path: /
Expand All @@ -110,15 +68,49 @@ spec:
port:
number: 80

---
apiVersion: traefik.io/v1alpha1
kind: Middleware
metadata:
name: redirectscheme
namespace: {{ .Values.namespace }}
spec:
redirectRegex:
regex: '^https?://(?:www\.)?(.+)'
replacement: "https://${1}"
permanent: true

---
apiVersion: traefik.io/v1alpha1
kind: Middleware
metadata:
name: redirectschemefipv
namespace: {{ .Values.namespace }}
spec:
redirectRegex:
regex: '.*'
replacement: "https://{{ .Values.domain }}"
permanent: true



{{- if .Values.production }}
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: fi-pv-redirection-ingress-http
name: fi-pv-redirection-ingress
namespace: {{ .Values.namespace }}
annotations:
traefik.ingress.kubernetes.io/router.entrypoints: web
cert-manager.io/cluster-issuer: letsencrypt
traefik.ingress.kubernetes.io/router.entrypoints: websecure
traefik.ingress.kubernetes.io/router.middlewares: default-redirectschemefipv@kubernetescrd
spec:
tls:
- hosts:
- "xn--fachinformatiker-prfungsvorbereitung-w0d.de"
- "fi.lna-dev.net"
secretName: fi-pv-cert-fipv
rules:
- host: xn--fachinformatiker-prfungsvorbereitung-w0d.de
http:
Expand All @@ -142,17 +134,17 @@ spec:
number: 80

---
# Needed because of HTTP to HTTPS redirecting
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: fi-pv-ingress-http
name: fi-pv-redirection-ingress-http
namespace: {{ .Values.namespace }}
annotations:
traefik.ingress.kubernetes.io/router.entrypoints: web
traefik.ingress.kubernetes.io/router.middlewares: default-redirectscheme@kubernetescrd
traefik.ingress.kubernetes.io/router.middlewares: default-redirectschemefipv@kubernetescrd
spec:
rules:
- host: fachinformatikerpruefungsvorbereitung.de
- host: xn--fachinformatiker-prfungsvorbereitung-w0d.de
http:
paths:
- path: /
Expand All @@ -162,7 +154,7 @@ spec:
name: fi-pv-service
port:
number: 80
- host: www.fachinformatikerpruefungsvorbereitung.de
- host: fi.lna-dev.net
http:
paths:
- path: /
Expand All @@ -173,24 +165,4 @@ spec:
port:
number: 80

---
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
name: redirectscheme
spec:
redirectRegex:
regex: '^https?://(?:www\.)?(.+)'
replacement: "https://${1}"
permanent: true

---
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
name: redirectschemefipv
spec:
redirectRegex:
regex: '.*'
replacement: "https://fachinformatikerpruefungsvorbereitung.de"
permanent: true
{{- end }}
4 changes: 4 additions & 0 deletions helm/templates/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: {{ .Values.namespace }}
12 changes: 12 additions & 0 deletions helm/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: fi-pv-service
namespace: {{ .Values.namespace }}
spec:
selector:
app: fi-pv
ports:
- port: 80
targetPort: port-http
name: http
4 changes: 4 additions & 0 deletions helm/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
runNumber: 0
domain: fachinformatikerpruefungsvorbereitung.de
namespace: fi-pv
production: true
Loading