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.
15 lines
606 B
Text
15 lines
606 B
Text
apiVersion: v1
|
|
kind: Secret
|
|
metadata:
|
|
name: aprs-secrets
|
|
namespace: aprs-app
|
|
type: Opaque
|
|
stringData: # Using stringData for readability, actual secrets should be base64 encoded if using `data`
|
|
DATABASE_URL: "ecto://postgres-service.aprs-app.svc.cluster.local/aprs_prod" # User/pass removed
|
|
POSTGRES_USER: "your_db_user"
|
|
POSTGRES_PASSWORD: "your_db_password"
|
|
SECRET_KEY_BASE: "your_super_secret_key_base_here"
|
|
# Add other secrets like APRS_CALLSIGN, APRS_PASSCODE if needed
|
|
APRS_CALLSIGN: "NOCALL"
|
|
APRS_PASSCODE: "NOPASS"
|
|
PHX_HOST: "your_app_domain.com" # Replace with your actual host
|