diff --git a/infra/helm/Readme.md b/infra/helm/Readme.md index 961f03c..a8228b7 100644 --- a/infra/helm/Readme.md +++ b/infra/helm/Readme.md @@ -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 @@ -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) diff --git a/infra/helm/charts/hikers-book/.gitignore b/infra/helm/charts/hikers-book/.gitignore deleted file mode 100644 index 0469bb9..0000000 --- a/infra/helm/charts/hikers-book/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -config -keys \ No newline at end of file diff --git a/infra/helm/environments/.gitignore b/infra/helm/environments/.gitignore deleted file mode 100644 index 60d2056..0000000 --- a/infra/helm/environments/.gitignore +++ /dev/null @@ -1 +0,0 @@ -**/secrets.yaml \ No newline at end of file diff --git a/infra/helm/environments/local/values.yaml b/infra/helm/environments/local/values.yaml deleted file mode 100644 index 7b69419..0000000 --- a/infra/helm/environments/local/values.yaml +++ /dev/null @@ -1,16 +0,0 @@ -apps: - authentication-api: - replicas: 1 - - graphql-api: - replicas: 1 - - stages-api: - replicas: 1 - - trips-api: - replicas: 1 - - hikers-book-ui: - replicas: 1 - \ No newline at end of file diff --git a/infra/helm/helm.sh b/infra/helm/helm.sh new file mode 100755 index 0000000..2d5d80e --- /dev/null +++ b/infra/helm/helm.sh @@ -0,0 +1,23 @@ +#!/bin/bash +if [ "$1" = "" ]; then + echo "Usage: $0 " + 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 \ No newline at end of file diff --git a/infra/helm/charts/hikers-book/Chart.yaml b/infra/helm/hikers-book/Chart.yaml similarity index 100% rename from infra/helm/charts/hikers-book/Chart.yaml rename to infra/helm/hikers-book/Chart.yaml diff --git a/infra/helm/hikers-book/environments/.gitignore b/infra/helm/hikers-book/environments/.gitignore new file mode 100644 index 0000000..369bdb4 --- /dev/null +++ b/infra/helm/hikers-book/environments/.gitignore @@ -0,0 +1,2 @@ +**/secrets.yaml +**/keys/*.pem* \ No newline at end of file diff --git a/infra/helm/environments/local/config/api.authentication.json b/infra/helm/hikers-book/environments/local/config/api.authentication.json similarity index 100% rename from infra/helm/environments/local/config/api.authentication.json rename to infra/helm/hikers-book/environments/local/config/api.authentication.json diff --git a/infra/helm/environments/local/config/api.graphql.json b/infra/helm/hikers-book/environments/local/config/api.graphql.json similarity index 100% rename from infra/helm/environments/local/config/api.graphql.json rename to infra/helm/hikers-book/environments/local/config/api.graphql.json diff --git a/infra/helm/environments/local/config/api.stages.json b/infra/helm/hikers-book/environments/local/config/api.stages.json similarity index 100% rename from infra/helm/environments/local/config/api.stages.json rename to infra/helm/hikers-book/environments/local/config/api.stages.json diff --git a/infra/helm/environments/local/config/api.trips.json b/infra/helm/hikers-book/environments/local/config/api.trips.json similarity index 100% rename from infra/helm/environments/local/config/api.trips.json rename to infra/helm/hikers-book/environments/local/config/api.trips.json diff --git a/infra/helm/environments/local/config/ui.hikers-book.json b/infra/helm/hikers-book/environments/local/config/ui.hikers-book.json similarity index 100% rename from infra/helm/environments/local/config/ui.hikers-book.json rename to infra/helm/hikers-book/environments/local/config/ui.hikers-book.json diff --git a/infra/helm/hikers-book/environments/local/keys/.gitkeeep b/infra/helm/hikers-book/environments/local/keys/.gitkeeep new file mode 100644 index 0000000..e69de29 diff --git a/infra/helm/environments/secrets.yaml.example b/infra/helm/hikers-book/environments/local/secrets.yaml.example similarity index 100% rename from infra/helm/environments/secrets.yaml.example rename to infra/helm/hikers-book/environments/local/secrets.yaml.example diff --git a/infra/helm/hikers-book/environments/local/values.yaml b/infra/helm/hikers-book/environments/local/values.yaml new file mode 100644 index 0000000..de545c3 --- /dev/null +++ b/infra/helm/hikers-book/environments/local/values.yaml @@ -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 + \ No newline at end of file diff --git a/infra/helm/environments/local/variables.yaml b/infra/helm/hikers-book/environments/local/variables.yaml similarity index 100% rename from infra/helm/environments/local/variables.yaml rename to infra/helm/hikers-book/environments/local/variables.yaml diff --git a/infra/helm/charts/hikers-book/templates/hikers-book-configmap.yaml b/infra/helm/hikers-book/templates/hikers-book-configmap.yaml similarity index 100% rename from infra/helm/charts/hikers-book/templates/hikers-book-configmap.yaml rename to infra/helm/hikers-book/templates/hikers-book-configmap.yaml diff --git a/infra/helm/charts/hikers-book/templates/hikers-book-deployment.yaml b/infra/helm/hikers-book/templates/hikers-book-deployment.yaml similarity index 100% rename from infra/helm/charts/hikers-book/templates/hikers-book-deployment.yaml rename to infra/helm/hikers-book/templates/hikers-book-deployment.yaml diff --git a/infra/helm/charts/hikers-book/templates/hikers-book-service.yaml b/infra/helm/hikers-book/templates/hikers-book-service.yaml similarity index 100% rename from infra/helm/charts/hikers-book/templates/hikers-book-service.yaml rename to infra/helm/hikers-book/templates/hikers-book-service.yaml diff --git a/infra/helm/charts/hikers-book/templates/ingress-srv-api.yaml b/infra/helm/hikers-book/templates/ingress-srv-api.yaml similarity index 100% rename from infra/helm/charts/hikers-book/templates/ingress-srv-api.yaml rename to infra/helm/hikers-book/templates/ingress-srv-api.yaml diff --git a/infra/helm/charts/hikers-book/templates/ingress-srv-ui.yaml b/infra/helm/hikers-book/templates/ingress-srv-ui.yaml similarity index 100% rename from infra/helm/charts/hikers-book/templates/ingress-srv-ui.yaml rename to infra/helm/hikers-book/templates/ingress-srv-ui.yaml diff --git a/infra/helm/charts/hikers-book/templates/mongodb.yaml b/infra/helm/hikers-book/templates/mongodb.yaml similarity index 100% rename from infra/helm/charts/hikers-book/templates/mongodb.yaml rename to infra/helm/hikers-book/templates/mongodb.yaml diff --git a/infra/helm/charts/hikers-book/templates/redis.yaml b/infra/helm/hikers-book/templates/redis.yaml similarity index 100% rename from infra/helm/charts/hikers-book/templates/redis.yaml rename to infra/helm/hikers-book/templates/redis.yaml diff --git a/infra/helm/charts/hikers-book/values.yaml b/infra/helm/hikers-book/values.yaml similarity index 72% rename from infra/helm/charts/hikers-book/values.yaml rename to infra/helm/hikers-book/values.yaml index 6ba6d1d..25fd74f 100644 --- a/infra/helm/charts/hikers-book/values.yaml +++ b/infra/helm/hikers-book/values.yaml @@ -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: @@ -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: @@ -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: @@ -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: @@ -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