Skip to content

Add helm charts + IaC Part 1 #174

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

Merged
merged 32 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
9d7643f
add basic helmcharts
uvulpos Mar 1, 2024
03b03af
commit
uvulpos Mar 3, 2024
a5f3691
add basic helmfile
uvulpos Mar 8, 2024
3bcc1a5
Merge branch 'main' into feat/add-helm-charts-and-iac
uvulpos Mar 11, 2024
b905632
add civo k3s iac provider and helmfile for ingress + longhorn
uvulpos Mar 24, 2024
cc582e6
rename folder
uvulpos Mar 27, 2024
dc8534f
add iac pipelines
uvulpos Apr 1, 2024
074fa92
fix issues
uvulpos Apr 1, 2024
ac7a2ad
rename files
uvulpos Apr 1, 2024
2a6696f
fix
uvulpos Apr 1, 2024
44ca7a8
fix
uvulpos Apr 1, 2024
8ab3868
fix token permissions
uvulpos Apr 1, 2024
68005a7
wip add terraform backend
uvulpos Apr 16, 2024
7442e8d
feat: add ci pipeline
uvulpos Apr 19, 2024
416edae
fix: add postgres test db credentials
uvulpos Apr 19, 2024
64e4c8e
fix: add pg_isready with 20s timeout
uvulpos Apr 19, 2024
c4be2fc
fix: formatting
uvulpos Apr 19, 2024
e9be1a2
fix: remove pgready dependency in docker compose
uvulpos Apr 19, 2024
19789f8
fix: name targeted docker compose service right
uvulpos Apr 19, 2024
3f1d2d4
fix: add to ci --abort-on-container-exit flag
uvulpos Apr 19, 2024
b8911c4
fix: ci errors
uvulpos Apr 19, 2024
e957d6b
fix: create folder first before file
uvulpos Apr 19, 2024
d603cc5
fix: add create swagger documentation in testing environment to preve…
uvulpos Apr 19, 2024
51fb40b
fix: install swag
uvulpos Apr 19, 2024
0b65c9b
fix: typo
uvulpos Apr 19, 2024
6e36db4
fix: create temp in frontend asset dir to prevent error in pipeline
uvulpos Apr 19, 2024
ff7af34
fix: ci tests, remove passkeys, add config management
uvulpos Apr 22, 2024
ca17f6f
fix: change host in ci for postgres host
uvulpos Apr 22, 2024
d407ea4
use own postgres server in ci
uvulpos Apr 22, 2024
3739dcf
fix db migration file
uvulpos Apr 22, 2024
5dca890
fix: frontend tests
uvulpos Apr 22, 2024
f87e987
remove frontend tests + iac code
uvulpos Apr 22, 2024
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
18 changes: 15 additions & 3 deletions .env
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_DB=postgres
APP_DB_ADDR="postgres"
APP_DB_PORT=5432
APP_DB_USERNAME="postgres"
APP_DB_PASSWORD="postgres"
APP_DB_DATABASE="postgres"
APP_DB_SSL_MODE=0

APP_PORT=3000
APP_SHOW_FRONTEND=1
APP_SHOW_SWAGGER=1





38 changes: 38 additions & 0 deletions .github/workflows/execute-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: "CI: Test Software"

on:
push:

jobs:
test-backend:
runs-on: ubuntu-latest
# continue-on-error: true

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: run backend tests
if: ${{ always() }}
run: make test-be
env:
APP_DATABASE_HOST: postgres
APP_DATABASE_PORT: 5432
APP_DATABASE_USERNAME: postgres
APP_DATABASE_PASSWORD: postgres
APP_DATABASE_DATABASE: postgres
APP_DATABASE_SSLMODE: False

# test-frontend:
# runs-on: ubuntu-latest
# continue-on-error: true

# steps:
# - uses: actions/checkout@v4
# with:
# fetch-depth: 0

# - name: run frontend tests
# if: ${{ always() }}
# run: make test-fe
40 changes: 0 additions & 40 deletions .github/workflows/release.yml

This file was deleted.

7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,9 @@ services/frontend/.svelte-kit
services/frontend/node_modules
services/backend/src/assets/frontend

.DS_Store
.DS_Store
*.tgz

.input
.secrets
node_modules
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
@bash ./devops/scripts/utils/install-dependencies.sh

dev: .install-deps ## start debugging in docker compose microservices (auto reload)
@docker compose -f compose-dev.yaml up backend frontend reverse-proxy
@docker compose -f compose-dev.yaml up --abort-on-container-exit backend frontend reverse-proxy

build-full: .install-deps ## build current plattform
@bash ./devops/scripts/build-service/binary.sh
Expand All @@ -12,10 +12,10 @@ local-release: .install-deps ## build all app versions locally (via goreleaser)
@bash ./devops/scripts/utils/local-release.sh

test-be: ## run golang tests
@docker compose -f compose-dev.yaml up postgres backend-tests
@docker compose -f compose-dev.yaml up --abort-on-container-exit postgres backend-tests

test-fe: ## run sveltekit tests
@docker compose -f compose-dev.yaml up fontend-tests
@docker compose -f compose-dev.yaml up --abort-on-container-exit frontend-tests

build-dockerfile-binary: ## build one dockerimage that contains everything
@bash ./devops/scripts/build-container/binary.sh
Expand Down
34 changes: 30 additions & 4 deletions compose-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,21 @@ services:
- intranet
command: ["sh", "-c", "cd /app && npm install && npm run test"]

frontend-tests-ci:
image: node:latest
container_name: web-ui-test
restart: always
volumes:
- ./services/frontend/package.json:/app/package.json
- ./services/frontend/svelte.config.js:/app/svelte.config.js
- ./services/frontend/tsconfig.json:/app/tsconfig.json
- ./services/frontend/vite.config.ts:/app/vite.config.ts
- ./services/frontend/static:/app/static
- ./services/frontend/src:/app/src
networks:
- intranet
command: ["sh", "-c", "cd /app && npm install && npm run test"]

# -----------------------------------------------------------------------------------------------------
#
# BACKEND
Expand All @@ -89,7 +104,8 @@ services:
condition: service_started
# gotify:
# condition: service_started
restart: always
env_file:
- "./.env"
labels:
- "traefik.enable=true"
- "traefik.http.routers.backend.rule=Host(`web.localhost`)&&(PathPrefix(`/api`)||PathPrefix(`/swagger`))"
Expand All @@ -115,6 +131,16 @@ services:
- TERM=xterm-256color`
command: ["sh", "-c", "cd /app && bash scripts/test-local-docker.sh"]

backend-tests-ci:
image: golang:latest
container_name: web-api-test
volumes:
- ./services/backend:/app
tty: true
environment:
- TERM=xterm-256color`
command: ["sh", "-c", "cd /app && bash scripts/test-local-docker.sh"]

# -----------------------------------------------------------------------------------------------------
#
# DATABASE
Expand All @@ -125,9 +151,9 @@ services:
image: postgis/postgis
restart: always
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_USER: ${APP_DB_USERNAME}
POSTGRES_PASSWORD: ${APP_DB_PASSWORD}
POSTGRES_DB: ${APP_DB_DATABASE}
PGDATA: /var/lib/postgresql/data/pgdata
ports:
- "5432:5432"
Expand Down
2 changes: 2 additions & 0 deletions devops/deployments/.ci-pipeline/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
config
k8s.civo.config
23 changes: 23 additions & 0 deletions devops/deployments/application-services/backend/.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/
7 changes: 7 additions & 0 deletions devops/deployments/application-services/backend/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v2
name: backend
description: A Helm chart for Kubernetes

type: application
version: 0.1.0
appVersion: "1.16.0"
Empty file.
Empty file.
Empty file.
23 changes: 23 additions & 0 deletions devops/deployments/application-services/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/
7 changes: 7 additions & 0 deletions devops/deployments/application-services/frontend/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v2
name: frontend
description: A Helm chart for Kubernetes

type: application
version: 0.1.0
appVersion: "1.16.0"
Empty file.
Empty file.
Empty file.
25 changes: 25 additions & 0 deletions devops/deployments/application-services/helmfile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
environments:
develop: {}
prod: {}

---

releases:
- name: frontend
chart: ./frontend
namespace: application-{{ .Environment.Name }}
createNamespace: true
installed: true
values:
- "./values/frontend-{{ .Environment.Name }}.yaml"

- name: backend
chart: ./backend
namespace: application-{{ .Environment.Name }}
createNamespace: true
installed: true
values:
- "./values/backend-{{ .Environment.Name }}.yaml"
# set:
# - name: database.password
# value: {{ requiredEnv "SOMETHING" }}
23 changes: 23 additions & 0 deletions devops/deployments/application-services/standalone/.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/
7 changes: 7 additions & 0 deletions devops/deployments/application-services/standalone/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v2
name: standalone
description: A Helm chart for Kubernetes

type: application
version: 0.1.0
appVersion: "1.16.0"
Empty file.
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
application:
environment:
name: "develop"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
application:
environment:
name: "production"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
application:
environment:
name: "develop"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
application:
environment:
name: "production"
54 changes: 54 additions & 0 deletions devops/deployments/base-applications/helmfile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
repositories:
- name: ingress-nginx
url: https://kubernetes.github.io/ingress-nginx
- name: goauthentik
url: https://charts.goauthentik.io/
- name: longhorn
url: https://charts.longhorn.io
- name: bitnami
url: https://charts.bitnami.com/bitnami

releases:
- name: ingress
chart: ingress-nginx/ingress-nginx
namespace: ingress
createNamespace: true
values:
- "./values/ingress-nginx.yaml"

- name: longhorn
chart: longhorn/longhorn
version: 1.6.0
namespace: longhorn
createNamespace: true
values:
- "./values/storage-longhorn.yaml"

- name: postgres
chart: bitnami/postgresql
namespace: postgres
createNamespace: true
needs:
- longhorn/longhorn
set:
- name: global.storageClass
value: longhorn
- name: global.postgresql.auth.postgresPassword
value: adminpw
- name: global.postgresql.auth.username
value: user
- name: global.postgresql.auth.password
value: userpassword

# - name: authentik
# chart: goauthentik/authentik
# version: 2024.2.2
# namespace: identityprovider
# createNamespace: true
# needs:
# - ingress
# - longhorn
# - postgres
# values:
# - "./values/authentik-identity-provider.yaml"

2 changes: 2 additions & 0 deletions devops/deployments/base-applications/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
run:
helmfile sync --kube-context my-cluster --kubeconfig ../.ci-pipeline/k8s.civo.config
Loading