aprs.me/k8s/app-deployment.yaml
google-labs-jules[bot] 1badb192b5 feat: Implement K3s deployment with GitHub Actions CI/CD
This commit introduces a complete setup for deploying the Phoenix application
to a K3s Kubernetes cluster, along with a GitHub Actions workflow for
automated builds and deployments.

Key changes include:

- **Kubernetes Manifests (`k8s/`)**:
    - Namespace (`aprs-app`) for isolating application resources.
    - PostgreSQL setup: PersistentVolumeClaim, Deployment, and Service.
    - Application setup: Deployment (with init container for migrations) and
      Service (NodePort).
    - An example secrets file (`k8s/secrets.yaml.example`) for configuration.
    - `.gitignore` updated to exclude `k8s/secrets.yaml`.

- **GitHub Actions Workflow (`.github/workflows/deploy-k3s.yaml`)**:
    - Builds the Docker image on pushes to the main branch.
    - Pushes the image to GitHub Container Registry (GHCR).
    - Deploys the application to K3s by applying the manifests.
    - Dynamically updates the application deployment with the correct image tag.
    - Requires `KUBE_CONFIG_DATA` GitHub secret for K3s authentication.

- **Application Configuration (`config/runtime.exs`)**:
    - Commented out `libcluster` configuration specific to Fly.io to prevent
      issues in a standard K3s environment.

- **Documentation (`README.md`)**:
    - Added a new "Kubernetes (K3s) Deployment" section detailing:
        - Prerequisites and initial setup (GitHub & K8s secrets).
        - Workflow overview.
        - Application configuration notes (health checks, migrations).
        - Instructions for accessing the application.

This setup provides a robust foundation for CI/CD and running the
application in a self-hosted K3s environment.
2025-06-13 18:18:34 +00:00

53 lines
1.7 KiB
YAML

apiVersion: apps/v1
kind: Deployment
metadata:
name: aprs-app-deployment
namespace: aprs-app
labels:
app: aprs-app
spec:
replicas: 1 # Start with 1, can be scaled later
selector:
matchLabels:
app: aprs-app
template:
metadata:
labels:
app: aprs-app
spec:
initContainers:
- name: db-migrate
image: your-ghcr-username/aprs-app:latest # Placeholder, will be set by CI
command: ["/app/bin/migrate"]
envFrom:
- secretRef:
name: aprs-secrets
containers:
- name: aprs-app
image: your-ghcr-username/aprs-app:latest # Placeholder, will be set by CI
ports:
- containerPort: 4000 # Default Phoenix port
envFrom:
- secretRef:
name: aprs-secrets
env: # Add non-secret env vars here if any
- name: PHX_SERVER
value: "true"
- name: PORT
value: "4000"
# The PHX_HOST is in secrets.yaml.example, it can be moved here if not sensitive
readinessProbe:
httpGet:
path: /health # Assuming you'll add a health check endpoint
port: 4000
initialDelaySeconds: 20
periodSeconds: 10
livenessProbe:
httpGet:
path: /health # Assuming you'll add a health check endpoint
port: 4000
initialDelaySeconds: 30
periodSeconds: 15
# Note: For the health endpoint, you might need to create a simple one in your Phoenix router
# e.g., scope "/", AprsWeb do; get "/health", PageController, :health; end
# and a `def health(conn, _params), do: json(conn, %{status: "ok"})` in PageController.