From b0fb15fe7b9d0b3dd137f9c363a4d74ccc7daa8e Mon Sep 17 00:00:00 2001 From: Thomas Richter Date: Wed, 4 Feb 2026 23:28:55 +0100 Subject: [PATCH] feat: add Kubernetes deployment with ArgoCD - Add k8s/ manifests (Deployment, Service, Ingress) - Use Kustomize for configuration - ArgoCD application for GitOps deployment - Traefik ingress with Let's Encrypt TLS - Deploy script for CI/CD workflow Deploys to: https://whalehunting.kube2.tricnet.de Co-Authored-By: Claude Opus 4.5 --- deploy-k8s.sh | 48 +++++++++++++++++++++++++++++++++++++ k8s/argocd-application.yaml | 20 ++++++++++++++++ k8s/deployment.yaml | 45 ++++++++++++++++++++++++++++++++++ k8s/ingress.yaml | 26 ++++++++++++++++++++ k8s/kustomization.yaml | 17 +++++++++++++ k8s/namespace.yaml | 6 +++++ k8s/service.yaml | 16 +++++++++++++ 7 files changed, 178 insertions(+) create mode 100755 deploy-k8s.sh create mode 100644 k8s/argocd-application.yaml create mode 100644 k8s/deployment.yaml create mode 100644 k8s/ingress.yaml create mode 100644 k8s/kustomization.yaml create mode 100644 k8s/namespace.yaml create mode 100644 k8s/service.yaml diff --git a/deploy-k8s.sh b/deploy-k8s.sh new file mode 100755 index 0000000..a4afc2b --- /dev/null +++ b/deploy-k8s.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +# Deploy whalehunting to Kubernetes via ArgoCD +# Prerequisites: +# 1. Create repo in Gitea: git.kube2.tricnet.de/admin/whalehunting +# 2. Push this repo to Gitea +# 3. Run this script to create the ArgoCD application + +set -e + +GITEA_URL="git.kube2.tricnet.de" +REPO_NAME="whalehunting" +IMAGE_TAG="${1:-latest}" + +echo "=== Whalehunting Kubernetes Deployment ===" +echo "" + +# Step 1: Build and push Docker image to Gitea registry +echo "1. Building Docker image..." +docker build -t ${GITEA_URL}/admin/${REPO_NAME}:${IMAGE_TAG} . + +echo "" +echo "2. Pushing image to Gitea registry..." +echo " (You may need to: docker login ${GITEA_URL})" +docker push ${GITEA_URL}/admin/${REPO_NAME}:${IMAGE_TAG} + +echo "" +echo "3. Updating image tag in kustomization.yaml..." +sed -i "s/newTag: .*/newTag: ${IMAGE_TAG}/" k8s/kustomization.yaml + +echo "" +echo "4. Committing and pushing to Gitea..." +git add -A +git commit -m "deploy: update image to ${IMAGE_TAG}" || echo "No changes to commit" +git push origin master + +echo "" +echo "5. Creating/updating ArgoCD application..." +ssh root@kube2.tricnet.de "kubectl apply -f -" < k8s/argocd-application.yaml + +echo "" +echo "=== Deployment initiated ===" +echo "ArgoCD will sync automatically." +echo "" +echo "Check status:" +echo " ssh root@kube2.tricnet.de 'kubectl get application whalehunting -n argocd'" +echo "" +echo "Game URL: https://whalehunting.kube2.tricnet.de" diff --git a/k8s/argocd-application.yaml b/k8s/argocd-application.yaml new file mode 100644 index 0000000..1bc2899 --- /dev/null +++ b/k8s/argocd-application.yaml @@ -0,0 +1,20 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: whalehunting + namespace: argocd +spec: + project: default + source: + repoURL: http://gitea-http.gitea.svc.cluster.local:3000/admin/whalehunting.git + targetRevision: HEAD + path: k8s + destination: + server: https://kubernetes.default.svc + namespace: whalehunting + syncPolicy: + automated: + prune: true + selfHeal: true + syncOptions: + - CreateNamespace=true diff --git a/k8s/deployment.yaml b/k8s/deployment.yaml new file mode 100644 index 0000000..ec18b10 --- /dev/null +++ b/k8s/deployment.yaml @@ -0,0 +1,45 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: whalehunting + namespace: whalehunting + labels: + app.kubernetes.io/name: whalehunting + app.kubernetes.io/component: web +spec: + replicas: 2 + selector: + matchLabels: + app.kubernetes.io/name: whalehunting + template: + metadata: + labels: + app.kubernetes.io/name: whalehunting + app.kubernetes.io/component: web + spec: + containers: + - name: whalehunting + image: git.kube2.tricnet.de/admin/whalehunting:latest + ports: + - name: http + containerPort: 80 + protocol: TCP + livenessProbe: + httpGet: + path: / + port: http + initialDelaySeconds: 5 + periodSeconds: 10 + readinessProbe: + httpGet: + path: / + port: http + initialDelaySeconds: 5 + periodSeconds: 10 + resources: + limits: + cpu: 100m + memory: 128Mi + requests: + cpu: 50m + memory: 64Mi diff --git a/k8s/ingress.yaml b/k8s/ingress.yaml new file mode 100644 index 0000000..4938003 --- /dev/null +++ b/k8s/ingress.yaml @@ -0,0 +1,26 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: whalehunting + namespace: whalehunting + annotations: + cert-manager.io/cluster-issuer: letsencrypt-prod + labels: + app.kubernetes.io/name: whalehunting +spec: + ingressClassName: traefik + rules: + - host: whalehunting.kube2.tricnet.de + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: whalehunting + port: + name: http + tls: + - hosts: + - whalehunting.kube2.tricnet.de + secretName: whalehunting-tls diff --git a/k8s/kustomization.yaml b/k8s/kustomization.yaml new file mode 100644 index 0000000..ebf44b5 --- /dev/null +++ b/k8s/kustomization.yaml @@ -0,0 +1,17 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +namespace: whalehunting + +resources: + - namespace.yaml + - deployment.yaml + - service.yaml + - ingress.yaml + +commonLabels: + app.kubernetes.io/managed-by: argocd + +images: + - name: git.kube2.tricnet.de/admin/whalehunting + newTag: latest diff --git a/k8s/namespace.yaml b/k8s/namespace.yaml new file mode 100644 index 0000000..dcab642 --- /dev/null +++ b/k8s/namespace.yaml @@ -0,0 +1,6 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: whalehunting + labels: + app.kubernetes.io/name: whalehunting diff --git a/k8s/service.yaml b/k8s/service.yaml new file mode 100644 index 0000000..e315d2a --- /dev/null +++ b/k8s/service.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: Service +metadata: + name: whalehunting + namespace: whalehunting + labels: + app.kubernetes.io/name: whalehunting +spec: + type: ClusterIP + ports: + - port: 80 + targetPort: http + protocol: TCP + name: http + selector: + app.kubernetes.io/name: whalehunting