Skip to content

Commit

Permalink
Merge pull request #865 from notaphplover/chore/add-k8s-ingress
Browse files Browse the repository at this point in the history
Add k8s ingress
  • Loading branch information
notaphplover authored Jan 12, 2024
2 parents c34e500 + 8251801 commit 1c4495f
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 1 deletion.
20 changes: 20 additions & 0 deletions docs/backend/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ A kubernetes config is provided to deploy all the services.
- `kubectl` version 1.28 or later.
- `helm` version 3.10 or later.
- k8s server should have [redis-operator](https://github.com/OT-CONTAINER-KIT/redis-operator) installed.
- k8s server should have [nginx-ingress](https://github.com/nginxinc/kubernetes-ingress) installed.

Consider the following script to install them:

```bash

helm install nginx-release oci://ghcr.io/nginxinc/charts/nginx-ingress --version 1.1.0

helm repo add ot-helm https://ot-container-kit.github.io/helm-charts/
helm repo add cnpg https://cloudnative-pg.github.io/charts

Expand Down Expand Up @@ -46,6 +50,22 @@ minikube image load one-game-backend-service-game:latest

Assuming you want to locally deploy services through minikube, consider `minikube tunnel` to provide external ips to exposed services.

#### Enabling minikube ingress

In order to enable ingress features, consider adding the right addon:

```bash
minikube addons enable ingress
```

Last but not least, you should find a way to resolve the expected hosts to your local minikube ip.

The most simple approach might be updating your host file (traditionally at `/etc/hosts`) with a new entry:

```
<your-minikube-ip> api.cornie.game
```

## Destroying services

Just connect to the cluster and run the destroy script:
Expand Down
1 change: 1 addition & 0 deletions k8s/deploy
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ kubectl apply \
-f "$SCRIPT_DIR"/grafana/grafana-dashboards-config.yaml \
-f "$SCRIPT_DIR"/grafana/grafana-datasources-config.yaml \
-f "$SCRIPT_DIR"/grafana/grafana.yaml \
-f "$SCRIPT_DIR"/ingress.yaml \
-f "$SCRIPT_DIR"/prometheus/prometheus-config.yaml \
-f "$SCRIPT_DIR"/prometheus/prometheus.yaml \
-f "$SCRIPT_DIR"/one-game-services/rest/common/rest-api-config.yaml \
Expand Down
1 change: 1 addition & 0 deletions k8s/destroy
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ kubectl delete \
-f "$SCRIPT_DIR"/grafana/grafana-dashboards-config.yaml \
-f "$SCRIPT_DIR"/grafana/grafana-datasources-config.yaml \
-f "$SCRIPT_DIR"/grafana/grafana.yaml \
-f "$SCRIPT_DIR"/ingress.yaml \
-f "$SCRIPT_DIR"/prometheus/prometheus-config.yaml \
-f "$SCRIPT_DIR"/prometheus/prometheus.yaml \
-f "$SCRIPT_DIR"/one-game-services/rest/common/rest-api-config.yaml \
Expand Down
42 changes: 42 additions & 0 deletions k8s/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
nginx.org/websocket-services: "rest-service-game"
labels:
name: rest-api-ingress
name: rest-api-ingress
namespace: one-game
spec:
rules:
- host: api.cornie.game
http:
paths:
- path: /v1/auth
pathType: Prefix
backend:
service:
name: rest-service-user
port:
number: 3001
- path: /v1/events/games
pathType: Prefix
backend:
service:
name: rest-service-game
port:
number: 3002
- path: /v1/games
pathType: Prefix
backend:
service:
name: rest-service-game
port:
number: 3002
- path: /v1/users
pathType: Prefix
backend:
service:
name: rest-service-user
port:
number: 3001
2 changes: 1 addition & 1 deletion k8s/one-game-services/rest/common/rest-api-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: rest-api-config
namespace: one-game
data:
api.base-url: http://localhost:8000
api.base-url: http://api.cornie.game:80

cors-origins: '["*"]'

Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
"build:api:graphql": "pnpm run build:api:rest --filter=backend-service-gateway",
"close:e2e": "turbo run close:e2e",
"commit": "commit",
"docker:build:game": "docker build . --target backendservicegame --tag one-game-backend-service-game:latest",
"docker:build:user": "docker build . --target backendserviceuser --tag one-game-backend-service-user:latest",
"format": "turbo run format",
"lint": "turbo run lint",
"migrations:run": "turbo run migrations:run",
Expand Down

0 comments on commit 1c4495f

Please sign in to comment.