Skip to content

feat(k8s): record each live ConfigMap change of the Service #5221

Done

Description

@dan-petty

Problem or Motivation

The live ConfigMap devops-cli-config changed 21 times in the 7 days to 2026-11-12 (kube-state-metrics). No record gives what changed, who changed it or why. The ConfigMap holds the models, the mode of each Service row, the budgets and the timeouts, so a change can change the job grades. The project review (#5219) flags a config change in a before-and-after compare. It can count the changes, but it cannot name them.

How the ConfigMap reaches the cluster today:

  • devops k8s deploy-stack --stack devops renders it from the template k8s/devops/configmap.example.yaml (in git) and from values of the local config.yaml (not in git, because the repository is public), and applies it with kubectl apply (k8s/README.md, "Go-live check" and the table of values). The live object has one field manager, kubectl-client-side-apply.
  • Argo CD does not own it: k8s/argocd/apps/projects.yaml lists it under orphanedResources.ignore.
  • The only trace on the object is the annotation kubectl.kubernetes.io/last-applied-configuration. It holds the last state and no history.
  • 20 commits changed the template in the same 7 days, but no record joins a live change to a commit, to an issue or to a value of config.yaml.

Proposed Solution & Architectural Design

Use the standard record. Measure the cost of each option and record the choice in the proposal ## Feasibility section:

  1. Option A: the public part of the ConfigMap comes from git through Argo CD, as llm-gateway-config does (a Kustomize configMapGenerator with a hash name, k8s/README.md and fix(k8s): a changed gateway ConfigMap rolls the gateway deployment, so deploy-stack never leaves a stale pod #1929). The private values of config.yaml (the repositories and the App identifiers) stay out of git, in a second object that deploy-stack writes. Each change of the public part is then a commit with its pull request and issue, and the hash name rolls the pods, so the hand restart of the Go-live check and the order problem of refactor(roadmap): remove the dead plan and review step classes #4036 go.
  2. Option B: deploy-stack writes annotations on the ConfigMap: the git commit of the template, the SHA-256 of the rendered data, the names (not the values) of the settings that changed, and an optional reason (an issue number). It logs the same fields as one record configmap_changed, so Loki keeps the history.
  3. A change by kubectl edit or kubectl patch does not go through either option. The Kubernetes audit log is the standard record of each writer. It is a change of the control plane, so it is an owner step if the item needs it.

Cost to build (estimate): option A about 0.6 M tokens and 3 hours elapsed; option B about 0.4 M tokens and 2 hours elapsed. Keep: no cost at run time beyond one annotation or one log record for each apply.

Target Subsystem

k8s/devops/, k8s/argocd/, src/devops_cli/commands/k8s/stack_lifecycle.py, k8s/README.md.

Existing Tool Considered

Argo CD with a Kustomize configMapGenerator (in use for the gateway), Kubernetes annotations, the Kubernetes audit log, and Loki for the change records. No new tool.

Acceptance Criteria

  • The proposal ## Feasibility section shows how each value of the ConfigMap reaches the cluster today, and names the option with its evidence.
  • Each change of the live ConfigMap gives one record that names the changed settings (no values), the git commit of the template and the time. A test of the renderer pins the record.
  • One query (Loki, the Kubernetes API or git) lists the changes of the last 7 days with the setting names.
  • No private value of config.yaml goes into git or into the record.
  • k8s/README.md describes the new path, and the Go-live check stays true.

Dependencies

None.

Related

Source: #5219

Alternatives check of 2026-11-19: 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-19, maintained.
Reason: Searches found no single tool for the whole need; Argo CD covers only the public, Git-tracked ConfigMap path and leaves private values, direct edits, field-level change records and a seven-day query uncovered.

Covers:

  • Git history for the public ConfigMap template
  • A commit and pull request for each public change
  • Hash-suffixed ConfigMap name rolls the pods

Lacks:

  • No record of private config.yaml values
  • No field-level names of changed settings
  • No record of direct kubectl edit or patch
  • No built-in seven-day history query

Proposed design

Problem statement

The live ConfigMap devops-cli-config changed 21 times in the 7 days to 2026-11-12. No record names the changed settings, the template commit or the time. devops k8s deploy-stack --stack devops renders the object from k8s/devops/configmap.example.yaml and the private config.yaml, and applies it with kubectl apply from the caller's checkout. The object keeps only its last state. This item makes each successful apply that changes the data write annotations: changed setting names (no values), template commit, data SHA-256 and time. It also writes one configmap_changed WARNING log record and one key of a 30-day history ConfigMap. One query then lists the changes of the last 7 days. A direct kubectl edit or kubectl patch is deferred to #6428. The Argo CD AppProject ignore entry is deferred to a dan-petty/homelab issue, because k8s/argocd/apps/projects.yaml is an environment path frozen in this repository.

Acceptance criteria

Requirement: OpenSpec records the path and the choice

The OpenSpec change SHALL state how each value of the ConfigMap reaches the cluster today and SHALL name the chosen option with its sources.

Scenario: OpenSpec validator

  • WHEN The validator uv run devops ci --check --only openspec runs on the change.
  • THEN It passes with a ## Feasibility section that names the render, the apply path, the deferred audit log and the option's sources.

Requirement: Change record names settings

The comparer SHALL name each changed setting by its dotted path and SHALL NOT hold its value.

Scenario: One changed setting

  • WHEN A test gives the comparer two rendered data maps whose devops-cli.yaml differs only at ai.model.
  • THEN The record lists ai.model and holds no value of ai.model.

Requirement: Annotations on the ConfigMap

deploy-stack SHALL put roadmap.devops-cli/config-template-commit, roadmap.devops-cli/data-sha256, roadmap.devops-cli/changed-settings, roadmap.devops-cli/changed-at and, when given, roadmap.devops-cli/change-reason in the manifest that it applies when the rendered data differs from the live data.

Scenario: Rendered annotations with a reason

  • WHEN A test renders the manifest that deploy-stack applies for changed data with an issue number as the reason.
  • THEN The rendered object holds all five annotations, and roadmap.devops-cli/changed-settings names the changed setting and no value.

Requirement: History object is created when absent

deploy-stack SHALL create ConfigMap devops-cli-config-changes in namespace devops when the read finds none, before it adds a record key.

Scenario: No history object

  • WHEN A test runs the history write against a kubectl stub that answers NotFound to the read.
  • THEN The command applies the empty history object before it patches the record key.

Requirement: History object holds one key for each change

deploy-stack SHALL add one data key <epoch seconds>-<first 8 characters of the data SHA-256> with one JSON line and SHALL delete each key older than 30 days in the same merge patch of ConfigMap devops-cli-config-changes.

Scenario: Add a key and prune

  • WHEN A test builds the merge patch for one record against a history data map that holds a key older than 30 days.
  • THEN The patch adds the new key and deletes the old key, and the new key holds only letters, digits, -, _ and ..

Requirement: No record when the data does not change

deploy-stack SHALL write no annotation, no history key and no log record when the rendered data has the same SHA-256 as the live data.

Scenario: An unchanged deploy

  • WHEN A test gives the comparison the same data twice and runs the apply path.
  • THEN It builds no record, and the command sends no history patch and logs no configmap_changed record.

Requirement: No record for a failed apply

deploy-stack SHALL patch the history object and emit the log record only after kubectl apply exits 0.

Scenario: Failed apply

  • WHEN A test runs the apply path with a kubectl stub that exits non-zero for the apply.
  • THEN The command sends no patch and the log holds no configmap_changed record.

Requirement: WARNING log record

deploy-stack SHALL emit one configmap_changed record at WARNING on logger devops_cli.k8s.configmap for each successful apply that changes the data.

Scenario: One record through the OTel bridge

  • WHEN A test attaches OTelLoggingHandler with a fake exporter and runs the apply path with one changed setting.
  • THEN The exporter receives one record named configmap_changed with the changed setting names, the template commit and the time.

Requirement: Private values stay out

The annotations, the history line and the log record SHALL NOT hold a value of config.yaml or of the rendered data.

Scenario: Private value sentinel

  • WHEN A test renders the record with a sentinel value under service.repos and a change of another setting.
  • THEN The three records name service.repos and hold no sentinel value.

Requirement: Seven-day history query

The history object SHALL answer one query that lists the changes of the last 7 days with the setting names, from lines whose time is an ISO-8601 UTC string.

Scenario: Live query

  • WHEN The live check runs kubectl -n devops get configmap devops-cli-config-changes -o json | jq -r '.data[] | fromjson | select((.time | fromdateiso8601) >= (now - 604800)) | [.time, (.changed_settings | join(","))] | @tsv'.
  • THEN It prints one line per apply of the last 7 days, each with the time and the changed setting names and no value.

Requirement: Docs describe the record

k8s/README.md SHALL describe the annotation keys, the history object, the configmap_changed record and the seven-day query, and the Go-live check of docs/CLUSTER.md SHALL keep its commands.

Scenario: Docs validator

  • WHEN The validator uv run devops ci --check --only docs runs.
  • THEN It passes with the new k8s/README.md section and the unchanged Go-live check commands of docs/CLUSTER.md.

Existing Tool Considered

Argo CD (https://github.com/argoproj/argo-cd), Apache-2.0, last activity 2026-11-19, maintained: the alternatives check of 2026-11-19 holds the verdict in-use, and its block in the issue body states what the tool covers and what it lacks. This item keeps the deploy-stack apply path that Argo CD does not own and builds only the comparison and the record text. It covers the lacks in the block by keeping private values in the apply path, naming changed settings without values, deferring direct kubectl edit and kubectl patch writers to #6428, and answering the seven-day query from the history ConfigMap. Cost to build that code: about 0.4 M tokens and 2 hours elapsed. Cost to keep: one kubectl get, one kubectl apply, one merge kubectl patch and one log record for each deploy. Cost to fix: none while the ConfigMap shape and the OTel handler stay as they are.

Key questions

  • How does the live ConfigMap reach the cluster today?: devops k8s deploy-stack --stack devops renders k8s/devops/configmap.example.yaml with the active config.yaml in memory and sends the result to kubectl apply -f - from the caller's checkout, on both _deploy_native_manifests and _handle_argo_managed_deployment. Argo CD does not own the object: AppProject homelab lists ConfigMap devops-cli-config under orphanedResources.ignore, and the Go-live check runs the command from a checkout of main. The object therefore keeps only the last state, in its data and in kubectl.kubernetes.io/last-applied-configuration, and k8s/README.md tells a person not to change it with kubectl edit or kubectl apply, because no record of such a change stays. [sources: src/devops_cli/k8s/configmap.py:135, src/devops_cli/commands/k8s/stack_lifecycle.py:944, src/devops_cli/commands/k8s/stack_lifecycle.py:953, src/devops_cli/commands/k8s/stack_lifecycle.py:1294, src/devops_cli/commands/k8s/stack_lifecycle.py:1317, k8s/argocd/apps/projects.yaml:95, docs/CLUSTER.md:176, k8s/README.md:1093]
  • Which option records a ConfigMap change of the Service?: Option B, extended: deploy-stack compares the live data with the new render, writes the five annotations on the object it applies, adds one key to history ConfigMap devops-cli-config-changes with one merge patch and emits one WARNING configmap_changed record. Option A moves only the public part to git and needs a split of the object. The audit log is a k3s server setting of the infra repository and is deferred to feat(k8s): Record kubectl writers of the ConfigMap #6428. (best practice) [sources: docs/CLUSTER.md:176, k8s/README.md:113, k8s/README.md:1092, k8s/README.md:1093, src/devops_cli/telemetry/logging_bridge.py:182, k8s/argocd/apps/projects.yaml:95]
    • Chosen: Option B, extended: comparison, five annotations, a history ConfigMap and one WARNING record from deploy-stack. It records each deploy-stack apply, names the changed settings and the template commit, keeps private values out of git and out of the record, and answers the seven-day query with one kubectl command.
    • Rejected: Option A: move the public part to Argo CD with a Kustomize configMapGenerator. It gives git history for the public part only, and it needs a second object and a split of the private values, so it does not record a private change in one pull request.
    • Rejected: Option C: the Kubernetes audit log only. The policy and the log path are k3s server settings of the infra repository, and the Request level holds the private data.
  • Where does the seven-day history of the changes live?: In ConfigMap devops-cli-config-changes of namespace devops, one data key for each change, pruned to 30 days. k8s/README.md already says that devops config set keeps a copy of config.yaml and a record of the changed keys with no value, so this object is the same record for the deploy path. The object sits beside devops-cli-config, and one kubectl query reads it. (best practice) [sources: k8s/README.md:1092, docs/CLUSTER.md:179, src/devops_cli/telemetry/logging_bridge.py:182, k8s/argocd/apps/projects.yaml:95]
    • Chosen: A history ConfigMap written by deploy-stack. It is in the cluster, one kubectl command reads it, it needs no telemetry, and it holds setting names only.
    • Rejected: Loki only, from the configmap_changed record. The record reaches Loki only while telemetry is enabled and pointed at the collector, so a run with telemetry off leaves no history.
    • Rejected: The Kubernetes audit log. The policy is a host setting of the infra repository, so the item would wait on an owner step.
  • Which annotation keys hold the change record?: Use the project's recorded annotation prefix roadmap.devops-cli/: roadmap.devops-cli/config-template-commit, roadmap.devops-cli/data-sha256, roadmap.devops-cli/changed-settings, roadmap.devops-cli/changed-at and the optional roadmap.devops-cli/change-reason. (best practice) [sources: docs/adr/0022-one-repository-reference-names-the-objects-labels-and-keys-of-each-repository.md:37, docs/adr/0022-one-repository-reference-names-the-objects-labels-and-keys-of-each-repository.md:77, docs/CLUSTER.md:74]
    • Chosen: roadmap.devops-cli/ prefix. It is the prefix the project records for its object annotations, it is a DNS subdomain, and it does not claim the app.kubernetes.io/ keys that the template uses for the application name and its part.
    • Rejected: devops-cli/ prefix. It is a single label and not the prefix the project records, so it risks a collision with another owner's keys.
    • Rejected: app.kubernetes.io/ prefix. The template already uses those keys for the application name and its part, not for a change record.
  • At which log level does the record reach the collector?: WARNING, on logger devops_cli.k8s.configmap, which is the module that builds the record. OTelLoggingHandler exports WARNING and above by default and special-cases only devops_cli.roadmap.job_result at INFO, so the record passes with no change to the handler. (best practice) [sources: src/devops_cli/telemetry/logging_bridge.py:182, src/devops_cli/telemetry/logging_bridge.py:205, src/devops_cli/telemetry/logging_bridge.py:213]
    • Chosen: WARNING on devops_cli.k8s.configmap. It passes the default threshold of the handler with no change to the handler.
    • Rejected: INFO on the new logger. The handler drops it unless every process lowers the handler's minimum level.
    • Rejected: Add the logger to the INFO allowlist. It adds a second exception to the handler for no need.
  • Where in the apply path is the record written?: A new _apply_devops_configmap in src/devops_cli/commands/k8s/stack_lifecycle.py reads the live data, calls the pure comparison and annotation builders of src/devops_cli/k8s/configmap.py, and applies the annotated manifest through _apply_rendered; the history patch and the log record run only after that call returns. Both apply paths (_deploy_native_manifests and _handle_argo_managed_deployment) call it in place of _apply_rendered. (best practice) [sources: src/devops_cli/commands/k8s/stack_lifecycle.py:944, src/devops_cli/commands/k8s/stack_lifecycle.py:953, src/devops_cli/commands/k8s/stack_lifecycle.py:1294, src/devops_cli/commands/k8s/stack_lifecycle.py:1317, src/devops_cli/k8s/configmap.py:58, src/devops_cli/k8s/configmap.py:135]
    • Chosen: After a successful apply, from pure builders in the command layer. The record is true only when the apply succeeds, the live read stays at the kubectl seam, and the pure builders let a test pin the record offline.
    • Rejected: Before the apply. A failed apply would leave a record of a change that did not happen.
    • Rejected: A cluster read inside the pure renderer. The renderer is pure and tested with no cluster, so a kubectl call there would break that seam.
  • How does deploy-stack add a history line without losing a concurrent one?: Use one data key for each record, named <epoch seconds>-<first 8 characters of the data SHA-256>, added by one kubectl patch --type merge. An ISO-8601 time holds :, which a ConfigMap key forbids, so the key holds the epoch seconds and the JSON line holds the ISO time. The same patch deletes the keys older than 30 days, and a merge patch adds or replaces only the keys it names, so two deploys at the same time keep both records. (best practice) [sources: docs/adr/0022-one-repository-reference-names-the-objects-labels-and-keys-of-each-repository.md:37, src/devops_cli/k8s/argocd_overrides.py:138, src/devops_cli/commands/k8s/stack_lifecycle.py:1044, k8s/README.md:1092]
    • Chosen: One data key for each record, added by one merge patch. A merge patch adds or replaces only the named keys, so two deploys at the same time keep both records, and the same patch prunes the old keys. The epoch-second key is a valid ConfigMap key.
    • Rejected: One changes.jsonl key that the command reads, appends and writes back. Two deploys that run together read the same text, and the second write drops the record of the first.
    • Rejected: One Secret that holds the history. No need: the record holds setting names and no value.
  • Should this item change the Argo CD orphan ignore list?: No. The edit belongs to dan-petty/homelab, because k8s/argocd/apps/projects.yaml is an environment path that the k8s environment-freeze gate refuses in devops-cli (tests/gate/k8s_checks/environment_freeze.py:38-45; docs/HOMELAB_REPO_SWITCH.md Step 11). The new issue adds ConfigMap devops-cli-config-changes to orphanedResources.ignore of AppProject homelab beside devops-cli-config. This item creates the history object and leaves the warning to that issue. (best practice) [sources: tests/gate/k8s_checks/environment_freeze.py:38-45, docs/HOMELAB_REPO_SWITCH.md, k8s/argocd/apps/projects.yaml:95]
    • Chosen: Defer the AppProject edit to a dan-petty/homelab issue. k8s/argocd/apps/projects.yaml is an environment path, and the k8s environment-freeze gate refuses a change to it in devops-cli.
    • Rejected: Edit k8s/argocd/apps/projects.yaml in this item. The k8s environment-freeze gate fails the pull request, as the stage return states.
    • Rejected: Leave the ignore list unchanged with no new issue. Argo CD reports the untracked history ConfigMap as orphaned, so the homelab issue must record the edit.
  • Does the item enable Kubernetes audit logging?: No. It defers the audit log to feat(k8s): Record kubectl writers of the ConfigMap #6428. A cluster logs no audit event without a policy file and a log path, and both are kube-apiserver flags of the k3s server in the infra repository. The deferred issue uses the Metadata level, because Request holds the request body, which is the private data. (best practice) [sources: k8s/README.md:556]
    • Chosen: Defer the audit log to feat(k8s): Record kubectl writers of the ConfigMap #6428. The policy is a host setting outside this repository and an owner step, and the main item can record the deploy-stack path in one pull request.
    • Rejected: Enable the audit log in this item. It makes the item wait on a k3s server change in the infra repository, and the Request level would write the private values into the audit log.
  • How does deploy-stack name the git commit of the template?: From the checkout, with git log -1 --format=%H -- k8s/devops/configmap.example.yaml, run with an argument array and shell=False as every external program is. When the product folder is not a git checkout the commit is empty and the annotation is left off, and the data SHA-256 still names the state. (best practice) [sources: CONTRIBUTING.md:70, ARCHITECTURE.md:144, src/devops_cli/k8s/configmap.py:145, src/devops_cli/commands/k8s/stack_lifecycle.py:944]
    • Chosen: The last commit that touched the template. It names the template that the render reads, and the data SHA-256 covers a change that comes from config.yaml alone.
    • Rejected: git rev-parse HEAD of the checkout. It changes on each unrelated commit, so two applies of one template would name two commits.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Moved to new items

#6428, #7148

Activity

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

    @dan-petty
    OwnerAuthor
  4. added
    priority/p2-medium
    on Nov 12, 2026
  5. devops-cli-service commented on Nov 17, 2026

    @devops-cli-service
    Contributor

    Waiting for the alternatives check to run. The next refine round looks at the item again after the check records a verdict.

  6. devops-cli-service commented on Nov 19, 2026

    @devops-cli-service
    Contributor

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

    Searches (10)

    Tools considered:

    Searches run:

    • track Kubernetes ConfigMap changes history GitOps diff tool, results: 5
    • Kubernetes ConfigMap change history audit record open source tool, results: 5
    • kubectl audit ConfigMap changes record annotations, results: 5
    • kubernetes audit log ConfigMap change history, results: 5
    • open source tool diff Kubernetees ConfigMap changes, results: 5
    • GitOps Argo CD ConfigMap history change record, results: 5
    • "ConfigMap" "change history" Kubernetes, results: 5
    • site:github.com kubernetes configmap change history tool, results: 5
    • site:github.com kubernetes audit log configmap changes, results: 5
    • configmap history kubernetes github, results: 5

    Sources:

  7. added
    status/ready
    and removed
    status/new
    on Nov 19, 2026
  8. devops-cli-service commented on Nov 19, 2026

    @devops-cli-service
    Contributor

    Next step: the stage job writes the plan of the item. See Moved to new items in the section Proposed design of the body.

  9. dan-petty commented on Nov 25, 2026

    @dan-petty
    OwnerAuthor

    Returning #5221 for re-scoping because one acceptance criterion modifies a path frozen for dan-petty/homelab while another product path now owns it:

    • Requirement: Argo CD ignores the history object requires editing k8s/argocd/apps/projects.yaml (AppProject homelab orphanedResources.ignore) and passing uv run devops ci --check --only k8s.
    • Checked tests/gate/k8s_checks/environment_freeze.py:38-45: is_environment_path("k8s/argocd/apps/projects.yaml") == True, so any pull request changing k8s/argocd/apps/projects.yaml in devops-cli fails the k8s (environment-freeze) gate (docs/HOMELAB_REPO_SWITCH.md Step 11).

    Please split the k8s/argocd/apps/projects.yaml orphanedResources.ignore edit into a dan-petty/homelab issue and keep the devops k8s deploy-stack ConfigMap change-tracking implementation in #5221.

  10. added
    status/new
    and removed
    status/ready
    on Nov 25, 2026
  11. added
    status/ready
    and removed
    status/new
    on Nov 25, 2026
  12. devops-cli-service commented on Nov 25, 2026

    @devops-cli-service
    Contributor

    Next step: the stage job writes the plan of the item. See Moved to new items in the section Proposed design of the body.

  13. added
    status/in-progress
    and removed
    status/ready
    on Nov 25, 2026
  14. added
    status/in-review
    and removed
    status/in-progress
    on Nov 25, 2026
  15. removed
    status/in-review
    on Nov 25, 2026
  16. devops-cli-service commented on Nov 25, 2026

    @devops-cli-service
    Contributor
  17. devops-cli-service commented on Nov 25, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-25 17:09 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/k8ssource/agenttype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions