Skip to content

fix(k8s): delete loki-ingress, whose backend the logging network policy blocks #2439

Description

@dan-petty

Problem Description

The Ingress loki-ingress in k8s/ingress/ingress-routes.yaml sends host loki.<domain> on the Traefik web entry point to Service loki, port 3100, in namespace logging. The NetworkPolicy logging-default-perimeter in k8s/logging/networkpolicy.yaml admits port 3100 only from pods in logging, from Grafana and the Alloy collectors in monitoring, and from the OpenTelemetry Collector in otel. It has no peer for Traefik, so each request through this Ingress fails.

The policy is correct. Loki runs with auth_enabled: false. A Traefik peer would open the Loki API without authentication (push, query and detected_fields) to each client that can reach Traefik. The change for #1632 recorded this decision: keep the policy closed and delete the Ingress.

Reproduction Steps

  1. Run kubectl get ingress -n logging. The list shows loki-ingress.
  2. Run kubectl get networkpolicy -n logging logging-default-perimeter -o yaml. No ingress peer selects the Traefik pods in kube-system.
  3. Send a request to http://loki.<domain>/ready through Traefik. Loki does not answer.

Expected vs Actual Behavior

  • Expected: no Ingress sends traffic to Loki, and a test fails when an Ingress sends traffic to a Service in logging again.
  • Actual: loki-ingress sends traffic to a backend that the policy blocks.

Proposed change

  • Delete loki-ingress from k8s/ingress/ingress-routes.yaml. Argo CD tracks main with prune, so it deletes the live Ingress after the merge.
  • Add an invariant test to tests/invariants/test_k8s_manifests.py: no Ingress under k8s/ names a backend Service in namespace logging.

Environment Diagnostics

Homelab k3s cluster. Argo CD Application ingress syncs k8s/ingress/ from main with prune and self-heal.

Source: #1632

Proposed design

Problem statement

The Ingress loki-ingress routes traffic to Loki in namespace logging, but the NetworkPolicy logging-default-perimeter blocks all traffic from Traefik to port 3100. Every request through this Ingress fails. The project decided in #1632 to keep the policy closed and delete the Ingress. This change removes the dead Ingress and adds a test that prevents a dead Ingress from returning.

Acceptance criteria

Requirement: loki-ingress removed

The file k8s/ingress/ingress-routes.yaml SHALL NOT contain an Ingress named loki-ingress.

Scenario: Parse the YAML and check for the Ingress name

  • WHEN A test loads every document in k8s/ingress/ingress-routes.yaml and collects the names of all Ingress objects
  • THEN The name loki-ingress is not in the collected set

Requirement: invariant test blocks logging Ingress

A test in tests/invariants/test_k8s_manifests.py SHALL fail when any Ingress document under k8s/ has metadata.namespace equal to logging.

Scenario: Add a fake Ingress in namespace logging and run the test

  • WHEN A test iterates over all Ingress documents returned by manifests() and collects those whose metadata.namespace is logging
  • THEN The collected list is empty, and the test passes

Existing Tool Considered

The project already has the test infrastructure: tests/support/k8s_tree.py provides the manifests() helper that reads all documents under k8s/, and tests/invariants/test_k8s_manifests.py holds the pattern for invariant tests. The change adds one test function of about 15 lines using the existing manifests() helper and yaml.safe_load_all, plus the deletion of one Ingress block of about 20 lines from the YAML. No external library is needed.

Key questions

  • Does the NetworkPolicy block Traefik from reaching Loki on port 3100?: Yes. The policy admits port 3100 only from pods in logging, from Grafana and the Alloy collectors in monitoring, and from the OpenTelemetry Collector in otel. No peer selects the Traefik pods in kube-system. [sources: k8s/logging/networkpolicy.yaml]
  • Did the project decide to keep the policy closed and delete the Ingress?: Yes. The design document for fix(k8s): loki runs from the grafana-community chart on loki 3.7, out of reach of cve-2026-21729 #1632 records: 'Admit Traefik in the NetworkPolicy of logging, so that loki-ingress reaches Loki. Rejected: Loki runs with auth_enabled: false, so a Traefik peer opens the API without authentication. The policy stays closed, and fix(k8s): delete loki-ingress, whose backend the logging network policy blocks #2439 deletes loki-ingress.' [sources: openspec/changes/archive/2026-10-28-1632-loki-grafana-community-chart/design.md:53]
  • How should the invariant test identify a dead Ingress for the logging namespace?: Check that no Ingress document under k8s/ has metadata.namespace equal to logging. This is equivalent to checking the backend Service namespace because Kubernetes Ingress routes to a Service in the same namespace. It is simpler than collecting Service names and matching them against backends. (best practice) [sources: tests/invariants/test_k8s_manifests.py, k8s/ingress/ingress-routes.yaml]
    • Chosen: Check metadata.namespace of every Ingress. Simpler, one field to read. Equivalent because Kubernetes Ingress routes to a Service in the same namespace. Matches the existing test pattern of reading a single field per document.
    • Rejected: Collect Service names in logging and match against Ingress backends. More complex: requires reading Service objects, building a name set, and matching against every backend path. Gives no extra coverage because an Ingress cannot route to a Service in another namespace.
  • Will Argo CD delete the live Ingress after the merge?: Yes. The Argo CD Application for ingress syncs k8s/ingress/ from main with prune and self-heal, so it removes the live Ingress when the manifest is gone. [sources: k8s/ingress/ingress-routes.yaml]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/bug
    status/new
    value/medium
    effort/low
    on Oct 28, 2026
  2. dan-petty commented on Oct 28, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/bug. The Ingress sends traffic to a backend the policy blocks, so it is a broken resource to remove.
    • Priority: P2-Medium. The policy already blocks the traffic, so no active harm occurs, but the dead resource causes confusion.
    • Value: Medium. It removes a misleading resource and adds a test that prevents a dead Ingress from returning.
    • Effort: Low. The change is one Ingress deletion in a YAML file plus one invariant test.
    • Related: fix(k8s): centralized logging perimeter hardening and fluent bit namespace scoping #121, which asks for a different change. Both concern the logging namespace perimeter, but #121 created the policy that blocks Traefik while this candidate deletes the dead Ingress that policy renders useless.
  3. added
    priority/p2-medium
    on Oct 28, 2026
  4. added
    status/ready
    and removed
    status/new
    on Oct 29, 2026
  5. devops-cli-service commented on Oct 29, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 38a0a44 (see proposed design in issue body).

  6. added a commit that references this issue on Oct 29, 2026
  7. removed
    status/ready
    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

    effort/lowpriority/p2-mediumsource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions