Skip to content

Commit 239ee38

Browse files
authored
Refactor api cqrs projections (#175)
1 parent 32e5bb2 commit 239ee38

48 files changed

Lines changed: 1091 additions & 224 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,3 +396,7 @@ FodyWeavers.xsd
396396

397397
# JetBrains Rider
398398
*.sln.iml
399+
400+
# Other
401+
.env
402+
*.env

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ Using the script
5757
-ServiceName AwesomeApp `
5858
-RabbitMqUserSecret rabbitmq-default-user `
5959
-MongoDbUserSecret mongodb-server-admin-admin `
60-
-RedisServiceName redis `
61-
-RedisServiceNamespace redis-system `
6260
-DestinationFolder c:/git
6361
```
6462

generator.ps1

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@ param (
66
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
77
[string]$RabbitMqUserSecret,
88
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
9-
[string]$MongoDbUserSecret,
10-
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
11-
[string]$RedisServiceName,
12-
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
13-
[string]$RedisServiceNamespace
9+
[string]$MongoDbUserSecret
1410
)
1511

1612
# Prepare service name
@@ -46,7 +42,6 @@ Get-ChildItem -Path "$ProjectFolder/k8s" -Recurse | ForEach-Object {
4642
(Get-Content -Path $filePath) `
4743
-creplace '{{RABBITMQ-SECRET-NAME}}', $RabbitMqUserSecret `
4844
-creplace '{{MONGODB-SECRET-NAME}}', $MongoDbUserSecret `
49-
-creplace '{{REDIS-SERVICE}}', "$RedisServiceName.$RedisServiceNamespace.svc" `
5045
-creplace 'applicationname', $kebabCaseServiceName `
5146
-creplace 'ApplicationName', $ServiceName `
5247
| Set-Content -Path $filePath

k8s/base/api/deployment.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ spec:
5757
secretKeyRef:
5858
name: '{{MONGODB-SECRET-NAME}}'
5959
key: connectionString.standard
60-
- name: redis__connection-string
61-
value: '{{REDIS-SERVICE}}'
60+
- name: valkey__connection-string
61+
value: 'applicationname-cache:6379'
6262
livenessProbe:
6363
httpGet:
6464
path: /healthz

k8s/base/cache/deployment.yaml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
apiVersion: apps/v1
3+
kind: Deployment
4+
metadata:
5+
name: applicationname-cache
6+
labels:
7+
app: applicationname-cache
8+
spec:
9+
replicas: 1
10+
revisionHistoryLimit: 2
11+
selector:
12+
matchLabels:
13+
app: applicationname-cache
14+
template:
15+
metadata:
16+
labels:
17+
app: applicationname-cache
18+
spec:
19+
automountServiceAccountToken: false
20+
containers:
21+
- name: valkey
22+
image: valkey/valkey:9.0.0-alpine
23+
command:
24+
- valkey-server
25+
- /etc/valkey/valkey.conf
26+
securityContext:
27+
runAsNonRoot: true
28+
runAsUser: 999
29+
runAsGroup: 999
30+
allowPrivilegeEscalation: false
31+
readOnlyRootFilesystem: false
32+
capabilities:
33+
drop:
34+
- all
35+
ports:
36+
- name: valkey
37+
containerPort: 6379
38+
livenessProbe:
39+
tcpSocket:
40+
port: 6379
41+
initialDelaySeconds: 3
42+
periodSeconds: 3
43+
volumeMounts:
44+
- name: valkey-data
45+
mountPath: /data
46+
- name: valkey-config
47+
mountPath: /etc/valkey
48+
# resources:
49+
# limits:
50+
# memory: 128Mi
51+
# cpu: 100m
52+
# requests:
53+
# memory: 64Mi
54+
# cpu: 50m
55+
volumes:
56+
- name: valkey-data
57+
emptyDir: {}
58+
- name: valkey-config
59+
configMap:
60+
name: applicationname-valkey-config

k8s/base/cache/kustomization.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
apiVersion: kustomize.config.k8s.io/v1beta1
3+
kind: Kustomization
4+
resources:
5+
- ./deployment.yaml
6+
- ./service.yaml
7+
- ./valkey-config.yaml

k8s/base/cache/service.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
apiVersion: v1
3+
kind: Service
4+
metadata:
5+
name: applicationname-cache
6+
spec:
7+
selector:
8+
app: applicationname-cache
9+
ports:
10+
- name: valkey
11+
protocol: TCP
12+
port: 6379
13+
targetPort: 6379

k8s/base/cache/valkey-config.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
apiVersion: v1
3+
kind: ConfigMap
4+
metadata:
5+
name: applicationname-valkey-config
6+
data:
7+
valkey.conf: |
8+
# Enable keyspace notifications for expired, evicted, and generic events
9+
# E = Keyspace events (published with __keyspace@<db>__ prefix)
10+
# g = Generic commands (DEL, EXPIRE, RENAME, etc.)
11+
# x = Expired events (generated when a key expires)
12+
notify-keyspace-events "Egx"
13+
14+
# Configure default user ACL permissions
15+
# on = enable the user
16+
# nopass = no password required
17+
# allkeys = access to all keys
18+
# &* = access to all pub/sub channels (required for cache invalidation)
19+
# +@all = all commands allowed
20+
# -FLUSHALL -FLUSHDB = explicitly deny these destructive commands
21+
user default on nopass allkeys &* +@all -FLUSHALL -FLUSHDB

k8s/base/kustomization.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ resources:
66
- ./worker
77
- ./api
88
- ./web
9+
- ./cache

k8s/base/worker/deployment.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ spec:
2323
containers:
2424
- name: applicationname-worker
2525
image: applicationname-worker:latest
26-
imagePullPolicy: Always
2726
securityContext:
2827
runAsNonRoot: true
2928
runAsUser: 10000
@@ -57,6 +56,8 @@ spec:
5756
secretKeyRef:
5857
name: '{{MONGODB-SECRET-NAME}}'
5958
key: connectionString.standard
59+
- name: valkey__connection-string
60+
value: 'applicationname-cache:6379'
6061
livenessProbe:
6162
httpGet:
6263
path: /healthz

0 commit comments

Comments
 (0)