Skip to content

feat(argocd): read the environment from the homelab repo #5134

Open
3 of 4 issues completed
Open

Description

@dan-petty

Problem or Motivation

After dan-petty/homelab#23, the homelab repo holds a copy of the environment, but every Application of Argo CD still reads dan-petty/devops-cli main (repoURL https://github.com/dan-petty/devops-cli, targetRevision main, prune: true, selfHeal: true). The private values still reach Argo CD as deploy-time overrides on the Applications devops, ingress and mattermost (live patches: devops 1, ingress 19, mattermost 1), with ignoreDifferences in k8s/argocd/bootstrap/cluster.yaml (#1290). #1291 planned a private config repo on Gitea for those values; the owner's direction of 2026-11-12 picks the private repo dan-petty/homelab instead, so this item supersedes #1291.

Proposed Solution & Architectural Design

Phase 2 of tracker #5120 (design section 10). The plan steps are the steps of the corrected plan on #5120. Do the work in this order:

  1. Owner (plan step 7). The owner gives the existing GitHub App devops-cli-argocd the permission Contents: read and installs it on dan-petty/homelab. The owner creates the Argo CD repository credential object in namespace argocd (label argocd.argoproj.io/secret-type=repository, url https://github.com/dan-petty/homelab, the githubApp* fields). There is no deploy key. The credential never goes into git. The owner also installs devops-cli-argocd with Deployments: write on homelab before step 3, so the deploy statuses of 11 Applications do not fail. The installation ID stays the same, so argocd-notifications-secret does not change. Check: argocd repo list --core shows homelab as Successful. The credential object is listed by name only.
  2. Agent, a person merges (plan step 8). Add https://github.com/dan-petty/homelab to sourceRepos of the AppProjects homelab (projects.yaml:12) and homelab-system (:140), and keep devops-cli. Add the repository credential object to orphanedResources.ignore. Add the docs/ runbook of plan steps 10-17 with roles only. The private-domain guard feat(security): refuse a diff that names the configured domain #5295 merges in the same plan step. Check: kubectl get appproject homelab homelab-system -n argocd -o jsonpath='{.spec.sourceRepos}' lists homelab, and all 34 Applications stay Synced.
    • Then dan-petty/homelab#23 (plan step 9) copies the environment at devops-cli commit S, which is taken after this step.
    • Pre-checks before step 3 (plan step 10), on the day of the switch. Run git diff --stat S origin/main -- <environment paths> and git diff --quiet vX origin/main -- k8s/devops/dashboards. If either shows a change, sync the copy again with a homelab PR and run the homelab#23 checks again. Post the baseline here with counts and key names only: 34 Applications, 33 Synced and Healthy and 1 Progressing; requiresPruning only on argocd, 3 hook objects; override keys on devops, ingress and mattermost. Make sure that 0 Applications have automated.enabled: false (a volume move pauses an Application this way, volume_move.py:234, 697), and that no volume move or node operation is in progress.
    • Prerequisites before step 3: the released fetch fix fix(k8s): deploy-stack fetches a private Application repo #5294 (argocd_overrides.py:97-108, in release vX), the credential and both App installations of step 1, the owner decisions on protection and Actions minutes (made on 2026-11-13, below), 0 paused Applications and no volume move in progress.
  3. The switch, agent after the owner says go (plan step 11). The agent asks the owner for go when plan steps 1 to 10 pass their checks. Write homelab origin/main k8s/argocd/bootstrap/bootstrap.yaml to a file in a temporary directory. Run uv run devops argo cd apps bootstrap-gitops --root-app <that file>. It creates or merge-patches the live bootstrap (crd.py:225-246). bootstrap syncs cluster from homelab, and cluster applies the 32 children. Every git source and every $values ref names homelab, except Application devops (devops-cli k8s/devops on main) and the product ref of Application prometheus (devops-cli main). Prune is off in all 34 Applications of the copy, bootstrap and cluster included.
  4. Check (plan step 11). Sync and health equal the baseline. argocd app diff --core --exit-code is 0 for all 34 Applications. There are 0 pruned and 0 PruneSkipped results, and requiresPruning equals the baseline. The override keys are still there. IngressServesPlaceholderHost does not fire. Post exit codes and counts only, never diff output or Application YAML. The Applications keep their names, so tracking does not change: no orphan, no duplicate.
    • Freeze and soak (plan step 12). Merge a temporary devops-cli CI check that refuses changes to the old environment paths in devops-cli. It starts after the switch, not at S, because devops-cli main deploys until the switch. Soak for at least 1 day and 1 release. Check: deploy statuses appear on homelab commits for 11 Applications and on devops-cli commits for devops. At the release, the digest on Application devops moves. No ComparisonError.
  5. Private values into git and prune on, in 3 parts.
    • 5a, homelab (plan step 13). Turn prune on in 2 PRs, leaves first. PR A turns prune on in the leaf Applications. After PR A is synced and its checks pass, PR B turns prune on in cluster and bootstrap. One PR cannot enforce this order. Check before each merge: diff exit code 0 for all 34, requiresPruning equals the baseline, PruneSkipped is 0, and the homelab name set equals the live set.
    • 5b, homelab (plan step 14). In one homelab PR, write each live patch list as it is into spec.source.kustomize.patches of the homelab files devops.yaml, ingress.yaml and mattermost.yaml. Copy the lists with jq into the files, never to output. In the same PR, narrow the devops entry of cluster.yaml to /spec/source/kustomize/images, and remove the ingress and mattermost entries. The render does not change, so no Application loses its sync for any period, and no agent patches a live object. A revert is safe, because kubectl-patch also owns the live patches. Check: all 34 Applications are Synced with an empty diff, the live patches equal the patches in git, devops holds the images from Image Updater, IngressServesPlaceholderHost does not fire, and no host appears in devops-cli or in a public comment.
    • 5c, devops-cli (plan step 15). deploy-stack stops writing the overrides (the goal of feat(k8s): Read homelab config from in-cluster Gitea, drop overrides #1291). Delete the HOMELAB_APPLICATIONS constants, the override functions, argocd_overrides.py, the 2 gate modules, their tests and the README section. Close feat(k8s): Read homelab config from in-cluster Gitea, drop overrides #1291 as superseded. Check: git grep CONST_K8S_ARGOCD_HOMELAB_APPLICATIONS in src/ and tests/ finds nothing, deploy-stack --dry-run writes no Application patch, and uv run devops ci passes.
  6. Delete the environment files, devops-cli (plan step 17). Do this after 7 days with no revert, after the refactor(k8s): read the environment tree from the infra repo #5131 fixture PR and after feat(k8s): run the environment checks in homelab CI #5296 (homelab environment checks, plan step 16). Delete the 130 environment files, the devops overlay, the environment Renovate managers, the environment tests, gate modules and fixtures, and the freeze check. Scope image-pins.yml to k8s/devops/**; do not delete it. Re-point the 52 OpenSpec specs. Check live that no devops-cli git source names a deleted path: the Application sources list only k8s/devops and k8s/devops/monitoring. git grep finds no environment file, uv run devops ci passes, and all 34 Applications stay Synced.

Revert of the switch. Compare the Application name sets first. Then run bootstrap-gitops from a devops-cli main checkout, with prune: false if the sets differ. The patches and the digests stay, because kubectl-patch and Image Updater also own them (managedFields). This works until step 6.

Risks. 31 of 34 Applications carry resources-finalizer, so keep prune off on bootstrap and cluster until PR B of step 5a, and change no Application name from S until then. One credential serves all homelab sources, Argo CD itself included: if it fails, every Application shows a comparison error, and nothing syncs or prunes. Public evidence holds exit codes and counts only, because the live objects hold the real hosts.

The deploy notification reads .app.spec.source.repoURL, so deploy statuses go to homelab commits after the switch. #1082 (Gitea mirrors) later mirrors the homelab repo. A pull mirror of a private repo needs a credential, which the owner gives later, outside this cutover.

Owner decisions (2026-11-13). The owner accepted the recommended owner steps:

  • Repository credential: the existing GitHub App devops-cli-argocd (Contents: read), installed on homelab, with an Argo CD repository credential object that the owner creates. No deploy key. Owner step, before step 3.
  • The owner installs devops-cli-argocd (Deployments: write) on homelab before step 3.
  • homelab is the development environment. It keeps the branch and pull request conventions and gets a .pre-commit-config.yaml with the pre-commit-hooks hook no-commit-to-branch (branch main). It gets no branch protection, no ruleset, no required check and no other gate that blocks or delays work. The environment checks of feat(k8s): run the environment checks in homelab CI #5296 are advisory: they report on each pull request and never block a merge or an apply. The freeze check of plan step 12 applies only to the old environment paths in devops-cli.
  • Actions minutes: path filters on each homelab workflow. Renovate makes the version bumps, so no workflow runs at each devops-cli release. Measure the minutes after one month.
  • The switch (step 3) waits for the owner's go. The agent asks when plan steps 1 to 10 pass their checks.
  • The owner merges the PRs in both repositories.
  • The Gitea pull-mirror credential comes later, outside this cutover.

Target Subsystem

Kubernetes & Minikube Automation

Existing Tool Considered

Argo CD app-of-apps, AppProject sourceRepos, repository credentials and argocd app diff. Cost: about 3M tokens to build, 0.2M a quarter to keep, 5 hours plus 1 hour of the owner.

Acceptance Criteria

  • A runbook in docs/ gives each step, the check after it and the revert.
  • Live, recorded in a PR comment with exit codes and counts only: after step 3 every Application is Synced and Healthy, argocd app diff --core --exit-code is 0 for all 34, and no resource was deleted (0 pruned and 0 PruneSkipped results).
  • After step 5, no field of an Application differs from git, except spec.source.kustomize.images on devops. The patches of devops, ingress and mattermost are in the homelab files, and cluster.yaml keeps only the /spec/source/kustomize/images entry of devops.
  • After step 6, git grep in devops-cli finds no environment file of the list in design section 10, and no live git source of devops-cli names a deleted path.

Dependencies

Owner: step 1 (the repository credential and both App installations). dan-petty/homelab#23 (plan step 9). #5294 released in vX, before step 3. #5295 with step 2. #5296 and the #5131 fixture PR, before step 6. #5135 comes after this item.

Alternatives check of 2026-11-22: in-use.
The repository already uses this tool.
Tool: argoproj/argo-cd (https://github.com/argoproj/argo-cd), Apache-2.0, last activity 2026-11-22, maintained.
Reason: Searches returned only general Argo CD material, but the issue already runs Argo CD: its repository credentials, per-project sourceRepos and app-of-apps cover pointing every Application at the private homelab repo. The rest is cutover work, not a missing tool.

Covers:

  • Repository credentials by URL, with GitHub App fields and no deploy key
  • AppProject sourceRepos allow-list that names several repositories at once
  • App-of-apps bootstrap and cluster Applications syncing from another repository
  • argocd app diff --core --exit-code as the post-switch check
  • Prune off per Application and ignoreDifferences for live patches

Lacks:

  • Credential object and App installation stay owner steps outside git
  • Private values must still be written into the homelab files
  • deploy-stack keeps patching live Applications until step 5c
  • No pull mirror of the private repo until a later credential
  • Copy of the environment and runbook remain manual steps

Sub-issues

Sub-issues

3 of 4 Issues completed
Loading 4 sub-issues

Activity

  1. added
    source/agent
    type/feature
    scope/argocd
    status/new
    value/high
    effort/medium
    on Nov 12, 2026
  2. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor
  3. added
    priority/p2-medium
    on Nov 12, 2026
  4. dan-petty commented on Nov 13, 2026

    @dan-petty
    OwnerAuthor

    Step 1 (plan step 7) is done (2026-11-13 03:45Z). The owner gave the GitHub App devops-cli-argocd Contents: read (Deployments: write kept); its installation covers all repositories of the account, with the same installation ID as the Argo CD notifications, so the notifications Secret does not change. The owner created the Argo CD repository credential repo-homelab in namespace argocd (type git, the homelab URL, the App ID and key from the notifications Secret). argocd repo list --core --refresh hard shows the homelab repository as Successful. The orphanedResources ignore entry for this Secret ships with the homelab copy (homelab#23).

  5. added
    owner/agent
    on Nov 13, 2026
  6. devops-cli-service commented on Nov 16, 2026

    @devops-cli-service
    Contributor

    Alternatives check: in-use

    Reason: Argo CD natively provides every feature the issue needs: app-of-apps (bootstrap → cluster → children), AppProject sourceRepos for multiple repositories, repository credentials including GitHub App authentication, argocd app diff for verification, prune management, self-heal, and kustomize patches with ignoreDifferences. The issue already names Argo CD as its existing tool in the title, body, and the "Existing Tool Considered" section.

    The repository already uses this tool.

    Tool: argoproj/argo-cd (https://github.com/argoproj/argo-cd)

    • License: Apache-2.0
    • Last activity: 2026-11-16
    • Maintained: yes

    Covers:

    • app-of-apps bootstrap (bootstrap → cluster → 32 children)
    • AppProject sourceRepos for pointing Applications at multiple git repos
    • repository credential objects supporting GitHub App authentication
    • argocd app diff --core --exit-code for drift verification
    • prune on/off and requiresPruning per Application
    • selfHeal and ignoreDifferences for live-patch coexistence
    • kustomize patches in spec.source.kustomize.patches

    Tools considered:

    Searches run:

    • Argo CD app-of-apps multi-repo sourceRepos GitOps repository credential, results: 5
    • Argo CD official GitHub repo argoproj/argocd app-of-apps, results: 5
    • github.com argoproj argocd, results: 5

    Sources:

    Checked on 2026-11-16. A person decides what this means for the item. The check changes no label and closes no issue.

  7. 8 remaining items

  8. dan-petty commented on Nov 25, 2026

    @dan-petty
    OwnerAuthor

    Step 12 of docs/HOMELAB_REPO_SWITCH.md (freeze and soak), checked on 2026-11-25. #6823 (the freeze check, the Renovate rule and the GitOps text) merged on 2026-11-23 at 02:05 UTC; the soak had more than 1 day and several devops-cli releases.

    • Deployments: 14 Applications subscribe to deploy notifications. Each one that synced after the switch has deployments on homelab commits (services 6, llm 4, monitoring 4, object-store 3, and 1 each for argo-workflows-manifests, base, gitea-manifests, gpu-feature-discovery and mattermost). devops has 49 deployments on devops-cli commits. agents, ingress, logging and otel last synced before the switch, so they have no new deployment.
    • At the releases, the digests of spec.source.kustomize.images on devops changed (service, runner and mcp-server).
    • Shared check 9: the placeholder alert gives 0. Comparison errors give 1: Application danielpetty-com (ApplicationSet service-workloads, created 2026-11-23 13:58) cannot read the private site repository, because the credential template of dan-petty/homelab#80 does not exist yet. This comes from the new service Application, not from the switch (dan-petty/homelab#131).

    So step 12 passes, except for that one error, which a person step fixes. The next step is step 13 (prune on, leaves first, two homelab pull requests).

  9. dan-petty commented on Nov 25, 2026

    @dan-petty
    OwnerAuthor

    Step 13 waits: since dan-petty/homelab#145 (Argo CD built from the infra values), shared check 3 gives 12 objects on argocd, not the 3 of the baseline. 11 of them are safe to prune (dex server, redis secret init, the cluster-wide RBAC of the notifications controller). Secret argocd-notifications-secret is not: it holds the GitHub App credentials of the deploy notifications, and a prune would delete it. dan-petty/homelab#219 keeps it out of the prune; after that, step 13 starts with the new baseline of 11.

  10. dan-petty commented on Nov 25, 2026

    @dan-petty
    OwnerAuthor

    Step 13 preparation, 2026-11-25, after dan-petty/homelab#220 merged.

    dan-petty/homelab#219 is done. argocd-notifications-secret is Synced, not marked for prune, and keeps its 4 keys. argocd marks 11 objects.

    The baseline of shared check 3 changed. Since the homelab services build from the infra values, 68 objects in 9 Applications are marked for prune, not only objects of argocd. None is a PersistentVolumeClaim, Namespace, CustomResourceDefinition or CloudNativePG Cluster.

    Application Count Kinds
    argo-workflows 6 1 ClusterRoleBinding, 1 Deployment, 1 Role, 1 RoleBinding, 1 Service, 1 ServiceAccount
    argocd 11 1 ClusterRole, 1 ClusterRoleBinding, 1 Deployment, 1 NetworkPolicy, 2 Role, 2 RoleBinding, 1 Service, 2 ServiceAccount
    dcgm-exporter 3 1 ConfigMap, 1 Role, 1 RoleBinding
    devops 2 2 NetworkPolicy
    gitea 22 3 ConfigMap, 1 Deployment, 3 NetworkPolicy, 4 PodDisruptionBudget, 2 Secret, 5 Service, 2 ServiceAccount, 2 StatefulSet
    grafana 3 1 ClusterRole, 1 ClusterRoleBinding, 1 Secret
    llm 2 2 NetworkPolicy
    prometheus 11 1 ClusterRole, 1 ClusterRoleBinding, 1 DaemonSet, 2 Deployment, 3 Service, 3 ServiceAccount
    pyroscope 8 1 ClusterRole, 1 ClusterRoleBinding, 1 ConfigMap, 1 PodDisruptionBudget, 2 Service, 1 ServiceAccount, 1 StatefulSet

    What was checked:

    • gitea: PostgreSQL HA and Valkey cluster objects. The running Gitea uses sqlite3. The claims of the StatefulSets stay after the prune.
    • prometheus: node-exporter, kube-state-metrics and Pushgateway are enabled: false in homelab. The k8s-monitoring exporters give the scraped series, and no metric comes from a Pushgateway.
    • pyroscope: its own Alloy. The infra values turn it off, and k8s-monitoring-alloy-profiles runs.
    • grafana: no workload reads Secret monitoring/grafana.
    • dcgm-exporter: no pod mounts the old ConfigMap.

    Recommendation for step 13. Set Prune=confirm in spec.syncPolicy.syncOptions of each Application in the same pull request that sets prune: true (Argo CD sync options). A person then approves each prune. Without it, an automerged infra bump that drops or renames an object deletes it with no review. The objects above came from renders that were wrong for a short time.

    Step 13 waits for the owner to accept this list and the recommendation.

  11. dan-petty commented on Nov 25, 2026

    @dan-petty
    OwnerAuthor

    Step 13, 2026-11-25. The owner accepted the list of the comment above and the Prune=confirm recommendation.

    Pull request A (dan-petty/homelab#228) is merged and synced: each child Application of cluster prunes with Prune=confirm.

    • 9 syncs waited for an approval. Their pending objects were equal to the accepted list: 68, no difference. The 4 Applications that the list gave no check for (argo-workflows, argocd, devops, llm) were checked before the approval.
    • The syncs were approved. 65 objects are gone. The 3 other objects are chart hooks of argocd, which Argo CD creates at each sync and never prunes.
    • No permission error in the logs of the workloads that used a pruned object, and no new alert.

    Pull request B (dan-petty/homelab#233) turns prune on in cluster and bootstrap, which mark no object. #7245 corrects the text of step 13.

    Checks before B: the diff check exits 0 for 40 Applications and 1 for k8s-monitoring. Its sync has waited since 2026-11-24 for a DaemonSet that cannot be healthy while one node is unreachable. It has no object to prune. A person needs to look at that node.

  12. dan-petty commented on Nov 25, 2026

    @dan-petty
    OwnerAuthor

    Correction to the comment above: the node was not broken. A person shut it down on 2026-11-19 (record on #5143). It is on again, and the k8s-monitoring sync finished: Synced, and the exporter DaemonSet is 5 of 5 ready.

    After dan-petty/homelab#233, the diff checks of base, bootstrap, cluster and k8s-monitoring exit 0.

  13. dan-petty commented on Nov 25, 2026

    @dan-petty
    OwnerAuthor

    Progress on 2026-11-25:

  14. dan-petty commented on Nov 25, 2026

    @dan-petty
    OwnerAuthor

    2026-11-25:

  15. dan-petty commented on Nov 26, 2026

    @dan-petty
    OwnerAuthor

    2026-11-26: the owner started step 17 and waived its condition of 7 days with no revert. The item is #7290. Shared checks before the work: 40 of 40 diffs exit 0, 0 comparison errors, 0 firing placeholder alerts, 0 paused Applications, and the devops-cli paths of check 7 are in the product folder only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumowner/agentpriority/p2-mediumscope/argocdsource/agentstatus/newtype/featurevalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions