Skip to content

Commit

Permalink
wip(kubernetes)
Browse files Browse the repository at this point in the history
  • Loading branch information
japsu committed Dec 8, 2024
1 parent 46e5223 commit 82fda13
Show file tree
Hide file tree
Showing 34 changed files with 463 additions and 40 deletions.
13 changes: 13 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"root": true,
"extends": ["next/core-web-vitals", "prettier"],
"rules": {
"import/order": [
"error",
{
"alphabetize": { "order": "asc", "caseInsensitive": true },
"warnOnUnassignedImports": false
}
]
}
}
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright © 2010–2020 Santtu Pajukanta
Copyright © 2010–2024 Santtu Pajukanta

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
19 changes: 6 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ To run tests:
alias dc-test="docker-compose --file=docker-compose.test.yml up --abort-on-container-exit --exit-code-from=test"
dc-test

#### Caveats

* Due to deep magic performed by the `react-scripts` proxy, picture & album downloads do not work in local dev and you are offered `index.html` instead.

### The Traditional Way

For developing the backend or frontend components without Docker Compose, please see the set-up instructions in their respective README files under `backend/` and `frontend/`.
Expand Down Expand Up @@ -71,8 +67,10 @@ The following services are required:

* [ingress-nginx](https://github.com/kubernetes/ingress-nginx) or some other ingress controller
* [cert-manager](https://github.com/jetstack/cert-manager) if you want TLS (not required for local development)
* postgres
* redis

The Kubernetes deployment uses [Emskaffolden](https://github.com/con2/emskaffolden) which in turn wraps [Skaffold](https://skaffold.dev) with [Emrichen](https://github.com/con2/emrichen).
The Kubernetes deployment uses [Skaffold](https://skaffold.dev) with [Depleten](https://github.com/japsu/depleten).

To deploy in [Docker Desktop](https://www.docker.com/products/docker-desktop) or similar local Kubernetes:

Expand All @@ -87,23 +85,18 @@ To deploy in [Docker Desktop](https://www.docker.com/products/docker-desktop) or
helm install -n cert-manager cert-manager jetstack/cert-manager --set installCRDs=true

# Once you have the above requirements installed
emskaffolden run
npm install
npm run k8s:dev

To customize, first see `kubernetes/default.vars.yaml` and make a copy of `kubernetes/staging.vars.yaml` under your environment name (eg. `kubernetes/myenv.vars.yaml`). Then activate your environment with `-E myenv`. For a non-local Kubernetes cluster, you also need to add your private registry using `--default-repo`. Eg.

emskaffolden run -E myenv -- --default-repo=harbor.con2.fi/con2

### Ansible & Docker

**DEPRECATED**: Will stop being maintained once we move Conikuvat.fi and Larppikuvat.fi to Kubernetes.

See [here](https://github.com/tracon/ansible-tracon/tree/master/roles/edegal/).

## License

The MIT License (MIT)

Copyright © 2010–2020 Santtu Pajukanta
Copyright © 2010–2024 Santtu Pajukanta

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
19 changes: 6 additions & 13 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,15 @@ services:
environment:
<<: *environment
frontend:
build: frontend
build:
context: frontend
dockerfile: dev.Dockerfile
init: true
command:
- node_modules/.bin/vite
- --host=0.0.0.0
ports:
- 3000:3000
# network_mode: service:router
depends_on:
- backend
volumes:
- ./frontend/src:/usr/src/app/src
tmpfs:
- /usr/src/app/node_modules/.cache
- /usr/src/app/node_modules/.vite
environment:
NEXT_PUBLIC_EDEGAL_PROXY_URL: http://backend:8000
NEXT_PUBLIC_EDEGAL_LOGIN_URL: http://localhost:8000/admin/
CI: "true"
postgres:
image: postgres
volumes:
Expand Down
10 changes: 3 additions & 7 deletions frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "frontend",
"version": "0.1.0",
"name": "edegal-frontend",
"version": "2.0.0",
"private": true,
"scripts": {
"dev": "next dev",
Expand All @@ -18,11 +18,7 @@
"sass": "^1.82.0"
},
"devDependencies": {
"@types/node": "^20",
"@types/react": "^19",
"@types/react-dom": "^19",
"eslint": "^8",
"eslint-config-next": "15.0.4",
"typescript": "^5"
"@types/react-dom": "^19"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions kubernetes/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.json
!package.json
!package-lock.json
!.eslintrc.json
!tsconfig.json
23 changes: 23 additions & 0 deletions kubernetes/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Kubernetes deployment for kompassi2

Generate Kubernetes manifests using

npm run k8s:generate

This runs the `kubernetes/manifest.ts` that is intended to be a brutally simple Node.js program with no other dependencies than `fs`. It accepts one environment variable, `ENV`, with the values `dev` (the default), `staging` and `production`, and outputs Kubernetes manifests as JSON files in the directory it was run.

Test with Skaffold (with Docker Desktop or similar local Kubernetes cluster):

npm run k8s:dev

Assuming you have an [ingress controller set up](https://outline.con2.fi/doc/ingress-controller-XfVUOHtp2t#h-installing-an-ingress-controller-for-local-development), you should now be able to view the UI at http://kompassi2.localhost.

For staging and production, deployment is done in two steps using Skaffold:

cd kubernetes && ENV=staging npx ts-node manifest.ts && cd -
skaffold build --file-output build.json
skaffold deploy -n kompassi2-staging -a build.json

See `skaffold.yaml` in the repository root.

You should, for the most part, not deploy manually. GitHub Actions CI/CD is set up to deploy all commits to `main` into the staging environment at https://v2.dev.kompassi.eu, and after a manual gate into production at https://v2.kompassi.eu. See `.github/workflows/cicd.yaml`.
Loading

0 comments on commit 82fda13

Please sign in to comment.