Skip to content

feat(k8s): Point Argo CD to Gitea for git and PR dev images #1082

Closed

Description

@dan-petty

Problem

Checked: release/v0.2.25 at e9973c7 (every cited line is the same at 132ecc5); the Argo CD v3.5.3 docs (operator-manual/cluster-bootstrapping.md, user-guide/diffing.md, user-guide/projects.md, declarative-setup) and source (app_project_types.go); and the homelab read-only on 2026-10-03.

Owner directions (2026-10-06 update).

  • When Gitea is implemented, Argo CD applications should point to Gitea for both git and container registries.
  • Development versions will be available to the cluster for all open pull requests.
  • Development images built for open PRs will be pushed to Gitea's in-cluster container registry and reconciled by Argo CD so there is zero gap between PR development and cluster availability.
  • Argo CD reads Git sources and pulls images directly from Gitea over in-cluster HTTP / internal registry endpoints.

What changed. The earlier body of this item switched every Application to read the release branch from a read-only Gitea mirror, to survive GitHub outages. On 2026-10-03 the owner made Gitea a writable internal forge ("internal iterative development that can happen without going out to github"). The owner also said "Gitea should be able to communicate inside the cluster using http". Three changes follow:

Argo CD already reads GitHub. Every Application at the tip uses https://github.com/dan-petty/devops-cli.git (k8s/argocd/apps/root-app.yaml:12, infra-apps.yaml:12 and :36, llm-apps.yaml:12), as it has since 22bba04 (#38, v0.2.11).

Argo CD's path to Gitea.

The devcontainer git daemon. Its removal was part of this item. It now has its own item, #1122, with no dependency (the owner: "the git daemon is a stub that was meant to enable simple argocd integration"). This item no longer touches it.

Acceptance criteria

In the gate. These tests are offline and use structural tuple assertions. New tests add under 1 s, checked with uv run pytest tests/test_k8s_argocd_trial.py tests/test_argo_trial.py tests/test_k8s_network_policies.py tests/test_k8s_push_secrets.py --durations=0.

  • AppProject trial. It joins feat(k8s): argo cd keeps the homelab cluster at the current release branch, with automated sync, prune and self-heal that never delete data #755's k8s/argocd/apps/projects.yaml:
    • sourceRepos is exactly http://gitea-http.gitea.svc.cluster.local:3000/*/*. Argo CD matches source globs with / as a separator (pkg/apis/application/v1alpha1/app_project_types.go:471 at v3.5.3), so a single /* would match no <owner>/<repo> URL;
    • destinations is exactly namespace trial-* on https://kubernetes.default.svc;
    • clusterResourceWhitelist is exactly []: a trial may create no cluster-scoped object, not even a Namespace. A Namespace kind in the list, even one restricted by name, would let a trial's manifests relabel its own Pod Security level or take over another namespace, and the finalizer would delete that namespace when the trial ends.
    • A test asserts the three fields. It also asserts that no namespace in the homelab or homelab-system destinations matches trial-*.
  • Safety rule. A test asserts that every git source (not Helm chart sources) of every Application under k8s/argocd/ is https://github.com/dan-petty/devops-cli.git, and that no source of any Application names a Gitea URL, in-cluster or git. alias. That covers bootstrap, cluster, argocd, gitea and every release-tracking leaf. A broken Gitea can therefore always be fixed by a commit on GitHub, and nothing but a trial depends on Gitea.
  • Orphans. feat(k8s): argo cd keeps the homelab cluster at the current release branch, with automated sync, prune and self-heal that never delete data #755's homelab orphan-ignore list gains Applications named trial-*. Trial Applications are not in git, carry no tracking label, and are never pruned by cluster.
  • Argo CD credential. feat(k8s): devops-cli runs in the homelab cluster as Jobs, and every cluster Secret is pushed from the keyring, also by deploy-stack (devops k8s push-secrets, devops k8s run-job) #741's push-secrets table gains the Secret argocd/gitea-repo-creds:
  • Policy.
    • k8s/argocd/networkpolicy.yaml gains egress to Gitea's pods in namespace gitea on TCP 3000.
    • tests/test_k8s_network_policies.py asserts that rule as a tuple.
    • The daemon item removes port 9418 from the same file and test. Whichever PR lands second rebases; neither waits for the other.
  • devops argo cd trial start --branch BRANCH --path PATH [--repo OWNER/NAME] [--name NAME] [--context CTX] [--dry-run]:
    • Defaults. --repo defaults to dan-petty/devops-cli, and --name to the branch name made into a DNS label.
    • Checks before applying. The branch exists on Gitea (GET /repos/{o}/{r}/branches/{b}, 200 or 404, through feat(repos): Add a gitea remote to every clone under repos/ #1090's client at gitea.url), and PATH exists in it. A GiteaAccessBlocked from that client exits 1 with its message.
    • The namespace. It server-side applies Namespace trial-<name> with the label app.kubernetes.io/managed-by: devops-cli and Pod Security restricted for enforce, warn and audit. The CLI owns it, not Argo CD, since project trial admits no cluster-scoped kind.
    • The Application it applies. trial-<name> in argocd, applied with get_argo_crd_service(context).apply_application, as bootstrap-gitops does (src/devops_cli/commands/argo.py:378-383). It sets:
      • project trial;
      • repoURL: http://gitea-http.gitea.svc.cluster.local:3000/<owner>/<name>.git, targetRevision: BRANCH and path: PATH;
      • destination namespace trial-<name>;
      • resources-finalizer.argocd.argoproj.io;
      • automated sync with prune and selfHeal, so every push to the branch redeploys;
      • no CreateNamespace: the namespace exists before the Application.
    • Output. The Application name and how to follow it.
    • Dry run. --dry-run prints the Application and applies nothing.
  • devops argo cd trial end NAME:
    • deletes the Application, and the finalizer removes its resources;
    • waits up to 120 s for the Application to go;
    • then deletes namespace trial-<name>.
    • Any other name, or a namespace not starting with trial-, exits 1.
  • devops argo cd trial list: the Applications in project trial, with branch, path, sync status, health and age.
  • Trial tests. tests/test_argo_trial.py covers:
    • the rendered Namespace (a structural tuple of name and labels) and Application (project, in-cluster repoURL, revision, path, destination and sync options, with no CreateNamespace);
    • refusal when the branch is missing, with no apply;
    • end deleting nothing outside trial-*;
    • --dry-run applying nothing.
    • It uses a recording CRD-service stub and an httpx2.MockTransport for Gitea.
  • Docs.
    • The trial help strings go in lang/en/help.py. Regenerate docs/commands/argo.md and docs/CLI_REFERENCE.md with devops docs generate.
    • The "Gitea" section in k8s/README.md gains "Trials", which covers:
      • what a trial is for: new components, or manifests that do not name a managed namespace;
      • why changes to an existing stack still go through a PR to main;
      • that Argo CD reads Gitea over in-cluster HTTP, while people push to https://git.<domain>;
      • the one-time credential setup: a read:repository token, then devops config set gitea.argocd_token and push-secrets;
      • start, follow, end;
      • that trial namespaces get no NetworkPolicy unless the trial brings one;
      • that every Application on main reads GitHub, and why.
  • uv run devops ci passes within its 5-minute budget.

Checks a person runs (on the cluster's kube context, after #1081's and #1090's checks pass):

  • Pending a person, Credential:
    • uv run devops k8s push-secrets --only argocd/gitea-repo-creds exits 0.
    • kubectl -n argocd get secret <masked-token> -o jsonpath='{.metadata.labels.argocd\.argoproj\.io/secret-type}{"\n"}' prints repo-creds (labels only, no value read), and kubectl -n argocd exec deploy/argocd-repo-server -- env GIT_TERMINAL_PROMPT=0 git ls-remote http://gitea-http.gitea.svc.cluster.local:3000/dan-petty/devops-cli.git HEAD fails with an authentication error, not "connection refused" or a timeout. That shows the path is open.
  • Pending a person, Trial:
    1. In a devops-cli worktree, add a directory k8s/trial-smoke/ holding one ConfigMap with no namespace. Commit it on a branch try/smoke and run git push gitea try/smoke. Nothing goes to GitHub.
    2. uv run devops argo cd trial start --branch try/smoke --path k8s/trial-smoke exits 0.
    3. Within 5 minutes, kubectl -n trial-try-smoke get configmap lists the ConfigMap, and kubectl get ns trial-try-smoke -o jsonpath='{.metadata.labels.pod-security\.kubernetes\.io/enforce}' prints restricted.
    4. Push a change to the ConfigMap on Gitea. It reaches the cluster within one reconciliation.
    5. uv run devops argo cd trial end try-smoke exits 0, and kubectl get ns trial-try-smoke reports NotFound.
  • Pending a person, Fenced:
    • a trial whose path renders a manifest with namespace: llm stays OutOfSync, and Argo CD reports that the namespace is not permitted in project trial. Nothing in llm changes;
    • a trial whose path renders a Namespace (any name) fails to sync, and Argo CD reports that the cluster-scoped kind is not permitted. kubectl get ns trial-<name> -o jsonpath='{.metadata.labels.pod-security\.kubernetes\.io/enforce}' still prints restricted.
  • Pending a person, Gitea outage:
    1. With a trial running, kubectl -n gitea scale deploy/gitea --replicas=0.
    2. Every Application outside project trial stays Synced and Healthy.
    3. The gitea Application, which reads GitHub, scales Gitea back within its self-heal interval.

Key questions

Strategic alignment

Update 2026-10-08: refinement

Alternatives check of 2026-11-18: none.
Tool: none found.
Reason: Searches found Argo CD and Gitea as building blocks, plus a generic preview-environment example; no tool provides the Gitea-backed trial CLI, namespace fence, credentials and cleanup.

Lacks:

  • No ready-made trial start, end or list command
  • No bundled Gitea repo credential, AppProject fence or egress rule
  • No per-trial namespace creation with restricted Pod Security and cleanup

Proposed design

Problem statement

Argo CD reads GitHub for every Application. The owner wants iteration branches and open pull requests to deploy from Gitea in-cluster. This item delivers the manual trial path: AppProject trial, the Gitea repository credential, the Argo CD egress rule, and devops argo cd trial start, end and list. It defers automatic all-open-PR Applications and the PR image path to a new issue. That part needs a namespace lifecycle, the shared credential from #1291, and the perimeter from #1371.

Acceptance criteria

Requirement: Trial AppProject

The AppProject trial SHALL admit only Gitea source URLs, only trial-* destination namespaces, and no cluster-scoped resource.

Scenario: Trial project fields

  • WHEN the test reads the trial AppProject from k8s/argocd/apps/projects.yaml
  • THEN it asserts sourceRepos is exactly http://gitea-http.gitea.svc.cluster.local:3000/*/*, destinations is exactly namespace trial-* on https://kubernetes.default.svc, and clusterResourceWhitelist is exactly [].

Requirement: Managed destination isolation

No destination of AppProject homelab or homelab-system SHALL match trial-*.

Scenario: Managed projects do not admit trial namespaces

  • WHEN the test reads every destination namespace of projects homelab and homelab-system
  • THEN it asserts no namespace matches the glob trial-*.

Requirement: GitHub safety rule

Every git source of every Application under k8s/argocd/ SHALL be https://github.com/dan-petty/devops-cli.git, except the one Application that #1291 exempts, and no Application SHALL name a Gitea URL.

Scenario: No unexempted Application reads Gitea

Requirement: Trial Applications orphan ignore

The homelab AppProject orphan-ignore list SHALL include Applications named trial-*.

Scenario: Trial Applications are not pruned

  • WHEN the test reads the orphan ignore list of the homelab AppProject
  • THEN it asserts an entry for group argoproj.io, kind Application, and name trial-*.

Requirement: Gitea repository credential

The push-secrets table SHALL contain a row for Secret argocd/gitea-repo-creds with the repo-creds label, the fixed Gitea URL, the configured username, the git type, the keyring token, stack gitea, no restart target, and a gate on namespace gitea.

Scenario: Credential row and gate

  • WHEN the test reads the push-secrets table and runs the row against a stub cluster without namespace gitea
  • THEN it asserts the row, its label and literals, and that the row is skipped.

Requirement: Argo CD egress to Gitea

The Argo CD perimeter SHALL admit egress to pods in namespace gitea on TCP 3000.

Scenario: Gitea egress tuple

  • WHEN the test reads k8s/argocd/networkpolicy.yaml
  • THEN it asserts an egress rule with namespace selector gitea and port TCP 3000.

Requirement: Trial start objects

devops argo cd trial start SHALL create a trial- namespace with restricted Pod Security and SHALL apply a trial Application that reads the Gitea branch and path.

Scenario: Rendered trial objects

  • WHEN the test runs trial start --branch try/smoke --path k8s/trial-smoke with a recording CRD stub and a Gitea MockTransport
  • THEN it asserts the Namespace name, labels and Pod Security levels, and the Application project, in-cluster repoURL, revision, path, destination, finalizer, sync options, and no CreateNamespace.

Requirement: Trial start branch check

devops argo cd trial start SHALL check the branch and path on Gitea before it applies anything, and SHALL exit 1 on a missing branch or a GiteaAccessBlocked.

Scenario: Missing branch applies nothing

  • WHEN the test runs trial start for a branch that Gitea returns 404 for
  • THEN it asserts exit status 1 and that the CRD stub recorded no apply.

Requirement: Trial start defaults

devops argo cd trial start SHALL default --repo to dan-petty/devops-cli and --name to the branch name made into a DNS label.

Scenario: Default repository and name

  • WHEN the test runs trial start --branch try/smoke --path k8s/trial-smoke without --repo or --name
  • THEN it asserts the Application uses dan-petty/devops-cli and the namespace is trial-try-smoke.

Requirement: Trial end order

devops argo cd trial end NAME SHALL delete the Application before the namespace and SHALL wait up to 120 s for the Application to go.

Scenario: End deletes in order

  • WHEN the test runs trial end try-smoke with a stub that records requests
  • THEN it asserts the Application delete precedes the namespace delete and the wait is 120 s.

Requirement: Trial end refusal

devops argo cd trial end NAME SHALL exit 1 for any name that does not start with trial-.

Scenario: End refuses a non-trial name

  • WHEN the test runs trial end llm
  • THEN it asserts exit status 1 and that no delete request was recorded.

Requirement: Trial list output

devops argo cd trial list SHALL list the Applications in project trial with branch, path, sync status, health and age.

Scenario: List fields

  • WHEN the test runs trial list with a stub that returns two trial Applications
  • THEN it asserts the output rows contain the five fields.

Requirement: Trial dry run

devops argo cd trial start --dry-run SHALL print the Application and SHALL make no apply request.

Scenario: Dry run records no apply

  • WHEN the test runs trial start --dry-run
  • THEN it asserts the printed Application and no recorded apply.

Requirement: Trial help and generated docs

The trial help strings SHALL be in src/devops_cli/lang/en/help.py, and docs/commands/argo.md and docs/CLI_REFERENCE.md SHALL be regenerated.

Scenario: Generated docs name trial commands

  • WHEN the test runs uv run devops docs generate
  • THEN it asserts both generated files contain devops argo cd trial start, end, and list.

Requirement: Trial README

The Gitea section of k8s/README.md SHALL describe trial purpose, credential setup, start, follow, end, and the GitHub-versus-Gitea split.

Scenario: README covers trial topics

  • WHEN the test reads the Gitea section of k8s/README.md
  • THEN it asserts the section names every required topic.

Requirement: CI budget

uv run devops ci SHALL pass within its 5-minute budget.

Scenario: CI passes

  • WHEN the test runs uv run devops ci on the branch
  • THEN it asserts exit code 0 within 300 s.

Existing Tool Considered

The alternatives check of 2026-10-29 found no tool that covers the custom trial lifecycle. Argo CD covers the AppProject fence and reconciliation, and Gitea covers the forge. The custom CLI costs about 9,000 tokens to build, 2,500 to keep and 1,200 to fix, with about 2 days elapsed.

Key questions

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#755, #741, #1081, #1090

Activity

  1. added
    type/feature
    scope/k8s
    scope/cli
    priority/p2-medium
    on Oct 3, 2026
  2. changed the title [-]feat(k8s): argo cd reads the homelab's manifests from the in-cluster gitea mirror, and the devcontainer git daemon is gone[/-] [+]feat(k8s): argo cd deploys iteration branches from gitea into trial namespaces while everything on the release branch keeps reading github, and the devcontainer git daemon is gone[/+] on Oct 3, 2026
  3. changed the title [-]feat(k8s): argo cd deploys iteration branches from gitea into trial namespaces while everything on the release branch keeps reading github, and the devcontainer git daemon is gone[/-] [+]feat(k8s): argo cd deploys iteration branches from gitea over in-cluster http into fenced trial namespaces, while everything on the release branch keeps reading github[/+] on Oct 3, 2026
  4. changed the title [-]feat(k8s): argo cd deploys iteration branches from gitea over in-cluster http into fenced trial namespaces, while everything on the release branch keeps reading github[/-] [+]feat(k8s): argo cd points to gitea for git and container registries, serving development versions to the cluster for all open pull requests[/+] on Oct 6, 2026
  5. dan-petty commented on Oct 18, 2026

    @dan-petty
    OwnerAuthor

    Correction from a read-only cluster audit (2026-10-17, main 3dd7fa6): the ApplicationSet controller is not off.

    • k8s/argocd/values.yaml:87-88 sets applicationSet: enabled: false, but chart argo-cd 10.9.6 has no applicationSet.enabled key (chart values.yaml:3546-3551: name, replicas: 1), and its applicationset Deployment template has no if-guard. helm template with the repo values renders the controller at replicas 1.
    • Live: Deployment argocd/argocd-applicationset-controller runs 1/1, with a Service on 7000. Its Role grants create/delete/patch/update on applications and applicationsets and get/list/watch on secrets in argocd. No NetworkPolicy selects the pod, and get applicationsets -A returns nothing.
    • The argocd perimeter item (filed separately) sets applicationSet.replicas: 0 with a comment pointing here. When this item enables the Pull Request generator, it sets replicas to 1 or more and adds a NetworkPolicy for the controller's webhook port 7000 and metrics port 8080, inside the namespace's default-deny perimeter.
  6. dan-petty commented on Oct 24, 2026

    @dan-petty
    OwnerAuthor

    Findings from the delivery of #1081 (PR #2145, 2026-10-24) that this item must use:

    • Image push and pull path. A node's container runtime resolves names with the node's DNS, so it cannot pull from Gitea's in-cluster address (gitea-http.gitea.svc.cluster.local:3000). Cloudflare refuses a request body over 100 MB (Free and Pro plans) with 413, so a large image layer cannot be pushed through https://git.<domain>. This item must choose a path that does neither: for example, a pull address that the nodes can reach on the LAN, and pushes from inside the cluster.
    • Argo CD egress. Argo CD's egress NetworkPolicy does not allow TCP 3000 to namespace gitea yet; Gitea's own perimeter (feat(k8s): the homelab runs gitea under argo cd as a read-write internal forge, served in-cluster over http and to workstations at https://git.<domain> through the cloudflare tunnel, with its admin secret pushed from the keyring #2145) already admits argocd-repo-server.
    • URLs. Gitea's ROOT_URL is the in-cluster address with PUBLIC_URL_DETECTION = auto. Gitea 1.27.3 builds clone URLs and the registry token realm of each request from its Host header and X-Forwarded-Proto, so requests through the tunnel get https://git.<domain> URLs. Text that Gitea writes outside a request (the links that a push prints) shows the in-cluster address.
    • Node mirrors. dan-petty/homelab#7 configures the nodes' registries.yaml; its mirror for Gitea needs the address from the first point, and credentials in configs.<mirror>.auth.
  7. 9 remaining items

  8. changed the title [-]feat(k8s): argo cd points to gitea for git and container registries, serving development versions to the cluster for all open pull requests[/-] [+]feat(k8s): Point Argo CD to Gitea for git and PR dev images[/+] on Nov 6, 2026
  9. dan-petty commented on Nov 6, 2026

    @dan-petty
    OwnerAuthor

    The job shortened the title of this item. The summary had 128 characters, and the limit is 60. The type and the scope stay.

    • Before: feat(k8s): argo cd points to gitea for git and container registries, serving development versions to the cluster for all open pull requests
    • After: feat(k8s): Point Argo CD to Gitea for git and PR dev images
    • Source of the summary: the background model
  10. devops-cli-service commented on Nov 18, 2026

    @devops-cli-service
    Contributor

    The result in the alternatives block of the issue body changed. Before this check: not-applicable, no tool. A person decides what the new result means for the item.

    Searches (10)

    Tools considered:

    Searches run:

    • open source Kubernetes ephemeral preview environments Argo CD pull request, results: 5
    • Argo CD ApplicationSet Pull Request generator Gitea support, results: 5
    • Kubernetes preview environment controller open source pull request namespace, results: 5
    • "ApplicationSet" "Pull Request" generator Gitea, results: 5
    • argo-cd.readthedocs.io application-set pull request generator, results: 5
    • Argo CD ApplicationSet Pull Request generator documentation, results: 5
    • argo application set pull request generator, results: 5
    • vcluster preview environments kubernetes, results: 5
    • Argo CD ApplicationSet pull request generator Gitea SCM provider, results: 5
    • preview environment operator gitea argocd, results: 5

    Sources:

  11. added
    status/in-progress
    and removed
    status/ready
    on Nov 19, 2026
  12. added
    status/in-review
    and removed
    status/in-progress
    on Nov 19, 2026
  13. removed
    status/in-review
    on Nov 19, 2026
  14. devops-cli-service commented on Nov 19, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-19 17:17 UTC

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/mediumpriority/p2-mediumscope/cliscope/k8stype/featurevalue/medium

    Type

    No type

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions