diff options
Diffstat (limited to 'gemfeed')
| -rw-r--r-- | gemfeed/2025-10-02-f3s-kubernetes-with-freebsd-part-7.gmi | 34 | ||||
| -rw-r--r-- | gemfeed/2025-10-02-f3s-kubernetes-with-freebsd-part-7.gmi.tpl | 33 | ||||
| -rw-r--r-- | gemfeed/2025-12-07-f3s-kubernetes-with-freebsd-part-8.gmi | 34 | ||||
| -rw-r--r-- | gemfeed/2025-12-07-f3s-kubernetes-with-freebsd-part-8.gmi.tpl | 33 | ||||
| -rw-r--r-- | gemfeed/DRAFT-f3s-kubernetes-with-freebsd-part-X.gmi | 1116 | ||||
| -rw-r--r-- | gemfeed/DRAFT-f3s-kubernetes-with-freebsd-part-X.gmi.tpl | 85 | ||||
| -rw-r--r-- | gemfeed/atom.xml | 82 |
7 files changed, 1326 insertions, 91 deletions
diff --git a/gemfeed/2025-10-02-f3s-kubernetes-with-freebsd-part-7.gmi b/gemfeed/2025-10-02-f3s-kubernetes-with-freebsd-part-7.gmi index aa3e071b..a413c609 100644 --- a/gemfeed/2025-10-02-f3s-kubernetes-with-freebsd-part-7.gmi +++ b/gemfeed/2025-10-02-f3s-kubernetes-with-freebsd-part-7.gmi @@ -19,6 +19,7 @@ This is the seventh blog post about the f3s series for my self-hosting demands i * ⇢ f3s: Kubernetes with FreeBSD - Part 7: k3s and first pod deployments * ⇢ ⇢ Introduction +* ⇢ ⇢ Important Note: GitOps Migration * ⇢ ⇢ Updating * ⇢ ⇢ Installing k3s * ⇢ ⇢ ⇢ Generating `K3S_TOKEN` and starting the first k3s node @@ -49,6 +50,26 @@ In this blog post, I am finally going to install k3s (the Kubernetes distributio => https://k3s.io +## Important Note: GitOps Migration + +**Note:** After publishing this blog post, the f3s cluster was migrated from imperative Helm deployments to declarative GitOps using ArgoCD. The Kubernetes manifests and Helm charts in the repository have been reorganized for ArgoCD-based continuous deployment. + +**To view the exact manifests and charts as they existed when this blog post was written** (before the ArgoCD migration), check out the pre-ArgoCD revision: + +```sh +$ git clone https://codeberg.org/snonux/conf.git +$ cd conf +$ git checkout 15a86f3 # Last commit before ArgoCD migration +$ cd f3s/ +``` + +**Current master branch** contains the ArgoCD-managed versions with: +- Application manifests organized under `argocd-apps/{monitoring,services,infra,test}/` +- Additional resources under `*/manifests/` directories (e.g., `prometheus/manifests/`) +- Justfiles updated to trigger ArgoCD syncs instead of direct Helm commands + +The deployment concepts and architecture remain the same—only the deployment method changed from imperative (`helm install/upgrade`) to declarative (GitOps with ArgoCD). For details on the GitOps migration, see Part X of this series. + ## Updating Before proceeding, I bring all systems involved up-to-date. On all three Rocky Linux 9 boxes `r0`, `r1`, and `r2`: @@ -800,18 +821,7 @@ All manifests for the f3s stack live in my configuration repository: => https://codeberg.org/snonux/conf/src/branch/master/f3s codeberg.org/snonux/conf/f3s -**Note:** After publishing this blog post, the f3s cluster was migrated to ArgoCD GitOps. The Kubernetes manifests and Helm charts in the repository have been reorganized for declarative deployment. To view the exact manifests and charts as they existed when this blog post was written (before ArgoCD migration), check out the pre-ArgoCD revision: - -```sh -$ git clone https://codeberg.org/snonux/conf.git -$ cd conf -$ git checkout 15a86f3 # Last commit before ArgoCD migration -$ cd f3s/ -``` - -The current master branch contains the ArgoCD-managed versions with manifests organized under `argocd-apps/` and `*/manifests/` directories. - -Within that repo, the `examples/conf/f3s/registry/` directory contains the Helm chart, a `Justfile`, and a detailed `README`. Here's the condensed walkthrough I used to roll out the registry with Helm. +Within that repo, the `f3s/registry/` directory contains the Helm chart, a `Justfile`, and a detailed `README`. Here's the condensed walkthrough I used to roll out the registry with Helm. ### Prepare the NFS-backed storage diff --git a/gemfeed/2025-10-02-f3s-kubernetes-with-freebsd-part-7.gmi.tpl b/gemfeed/2025-10-02-f3s-kubernetes-with-freebsd-part-7.gmi.tpl index bb5dab4e..6e3fd42b 100644 --- a/gemfeed/2025-10-02-f3s-kubernetes-with-freebsd-part-7.gmi.tpl +++ b/gemfeed/2025-10-02-f3s-kubernetes-with-freebsd-part-7.gmi.tpl @@ -16,6 +16,26 @@ In this blog post, I am finally going to install k3s (the Kubernetes distributio => https://k3s.io +## Important Note: GitOps Migration + +**Note:** After publishing this blog post, the f3s cluster was migrated from imperative Helm deployments to declarative GitOps using ArgoCD. The Kubernetes manifests and Helm charts in the repository have been reorganized for ArgoCD-based continuous deployment. + +**To view the exact manifests and charts as they existed when this blog post was written** (before the ArgoCD migration), check out the pre-ArgoCD revision: + +```sh +$ git clone https://codeberg.org/snonux/conf.git +$ cd conf +$ git checkout 15a86f3 # Last commit before ArgoCD migration +$ cd f3s/ +``` + +**Current master branch** contains the ArgoCD-managed versions with: +- Application manifests organized under `argocd-apps/{monitoring,services,infra,test}/` +- Additional resources under `*/manifests/` directories (e.g., `prometheus/manifests/`) +- Justfiles updated to trigger ArgoCD syncs instead of direct Helm commands + +The deployment concepts and architecture remain the same—only the deployment method changed from imperative (`helm install/upgrade`) to declarative (GitOps with ArgoCD). For details on the GitOps migration, see Part X of this series. + ## Updating Before proceeding, I bring all systems involved up-to-date. On all three Rocky Linux 9 boxes `r0`, `r1`, and `r2`: @@ -767,18 +787,7 @@ All manifests for the f3s stack live in my configuration repository: => https://codeberg.org/snonux/conf/src/branch/master/f3s codeberg.org/snonux/conf/f3s -**Note:** After publishing this blog post, the f3s cluster was migrated to ArgoCD GitOps. The Kubernetes manifests and Helm charts in the repository have been reorganized for declarative deployment. To view the exact manifests and charts as they existed when this blog post was written (before ArgoCD migration), check out the pre-ArgoCD revision: - -```sh -$ git clone https://codeberg.org/snonux/conf.git -$ cd conf -$ git checkout 15a86f3 # Last commit before ArgoCD migration -$ cd f3s/ -``` - -The current master branch contains the ArgoCD-managed versions with manifests organized under `argocd-apps/` and `*/manifests/` directories. - -Within that repo, the `examples/conf/f3s/registry/` directory contains the Helm chart, a `Justfile`, and a detailed `README`. Here's the condensed walkthrough I used to roll out the registry with Helm. +Within that repo, the `f3s/registry/` directory contains the Helm chart, a `Justfile`, and a detailed `README`. Here's the condensed walkthrough I used to roll out the registry with Helm. ### Prepare the NFS-backed storage diff --git a/gemfeed/2025-12-07-f3s-kubernetes-with-freebsd-part-8.gmi b/gemfeed/2025-12-07-f3s-kubernetes-with-freebsd-part-8.gmi index e82055c6..d8460dea 100644 --- a/gemfeed/2025-12-07-f3s-kubernetes-with-freebsd-part-8.gmi +++ b/gemfeed/2025-12-07-f3s-kubernetes-with-freebsd-part-8.gmi @@ -19,6 +19,7 @@ This is the 8th blog post about the f3s series for my self-hosting demands in a * ⇢ f3s: Kubernetes with FreeBSD - Part 8: Observability * ⇢ ⇢ Introduction +* ⇢ ⇢ Important Note: GitOps Migration * ⇢ ⇢ Persistent storage recap * ⇢ ⇢ The monitoring namespace * ⇢ ⇢ Installing Prometheus and Grafana @@ -59,7 +60,27 @@ Together, these form the "PLG" stack (Prometheus, Loki, Grafana), which is a pop All manifests for the f3s stack live in my configuration repository: -=> https://codeberg.org/snonux/conf/src/branch/master/f3s codeberg.org/snonux/conf/f3s +=> https://codeberg.org/snonux/conf/src/branch/master/f3s codeberg.org/snonux/conf/f3s + +## Important Note: GitOps Migration + +**Note:** After publishing this blog post, the f3s cluster was migrated from imperative Helm deployments to declarative GitOps using ArgoCD. The Kubernetes manifests, Helm charts, and Justfiles in the repository have been reorganized for ArgoCD-based continuous deployment. + +**To view the exact configuration as it existed when this blog post was written** (before the ArgoCD migration), check out the pre-ArgoCD revision: + +```sh +$ git clone https://codeberg.org/snonux/conf.git +$ cd conf +$ git checkout 15a86f3 # Last commit before ArgoCD migration +$ cd f3s/prometheus/ +``` + +**Current master branch** contains the ArgoCD-managed versions with: +- Application manifests organized under `argocd-apps/{monitoring,services,infra,test}/` +- Resources organized under `prometheus/manifests/`, `loki/`, etc. +- Justfiles updated to trigger ArgoCD syncs instead of direct Helm commands + +The deployment concepts and architecture remain the same—only the deployment method changed from imperative (`helm install/upgrade`) to declarative (GitOps with ArgoCD). For details on the GitOps migration, see Part X of this series. ## Persistent storage recap @@ -88,17 +109,6 @@ namespace/monitoring created ## Installing Prometheus and Grafana -**Note:** After publishing this blog post, the f3s cluster was migrated to ArgoCD GitOps. The Kubernetes manifests, Helm charts, and Justfiles in the repository have been reorganized for declarative deployment. To view the exact configuration as it existed when this blog post was written (before ArgoCD migration), check out the pre-ArgoCD revision: - -```sh -$ git clone https://codeberg.org/snonux/conf.git -$ cd conf -$ git checkout 15a86f3 # Last commit before ArgoCD migration -$ cd f3s/prometheus/ -``` - -The current master branch contains the ArgoCD-managed versions with Application manifests under `argocd-apps/` and resources organized under `prometheus/manifests/`, `loki/`, etc. The Justfiles have been updated to trigger ArgoCD syncs instead of direct Helm commands. - Prometheus and Grafana are deployed together using the `kube-prometheus-stack` Helm chart from the Prometheus community. This chart bundles Prometheus, Grafana, Alertmanager, and various exporters (Node Exporter, Kube State Metrics) into a single deployment. Ill explain what each component does in detail later when we look at the running pods. ### Prerequisites diff --git a/gemfeed/2025-12-07-f3s-kubernetes-with-freebsd-part-8.gmi.tpl b/gemfeed/2025-12-07-f3s-kubernetes-with-freebsd-part-8.gmi.tpl index 1b9bd6bc..75bb892d 100644 --- a/gemfeed/2025-12-07-f3s-kubernetes-with-freebsd-part-8.gmi.tpl +++ b/gemfeed/2025-12-07-f3s-kubernetes-with-freebsd-part-8.gmi.tpl @@ -23,7 +23,27 @@ Together, these form the "PLG" stack (Prometheus, Loki, Grafana), which is a pop All manifests for the f3s stack live in my configuration repository: -=> https://codeberg.org/snonux/conf/src/branch/master/f3s codeberg.org/snonux/conf/f3s +=> https://codeberg.org/snonux/conf/src/branch/master/f3s codeberg.org/snonux/conf/f3s + +## Important Note: GitOps Migration + +**Note:** After publishing this blog post, the f3s cluster was migrated from imperative Helm deployments to declarative GitOps using ArgoCD. The Kubernetes manifests, Helm charts, and Justfiles in the repository have been reorganized for ArgoCD-based continuous deployment. + +**To view the exact configuration as it existed when this blog post was written** (before the ArgoCD migration), check out the pre-ArgoCD revision: + +```sh +$ git clone https://codeberg.org/snonux/conf.git +$ cd conf +$ git checkout 15a86f3 # Last commit before ArgoCD migration +$ cd f3s/prometheus/ +``` + +**Current master branch** contains the ArgoCD-managed versions with: +- Application manifests organized under `argocd-apps/{monitoring,services,infra,test}/` +- Resources organized under `prometheus/manifests/`, `loki/`, etc. +- Justfiles updated to trigger ArgoCD syncs instead of direct Helm commands + +The deployment concepts and architecture remain the same—only the deployment method changed from imperative (`helm install/upgrade`) to declarative (GitOps with ArgoCD). For details on the GitOps migration, see Part X of this series. ## Persistent storage recap @@ -52,17 +72,6 @@ namespace/monitoring created ## Installing Prometheus and Grafana -**Note:** After publishing this blog post, the f3s cluster was migrated to ArgoCD GitOps. The Kubernetes manifests, Helm charts, and Justfiles in the repository have been reorganized for declarative deployment. To view the exact configuration as it existed when this blog post was written (before ArgoCD migration), check out the pre-ArgoCD revision: - -```sh -$ git clone https://codeberg.org/snonux/conf.git -$ cd conf -$ git checkout 15a86f3 # Last commit before ArgoCD migration -$ cd f3s/prometheus/ -``` - -The current master branch contains the ArgoCD-managed versions with Application manifests under `argocd-apps/` and resources organized under `prometheus/manifests/`, `loki/`, etc. The Justfiles have been updated to trigger ArgoCD syncs instead of direct Helm commands. - Prometheus and Grafana are deployed together using the `kube-prometheus-stack` Helm chart from the Prometheus community. This chart bundles Prometheus, Grafana, Alertmanager, and various exporters (Node Exporter, Kube State Metrics) into a single deployment. Ill explain what each component does in detail later when we look at the running pods. ### Prerequisites diff --git a/gemfeed/DRAFT-f3s-kubernetes-with-freebsd-part-X.gmi b/gemfeed/DRAFT-f3s-kubernetes-with-freebsd-part-X.gmi new file mode 100644 index 00000000..0d6aff7e --- /dev/null +++ b/gemfeed/DRAFT-f3s-kubernetes-with-freebsd-part-X.gmi @@ -0,0 +1,1116 @@ +# f3s: Kubernetes with FreeBSD - Part X: GitOps with ArgoCD + +> DRAFT - Not yet published + +This is part X of the f3s series for my self-hosting demands in a home lab. f3s? The "f" stands for FreeBSD, and the "3s" stands for k3s, the Kubernetes distribution I use on FreeBSD-based physical machines. + +=> ./2024-11-17-f3s-kubernetes-with-freebsd-part-1.gmi 2024-11-17 f3s: Kubernetes with FreeBSD - Part 1: Setting the stage +=> ./2024-12-03-f3s-kubernetes-with-freebsd-part-2.gmi 2024-12-03 f3s: Kubernetes with FreeBSD - Part 2: Hardware and base installation +=> ./2025-02-01-f3s-kubernetes-with-freebsd-part-3.gmi 2025-02-01 f3s: Kubernetes with FreeBSD - Part 3: Protecting from power cuts +=> ./2025-04-05-f3s-kubernetes-with-freebsd-part-4.gmi 2025-04-05 f3s: Kubernetes with FreeBSD - Part 4: Rocky Linux Bhyve VMs +=> ./2025-05-11-f3s-kubernetes-with-freebsd-part-5.gmi 2025-05-11 f3s: Kubernetes with FreeBSD - Part 5: WireGuard mesh network +=> ./2025-07-14-f3s-kubernetes-with-freebsd-part-6.gmi 2025-07-14 f3s: Kubernetes with FreeBSD - Part 6: Storage +=> ./2025-10-02-f3s-kubernetes-with-freebsd-part-7.gmi 2025-10-02 f3s: Kubernetes with FreeBSD - Part 7: k3s and first pod deployments +=> ./2025-12-07-f3s-kubernetes-with-freebsd-part-8.gmi 2025-12-07 f3s: Kubernetes with FreeBSD - Part 8: Observability + +=> ./f3s-kubernetes-with-freebsd-part-1/f3slogo.png f3s logo + +## Table of Contents + +* ⇢ f3s: Kubernetes with FreeBSD - Part X: GitOps with ArgoCD +* ⇢ ⇢ Introduction +* ⇢ ⇢ What is GitOps? +* ⇢ ⇢ What is ArgoCD? +* ⇢ ⇢ Why ArgoCD for f3s? +* ⇢ ⇢ Deploying ArgoCD +* ⇢ ⇢ ⇢ Prerequisites +* ⇢ ⇢ ⇢ Installing ArgoCD +* ⇢ ⇢ ⇢ Accessing ArgoCD +* ⇢ ⇢ ArgoCD Application Structure +* ⇢ ⇢ Repository Organization +* ⇢ ⇢ Migration Strategy: Incremental, One App at a Time +* ⇢ ⇢ ⇢ Migration Phases +* ⇢ ⇢ Example Migration: Miniflux +* ⇢ ⇢ ⇢ Before: Imperative Helm deployment +* ⇢ ⇢ ⇢ After: Declarative GitOps with ArgoCD +* ⇢ ⇢ ⇢ Migration procedure +* ⇢ ⇢ Complex Migration: Prometheus with Multi-Source +* ⇢ ⇢ ⇢ Sync Waves and Hooks +* ⇢ ⇢ Migration Results +* ⇢ ⇢ Benefits Realized +* ⇢ ⇢ ⇢ 1. Single Source of Truth +* ⇢ ⇢ ⇢ 2. Automatic Synchronization +* ⇢ ⇢ ⇢ 3. Drift Detection and Self-Healing +* ⇢ ⇢ ⇢ 4. Easy Rollbacks +* ⇢ ⇢ ⇢ 5. Disaster Recovery +* ⇢ ⇢ ⇢ 6. Documentation by Default +* ⇢ ⇢ ⇢ 7. Safe Experimentation +* ⇢ ⇢ Challenges and Solutions +* ⇢ ⇢ ⇢ Challenge 1: Helm Release Adoption +* ⇢ ⇢ ⇢ Challenge 2: Persistent Volumes Not Tracked by Helm +* ⇢ ⇢ ⇢ Challenge 3: Secrets Management +* ⇢ ⇢ ⇢ Challenge 4: Grafana Not Reloading Datasources +* ⇢ ⇢ ⇢ Challenge 5: Prometheus With Multiple Sources +* ⇢ ⇢ ⇢ Challenge 6: Sync Ordering for Prometheus +* ⇢ ⇢ Justfile Evolution +* ⇢ ⇢ Lessons Learned +* ⇢ ⇢ Future Improvements +* ⇢ ⇢ ⇢ 1. External Secrets Operator +* ⇢ ⇢ ⇢ 2. ApplicationSet for Similar Apps +* ⇢ ⇢ ⇢ 3. App-of-Apps Pattern +* ⇢ ⇢ ⇢ 4. ArgoCD Image Updater +* ⇢ ⇢ Summary + +## Introduction + +In the previous posts, I deployed applications to the k3s cluster using Helm charts and Justfiles—running `just install` or `just upgrade` to imperatively push changes to the cluster. While this approach works, it has several drawbacks: + +* **No single source of truth**: The cluster state depends on which commands were run and when +* **Manual synchronization**: Every change requires manually running commands +* **Drift detection is hard**: No easy way to know if cluster state matches the desired configuration +* **Rollback complexity**: Rolling back changes means re-running old Helm commands +* **No audit trail**: Hard to track who changed what and when + +This blog post covers the migration from imperative Helm deployments to declarative GitOps using ArgoCD. After this migration, the Git repository becomes the single source of truth, and ArgoCD automatically ensures the cluster matches what's defined in Git. + +## What is GitOps? + +GitOps is an operational framework that applies DevOps best practices—like version control, collaboration, and CI/CD—to infrastructure automation. The core idea is simple: the entire desired state of your infrastructure is stored in Git, and automated processes ensure the actual state matches the desired state. + +Key principles: + +* **Declarative**: The system's desired state is described declaratively (YAML manifests, Helm values) +* **Versioned and immutable**: All changes are committed to Git, providing a complete history +* **Pulled automatically**: An agent in the cluster continuously pulls the desired state from Git +* **Continuously reconciled**: The agent ensures the actual state matches the desired state, automatically correcting drift + +For Kubernetes, this means: + +1. All manifests, Helm charts, and configuration live in a Git repository +2. A tool (ArgoCD in our case) watches the repository +3. When changes are pushed to Git, ArgoCD automatically applies them to the cluster +4. If someone manually changes resources in the cluster, ArgoCD detects the drift and can automatically revert it + +## What is ArgoCD? + +ArgoCD is a declarative, GitOps continuous delivery tool for Kubernetes. It's implemented as a Kubernetes controller that continuously monitors running applications and compares the current, live state against the desired target state defined in Git. + +=> https://argo-cd.readthedocs.io ArgoCD Documentation + +Key features: + +* **Automated deployment**: Monitors Git repositories and automatically syncs changes to the cluster +* **Application definitions**: Defines applications as CRDs (Custom Resource Definitions) +* **Health assessment**: Understands Kubernetes resources and can determine if an application is healthy +* **Web UI and CLI**: Provides both a web interface and command-line tool for managing applications +* **RBAC**: Role-based access control for team collaboration +* **SSO integration**: Can integrate with existing authentication systems +* **Multi-cluster support**: Can manage applications across multiple Kubernetes clusters +* **Sync waves and hooks**: Control the order of resource deployment and run jobs at specific lifecycle points + +## Why ArgoCD for f3s? + +For a home lab cluster, ArgoCD provides several benefits: + +**Disaster recovery**: If the entire cluster is lost, I can rebuild it by: +1. Bootstrapping a new k3s cluster +2. Installing ArgoCD +3. Pointing ArgoCD at the Git repository +4. All applications automatically deploy to the desired state + +**Experimentation safety**: I can test changes in a separate Git branch without affecting the running cluster. Once validated, merge to master and ArgoCD applies the changes. + +**Drift detection**: If I manually change something in the cluster (for debugging), ArgoCD shows the difference and can automatically revert it. + +**Declarative configuration**: The Git repository documents the entire cluster configuration. No need to remember which `just` commands to run or in which order. + +**Automatic sync**: Push to Git, and changes deploy automatically. No need to SSH to a workstation and run Helm commands. + +## Deploying ArgoCD + +ArgoCD itself runs as a set of Kubernetes resources in the cluster. The official installation method uses `kubectl apply`, which is fitting—ArgoCD manages everything else via GitOps, but ArgoCD itself needs a bootstrap. + +### Prerequisites + +Create the `cicd` namespace where ArgoCD will run: + +```sh +$ kubectl create namespace cicd +namespace/cicd created +``` + +### Installing ArgoCD + +The ArgoCD installation lives in the configuration repository: + +=> https://codeberg.org/snonux/conf/src/branch/master/f3s/argocd codeberg.org/snonux/conf/f3s/argocd + +I deployed ArgoCD using Helm instead of the raw manifests. This provides easier upgrades and customization. The installation is managed via a Justfile: + +```sh +$ cd conf/f3s/argocd +$ just install +helm repo add argo https://argoproj.github.io/argo-helm +helm repo update +helm install argocd argo/argo-cd \ + --namespace cicd \ + --version 7.7.12 \ + -f values.yaml +NAME: argocd +LAST DEPLOYED: ... +NAMESPACE: cicd +STATUS: deployed +``` + +The `values.yaml` file configures several important aspects: + +**Persistent storage for the repo-server**: ArgoCD clones Git repositories to cache them locally. I configured a persistent volume so the cache survives pod restarts: + +```yaml +repoServer: + volumes: + - name: repo-cache + persistentVolumeClaim: + claimName: argocd-repo-cache-pvc + volumeMounts: + - name: repo-cache + mountPath: /tmp +``` + +**Admin password preservation**: By default, the admin password is auto-generated and stored in a secret. To ensure it persists across Helm upgrades: + +```yaml +configs: + secret: + createSecret: false +``` + +I manually created the secret before installation: + +```sh +$ ARGOCD_ADMIN_PASSWORD=$(pwgen -s 32 1) +$ BCRYPT_HASH=$(htpasswd -nbBC 10 "" "$ARGOCD_ADMIN_PASSWORD" | tr -d ':\n' | sed 's/$2y/$2a/') +$ kubectl create secret generic argocd-secret \ + --from-literal=admin.password="$BCRYPT_HASH" \ + -n cicd +$ echo "ArgoCD admin password: $ARGOCD_ADMIN_PASSWORD" +``` + +**Server configuration**: Enabled insecure mode since TLS is handled by the OpenBSD edge relays: + +```yaml +server: + insecure: true +``` + +### Accessing ArgoCD + +After deployment, ArgoCD runs several pods in the `cicd` namespace: + +```sh +$ kubectl get pods -n cicd +NAME READY STATUS RESTARTS AGE +argocd-application-controller-0 1/1 Running 0 45d +argocd-applicationset-controller-66d6b9b8f4-vhm9k 1/1 Running 0 45d +argocd-dex-server-7fb556b7dd-xjr2l 1/1 Running 0 45d +argocd-notifications-controller-6d8dd4c5f5-b8vwl 1/1 Running 0 45d +argocd-redis-77b8d6c6d4-mz9hg 1/1 Running 0 45d +argocd-repo-server-5f98f77b97-8xtcq 1/1 Running 0 45d +argocd-server-6b9c4b4f8d-kxw7p 1/1 Running 0 45d +``` + +I created an ingress to expose the ArgoCD web UI: + +```yaml +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: argocd-server-ingress + namespace: cicd + annotations: + spec.ingressClassName: traefik + traefik.ingress.kubernetes.io/router.entrypoints: web +spec: + rules: + - host: argocd.f3s.buetow.org + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: argocd-server + port: + number: 80 +``` + +Following the same pattern as other services, the OpenBSD edge relays terminate TLS and forward traffic through WireGuard to the cluster. ArgoCD is now accessible at: + +=> https://argocd.f3s.buetow.org ArgoCD Web UI + +The ArgoCD CLI can also be used for operations: + +```sh +$ argocd login argocd.f3s.buetow.org +$ argocd app list +``` + +## ArgoCD Application Structure + +ArgoCD uses a CRD called `Application` to define what should be deployed. Each application specifies: + +* **Source**: Where the manifests live (Git repo, Helm chart repository, or both) +* **Destination**: Which cluster and namespace to deploy to +* **Sync policy**: Whether to automatically sync changes + +Here's a simple example for the miniflux application: + +```yaml +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: miniflux + namespace: cicd + finalizers: + - resources-finalizer.argocd.argoproj.io +spec: + project: default + source: + repoURL: https://codeberg.org/snonux/conf.git + targetRevision: master + path: f3s/miniflux/helm-chart + destination: + server: https://kubernetes.default.svc + namespace: services + syncPolicy: + automated: + prune: true + selfHeal: true + syncOptions: + - CreateNamespace=false + retry: + limit: 3 + backoff: + duration: 5s + factor: 2 + maxDuration: 1m +``` + +Key fields: + +* `source.path`: Points to the Helm chart directory in Git +* `destination.namespace`: Where to deploy the application +* `syncPolicy.automated.prune`: Delete resources that are removed from Git +* `syncPolicy.automated.selfHeal`: Automatically revert manual changes in the cluster +* `finalizers`: Ensures ArgoCD deletes all resources when the Application is deleted + +## Repository Organization + +I reorganized the configuration repository to support GitOps: + +``` +/home/paul/git/conf/f3s/ +├── argocd-apps/ # ArgoCD Application manifests (organized by namespace) +│ ├── README.md # Documentation of structure +│ ├── monitoring/ # Observability stack (6 apps) +│ │ ├── alloy.yaml +│ │ ├── grafana-ingress.yaml +│ │ ├── loki.yaml +│ │ ├── prometheus.yaml +│ │ ├── pushgateway.yaml +│ │ └── tempo.yaml +│ ├── services/ # User-facing applications (13 apps) +│ │ ├── anki-sync-server.yaml +│ │ ├── audiobookshelf.yaml +│ │ ├── filebrowser.yaml +│ │ ├── immich.yaml +│ │ ├── keybr.yaml +│ │ ├── kobo-sync-server.yaml +│ │ ├── miniflux.yaml +│ │ ├── opodsync.yaml +│ │ ├── radicale.yaml +│ │ ├── syncthing.yaml +│ │ ├── tracing-demo.yaml +│ │ ├── wallabag.yaml +│ │ └── webdav.yaml +│ ├── infra/ # Infrastructure services (1 app) +│ │ └── registry.yaml +│ └── test/ # Test/example applications (1 app) +│ └── example-apache-volume-claim.yaml +├── miniflux/ # Application directories (unchanged) +│ ├── helm-chart/ +│ │ ├── Chart.yaml +│ │ ├── values.yaml +│ │ └── templates/ +│ └── Justfile # Updated for ArgoCD +├── prometheus/ +│ ├── manifests/ # NEW: Additional manifests +│ │ ├── persistent-volumes.yaml +│ │ ├── grafana-restart-hook.yaml +│ │ ├── freebsd-recording-rules.yaml +│ │ └── ... +│ └── Justfile # Updated for ArgoCD +└── ... +``` + +The application directories (miniflux, prometheus, etc.) remained mostly unchanged—ArgoCD references the same Helm charts. The main additions: + +1. **argocd-apps/**: Application manifests organized by Kubernetes namespace for better clarity + - `monitoring/`: 6 observability applications + - `services/`: 13 user-facing applications + - `infra/`: 1 infrastructure application (registry) + - `test/`: 1 test application +2. ***/manifests/**: Additional Kubernetes manifests for complex apps (like Prometheus) +3. **Justfiles updated**: Changed from `helm install/upgrade` to `argocd app sync` + +This organization makes it easy to apply all applications in a specific namespace or manage them independently. + +## Migration Strategy: Incremental, One App at a Time + +Rather than attempting a "big bang" migration of all 21 applications at once, I migrated them incrementally: + +1. **Start with a simple app**: Validate the pattern with a low-risk application +2. **Migrate in waves**: Group similar applications and migrate together +3. **Validate thoroughly**: Ensure each app is healthy before moving to the next +4. **Learn and iterate**: Apply lessons from earlier migrations to later ones + +This approach reduced risk and allowed me to refine the migration process. + +### Migration Phases + +**Phase 1: Simple services** (13 apps) +* miniflux, freshrss, wallabag +* anki-sync-server, kobo-sync-server, opodsync +* radicale, syncthing, audiobookshelf +* filebrowser, keybr, webdav +* example-apache, example-apache-volume-claim + +These apps have straightforward Helm charts with no complex dependencies. Pattern established: +1. Create Application manifest in `argocd-apps/` +2. Apply with `kubectl apply -f argocd-apps/<app>.yaml` +3. Verify sync status: `argocd app get <app>` +4. Update Justfile to use ArgoCD commands + +**Phase 2: Infrastructure apps** (3 apps) +* registry (Docker image registry) +* pushgateway (Prometheus metrics ingestion) +* immich (photo management with complex dependencies) + +**Phase 3: Monitoring stack** (4 apps) +* tempo (distributed tracing) +* loki (log aggregation) +* alloy (log collection) +* prometheus (metrics and monitoring) + +**Phase 4: Monitoring addons** (1 app) +* grafana-ingress (separate ingress for Grafana) + +## Example Migration: Miniflux + +Let me walk through the migration of miniflux as a concrete example. + +### Before: Imperative Helm deployment + +Original Justfile: + +```makefile +NAMESPACE := "services" +APP_NAME := "miniflux" + +install: + kubectl apply -f helm-chart/persistent-volumes.yaml + helm install {{APP_NAME}} ./helm-chart --namespace {{NAMESPACE}} + +upgrade: + helm upgrade {{APP_NAME}} ./helm-chart --namespace {{NAMESPACE}} + +uninstall: + helm uninstall {{APP_NAME}} --namespace {{NAMESPACE}} + kubectl delete -f helm-chart/persistent-volumes.yaml + +status: + @kubectl get all -n {{NAMESPACE}} -l app={{APP_NAME}} +``` + +Workflow: +1. Make changes to `helm-chart/` +2. Run `just upgrade` +3. Helm pushes changes to cluster + +### After: Declarative GitOps with ArgoCD + +Created `argocd-apps/services/miniflux.yaml`: + +```yaml +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: miniflux + namespace: cicd + finalizers: + - resources-finalizer.argocd.argoproj.io +spec: + project: default + source: + repoURL: https://codeberg.org/snonux/conf.git + targetRevision: master + path: f3s/miniflux/helm-chart + destination: + server: https://kubernetes.default.svc + namespace: services + syncPolicy: + automated: + prune: true + selfHeal: true + syncOptions: + - CreateNamespace=false + retry: + limit: 3 + backoff: + duration: 5s + factor: 2 + maxDuration: 1m +``` + +Updated Justfile: + +```makefile +NAMESPACE := "services" +APP_NAME := "miniflux" + +status: + @echo "=== Pods ===" + @kubectl get pods -n {{NAMESPACE}} -l app={{APP_NAME}} + @echo "" + @echo "=== Services ===" + @kubectl get svc -n {{NAMESPACE}} -l app={{APP_NAME}} + @echo "" + @echo "=== ArgoCD Status ===" + @kubectl get application {{APP_NAME}} -n cicd -o jsonpath='Sync: {.status.sync.status}, Health: {.status.health.status}' 2>/dev/null && echo "" + +sync: + @echo "Triggering ArgoCD sync..." + @kubectl annotate application {{APP_NAME}} -n cicd argocd.argoproj.io/refresh=normal --overwrite + @sleep 2 + @kubectl get application {{APP_NAME}} -n cicd -o jsonpath='Sync: {.status.sync.status}, Health: {.status.health.status}' && echo "" + +argocd-status: + argocd app get {{APP_NAME}} --core + +logs: + kubectl logs -n {{NAMESPACE}} -l app={{APP_NAME}} --tail=100 -f +``` + +New workflow: +1. Make changes to `helm-chart/` +2. Commit and push to Git +3. ArgoCD automatically detects and syncs changes +4. (Optional) Run `just sync` to force immediate sync + +### Migration procedure + +1. **Backup current state**: +```sh +$ helm get values miniflux -n services > /tmp/miniflux-backup-values.yaml +$ kubectl get all,ingress -n services -o yaml > /tmp/miniflux-backup.yaml +``` + +2. **Create Application manifest**: +```sh +$ kubectl apply -f argocd-apps/services/miniflux.yaml +application.argoproj.io/miniflux created +``` + +3. **Verify ArgoCD adopted the resources**: +```sh +$ argocd app get miniflux +Name: miniflux +Project: default +Server: https://kubernetes.default.svc +Namespace: services +URL: https://argocd.f3s.buetow.org/applications/miniflux +Repo: https://codeberg.org/snonux/conf.git +Target: master +Path: f3s/miniflux/helm-chart +SyncWindow: Sync Allowed +Sync Policy: Automated (Prune) +Sync Status: Synced to master (4e3c216) +Health Status: Healthy +``` + +4. **Monitor for issues**: +```sh +$ kubectl get pods -n services -l app=miniflux -w +NAME READY STATUS RESTARTS AGE +miniflux-postgres-556444cb8d-xvv2p 1/1 Running 0 54d +miniflux-server-85d7c64664-stmt9 1/1 Running 0 54d +``` + +5. **Test the application**: +```sh +$ curl -I https://flux.f3s.buetow.org +HTTP/2 200 +``` + +6. **Update Justfile** and commit changes + +Total time: 10 minutes. Zero downtime. + +## Complex Migration: Prometheus with Multi-Source + +The Prometheus migration was more complex because it combines: +* Upstream Helm chart (kube-prometheus-stack) +* Custom manifests (PersistentVolumes, recording rules, dashboards) +* Sync hooks (PostSync job to restart Grafana) + +ArgoCD supports "multi-source" Applications that combine multiple sources: + +```yaml +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: prometheus + namespace: cicd + finalizers: + - resources-finalizer.argocd.argoproj.io +spec: + project: default + sources: + # Source 1: Upstream Helm chart from prometheus-community + - repoURL: https://prometheus-community.github.io/helm-charts + chart: kube-prometheus-stack + targetRevision: 55.5.0 + helm: + releaseName: prometheus + valuesObject: + # Full Prometheus configuration embedded here + kubeEtcd: + enabled: true + endpoints: + - 192.168.2.120 + - 192.168.2.121 + - 192.168.2.122 + # ... (hundreds of lines of configuration) + + # Source 2: Additional manifests from Git repository + - repoURL: https://codeberg.org/snonux/conf.git + targetRevision: master + path: f3s/prometheus/manifests + + destination: + server: https://kubernetes.default.svc + namespace: monitoring + + syncPolicy: + automated: + prune: false # Manual pruning for safety on complex stack + selfHeal: true + syncOptions: + - CreateNamespace=false + - ServerSideApply=true + retry: + limit: 3 + backoff: + duration: 10s + factor: 2 + maxDuration: 3m +``` + +The `prometheus/manifests/` directory contains: + +``` +f3s/prometheus/manifests/ +├── persistent-volumes.yaml # Sync wave 0 +├── additional-scrape-configs-secret.yaml # Sync wave 1 +├── grafana-datasources-configmap.yaml # Sync wave 1 +├── freebsd-recording-rules.yaml # Sync wave 3 +├── openbsd-recording-rules.yaml # Sync wave 3 +├── zfs-recording-rules.yaml # Sync wave 3 +├── epimetheus-dashboard.yaml # Sync wave 4 +├── zfs-dashboards.yaml # Sync wave 4 +├── grafana-restart-hook.yaml # Sync wave 10 (PostSync) +└── grafana-restart-rbac.yaml # Sync wave 0 +``` + +### Sync Waves and Hooks + +ArgoCD allows controlling the order of resource deployment using sync waves (the `argocd.argoproj.io/sync-wave` annotation): + +* **Wave 0**: Infrastructure (PersistentVolumes, RBAC) +* **Wave 1**: Configuration (Secrets, ConfigMaps) +* **Wave 3**: Recording rules (PrometheusRule CRDs) +* **Wave 4**: Dashboards (ConfigMaps with `grafana_dashboard: '1'` label) +* **Wave 10**: PostSync hooks (Jobs that run after everything else) + +The Grafana restart hook ensures Grafana reloads datasources after they're updated: + +```yaml |
