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 <noreply@anthropic.com>
This commit is contained in:
48
deploy-k8s.sh
Executable file
48
deploy-k8s.sh
Executable file
@@ -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"
|
||||
20
k8s/argocd-application.yaml
Normal file
20
k8s/argocd-application.yaml
Normal file
@@ -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
|
||||
45
k8s/deployment.yaml
Normal file
45
k8s/deployment.yaml
Normal file
@@ -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
|
||||
26
k8s/ingress.yaml
Normal file
26
k8s/ingress.yaml
Normal file
@@ -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
|
||||
17
k8s/kustomization.yaml
Normal file
17
k8s/kustomization.yaml
Normal file
@@ -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
|
||||
6
k8s/namespace.yaml
Normal file
6
k8s/namespace.yaml
Normal file
@@ -0,0 +1,6 @@
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: whalehunting
|
||||
labels:
|
||||
app.kubernetes.io/name: whalehunting
|
||||
16
k8s/service.yaml
Normal file
16
k8s/service.yaml
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user