Skip to content

fix(argocd): argo cd syncs the argocd namespace perimeter, and the unused applicationset controller runs no replicas #1673

Closed

Description

@dan-petty

Friction

The argocd namespace has no default-deny perimeter on the Argo CD-managed homelab, although #1371 put one in git. k8s/argocd/networkpolicy.yaml is listed only in deploy-stack's native manifest list, deploy-stack skips every manifest once Application cluster exists, and no Application syncs the file. CI stays green because the deploy guard counts the native list as deployed. In the same namespace, k8s/argocd/values.yaml "disables" the ApplicationSet controller with a key the argo-cd chart does not have, so an unused controller with an Application-creating token runs with no NetworkPolicy selecting it, and open #1082 plans on the false premise that it is off.

Evidence

Live, read-only, 2026-10-17 (main = 3dd7fa6; release/v0.2.37 = 4ee3e01 has no change here):

  • kubectl get networkpolicy -n argocd lists only the chart's four ingress-only policies: argocd-application-controller, argocd-redis, argocd-repo-server, argocd-server (tracking id argocd:networking.k8s.io/NetworkPolicy). argocd-server's is ingress: [{}]. argocd-default-perimeter does not exist.
  • Pods argocd-applicationset-controller and argocd-image-updater-controller match no NetworkPolicy. No argocd pod has egress limits.
  • Every other namespace with a git perimeter has it live (cloudflared, devops, llm, logging, monitoring, otel).
  • Deployment argocd/argocd-applicationset-controller (chart argo-cd-10.9.6, v3.5.3) runs 1 replica, with a Service on 7000, and a Role granting create/delete/patch/update on applications and applicationsets and get/list/watch on secrets in argocd. kubectl auth can-i create applications.argoproj.io -n argocd --as=system:serviceaccount:argocd:argocd-applicationset-controller = yes. get applicationsets -A returns nothing. AppProject default allows */*, so a created Application reaches cluster-admin through the application controller.
  • argocd-server runs --port=8080 --metrics-port=8083 --insecure; the Service is NodePort by design (k8s/argocd/values.yaml:25-30), and Ingress argocd-ingress (traefik) exists.
  • Nothing scrapes argocd today (up{namespace="argocd"} is empty). Nodes are bare-metal k3s with no cloud metadata service, so the 169.254.169.254 exclusion is defence in depth.

Repo:

  • k8s/argocd/networkpolicy.yaml (ingress from Traefik and monitoring on 8082/8084/9121 at :31-41; egress to DNS, the API server and git/Helm with the metadata IP excluded) is registered only at src/devops_cli/commands/k8s/stack_lifecycle.py:178 (_MANIFESTS_BY_STACK["infra"]).
  • _handle_argo_managed_deployment (stack_lifecycle.py:917-943, message at :941) applies no manifests when cluster exists.
  • k8s/argocd/apps/argocd.yaml is chart plus $values only.
  • tests/test_k8s_network_policies.py:84-106 treats _MANIFESTS_BY_STACK membership as deployed. tests/test_k8s_argocd_apps.py:354-367 forbids any app syncing k8s/argocd/networkpolicy.yaml, and reads only single-source spec.source.path.
  • docs/agent/tasks/task-1371-argocd-otel-perimeters.md still lists its kubectl diff step as pending a person; fix(k8s): the argocd and otel perimeters admit 0.0.0.0/0 ingress and deploy-stack applies neither #1371 closed in v0.2.31.
  • k8s/argocd/values.yaml:80 ("Disable components unnecessary for local dev") and :87-88 applicationSet: enabled: false. Chart 10.9.6 values.yaml:3546-3551 has applicationSet.name and replicas: 1, no enabled; its applicationset Deployment template has no if-guard. helm template with the repo values renders the controller with replicas 1. With applicationSet.replicas: 0 it renders replicas 0, and a server dry run of that Deployment was accepted.
  • feat(k8s): Point Argo CD to Gitea for git and PR dev images #1082 says the ApplicationSet Pull Request generator is "off today, k8s/argocd/values.yaml:87-88".

Remedy

Tests first:

  1. Change tests/test_k8s_network_policies.py:84-106 so a policy counts as deployed only when an Argo CD Application path or source renders it as well as a native list (or it carries an owned exemption). Replace tests/test_k8s_argocd_apps.py:354-367 with a test that exactly one Application renders argocd-default-perimeter, reading both source and sources. Add an offline test that applicationSet.replicas == 0 and that applicationSet has no enabled key.
  2. Deploy the perimeter through Argo CD: add {repoURL: https://github.com/dan-petty/devops-cli, targetRevision: main, path: k8s/argocd} as a third source of k8s/argocd/apps/argocd.yaml (the directory's kustomization lists only networkpolicy.yaml), or a small argocd-perimeter Application. Do not apply it from _handle_argo_managed_deployment; that would leave an object outside git ownership.
  3. Before enabling it, settle argocd-server's exposure: either Service type ClusterIP behind Ingress argocd-ingress and the chart's global.networkPolicy.create: false (or a narrowed argocd-server policy) so the chart's ingress: [{}] stops admitting everything, or keep NodePort and admit it explicitly in the perimeter. The NodePort is a documented access path (.devops/review.md:100-101), so this is the owner's choice; the perimeter must not silently cut it.
  4. k8s/argocd/values.yaml:87-88: replace applicationSet: enabled: false with applicationSet: replicas: 0, with a comment that the chart has no enable switch for this controller, that its SA, Role, RoleBinding and Service still render, and that feat(k8s): Point Argo CD to Gitea for git and PR dev images #1082 turns it back on (with replicas >= 1 and a policy for webhook port 7000).
  5. Add metrics ports to the perimeter only when a scrape exists (Metrics for the rest of the platform #551): 8083 server, 8080 applicationset, 8443 image-updater. Existing egress rules already cover DNS, the API server, GitHub/Helm and ghcr.io.
  6. Verify with kubectl apply --dry-run=server on a throwaway copy, then after the sync: repo-server still pulls git and Helm, the controller reaches the API server, Image Updater resolves ghcr.io digests, Traefik reaches argocd-server, and the applicationset Deployment shows 0/0. Finish the fix(k8s): the argocd and otel perimeters admit 0.0.0.0/0 ingress and deploy-stack applies neither #1371 checklist in its task file.
  7. changelog.d/<issue>.md under ### Security.

Priority: P2. Severity medium: chart ingress policies already confine redis, repo-server and the controller; the open surface is argocd-server, the applicationset controller and image-updater, plus unrestricted egress from cluster-admin pods.

Proposed design

Problem statement

The argocd namespace lacks a default-deny perimeter policy, and the ApplicationSet controller runs with no replicas despite being disabled in configuration. This creates security vulnerabilities by exposing unnecessary services and allowing unrestricted access to the cluster.

Acceptance criteria

  • Criterion 1: The argocd-default-perimeter NetworkPolicy is deployed through Argo CD and properly configured with ingress from Traefik and monitoring namespace, and egress to DNS, API server, and git/Helm with metadata IP exclusion
    Verification: kubectl get networkpolicy -n argocd shows argocd-default-perimeter policy exists and matches k8s/argocd/networkpolicy.yaml
  • Criterion 2: The ApplicationSet controller Deployment runs with 0 replicas as configured in k8s/argocd/values.yaml
    Verification: kubectl get deployment -n argocd argocd-applicationset-controller shows replicas: 0
  • Criterion 3: No Argo CD Application syncs k8s/argocd/networkpolicy.yaml directly, but the policy is deployed via Argo CD's application controller
    Verification: Tests verify that exactly one Application renders argocd-default-perimeter by checking both source and sources fields
  • Criterion 4: The argocd-server Service uses ClusterIP type with Ingress and NetworkPolicy controls, rather than exposing NodePort without restrictions
    Verification: kubectl get service -n argocd argocd-server shows type: ClusterIP and appropriate NetworkPolicy is applied

Key questions

  • What is the current state of the argocd namespace perimeter?: The argocd namespace has no default-deny perimeter policy. Only the chart's four ingress-only policies exist (argocd-application-controller, argocd-redis, argocd-repo-server, argocd-server) and no argocd-default-perimeter policy is deployed. [sources: src/devops_cli/commands/k8s/stack_lifecycle.py:178, k8s/argocd/networkpolicy.yaml]
  • Why does the ApplicationSet controller run with 1 replica despite being disabled?: The configuration in k8s/argocd/values.yaml uses 'applicationSet: enabled: false' which doesn't map to the chart's actual parameter structure. The chart has no 'enabled' key for applicationSet, only 'replicas'. [sources: k8s/argocd/values.yaml:87-88, src/devops_cli/commands/k8s/stack_lifecycle.py:917-943]
  • How should the argocd-server exposure be handled?: The decision is to either use Service type ClusterIP behind Ingress with chart's global.networkPolicy.create: false, or keep NodePort but explicitly admit it in the perimeter. The NodePort is a documented access path so this choice is left to the owner. (proposed) [sources: k8s/argocd/values.yaml:25-30, .devops/review.md:100-101]
  • What is the expected behavior for the ApplicationSet controller?: The ApplicationSet controller should run with 0 replicas to disable it, as configured in k8s/argocd/values.yaml by changing 'applicationSet: enabled: false' to 'applicationSet: replicas: 0'. [sources: k8s/argocd/values.yaml:87-88, src/devops_cli/commands/k8s/stack_lifecycle.py:917-943]

Fit

Needs splitting into 4 items:

  1. Test changes to verify the perimeter is deployed through Argo CD
  2. Deploy the argocd-default-perimeter NetworkPolicy via Argo CD
  3. Configure ApplicationSet controller with 0 replicas
  4. Update argocd-server exposure handling

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/bug
    on Oct 18, 2026
  2. dan-petty commented on Oct 18, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: at intake only a critical fix goes into a release; a release start pulls Ready items in, P0 features first.

    • Type: type/bug. The candidate describes a bug where Argo CD syncs the namespace perimeter and an unused controller runs no replicas.
    • Priority: P1-High. The issue affects security by leaving the argocd namespace without a default-deny perimeter and has an unused controller running with no NetworkPolicy.
    • Value: High. This change fixes critical security issues in the argocd namespace and ensures proper network policy enforcement.
    • Effort: Medium. The fix involves modifying manifest lists, application syncing logic, and test assertions, which requires moderate development effort.
  3. dan-petty commented on Oct 18, 2026

    @dan-petty
    OwnerAuthor

    Proposal needs splitting into 4 items at 25e2cda (see proposed design in issue body).

  4. added this to the v0.2.37 milestone on Oct 19, 2026
  5. added
    status/in-progress
    status/in-review
    and removed
    status/in-progress
    on Oct 20, 2026
  6. dan-petty commented on Oct 20, 2026

    @dan-petty
    OwnerAuthor

    What changed

    #1714, merged into release/v0.2.37 as 2871b72.

    Closes #1673

    7 file(s) changed.

    How it was verified

    Check runs at 98e15a2:

    • Prune PR DevContainer Images: pass
    • Audit Defect PR Hardening: skipping
    • zizmor: pass
    • devops-cli: pass
    • bandit: pass
    • CodeQL: pass
    • DevContainer Image: skipping
    • Service Image: skipping
    • Rule Pack Tests: pass
    • Analyze (actions): pass
    • Static Analysis: pass
    • Fail-to-Pass Self-Check: pass
    • Changed-Test Independence: pass
    • Tests & Coverage: pass
    • Analyze (python): pass
    • Fail-to-Pass Check: pass
    • Dependency Freshness: skipping

    Acceptance Criteria of docs/agent/tasks/task-1673-argocd-namespace-perimeter.md:

    No Acceptance Criteria section.

  7. removed
    status/in-review
    on Oct 30, 2026
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

    source/agenttype/bug

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions