fix actions

This commit is contained in:
2026-05-13 09:10:47 +02:00
parent a281d9cce9
commit d7ae020130
15 changed files with 327 additions and 1 deletions

View File

@@ -3,7 +3,7 @@ name: Build and Push Container Image
on: on:
push: push:
branches: branches:
- master - main
paths-ignore: paths-ignore:
- "deploy/**" - "deploy/**"
env: env:

0
deploy/.gitkeep Normal file
View File

13
deploy/base/cert.yaml Normal file
View File

@@ -0,0 +1,13 @@
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: election-tls
namespace: vhsmp
spec:
secretName: election-tls
issuerRef:
name: letsencrypt-prod
kind: ClusterIssuer
dnsNames:
- taskarr.milasholsting.dk

View File

@@ -0,0 +1,77 @@
# https://kubernetes.io/docs/concepts/workloads/controllers/deployment/
apiVersion: apps/v1
kind: Deployment
metadata:
name: election
namespace: vhsmp
labels:
app: election
spec:
selector:
matchLabels:
app: election
replicas: 1
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
annotations:
kubectl.kubernetes.io/default-container: election
labels:
app: election
spec:
containers:
- name: election
image: election
imagePullPolicy: IfNotPresent
resources:
requests:
cpu: 100m
memory: 100Mi
limits:
cpu: 100m
memory: 100Mi
livenessProbe:
tcpSocket:
port: 3000
initialDelaySeconds: 5
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 3
periodSeconds: 10
ports:
- containerPort: 3000
name: election
env:
- name: DATABASE_URL
valueFrom:
secretKeyRef:
name: election
key: DATABASE_URL
- name: ORIGIN
valueFrom:
secretKeyRef:
name: election
key: ORIGIN
- name: BETTER_AUTH_SECRET
valueFrom:
secretKeyRef:
name: election
key: BETTER_AUTH_SECRET
- name: GITHUB_CLIENT_SECRET
valueFrom:
secretKeyRef:
name: election
key: GITHUB_CLIENT_SECRET
- name: GITHUB_CLIENT_ID
valueFrom:
secretKeyRef:
name: election
key: GITHUB_CLIENT_ID
restartPolicy: Always
---

19
deploy/base/ingress.yaml Normal file
View File

@@ -0,0 +1,19 @@
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
name: election-ingress
namespace: vhsmp
spec:
entryPoints:
- websecure
- web
routes:
- match: Host(`election.milasholsting.dk`)
kind: Rule
services:
- name: election
port: 3000
tls:
secretName: election-tls

View File

@@ -0,0 +1,13 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: vhsmp
resources:
- ./deployment.yaml
- ./ingress.yaml
- ./cert.yaml
- ./service.yaml
- ./migration-job.yaml
- ./postgres-service.yaml
- ./postgres-storage.yaml
- ./postgres.yaml

View File

@@ -0,0 +1,35 @@
# https://kubernetes.io/docs/concepts/workloads/controllers/job/
apiVersion: batch/v1
kind: Job
metadata:
name: election-migration
annotations:
# 1. Tells Argo this is a hook to run during sync
argocd.argoproj.io/hook: Sync
# 2. Ensures the migration runs BEFORE the deployment
argocd.argoproj.io/sync-wave: "1"
# 3. Deletes the job after it succeeds so it can run again next time
argocd.argoproj.io/hook-delete-policy: BeforeHookCreation
labels:
app: election-migration
spec:
template:
metadata:
name: election-migration
labels:
app: election-migration
spec:
containers:
- name: election-migration
image: election-migration
env:
- name: DATABASE_URL
valueFrom:
secretKeyRef:
name: election
key: DATABASE_URL
restartPolicy: OnFailure
dnsPolicy: ClusterFirst

View File

@@ -0,0 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: postgres-service
spec:
selector:
app: postgres
ports:
- protocol: TCP
port: 5432
targetPort: 5432
type: ClusterIP

View File

@@ -0,0 +1,11 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: postgres-pvc
spec:
storageClassName: local-path
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi

33
deploy/base/postgres.yaml Normal file
View File

@@ -0,0 +1,33 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: postgres
spec:
replicas: 1
selector:
matchLabels:
app: postgres
template:
metadata:
labels:
app: postgres
spec:
containers:
- name: postgres
image: postgres:18
ports:
- containerPort: 5432
env:
- name: POSTGRES_DB
value: mydatabase
- name: POSTGRES_USER
value: user123
- name: POSTGRES_PASSWORD
value: password123 # In production, use a Secret!
volumeMounts:
- mountPath: /var/lib/postgresql
name: postgredb
volumes:
- name: postgredb
persistentVolumeClaim:
claimName: postgres-pvc

16
deploy/base/service.yaml Normal file
View File

@@ -0,0 +1,16 @@
# https://kubernetes.io/docs/concepts/services-networking/service/
apiVersion: v1
kind: Service
metadata:
name: election
namespace: vhsmp
spec:
selector:
app: election
type: ClusterIP
ports:
- name: election
protocol: TCP
port: 3000
targetPort: 3000

View File

@@ -0,0 +1,26 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: election # Must match the name in base/
spec:
replicas: 2 # Scale up for production
template:
spec:
containers:
- name: election # This name must match base EXACTLY
ports: # Adding this back into the patch solves the diff
- containerPort: 3000
name: election
# Production-specific resource limits
resources:
limits:
cpu: "1"
memory: "1Gi"
requests:
cpu: "500m"
memory: "512Mi"
# Adding a production-only environment variable
env:
- name: NODE_ENV
value: "production"

View File

@@ -0,0 +1,21 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
# 1. Point to the base manifests
resources:
- ../../base
# 2. Apply the production-specific changes
patches:
- path: deployment.yaml
target:
kind: Deployment
name: election
# 4. Change the namespace for this overlay
namespace: vhsmp
#images:
#- name: election
# newName: reg.milasholsting.dk/vhsmp/election
# newTag: sha-15f1270

View File

@@ -0,0 +1,26 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: election # Must match the name in base/
spec:
replicas: 2 # Scale up for production
template:
spec:
containers:
- name: election # This name must match base EXACTLY
ports: # Adding this back into the patch solves the diff
- containerPort: 3000
name: election
# Production-specific resource limits
resources:
limits:
cpu: "1"
memory: "1Gi"
requests:
cpu: "500m"
memory: "512Mi"
# Adding a production-only environment variable
env:
- name: NODE_ENV
value: "production"

View File

@@ -0,0 +1,24 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
# 1. Point to the base manifests
resources:
- ../../base
# 2. Apply the production-specific changes
patches:
- path: deployment.yaml
target:
kind: Deployment
name: election
# 4. Change the namespace for this overlay
namespace: vhsmp
images:
- name: election
newName: reg.milasholsting.dk/vhsmp/election
newTag: sha-6017ea9
- name: election-migration
newName: reg.milasholsting.dk/vhsmp/election-migrator
newTag: sha-6017ea9