Skip to content

feat(service): the roadmap Service uses its own gateway key #3685

Closed

Description

@dan-petty

Problem

The roadmap Service calls the LLM gateway with the master key, the same key as every other caller. So the gateway cannot set a budget or a requests-per-minute limit for the Service, and a fault in the Service can spend without limit. The end_user label shows the spend per caller, but this label sets no limit.

The Service and the cluster Jobs read DEVOPS_CLI_AI_API_KEY from the same Secret devops/devops-cli (k8s/devops/roadmap-service/deployment.yaml, k8s/devops/cronjob.yaml). #1635 puts the change of the key of the Jobs out of its scope. So the Service needs its own source for this variable.

This work cannot start yet. LiteLLM keeps virtual keys only in Postgres, and the gateway has no database: no manifest under k8s/ sets DATABASE_URL, and general_settings in k8s/llm/gateway/config.yaml has no database setting. #1635 adds the database.

Blocked by #1635.

Expected

The Service calls the gateway with its own virtual key, and the key has a budget and a requests-per-minute limit. The Jobs keep their key. The Service holds no reference to the master key.

A person mints the key and stores it, because only a person changes secrets (AGENTS.md). The pull request names the Secret and the key name, and no key value.

Acceptance criteria

  • kustomize build k8s/devops/roadmap-service/ gives a Deployment that reads DEVOPS_CLI_AI_API_KEY from the source of the virtual key, and not from the source of the master key.
  • A person mints the key, with a budget and a requests-per-minute limit. This is a step for a person, and k8s/README.md gives the step.
  • k8s/README.md says which key the Service uses and how to rotate it.
  • CLUSTER_SECRETS (src/devops_cli/k8s/cluster_secrets.py) has a row for the key if devops k8s push-secrets pushes it, and a test covers the row.

Existing tool considered

LiteLLM virtual keys, on the gateway that is deployed. Nothing is built.

Related

Source: #2479

Alternatives check of 2026-11-08: covers.
Tool: BerriAI/litellm (https://github.com/BerriAI/litellm), NOASSERTION, last activity 2026-11-08, maintained.

Proposed design

Problem statement

The roadmap Service and CronJob roadmap-stage read DEVOPS_CLI_AI_API_KEY from Secret devops-cli, which holds the gateway master key. The gateway sets no budget and no requests-per-minute limit for the Service, so a fault in the Service can spend without limit. The gateway database that LiteLLM virtual keys need is delivered (#1635), so the change can be built. The change gives the Service and its stage Job one virtual key with a budget, a requests-per-minute limit and a model list, and leaves the other cluster Jobs on their key.

Acceptance criteria

Requirement: Service reads its virtual key

The roadmap Service Deployment SHALL read DEVOPS_CLI_AI_API_KEY from the api-key key of Secret roadmap-service-llm-key and SHALL NOT take that variable from Secret devops-cli.

Scenario: Build the roadmap Service kustomization

  • WHEN A person runs kustomize build k8s/devops/roadmap-service/.
  • THEN The Deployment has one env entry DEVOPS_CLI_AI_API_KEY with secretKeyRef name roadmap-service-llm-key and key api-key, and the pod template has no envFrom entry for Secret devops-cli.

Requirement: Service stops loading the shared Secret

The roadmap Service pod template SHALL NOT load Secret devops-cli with envFrom, and SHALL read each other variable of that Secret with an explicit secretKeyRef.

Scenario: Inspect the pod environment sources

  • WHEN The built Deployment is read.
  • THEN The pod template has no envFrom entry, and the six variables DEVOPS_CLI_SERVICE_GITHUB_APP_PRIVATE_KEY, DEVOPS_CLI_SERVICE_WEBHOOK_SECRETS, DEVOPS_CLI_FIRECRAWL_API_KEY, DEVOPS_CLI_VALKEY_PASSWORD, DEVOPS_CLI_MATTERMOST_COMMAND_TOKEN and DEVOPS_CLI_CRAWL4AI_API_TOKEN each have a secretKeyRef to Secret devops-cli, with optional: true on the four optional keys.

Requirement: Stage Job reads the virtual key

CronJob roadmap-stage SHALL read DEVOPS_CLI_AI_API_KEY from the api-key key of Secret roadmap-service-llm-key and SHALL keep DEVOPS_CLI_SERVICE_GITHUB_APP_PRIVATE_KEY from Secret devops-cli.

Scenario: Build the devops kustomization

  • WHEN A person runs kustomize build k8s/devops/.
  • THEN CronJob roadmap-stage has an env entry DEVOPS_CLI_AI_API_KEY with secretKeyRef name roadmap-service-llm-key and key api-key, and its DEVOPS_CLI_SERVICE_GITHUB_APP_PRIVATE_KEY entry still names Secret devops-cli.

Requirement: Stage Job key constant and policy agree

CONST_ROADMAP_STAGE_JOB_SECRET_KEYS and the admission policy roadmap-service-jobs SHALL name Secret roadmap-service-llm-key key api-key as the source of DEVOPS_CLI_AI_API_KEY of a stage Job pod.

Scenario: Read the stage Job key constant and the policy

  • WHEN A test reads CONST_ROADMAP_STAGE_JOB_SECRET_KEYS and k8s/devops/roadmap-service/admissionpolicy.yaml.
  • THEN The entry of DEVOPS_CLI_AI_API_KEY names Secret roadmap-service-llm-key and key api-key, and no entry of the constant or the policy names Secret devops-cli for that variable.

Requirement: Virtual key is a cluster secret row

CLUSTER_SECRETS SHALL hold a row for Secret devops/roadmap-service-llm-key with the key api-key from keyring roadmap_service_llm_key, and keyring_only_keys() SHALL declare that keyring key.

Scenario: Read the cluster secret table

  • WHEN A test reads CLUSTER_SECRETS and keyring_only_keys().
  • THEN It finds the row devops/roadmap-service-llm-key with the entry api-key from keyring roadmap_service_llm_key and the restart of deployment/roadmap-service, and keyring_only_keys() holds roadmap_service_llm_key.

Requirement: README gives the Service key step

k8s/README.md SHALL give the step for a person to mint the virtual key of the roadmap Service with a budget and a requests-per-minute limit, and to rotate it.

Scenario: Read the Service key section

  • WHEN A person reads the roadmap Service steps and the Cluster Secrets table of k8s/README.md.
  • THEN It names Secret devops/roadmap-service-llm-key, key api-key, keyring roadmap_service_llm_key, the models deepseek-v4.1-flash-1017 and qwen3-embedding:0.6b, max_budget 100 with budget_duration 30d, rpm_limit 300, the mint step and the rotation step, and the Cluster Secrets table holds the row.

Requirement: README names the Service as a virtual-key caller

k8s/README.md SHALL name the roadmap Service as a caller that sends a virtual key, and SHALL keep the master key for the cluster Jobs and Open WebUI.

Scenario: Read the gateway caller paragraph

  • WHEN A person reads the AI spend dashboard paragraph and the gateway database section of k8s/README.md.
  • THEN The text names Secret roadmap-service-llm-key as the key of the Service and the master key as the key of the cluster Jobs and Open WebUI, and it no longer says that every caller sends the master key.

Requirement: Cluster Job templates keep their key

The cluster Job templates SHALL keep reading DEVOPS_CLI_AI_API_KEY from Secret devops/devops-cli, and no template other than roadmap-stage SHALL name Secret roadmap-service-llm-key.

Scenario: Build the devops kustomization

  • WHEN A person runs kustomize build k8s/devops/.
  • THEN CronJob devops-cli still has its envFrom entry for Secret devops-cli and no DEVOPS_CLI_AI_API_KEY override, and no other CronJob under k8s/devops/ names Secret roadmap-service-llm-key.

Existing Tool Considered

LiteLLM virtual keys (https://github.com/BerriAI/litellm) cover the need: the deployed gateway mints a per-key budget, a requests-per-minute limit and a model list, stored in the gateway database. LiteLLM lacks a way to mint or rotate a key without a person, and it ships no Kubernetes manifest and no keyring row; this repository adds those. Nothing is built.

Key questions

  • The alternatives check found that https://github.com/BerriAI/litellm covers this item. Adopt the tool, or keep the item and give the reason.: Adopt the tool. The reply of the issue works from the Service's own virtual key and asks for the stage Job to share it. The Service and its stage Job then get one LiteLLM virtual key with a per-key budget, a requests-per-minute limit and a model list. (best practice) [sources: k8s/README.md, k8s/llm/gateway/config.yaml]
    • Chosen: Adopt LiteLLM virtual keys for the Service. The key bounds the spend and the request rate of the Service, and the gateway database that keys need is delivered.
    • Rejected: Keep the master key. The gateway sets no budget and no requests-per-minute limit for the Service, which is the problem.
  • Does this item change the key source of the stage Job, and which key does the stage Job get?: Yes. CronJob roadmap-stage reads the same virtual key as the Service: Secret roadmap-service-llm-key, key api-key. The reply of the issue asks for the same key or one of its own, with a budget, and it names the template, CONST_ROADMAP_STAGE_JOB_SECRET_KEYS and the admission policy roadmap-service-jobs as one change. The stage Job template exists now, and feat(roadmap): run each stage item in its own Job #4559 only makes the Service create the Jobs, so the change needs no other item first. (best practice) [sources: k8s/devops/cronjob-stage.yaml, src/devops_cli/config/constants.py, k8s/devops/roadmap-service/admissionpolicy.yaml, docs/CLUSTER.md]
    • Chosen: The stage Job reads the same virtual key as the Service. One key, one budget and one person step cover the Service and the Jobs that it creates, and the stage Job is the Service's own work.
    • Rejected: The stage Job gets its own virtual key. A second key needs a second Secret, a second keyring entry, a second cluster secret row and a second person step.
    • Rejected: The stage Job keeps the master key. After feat(roadmap): run each stage item in its own Job #4559 most of the Service's model spend runs in that pod, so the gateway would bound nothing there.
  • Which Secret and key hold the Service virtual key?: Secret devops/roadmap-service-llm-key with key api-key, from keyring roadmap_service_llm_key. The CLUSTER_SECRETS row restarts deployment/roadmap-service. (best practice) [sources: src/devops_cli/k8s/cluster_secrets.py, k8s/devops/roadmap-service/deployment.yaml, k8s/README.md]
    • Chosen: A new Secret roadmap-service-llm-key in namespace devops. The Service has one source for its key, push-secrets writes one row, and Secret devops-cli keeps only the variables that the Service and the Jobs share.
    • Rejected: A new key in Secret devops-cli. The Service reads that Secret with envFrom, so it would still receive the master key under the name DEVOPS_CLI_AI_API_KEY.
    • Rejected: Reuse the master key. The gateway cannot set a budget or a requests-per-minute limit for the Service.
  • How does the Service stop reading the master key from Secret devops-cli?: Remove the envFrom entry for Secret devops-cli and read each other Service variable with an explicit secretKeyRef, with optional: true on the optional keys. (best practice) [sources: k8s/devops/roadmap-service/deployment.yaml, src/devops_cli/k8s/cluster_secrets.py]
    • Chosen: Remove envFrom and use explicit secretKeyRef entries. The Deployment then names one source for each variable, and no source of DEVOPS_CLI_AI_API_KEY is Secret devops-cli.
    • Rejected: Keep envFrom and add an env override. The Deployment then reads DEVOPS_CLI_AI_API_KEY from two sources, and a reader cannot tell which source wins.
    • Rejected: Split Secret devops-cli into a Service Secret and a Job Secret. The cluster Job templates read that one Secret with envFrom, so a split changes their templates and their secret row too.
  • Which model list does the Service virtual key allow?: The two models that the Service ConfigMap names: deepseek-v4.1-flash-1017 for every chat slot and qwen3-embedding:0.6b for embedding. A model change needs a new key. (best practice) [sources: k8s/devops/configmap.example.yaml, k8s/llm/gateway/config.yaml]
    • Chosen: Restrict the key to the two models of the ConfigMap. The key cannot call another group, such as a hosted model that the Service does not name.
    • Rejected: Allow every model of the gateway. The key could call every hosted group, and only the budget would bound the spend.
  • What budget and requests-per-minute limit does the Service virtual key set?: max_budget 100 USD with budget_duration 30d, and rpm_limit 300. The budget bounds a runaway loop, and 300 requests a minute is above the burst of a stage round and still caps a loop. (best practice) [sources: k8s/devops/configmap.example.yaml, k8s/README.md]
    • Chosen: 100 USD per 30 days and 300 requests per minute. It bounds the Service's own hosted spend and request rate, with room for a stage round of 3 plans of about 23 requests each.
    • Rejected: No limit. A fault in the Service spends without limit, which is the problem.
    • Rejected: 10 USD per 30 days and 60 requests per minute. A stage round of 3 plans can exceed 60 requests in a minute, so the gateway would refuse legitimate work.
  • Does the gateway database that virtual keys need exist?: Yes. feat(k8s): the LiteLLM gateway keeps virtual keys in an in-cluster Postgres, so devops-cli can mint scoped, expiring gateway keys #1635 is delivered: k8s/llm/gateway-db.yaml defines the gateway database, and the gateway Deployment reads DATABASE_URL from the uri key of Secret llm-gateway-db-app. The block in the issue is stale. [sources: k8s/llm/gateway-db.yaml, k8s/llm/gateway/deployment.yaml, k8s/README.md, openspec/changes/archive/2026-11-06-1635-gateway-database/design.md]
  • Who mints the virtual key and sets its budget and requests-per-minute limit?: A person, because only a person changes secrets. The person mints the key at the gateway with POST /key/generate (alias roadmap-service, the two models, max_budget 100 with budget_duration 30d, rpm_limit 300), stores it with uv run keyring set devops-cli roadmap_service_llm_key, and pushes it with uv run devops k8s push-secrets --only devops/roadmap-service-llm-key before push-secrets --stack devops. To rotate, the person mints a new key, stores it, pushes with --rotate, and deletes the old key in the gateway. (a person decides) [sources: AGENTS.md, k8s/README.md]

Open questions

  • Who mints the virtual key and sets its budget and requests-per-minute limit? (a person decides)

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    on Nov 5, 2026
  2. added
    type/feature
    scope/service
    status/new
    value/medium
    effort/low
    on Nov 5, 2026
  3. dan-petty commented on Nov 5, 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/feature. The feat prefix of the title gives the type.
    • Scope: scope/service. The (service) scope of the title gives the scope.
    • Priority: P2-Medium. It reduces blast radius of the master key but is blocked by #1635 and the Service works today.
    • Value: Medium. It caps Service spend and isolates its fault, but the master key still functions and no user-facing feature is added.
    • Effort: Low. The change is a k8s manifest edit, a README note, and one CLUSTER_SECRETS row with a test.
    • Related: feat(k8s): the LiteLLM gateway keeps virtual keys in an in-cluster Postgres, so devops-cli can mint scoped, expiring gateway keys #1635, which asks for a different change. Both concern virtual gateway keys, but #1635 adds the Postgres backend so keys can be minted, while the candidate points the Service Deployment at one such key.
  4. added
    priority/p2-medium
    on Nov 5, 2026
  5. devops-cli-service commented on Nov 7, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at 72c52c6 until a person answers the questions below. Reply in a comment or edit the body, and the next refine round looks at the item again.

    • Who mints the virtual key and sets its budget and requests-per-minute limit? (a person decides)
  6. devops-cli-service commented on Nov 8, 2026

    @devops-cli-service
    Contributor

    Alternatives check: covers

    Reason: LiteLLM's virtual keys are the mechanism the item itself names, and they give a per-key budget, a requests-per-minute limit and a model list stored in the gateway database, so one key minted for the Service bounds its spend and rate without touching the Jobs' key. The searches found only LiteLLM itself (an active, non-archived gateway project with Postgres-backed keys, budgets and spend tracking), and no other tool covers this need.

    Tool: BerriAI/litellm (https://github.com/BerriAI/litellm)

    • License: NOASSERTION
    • Last activity: 2026-11-08
    • Maintained: yes

    Covers:

    Lacks:

    • No way to mint or rotate the key without a person (the item expects a manual step anyway)
    • No Kubernetes manifest or keyring row out of the box; the Deployment change and the CLUSTER_SECRETS row are still this repository's work

    Tools considered:

    Searches run:

    • LiteLLM virtual keys budget rpm_limit per key, results: 5
    • litellm docs virtual keys max_budget rpm_limit key generate, results: 5
    • litellm proxy virtual keys documentation, results: 5
    • LLM gateway virtual key per key budget and requests per minute limit, results: 5
    • litellm, results: 5
    • BerriAI litellm proxy key budget and rate limits per virtual key, results: 5
    • litellm virtual keys spend tracking budgets rate limits documentation site, results: 5

    Sources:

    Checked on 2026-11-08. A person decides what this means for the item. The check changes no label and closes no issue.

  7. devops-cli-service commented on Nov 8, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at 1f03ee3 until a person answers the questions below. Reply in a comment or edit the body, and the next refine round looks at the item again.

    • Who mints the virtual key and sets its budget and requests-per-minute limit? (a person decides)
    • The alternatives check found that https://github.com/BerriAI/litellm covers this item. Adopt the tool, or keep the item and give the reason. (a person decides)
  8. dan-petty commented on Nov 13, 2026

    @dan-petty
    OwnerAuthor

    A new caller of the gateway: the stage Job (#5483, PR #5545; the Service switches to it in #4559). CronJob roadmap-stage gives its pod DEVOPS_CLI_AI_API_KEY through secretKeyRef of Secret devops-cli, which is a copy of the master key. After #4559 the stage planner runs in this pod and not in the Service pod, so most of the model spend of the Service moves to it.

    When this item gives the Service a virtual key, give the stage Job the same key or one of its own, with a budget. The admission policy roadmap-service-jobs pins the key names of a stage Job (CONST_ROADMAP_STAGE_JOB_SECRET_KEYS), so the change of the key source changes the template, the constant and the policy in one pull request. Found in the review of #4559 (finding gateway-master-key-in-job-pods).

  9. devops-cli-service commented on Nov 14, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at ffce5d9 until a person answers the questions below. Reply in a comment or edit the body, and the next refine round looks at the item again.

    • Who mints the virtual key and sets its budget and requests-per-minute limit? (a person decides)
  10. added
    status/in-progress
    and removed
    status/new
    on Nov 14, 2026
  11. added
    status/in-review
    and removed
    status/in-progress
    on Nov 14, 2026
  12. removed
    status/in-review
    on Nov 14, 2026
  13. devops-cli-service commented on Nov 14, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-14 21:08 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/servicesource/agenttype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions