Skip to content

Commit 889a284

Browse files
committed
replace mongodb with ferretdb
1 parent 239ee38 commit 889a284

11 files changed

Lines changed: 71 additions & 32 deletions

File tree

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ Using the script
5656
.\generator.ps1 `
5757
-ServiceName AwesomeApp `
5858
-RabbitMqUserSecret rabbitmq-default-user `
59-
-MongoDbUserSecret mongodb-server-admin-admin `
6059
-DestinationFolder c:/git
6160
```
6261

@@ -74,12 +73,14 @@ dotnet new msa-web -n Awesome -o web
7473

7574
## What you get
7675

77-
These templates are intended to be used together as a small “vertical slice of a message-driven system:
76+
These templates are intended to be used together as a "vertical slice" of a message-driven system:
7877

7978
- **Shared**: contracts and shared abstractions used across services within the same domain.
8079
- **Worker**: consumes commands and external events, applies business logic, persists state, and publishes domain events.
8180
- **API**: serves HTTP endpoints, validates input, sends commands to the worker, and fans out updates through SignalR.
8281
- **Web**: a blank Angular Next frontend scaffolded to work with the API.
82+
- **Kubernetes manifests** for deploying the API, Worker and Web to any Kubernetes cluster.
83+
- **krun** config files for usage with the [krun](https://github.com/ftechmax/krun) development tool.
8384

8485
The templates come with sensible defaults for:
8586

generator.ps1

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,38 @@ Get-ChildItem -Path "$ProjectFolder/k8s" -Recurse | ForEach-Object {
4747
| Set-Content -Path $filePath
4848
}
4949
}
50+
51+
# Create krun.json
52+
$krunJsonPath = (Join-Path -Path $ProjectFolder -ChildPath 'krun.json')
53+
$krunJsonContent = @'
54+
[
55+
{
56+
"name": "applicationname-worker",
57+
"path": "src/worker",
58+
"dockerfile": "ApplicationName.Worker",
59+
"context": "src/",
60+
"intercept_port": 5001
61+
},
62+
{
63+
"name": "applicationname-api",
64+
"path": "src/api",
65+
"dockerfile": "ApplicationName.Api",
66+
"context": "src/",
67+
"intercept_port": 5000
68+
},
69+
{
70+
"name": "applicationname-web",
71+
"path": "src/web",
72+
"dockerfile": ".",
73+
"context": "src/web"
74+
}
75+
]
76+
'@
77+
78+
$krunJsonContent = $krunJsonContent `
79+
-creplace 'applicationname', $kebabCaseServiceName `
80+
-creplace 'ApplicationName', $ServiceName
81+
82+
$krunJsonContent | Set-Content -Path $krunJsonPath
83+
Write-Host "Created krun.json: $krunJsonPath"
84+

k8s/base/api/deployment.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,6 @@ spec:
5252
secretKeyRef:
5353
name: '{{RABBITMQ-SECRET-NAME}}'
5454
key: password
55-
- name: mongodb__connection-string
56-
valueFrom:
57-
secretKeyRef:
58-
name: '{{MONGODB-SECRET-NAME}}'
59-
key: connectionString.standard
6055
- name: valkey__connection-string
6156
value: 'applicationname-cache:6379'
6257
livenessProbe:

k8s/base/cache/deployment.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ spec:
4545
mountPath: /data
4646
- name: valkey-config
4747
mountPath: /etc/valkey
48-
# resources:
49-
# limits:
50-
# memory: 128Mi
51-
# cpu: 100m
52-
# requests:
53-
# memory: 64Mi
54-
# cpu: 50m
48+
resources:
49+
limits:
50+
memory: 64Mi
51+
cpu: 100m
52+
requests:
53+
memory: 3Mi
54+
cpu: 5m
5555
volumes:
5656
- name: valkey-data
5757
emptyDir: {}

k8s/base/worker/db-user.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
apiVersion: k8s.ftechmax.net/v1alpha1
3+
kind: FerretDbUser
4+
metadata:
5+
name: applicationname-user
6+
spec:
7+
database: applicationname
8+
secret: applicationname-user
9+
roles:
10+
- readWrite
11+
- dbAdmin

k8s/base/worker/deployment.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ spec:
3535
ports:
3636
- name: http
3737
containerPort: 8080
38+
envFrom:
39+
- secretRef:
40+
name: applicationname-user
3841
env:
3942
- name: rabbitmq__host
4043
valueFrom:
@@ -52,10 +55,7 @@ spec:
5255
name: '{{RABBITMQ-SECRET-NAME}}'
5356
key: password
5457
- name: mongodb__connection-string
55-
valueFrom:
56-
secretKeyRef:
57-
name: '{{MONGODB-SECRET-NAME}}'
58-
key: connectionString.standard
58+
value: 'mongodb://$(database_username):$(database_password)@ferretdb.ferretdb-system.svc:27017/'
5959
- name: valkey__connection-string
6060
value: 'applicationname-cache:6379'
6161
livenessProbe:

k8s/base/worker/kustomization.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
apiVersion: kustomize.config.k8s.io/v1beta1
33
kind: Kustomization
44
resources:
5+
- ./db-user.yaml
56
- ./deployment.yaml
67
- ./service.yaml

k8s/overlays/local/db-secret.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
apiVersion: v1
3+
kind: Secret
4+
type: Opaque
5+
metadata:
6+
name: applicationname-user
7+
stringData:
8+
database_username: admin
9+
database_password: admin

k8s/overlays/local/kustomization.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ apiVersion: kustomize.config.k8s.io/v1beta1
33
kind: Kustomization
44
namespace: default
55
resources:
6+
- ./db-secret.yaml
67
- ./../../base
78
patches:
89
- target:

src/templates/api/.template.config/template.json

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,6 @@
2727
"defaultValue": "rabbitmq-default-user",
2828
"replaces": "{{RABBITMQ-SECRET-NAME}}",
2929
"description": "The name of the RabbitMQ secret"
30-
},
31-
"MongoDbSecret": {
32-
"type": "parameter",
33-
"datatype": "string",
34-
"defaultValue": "mongodb-user-password",
35-
"replaces": "{{MONGODB-SECRET-NAME}}",
36-
"description": "The name of the MongoDB secret"
3730
}
3831
}
3932
}

0 commit comments

Comments
 (0)