Skip to content
This repository has been archived by the owner on Jul 12, 2024. It is now read-only.

Commit

Permalink
ci: apply k8s
Browse files Browse the repository at this point in the history
  • Loading branch information
foxminchan committed Jun 9, 2024
1 parent 9b4c70f commit 1ec9f46
Show file tree
Hide file tree
Showing 31 changed files with 644 additions and 179 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ Build an e-commerce web site with minimum functionality below:
- Install Node.js: [https://nodejs.org/en/download/](https://nodejs.org/en/download/)
- Install bun: [https://bun.sh/](https://bun.sh/)
- Install Stripe CLI: [https://stripe.com/docs/stripe-cli](https://stripe.com/docs/stripe-cli)
- Install k3d: [https://k3d.io/](https://k3d.io/)
- Open AI API Key: [https://platform.openai.com/](https://platform.openai.com/)

#### Windows with Visual Studio
Expand Down Expand Up @@ -219,10 +220,13 @@ Deploying the application to the production environment by using <a href="https:
</p>
```bash
dotnet aspirate generate
cd src/RookieShop.AppHost
dotnet aspirate apply
```
> [!WARNING]
> Ensure <code>k3d</code> is started and has the <code>cluster</code> context.
## Observability

<p align="justify">
Expand Down
9 changes: 0 additions & 9 deletions src/RookieShop.AppHost/aspirate-output/.env.example

This file was deleted.

40 changes: 40 additions & 0 deletions src/RookieShop.AppHost/aspirate-output/api-service/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: api-service
labels:
app: api-service
spec:
minReadySeconds: 60
replicas: 1
selector:
matchLabels:
app: api-service
strategy:
type: Recreate
template:
metadata:
labels:
app: api-service
spec:
containers:
- name: api-service
image: api-service:latest
imagePullPolicy: IfNotPresent
resources:
limits:
memory: "512Mi"
cpu: "500m"
ports:
- name: http
containerPort: 8080
- name: https
containerPort: 8443
envFrom:
- configMapRef:
name: api-service-env
- secretRef:
name: api-service-secrets
terminationGracePeriodSeconds: 180
automountServiceAccountToken: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
resources:
- deployment.yaml
- service.yaml

generatorOptions:
disableNameSuffixHash: true

configMapGenerator:
- name: api-service-env
literals:
- OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES=true
- OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES=true
- OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY=in_memory
- ASPNETCORE_FORWARDEDHEADERS_ENABLED=true
- AiOptions__OpenAi__EmbeddingName=text-embedding-3-small
- AzuriteSettings__ConnectionString={storage.outputs.blobEndpoint}
- CorsSettings__Backoffice=http://backoffice:8000
- OTEL_EXPORTER_OTLP_ENDPOINT=http://aspire-dashboard:18889
- OTEL_SERVICE_NAME=api-service
- ASPNETCORE_URLS=http://+:8080;

secretGenerator:
- name: api-service-secrets
envs:
- .api-service.secrets
16 changes: 16 additions & 0 deletions src/RookieShop.AppHost/aspirate-output/api-service/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
apiVersion: v1
kind: Service
metadata:
name: api-service
spec:
type: ClusterIP
selector:
app: api-service
ports:
- name: http
port: 8080
targetPort: 8080
- name: https
port: 8443
targetPort: 8443
36 changes: 36 additions & 0 deletions src/RookieShop.AppHost/aspirate-output/backoffice/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: backoffice
labels:
app: backoffice
spec:
minReadySeconds: 60
replicas: 1
selector:
matchLabels:
app: backoffice
strategy:
type: Recreate
template:
metadata:
labels:
app: backoffice
spec:
containers:
- name: backoffice
image: backoffice:latest
imagePullPolicy: IfNotPresent
resources:
limits:
memory: "128Mi"
cpu: "500m"
ports:
- name: http
containerPort: 8000
envFrom:
- configMapRef:
name: backoffice-env
terminationGracePeriodSeconds: 180
automountServiceAccountToken: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
resources:
- deployment.yaml
- service.yaml

generatorOptions:
disableNameSuffixHash: true

configMapGenerator:
- name: backoffice-env
literals:
- NODE_ENV=development
- PORT=8000
- BROWSER=none
- OTEL_EXPORTER_OTLP_ENDPOINT=http://aspire-dashboard:18889
- OTEL_SERVICE_NAME=backoffice
13 changes: 13 additions & 0 deletions src/RookieShop.AppHost/aspirate-output/backoffice/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
apiVersion: v1
kind: Service
metadata:
name: backoffice
spec:
type: ClusterIP
selector:
app: backoffice
ports:
- name: http
port: 3000
targetPort: 8000
40 changes: 40 additions & 0 deletions src/RookieShop.AppHost/aspirate-output/bff/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: bff
labels:
app: bff
spec:
minReadySeconds: 60
replicas: 1
selector:
matchLabels:
app: bff
strategy:
type: Recreate
template:
metadata:
labels:
app: bff
spec:
containers:
- name: bff
image: bff:latest
imagePullPolicy: IfNotPresent
resources:
limits:
memory: "512Mi"
cpu: "500m"
ports:
- name: http
containerPort: 8080
- name: https
containerPort: 8443
envFrom:
- configMapRef:
name: bff-env
- secretRef:
name: bff-secrets
terminationGracePeriodSeconds: 180
automountServiceAccountToken: false
24 changes: 24 additions & 0 deletions src/RookieShop.AppHost/aspirate-output/bff/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
resources:
- deployment.yaml
- service.yaml

generatorOptions:
disableNameSuffixHash: true

configMapGenerator:
- name: bff-env
literals:
- OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES=true
- OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES=true
- OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY=in_memory
- ASPNETCORE_FORWARDEDHEADERS_ENABLED=true
- ReverseProxy__Clusters__api__Destinations__api__Address=/api/v1
- BFF__Api__RemoteUrl=/api/v1/categories
- OTEL_EXPORTER_OTLP_ENDPOINT=http://aspire-dashboard:18889
- OTEL_SERVICE_NAME=bff
- ASPNETCORE_URLS=http://+:8080;

secretGenerator:
- name: bff-secrets
envs:
- .bff.secrets
16 changes: 16 additions & 0 deletions src/RookieShop.AppHost/aspirate-output/bff/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
apiVersion: v1
kind: Service
metadata:
name: bff
spec:
type: ClusterIP
selector:
app: bff
ports:
- name: http
port: 8080
targetPort: 8080
- name: https
port: 8443
targetPort: 8443
54 changes: 54 additions & 0 deletions src/RookieShop.AppHost/aspirate-output/dashboard.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: aspire-dashboard
labels:
app: aspire-dashboard
spec:
replicas: 1
selector:
matchLabels:
app: aspire-dashboard
template:
metadata:
labels:
app: aspire-dashboard
spec:
terminationGracePeriodSeconds: 30
containers:
- name: aspire-dashboard
image: mcr.microsoft.com/dotnet/aspire-dashboard:8.0
resources:
requests:
cpu: "500m"
memory: "512Mi"
limits:
memory: "512Mi"
cpu: "500m"
ports:
- name: dashboard-ui
containerPort: 18888
- name: otlp
containerPort: 18889
env:
- name: DOTNET_DASHBOARD_UNSECURED_ALLOW_ANONYMOUS
value: "true"
automountServiceAccountToken: false
---
apiVersion: v1
kind: Service
metadata:
name: aspire-dashboard
spec:
selector:
app: aspire-dashboard
ports:
- name: dashboard-ui
protocol: TCP
port: 18888
targetPort: 18888
- name: otlp
protocol: TCP
port: 18889
targetPort: 18889
type: ClusterIP
38 changes: 38 additions & 0 deletions src/RookieShop.AppHost/aspirate-output/db/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: db
labels:
app: db
spec:
minReadySeconds: 60
replicas: 1
selector:
matchLabels:
app: db
strategy:
type: Recreate
template:
metadata:
labels:
app: db
spec:
containers:
- name: db
image: docker.io/ankane/pgvector:latest
imagePullPolicy: IfNotPresent
resources:
limits:
memory: "512Mi"
cpu: "500m"
ports:
- name: tcp
containerPort: 5432
envFrom:
- configMapRef:
name: db-env
- secretRef:
name: db-secrets
terminationGracePeriodSeconds: 180
automountServiceAccountToken: false
20 changes: 20 additions & 0 deletions src/RookieShop.AppHost/aspirate-output/db/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
resources:
- deployment.yaml
- service.yaml

generatorOptions:
disableNameSuffixHash: true

configMapGenerator:
- name: db-env
literals:
- POSTGRES_HOST_AUTH_METHOD=scram-sha-256
- POSTGRES_INITDB_ARGS=--auth-host=scram-sha-256 --auth-local=scram-sha-256
- POSTGRES_USER=root
- OTEL_EXPORTER_OTLP_ENDPOINT=http://aspire-dashboard:18889
- OTEL_SERVICE_NAME=db

secretGenerator:
- name: db-secrets
envs:
- .db.secrets
13 changes: 13 additions & 0 deletions src/RookieShop.AppHost/aspirate-output/db/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
apiVersion: v1
kind: Service
metadata:
name: db
spec:
type: ClusterIP
selector:
app: db
ports:
- name: tcp
port: 5432
targetPort: 5432
Loading

0 comments on commit 1ec9f46

Please sign in to comment.