Skip to content

Commit

Permalink
chore: move environments to helm chart directory
Browse files Browse the repository at this point in the history
  • Loading branch information
radoslavirha committed Dec 16, 2023
1 parent 072ebcc commit 5e986a3
Show file tree
Hide file tree
Showing 24 changed files with 102 additions and 40 deletions.
23 changes: 16 additions & 7 deletions infra/helm/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,20 @@ kubectl label nodes docker-desktop size=large

## Run cluster

### Environment prerequisites

Create keys for each environment

```sh
cd hikers-book/environments
cd {{ environment }}
mkdir keys
openssl genrsa -out keys/access.pem 2048 && openssl rsa -in keys/access.pem -outform PEM -pubout -out keys/access.pem.pub
openssl genrsa -out keys/refresh.pem 2048 && openssl rsa -in keys/refresh.pem -outform PEM -pubout -out keys/refresh.pem.pub
```

### Start

1. Build containers

```sh
Expand All @@ -65,13 +79,8 @@ kubectl label nodes docker-desktop size=large

```sh
cd infra/helm
cp -r environments/local/config charts/hikers-book/
cd charts/hikers-book/
mkdir keys
openssl genrsa -out keys/access.pem 2048 && openssl rsa -in keys/access.pem -outform PEM -pubout -out keys/access.pem.pub
openssl genrsa -out keys/refresh.pem 2048 && openssl rsa -in keys/refresh.pem -outform PEM -pubout -out keys/refresh.pem.pub
cd ../..
helm install hikers-book charts/hikers-book -f environments/local/values.yaml -f environments/local/variables.yaml -f environments/local/secrets.yaml
# LOCAL environment
./helm.sh local
```

3. [Visit hikers-book.dev.info](https://hikers-book.dev.info)
Expand Down
2 changes: 0 additions & 2 deletions infra/helm/charts/hikers-book/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion infra/helm/environments/.gitignore

This file was deleted.

16 changes: 0 additions & 16 deletions infra/helm/environments/local/values.yaml

This file was deleted.

23 changes: 23 additions & 0 deletions infra/helm/helm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
if [ "$1" = "" ]; then
echo "Usage: $0 <environment>"
exit 1
fi

if [[ $# -ne 1 ]]; then
echo 'Too many arguments, expecting "local"' >&2
exit 1
fi

case $1 in
# LOCAL|WAHTEVER|WHATEVER ELSE
local) # Ok
;;
*)
# The wrong first argument.
echo 'Expected "local"' >&2
exit 1
esac

echo "Deploying to $1"
helm install hikers-book hikers-book -f hikers-book/environments/$1/values.yaml -f hikers-book/environments/$1/variables.yaml -f hikers-book/environments/$1/secrets.yaml
File renamed without changes.
2 changes: 2 additions & 0 deletions infra/helm/hikers-book/environments/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**/secrets.yaml
**/keys/*.pem*
Empty file.
47 changes: 47 additions & 0 deletions infra/helm/hikers-book/environments/local/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
apps:
authentication-api:
replicas: 1
configMap:
authentication-api-configmap-keys:
data:
access.pem: environments/local/keys/access.pem
access.pem.pub: environments/local/keys/access.pem.pub
refresh.pem: environments/local/keys/refresh.pem
refresh.pem.pub: environments/local/keys/refresh.pem.pub
jinja2:
templates:
config:
template: environments/local/config/api.authentication.json

graphql-api:
replicas: 1
jinja2:
templates:
config:
template: environments/local/config/api.graphql.json

stages-api:
replicas: 1
jinja2:
templates:
config:
template: environments/local/config/api.stages.json

trips-api:
replicas: 1
jinja2:
templates:
config:
template: environments/local/config/api.trips.json

hikers-book-ui:
replicas: 1
jinja2:
templates:
cs:
template: environments/local/config/ui.hikers-book.json
en-us:
template: environments/local/config/ui.hikers-book.json
sk:
template: environments/local/config/ui.hikers-book.json

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ apps:
image: radoslavirha/hikers-book-api-authentication
service:
targetPort: 4000
configMap:
authentication-api-configmap-keys:
data:
access.pem: keys/access.pem
access.pem.pub: keys/access.pem.pub
refresh.pem: keys/refresh.pem
refresh.pem.pub: keys/refresh.pem.pub
# configMap:
# authentication-api-configmap-keys:
# data:
# access.pem: environments/ENV/keys/access.pem
# access.pem.pub: environments/ENV/keys/access.pem.pub
# refresh.pem: environments/ENV/keys/refresh.pem
# refresh.pem.pub: environments/ENV/keys/refresh.pem.pub
jinja2:
templates:
config:
template: config/api.authentication.json
# template: environments/ENV/config/api.authentication.json
path: /app/api/authentication/config
file: production.json
volumes:
Expand All @@ -35,7 +35,7 @@ apps:
jinja2:
templates:
config:
template: config/api.graphql.json
# template: environments/ENV/config/api.graphql.json
path: /app/api/graphql/config
file: production.json
initContainers:
Expand All @@ -49,7 +49,7 @@ apps:
jinja2:
templates:
config:
template: config/api.stages.json
# template: environments/ENV/config/api.stages.json
path: /app/api/stages/config
file: production.json
initContainers:
Expand All @@ -63,7 +63,7 @@ apps:
jinja2:
templates:
config:
template: config/api.trips.json
# template: environments/ENV/config/api.trips.json
path: /app/api/trips/config
file: production.json
initContainers:
Expand All @@ -77,15 +77,15 @@ apps:
jinja2:
templates:
cs:
template: config/ui.hikers-book.json
# template: environments/ENV/config/ui.hikers-book.json
path: /usr/share/nginx/html/cs/assets/config
file: config.json
en-us:
template: config/ui.hikers-book.json
# template: environments/ENV/config/ui.hikers-book.json
path: /usr/share/nginx/html/en-US/assets/config
file: config.json
sk:
template: config/ui.hikers-book.json
# template: environments/ENV/config/ui.hikers-book.json
path: /usr/share/nginx/html/sk/assets/config
file: config.json

Expand Down

0 comments on commit 5e986a3

Please sign in to comment.