Skip to content
This repository was archived by the owner on Sep 16, 2025. It is now read-only.

Commit 52730b4

Browse files
committed
Refactor Kubernetes deployment configuration to use kustomize overlays and update ingress handling
1 parent 50c7a41 commit 52730b4

8 files changed

Lines changed: 82 additions & 11 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,12 @@ jobs:
6868
- name: Deploy to Kubernetes
6969
run: |
7070
if [ "${{ github.ref_name }}" = "main" ]; then
71-
INGRESS_HOST="wiki.coregame.de"
71+
OVERLAY=main
7272
elif [ "${{ github.ref_name }}" = "dev" ]; then
73-
INGRESS_HOST="dev.wiki.coregame.de"
73+
OVERLAY=dev
7474
else
75-
echo "Branch is not main or dev, skipping ingress update."
75+
echo "Branch is not main or dev, skipping deployment."
7676
exit 1
7777
fi
78-
sed -i "s|IMAGE_TAG|${{ env.IMAGE_NAME }}|g" k8s/deployment.yml
79-
sed -i "s|INGRESS_HOST|$INGRESS_HOST|g" k8s/ingress.yml
80-
kubectl apply -f k8s/deployment.yml
81-
kubectl apply -f k8s/service.yml
82-
kubectl apply -f k8s/ingress.yml
78+
cd k8s/overlays/$OVERLAY
79+
kustomize build . | kubectl apply -f -

k8s/deployment.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ apiVersion: apps/v1
22
kind: Deployment
33
metadata:
44
name: public-wiki
5+
namespace: wiki
56
spec:
6-
replicas: 1
7+
replicas: 3 # default, will be overridden by overlays
78
selector:
89
matchLabels:
910
app: public-wiki
@@ -14,6 +15,6 @@ spec:
1415
spec:
1516
containers:
1617
- name: public-wiki
17-
image: IMAGE_TAG
18+
image: IMAGE_TAG # will be replaced by kustomize
1819
ports:
1920
- containerPort: 3000

k8s/ingress.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ apiVersion: networking.k8s.io/v1
22
kind: Ingress
33
metadata:
44
name: public-wiki-ingress
5+
namespace: wiki
56
annotations:
67
nginx.ingress.kubernetes.io/rewrite-target: /
78
spec:
89
rules:
9-
- host: INGRESS_HOST
10+
- host: PLACEHOLDER_HOST
1011
http:
1112
paths:
1213
- path: /

k8s/kustomization.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
resources:
2+
- namespace.yml
3+
- deployment.yml
4+
- service.yml
5+
- ingress.yml
6+
7+
images:
8+
- name: public-wiki
9+
newName: IMAGE_TAG
10+
11+
namespace: wiki

k8s/namespace.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
apiVersion: v1
2+
kind: Namespace
3+
metadata:
4+
name: wiki

k8s/overlays/dev/kustomization.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
resources:
2+
- ../../deployment.yml
3+
- ../../service.yml
4+
- ../../ingress.yml
5+
- ../../namespace.yml
6+
7+
namespace: wiki
8+
9+
patches:
10+
- target:
11+
kind: Deployment
12+
name: public-wiki
13+
patch: |-
14+
- op: replace
15+
path: /spec/replicas
16+
value: 1
17+
- target:
18+
kind: Ingress
19+
name: public-wiki-ingress
20+
patch: |-
21+
- op: replace
22+
path: /spec/rules/0/host
23+
value: dev.wiki.coregame.de
24+
25+
images:
26+
- name: IMAGE_TAG
27+
newName: ghcr.io/42core-team/wiki
28+
newTag: dev
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
resources:
2+
- ../../deployment.yml
3+
- ../../service.yml
4+
- ../../ingress.yml
5+
- ../../namespace.yml
6+
7+
namespace: wiki
8+
9+
patches:
10+
- target:
11+
kind: Deployment
12+
name: public-wiki
13+
patch: |-
14+
- op: replace
15+
path: /spec/replicas
16+
value: 3
17+
- target:
18+
kind: Ingress
19+
name: public-wiki-ingress
20+
patch: |-
21+
- op: replace
22+
path: /spec/rules/0/host
23+
value: wiki.coregame.de
24+
25+
images:
26+
- name: IMAGE_TAG
27+
newName: ghcr.io/42core-team/wiki
28+
newTag: main

k8s/service.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ apiVersion: v1
22
kind: Service
33
metadata:
44
name: public-wiki
5+
namespace: wiki
56
spec:
67
selector:
78
app: public-wiki

0 commit comments

Comments
 (0)