Skip to content

Commit

Permalink
split frontend and backend
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreKoepke committed Nov 17, 2024
1 parent c3fc671 commit 134a76e
Show file tree
Hide file tree
Showing 12 changed files with 137 additions and 28 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/connect-to-wireguard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Connect to wireguard
# Schema: https://json.schemastore.org/github-action.json

runs:
using: 'composite'
steps:
- run: sudo apt install wireguard
- run: echo "${{ secrets.WIREGUARD_CLIENT_PRIVATE_KEY }}" > privatekey
- run: sudo ip link add dev wg0 type wireguard
- run: sudo ip address add dev wg0 ${{ secrets.WIREGUARD_CLIENT_IP }} peer ${{ secrets.WIREGUARD_ALLOWED_IPS }}
- run: sudo wg set wg0 private-key privatekey peer ${{ secrets.WIREGUARD_SERVER_PUBLIC_KEY }} allowed-ips ${{ secrets.WIREGUARD_ALLOWED_IPS }} endpoint ${{ secrets.WIREGUARD_ENDPOINT }}
- run: sudo ip link set up dev wg0

10 changes: 2 additions & 8 deletions .github/workflows/publish-backend-feature.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,11 @@ jobs:
runs-on: ubuntu-latest
needs: publish
steps:
- run: sudo apt install wireguard
- run: echo "${{ secrets.WIREGUARD_CLIENT_PRIVATE_KEY }}" > privatekey
- run: sudo ip link add dev wg0 type wireguard
- run: sudo ip address add dev wg0 ${{ secrets.WIREGUARD_CLIENT_IP }} peer ${{ secrets.WIREGUARD_ALLOWED_IPS }}
- run: sudo wg set wg0 private-key privatekey peer ${{ secrets.WIREGUARD_SERVER_PUBLIC_KEY }} allowed-ips ${{ secrets.WIREGUARD_ALLOWED_IPS }} endpoint ${{ secrets.WIREGUARD_ENDPOINT }}
- run: sudo ip link set up dev wg0

- uses: actions/checkout@v3
- uses: ./.github/workflows/connect-to-wireguard.yml
- name: Deploy
uses: WyriHaximus/github-action-helm3@v3
with:
exec: echo '${{ secrets.VALUES_YAML_HOME_SYSTEM_FEATURE }}' | helm upgrade akops-home ./deploy/backend --install --wait --atomic --values -
exec: echo '${{ secrets.VALUES_YAML_HOME_SYSTEM_FEATURE }}' | helm upgrade akops-home-backend ./deploy/backend --install --wait --atomic --values -
kubeconfig: '${{ secrets.K8S_CONF_AKOP_ONLINE }}'

10 changes: 2 additions & 8 deletions .github/workflows/publish-backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,11 @@ jobs:
runs-on: ubuntu-latest
needs: publish
steps:
- run: sudo apt install wireguard
- run: echo "${{ secrets.WIREGUARD_CLIENT_PRIVATE_KEY }}" > privatekey
- run: sudo ip link add dev wg0 type wireguard
- run: sudo ip address add dev wg0 ${{ secrets.WIREGUARD_CLIENT_IP }} peer ${{ secrets.WIREGUARD_ALLOWED_IPS }}
- run: sudo wg set wg0 private-key privatekey peer ${{ secrets.WIREGUARD_SERVER_PUBLIC_KEY }} allowed-ips ${{ secrets.WIREGUARD_ALLOWED_IPS }} endpoint ${{ secrets.WIREGUARD_ENDPOINT }}
- run: sudo ip link set up dev wg0

- uses: actions/checkout@v3
- uses: ./.github/workflows/connect-to-wireguard.yml
- name: Deploy
uses: WyriHaximus/github-action-helm3@v3
with:
exec: echo '${{ secrets.VALUES_YAML_HOME_SYSTEM }}' | helm upgrade akops-home ./deploy/backend --install --wait --atomic --values -
exec: echo '${{ secrets.VALUES_YAML_HOME_SYSTEM }}' | helm upgrade akops-home-backend ./deploy/backend --install --wait --atomic --values -
kubeconfig: '${{ secrets.K8S_CONF_AKOP_ONLINE }}'

12 changes: 3 additions & 9 deletions .github/workflows/publish-frontend.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish backend to DockerHub
name: Publish frontend
on:
push:
branches: [ master, feature/* ]
Expand Down Expand Up @@ -34,17 +34,11 @@ jobs:
runs-on: ubuntu-latest
needs: publish
steps:
- run: sudo apt install wireguard
- run: echo "${{ secrets.WIREGUARD_CLIENT_PRIVATE_KEY }}" > privatekey
- run: sudo ip link add dev wg0 type wireguard
- run: sudo ip address add dev wg0 ${{ secrets.WIREGUARD_CLIENT_IP }} peer ${{ secrets.WIREGUARD_ALLOWED_IPS }}
- run: sudo wg set wg0 private-key privatekey peer ${{ secrets.WIREGUARD_SERVER_PUBLIC_KEY }} allowed-ips ${{ secrets.WIREGUARD_ALLOWED_IPS }} endpoint ${{ secrets.WIREGUARD_ENDPOINT }}
- run: sudo ip link set up dev wg0

- uses: actions/checkout@v3
- uses: ./.github/workflows/connect-to-wireguard.yml
- name: Deploy
uses: WyriHaximus/github-action-helm3@v3
with:
exec: echo '${{ secrets.VALUES_YAML_HOME_SYSTEM }}' | helm upgrade akops-home ./deploy/backend --install --wait --atomic --values -
exec: echo '${{ secrets.VALUES_YAML_HOME_SYSTEM_FRONTEND }}' | helm upgrade akops-home-frontend ./deploy/frontend --install --wait --atomic --values -
kubeconfig: '${{ secrets.K8S_CONF_AKOP_ONLINE }}'

1 change: 1 addition & 0 deletions deploy/frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
values.yaml
23 changes: 23 additions & 0 deletions deploy/frontend/.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/
24 changes: 24 additions & 0 deletions deploy/frontend/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: home-system
description: A Helm chart for Kubernetes

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"
62 changes: 62 additions & 0 deletions deploy/frontend/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "home-system.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 "home-system.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 "home-system.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

{{/*
Selector labels
*/}}
{{- define "home-system.selectorLabels" -}}
app.kubernetes.io/name: {{ include "home-system.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "home-system.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "home-system.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ spec:
automountServiceAccountToken: false
containers:
- name: backend
image: {{ .Values.frontend.image.base }}:{{ .Values.frontend.image.tag }}
image: {{ .Values.image.base }}:{{ .Values.image.tag }}
imagePullPolicy: Always
ports:
- containerPort: 4000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ metadata:

spec:
rules:
- host: {{ .Values.frontend.host }}
- host: {{ .Values.host }}
http:
paths:
- path: /
Expand All @@ -21,5 +21,5 @@ spec:

tls:
- hosts:
- {{ .Values.frontend.host }}
- {{ .Values.host }}
secretName: home-system-frontend
4 changes: 4 additions & 0 deletions deploy/frontend/values.example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
image:
base: akop/home-system-frontend
tag: latest
host: host-which-will-be-used-for-frontend.webhook.com

0 comments on commit 134a76e

Please sign in to comment.