This commit is contained in:
Jun-te Kim 2025-12-06 20:47:50 +00:00
parent 5da5b9a35b
commit 58104a9706

View file

@ -6,7 +6,8 @@ on:
jobs: jobs:
bootstrap: bootstrap:
runs-on: mealcraft-runners runs-on: mealcraft-runners
container: ubuntu:22.04 container:
image: ubuntu:22.04
steps: steps:
# ----------------------------------------------------- # -----------------------------------------------------
@ -25,7 +26,7 @@ jobs:
install -m 0755 kubectl /usr/local/bin/kubectl install -m 0755 kubectl /usr/local/bin/kubectl
# ----------------------------------------------------- # -----------------------------------------------------
# Configure kubeconfig using the ARC pod token # Configure kubeconfig using ARC pod token
# ----------------------------------------------------- # -----------------------------------------------------
- name: Configure kubeconfig - name: Configure kubeconfig
run: | run: |
@ -40,29 +41,33 @@ jobs:
kubectl config use-context runner-context kubectl config use-context runner-context
# ----------------------------------------------------- # -----------------------------------------------------
# Docker Login # Build & Push Docker image (ARC-safe, no Docker daemon)
# ----------------------------------------------------- # -----------------------------------------------------
- name: Docker Login
uses: ./.github/actions/docker-login - name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx (rootless)
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with: with:
username: ${{ secrets.DOCKER_HUB_USERNAME }} username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }} password: ${{ secrets.DOCKER_HUB_TOKEN }}
# ----------------------------------------------------- - name: Build & Push Traefik Image
# Build & Push the Docker Image (idempotent) uses: docker/build-push-action@v5
# ----------------------------------------------------- with:
- name: Build Traefik Image context: ./traefik
run: | file: traefik/Dockerfile
docker build traefik \ push: true
--file traefik/Dockerfile \ tags: |
--tag docker.io/kimjunte/edge_router:$GITHUB_SHA docker.io/kimjunte/edge_router:${{ github.sha }}
docker.io/kimjunte/edge_router:latest
- name: Push Traefik Image
run: |
docker push docker.io/kimjunte/edge_router:$GITHUB_SHA
# ----------------------------------------------------- # -----------------------------------------------------
# Apply Storage Classes + PVCs — idempotent with apply # Apply Storage Classes + PVCs
# ----------------------------------------------------- # -----------------------------------------------------
- name: Apply StorageClass + PV - name: Apply StorageClass + PV
run: | run: |
@ -71,25 +76,24 @@ jobs:
kubectl get storageclass kubectl get storageclass
# ----------------------------------------------------- # -----------------------------------------------------
# Apply Traefik CRDs only if missing # Install Traefik CRDs (idempotent)
# ----------------------------------------------------- # -----------------------------------------------------
- name: Install Traefik CRDs (idempotent) - name: Install Traefik CRDs
run: | run: |
if ! kubectl get crd ingressroutes.traefik.containo.us >/dev/null 2>&1; then if ! kubectl get crd ingressroutes.traefik.containo.us >/dev/null 2>&1; then
echo "Traefik CRDs not found — installing..." echo "Installing Traefik CRDs..."
kubectl apply -f https://raw.githubusercontent.com/traefik/traefik/v2.10/docs/content/reference/dynamic-configuration/kubernetes-crd-definition-v1.yml kubectl apply -f https://raw.githubusercontent.com/traefik/traefik/v2.10/docs/content/reference/dynamic-configuration/kubernetes-crd-definition-v1.yml
kubectl apply -f https://raw.githubusercontent.com/traefik/traefik/v2.10/docs/content/reference/dynamic-configuration/kubernetes-crd-rbac.yml kubectl apply -f https://raw.githubusercontent.com/traefik/traefik/v2.10/docs/content/reference/dynamic-configuration/kubernetes-crd-rbac.yml
kubectl apply -f https://raw.githubusercontent.com/traefik/traefik/v2.10/docs/content/user-guides/crd-acme/05-tlsoption.yml kubectl apply -f https://raw.githubusercontent.com/traefik/traefik/v2.10/docs/content/user-guides/crd-acme/05-tlsoption.yml
else else
echo "Traefik CRDs already installed — skipping." echo "CRDs already exist — skipping."
fi fi
# ----------------------------------------------------- # -----------------------------------------------------
# Deploy Traefik — idempotent with kubectl apply # Deploy Traefik
# ----------------------------------------------------- # -----------------------------------------------------
- name: Deploy Traefik (safe repeat) - name: Deploy Traefik
run: | run: |
echo "Applying Traefik PVC/Deployments/Services/etc…"
kubectl apply -f traefik/edge-router/pvc.yaml kubectl apply -f traefik/edge-router/pvc.yaml
kubectl apply -f traefik/edge-router/traefik-deployment.yml kubectl apply -f traefik/edge-router/traefik-deployment.yml
kubectl apply -f traefik/edge-router/traefik-services.yml kubectl apply -f traefik/edge-router/traefik-services.yml
@ -98,7 +102,7 @@ jobs:
kubectl apply -f traefik/edge-router/traefik-ingressroute.yml kubectl apply -f traefik/edge-router/traefik-ingressroute.yml
# ----------------------------------------------------- # -----------------------------------------------------
# Deploy whoami — idempotent # Deploy whoami
# ----------------------------------------------------- # -----------------------------------------------------
- name: Deploy whoami test service - name: Deploy whoami test service
run: | run: |
@ -107,21 +111,21 @@ jobs:
kubectl apply -f traefik/who-am-i/whoami-ingressroute.yml kubectl apply -f traefik/who-am-i/whoami-ingressroute.yml
# ----------------------------------------------------- # -----------------------------------------------------
# Create Docker Registry Secrets — idempotent # Create registry secret
# ----------------------------------------------------- # -----------------------------------------------------
- name: Create registry secret (default ns) - name: Create registry secret (default ns)
run: | run: |
kubectl apply -f traefik/docker-registry-credentials/docker-credentials.yml kubectl apply -f traefik/docker-registry-credentials/docker-credentials.yml
# ----------------------------------------------------- # -----------------------------------------------------
# Create staging namespace if not exists # Create staging namespace
# ----------------------------------------------------- # -----------------------------------------------------
- name: Create staging namespace - name: Create staging namespace
run: | run: |
kubectl get namespace staging >/dev/null 2>&1 || kubectl create namespace staging kubectl get namespace staging >/dev/null 2>&1 || kubectl create namespace staging
# ----------------------------------------------------- # -----------------------------------------------------
# Apply registry secret to staging — idempotent # Apply registry secret to staging
# ----------------------------------------------------- # -----------------------------------------------------
- name: Registry secret in staging namespace - name: Registry secret in staging namespace
run: | run: |