Skip to content

fix(k8s): set the kube context and namespace on devops pods #4512

Closed

Description

@dan-petty

Problem Description

The spans and the OTLP log records of the devops-cli pods name the wrong cluster. All 1,705 roadmap-service spans of 2026-11-11 03:50Z-04:04Z have k8s.cluster.name=minikube. The runner OTLP log records have k8s_cluster_name=minikube. The workstation spans have homelab-k3s, which is the cluster name that the monitoring stack uses (k8s/monitoring/k8s-monitoring-values.yaml, cluster.name). The pod spans also have no k8s.namespace.name.

Cause: _detect_k8s_context in src/devops_cli/telemetry/tracer.py reads K8S_CONTEXT and POD_NAMESPACE from the environment first. No pod spec in k8s/devops/ sets them. Then the tracer uses the setting k8s.context, whose default is minikube (CONST_K8S_MINIKUBE_CONTEXT).

No code change is necessary. Each devops-cli pod spec sets the two values:

  • K8S_CONTEXT: the cluster name of the monitoring stack.
  • POD_NAMESPACE: the Downward API (metadata.namespace). The runner CronJob template is the exception: the admission policy roadmap-service-jobs refuses a Job env entry with valueFrom, so the template sets the namespace as a plain value.

The pods are the roadmap-service Deployment, the mcp-server Deployment, the CronJobs devops-cli and devops-cli-runner (the runner Job template), and the WorkflowTemplate devops-cli-rag-ingest.

Reproduction Steps

  1. In Grafana Explore, run the TraceQL { resource.service.name = "roadmap-service" } | count_over_time() by (resource.k8s.cluster.name).
  2. See that each span has minikube.

Expected vs Actual Behavior

Expected: the spans and log records of the devops pods have k8s.cluster.name=homelab-k3s and k8s.namespace.name=devops.
Actual: k8s.cluster.name=minikube, and no k8s.namespace.name.

Acceptance

  • A check of the k8s row of devops ci fails when a devops-cli container in the render of k8s/devops has no K8S_CONTEXT equal to the monitoring cluster name, or no POD_NAMESPACE that gives the namespace of its object.
  • After the rollout, TraceQL { resource.service.name = "roadmap-service" && resource.k8s.cluster.name = "minikube" } finds no new span.

Logs, Traces, or Terminal Output

Evidence: the observability study of 2026-11-11 (skeptic item W13, practice item P15). The study measured the span counts with TraceQL { } | count_over_time() by (resource.service.name, resource.k8s.cluster.name).

Out of scope: a per-pod service.instance.id and k8s.pod.name (the router change and #2536 own them).

Activity

  1. added
    source/agent
    type/bug
    scope/k8s
    status/new
    value/medium
    effort/low
    on Nov 11, 2026
  2. dan-petty commented on Nov 11, 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 fix prefix of the title gives the type.
    • Scope: scope/k8s. The (k8s) scope of the title gives the scope.
    • Priority: P2-Medium. Telemetry labels are wrong but the service still functions; this is a correctness issue in observability data.
    • Value: Medium. Incorrect cluster and namespace labels mislead debugging and monitoring queries for all devops pods.
    • Effort: Low. No code change needed; only two env vars added to existing pod specs plus a CI check.
    • Related: feat(k8s): configurable k8s context setting and conditional minikube autostart #172, which asks for a different change. Both involve the k8s.context setting, but #172 adds the setting and its default; the candidate sets the correct env var values on pod specs to override that default in telemetry.
  3. added
    priority/p2-medium
    owner/agent
    status/in-progress
    and removed
    status/new
    on Nov 11, 2026
  4. removed
    status/in-progress
    owner/agent
    on Nov 11, 2026
  5. devops-cli-service commented on Nov 11, 2026

    @devops-cli-service
    Contributor
  6. devops-cli-service commented on Nov 11, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-11 14:13 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/lowpriority/p2-mediumscope/k8ssource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions