Skip to content

chore(k8s): remove the unused Portkey gateway and provider #5007

Open

Description

@dan-petty

Update 2026-11-26 (infra move): the Portkey manifests go to dan-petty/homelab.

This issue keeps the removal of the provider and of ai.portkey_url from src/ with its tests, documents and specs, and of the three llm/portkey/ lines of MANIFESTS_BY_STACK. k8s/llm/portkey/ and its kustomization and NetworkPolicy lines are deleted in homelab. Merge the two changes together, else deploy-stack can name a missing file.

Follow-up: dan-petty/homelab#288.


Problem or Motivation

Portkey has no client: 0 log lines in 7 d, no route, egress only to Ollama, and the live config uses provider gateway. It holds 200m CPU and 256Mi of requests for 1m and 81Mi of use. It is one more gateway to patch and document, and no ADR keeps it. This item is rank 17 of the cluster integration plan #4989.

Proposed Solution & Architectural Design

  1. Delete the llm/portkey/ lines of MANIFESTS_BY_STACK. The manifests are deleted in dan-petty/homelab.
  2. Remove the portkey provider from src/devops_cli (9 files).
  3. Add ai.portkey_url to CONST_REMOVED_CONFIG_KEYS, so that the load error names devops config unset ai.portkey_url.

Owner decision

After the merge, run devops config unset ai.portkey_url on each workstation config. The ai section refuses unknown keys, and agents never change config.yaml. The recommended answer on #4989 is yes.

Target Subsystem

AI & Agentic Review Pipeline (src/devops_cli, k8s/llm/).

Existing Tool Considered

The LiteLLM gateway already serves every route. Removal builds nothing.

Acceptance Criteria

  • git grep -i portkey finds only the removed-key entry, its test and the changelog.
  • A config with ai.portkey_url fails to load, and the error names devops config unset ai.portkey_url.
  • Argo CD prunes the Portkey objects.

Dependencies

None. Owner decision 4 on #4989 comes after the merge.

Source: #4989

Alternatives check of 2026-11-26: not-applicable.
Class: chore, no model call.
Tool: none found.

Proposed design

Problem statement

Portkey runs in the cluster with no client: no route names it, it served no request in 7 days, and its traffic went only to Ollama. It holds 200m CPU and 256Mi of requests while it uses 1m and 81Mi, it is one more gateway to patch and document, and no ADR keeps it. The change deletes k8s/llm/portkey/ and the Portkey provider in src/devops_cli, and it updates the tests, the documents, the example config, the research watch note and the two live specs that name it. LiteLLM and Ollama stay, and a person unsets ai.portkey_url on each workstation config after the merge.

Acceptance criteria

Requirement: Cascade provider list

The cascade model MUST build with no Portkey provider and no ai.portkey_url.

Scenario: Cascade with no Portkey URL

  • WHEN A test builds the cascade model from settings with ai.portkey_url unset.
  • THEN The build raises no ConfigurationError, and CONST_AI_CASCADE_PROVIDERS holds no portkey entry.

Requirement: Gateway provider value

The ai settings MUST refuse an ai.gateway_provider that names no gateway the project serves.

Scenario: A leftover Portkey gateway provider

  • WHEN A test loads a settings dict that holds ai.gateway_provider: portkey.
  • THEN The load fails, and the error names litellm as the gateway provider to set.

Requirement: AI settings fields

The ai settings section MUST declare no portkey_url field.

Scenario: Fields of the ai section

  • WHEN A test reads the fields of the AIConfig settings model.
  • THEN The field names hold no portkey_url.

Requirement: Refused config key

A config that holds ai.portkey_url MUST fail to load and MUST name devops config unset ai.portkey_url.

Scenario: Loader refuses the removed key

  • WHEN A test passes a settings dict that holds ai.portkey_url to the config loader.
  • THEN The load fails, and the error text names devops config unset ai.portkey_url.

Requirement: Gateway provider constants

The gateway provider constants MUST hold no Portkey provider or Portkey URL setting.

Scenario: Gateway provider constants

  • WHEN A test reads CONST_AI_GATEWAY_PROVIDERS, CONST_AI_GATEWAY_PROVIDER_PORTKEY and CONST_AI_GATEWAY_URL_SETTINGS.
  • THEN The provider tuple holds no portkey, the Portkey provider constant is absent, and the URL settings map has no portkey key.

Requirement: No Portkey reference

The live source, the documents, the research watch list and the live specs MUST hold no portkey reference.

Scenario: Search the live files at the branch head

  • WHEN A test runs ! git grep -n -i -F portkey src/ docs/CONFIGURATION.md docs/MCP_TOOLS.md docs/commands/ai.md docs/SERVICE_PATTERNS.md k8s/README.md .devops/research-watch.toml openspec/specs/ at the branch head.
  • THEN The test passes and the command prints no line.

Requirement: Portkey manifests

The change MUST delete k8s/llm/portkey/ and each kustomization, policy and gate entry that names it.

Scenario: The k8s check

  • WHEN uv run devops ci --check --only k8s runs on the branch.
  • THEN The check reports success.

Requirement: Generated documents

The generated settings and command documents MUST hold no Portkey row.

Scenario: The docs check

  • WHEN uv run devops ci --check --only docs runs on the branch after uv run devops docs generate.
  • THEN The docs row reports success.

Requirement: Argo CD prunes Portkey

After the merge, Argo CD MUST prune each Portkey object of the cluster.

Scenario: Live check after the merge

  • WHEN After the merge, kubectl get deployment,service,configmap -A -o name | grep -i portkey runs on the cluster.
  • THEN The command returns no line.

Existing Tool Considered

The alternatives check of 2026-11-15 gives verdict not-applicable (class chore, no search), so it names no tool. The open, maintained gateway that covers the remaining need is LiteLLM (ghcr.io/berriai/litellm, .devops/research-watch.toml). It already serves every route that remains. The change adds no code that the project builds or keeps, so the build cost is 0 tokens and 0 elapsed time.

Key questions

  • Which live files hold the Portkey provider and manifests that the change removes?: The code holds the Portkey constants in src/devops_cli/config/constants.py and the portkey_url field in src/devops_cli/config/settings.py. The router holds the Portkey URL and provider branches in src/devops_cli/ai/gateway.py, and the spend report reads the URL in src/devops_cli/ai/spend/pricing.py. The bridge and the --provider help also name it. The manifests are k8s/llm/portkey/, k8s/llm/kustomization.yaml, k8s/llm/networkpolicy.yaml and the gate exemption in tests/gate/k8s_checks/monitoring.py. The documents and live specs are config.example.yaml, docs/CONFIGURATION.md, docs/MCP_TOOLS.md, docs/commands/ai.md, docs/SERVICE_PATTERNS.md, k8s/README.md, .devops/research-watch.toml, openspec/specs/ai-gateway-routing/spec.md and openspec/specs/k8s-network-policies/spec.md. [sources: src/devops_cli/config/constants.py, src/devops_cli/config/settings.py, src/devops_cli/ai/gateway.py, src/devops_cli/ai/spend/pricing.py, src/devops_cli/ai/pydantic_ai_bridge.py, src/devops_cli/commands/ai_gateway.py, k8s/llm/kustomization.yaml, k8s/llm/networkpolicy.yaml, tests/gate/k8s_checks/monitoring.py, config.example.yaml, docs/CONFIGURATION.md, docs/MCP_TOOLS.md, docs/commands/ai.md, docs/SERVICE_PATTERNS.md, k8s/README.md, .devops/research-watch.toml, openspec/specs/ai-gateway-routing/spec.md, openspec/specs/k8s-network-policies/spec.md]
  • Does the load error name devops config unset ai.portkey_url without an entry in CONST_REMOVED_CONFIG_KEYS?: Yes. _describe in src/devops_cli/config/unknown_keys.py builds devops config unset <dotted key> for each key that a section refuses. _reason adds a release only when the removed-key map holds the key. A config with ai.portkey_url therefore fails to load and names the command before the map entry exists. [sources: src/devops_cli/config/unknown_keys.py, src/devops_cli/config/constants.py, docs/CONFIGURATION.md]
  • Must the change remove portkey from CONST_AI_CASCADE_PROVIDERS in the same pull request?: Yes. The tuple holds (litellm, portkey, ollama) today. The bridge reads ai.portkey_url for the Portkey member. A cascade member with an unset URL raises a ConfigurationError. The same pull request removes the member. (best practice) [sources: src/devops_cli/config/constants.py, src/devops_cli/ai/pydantic_ai_bridge.py]
    • Chosen: Remove the member in this change. The cascade model fails as soon as a person unsets ai.portkey_url, which is the owner's step after the merge.
    • Rejected: File a separate item for the tuple. It leaves the cascade model broken between two merges.
  • What does a config that still holds ai.gateway_provider: portkey do?: A config with ai.gateway_provider: portkey must fail at load. The field is a plain string today. After the removal, the value would fall through the router to ai.gateway_url and build a model with an unknown portkey: prefix. The change adds a field validator that admits only CONST_AI_GATEWAY_PROVIDERS. (best practice) [sources: src/devops_cli/config/settings.py, src/devops_cli/config/constants.py, src/devops_cli/ai/gateway.py]
    • Chosen: Refuse the value at load and name the remaining gateway. A leftover value fails closed with a fix, as an unknown settings key does.
    • Rejected: Accept the value and fall back to LiteLLM. It sends the models to a gateway URL that the value does not name and reports an unrelated model error later.
    • Rejected: Leave the field with no validator. The router would build a model with an unknown portkey: prefix.
  • Does the change update the live specs that name Portkey?: Yes. openspec/specs/ai-gateway-routing/spec.md says a configured gateway has the origin of ai.gateway_url or ai.portkey_url. openspec/specs/k8s-network-policies/spec.md requires the Portkey perimeter NetworkPolicy. The change edits both with the removal, so no live requirement names a setting or a policy that no longer exists. (best practice) [sources: openspec/specs/ai-gateway-routing/spec.md, openspec/specs/k8s-network-policies/spec.md]
    • Chosen: Edit both live specs in this change. Both requirements name a setting and a manifest that the change deletes.
    • Rejected: Leave the specs for a later item. The live spec then requires a setting that no config can hold and a policy that no manifest declares.
  • Must the change remove the note about the portkeyai/gateway image from .devops/research-watch.toml?: Yes. The file holds no watch entry for the image. Line 30 is the last item of the Not mapped comment at lines 28-30. The change removes that item because the image leaves the repository. (best practice) [sources: .devops/research-watch.toml]
    • Chosen: Remove the Not mapped item. The note names an image that no manifest pins after the change.
    • Rejected: Keep the note. It documents an image that the project no longer deploys.
  • Which Portkey references stay in the tree?: Keep CHANGELOG.md, docs/SELF_IMPROVEMENT.md and the archived OpenSpec changes under openspec/changes/archive/. They record a past release or a past scan. The change removes live references only. (best practice) [sources: CHANGELOG.md, docs/SELF_IMPROVEMENT.md, openspec/changes/archive/2026-10-27-2046-portkey-unused-config/proposal.md]
    • Chosen: Keep the release and scan records. A changelog entry and a remediated finding record a past release, not a live reference.
    • Rejected: Rewrite the records. It edits the history that release-please writes and the record of a past finding.
  • What does a person do with ai.portkey_url on each workstation config after the merge?: Run devops config unset ai.portkey_url on each workstation config after the merge. The ai section refuses the unknown key. Agents never change config.yaml, so a person runs the command. (a person decides) [sources: src/devops_cli/config/unknown_keys.py, docs/CONFIGURATION.md]

Open questions

  • What does a person do with ai.portkey_url on each workstation config after the merge? (a person decides)

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    on Nov 12, 2026
  2. added
    type/chore
    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/p3-low
    on Nov 12, 2026
  5. dan-petty commented on Nov 13, 2026

    @dan-petty
    OwnerAuthor

    New evidence (2026-11-13, read-only investigation of the LiteLLM gateway):

    • The local ai.portkey_url holds the same URL as ai.gateway_url. Thus devops ai gateway status and devops ai gateway routes --provider portkey probe LiteLLM, not Portkey.
    • Portkey has no clients and no route to LiteLLM. No Ingress names Portkey, and k8s/llm/portkey/networkpolicy.yaml allows egress only to Ollama port 11434 and DNS. Loki over 7 days: 16 Portkey lines, all from the 2026-11-12T14:29Z rollout, and no request. No x-portkey-* header is in src.
    • CONST_AI_CASCADE_PROVIDERS = (litellm, portkey, ollama) (src/devops_cli/config/constants.py:2951) uses ai.portkey_url for its second step, so the cascade calls LiteLLM a second time.
    • The removal must also drop portkey from CONST_AI_CASCADE_PROVIDERS. If not, the model cascade fails with a ConfigurationError when the URL is unset (src/devops_cli/ai/pydantic_ai_bridge.py:84-90, 302-307).
  6. devops-cli-service commented on Nov 15, 2026

    @devops-cli-service
    Contributor

    Alternatives check: not-applicable

    Class: chore. The check makes no search and no model call for an item of this class.

    Tool: none found

    Checked on 2026-11-15. 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 19, 2026

    @devops-cli-service
    Contributor

    Owner question: See the first point of Open questions in the section Proposed design of the body.

    Options

    1. Decide the question: The job refines the item with your answer.
    2. Leave it to the job: The job records the best-practice answer and goes on.

    Recommendation: Decide the question: only a person can answer it.

    Evidence

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

    @devops-cli-service
    Contributor

    Owner question: See the first point of Open questions in the section Proposed design of the body.

    Options

    1. Decide the question: The job refines the item with your answer.
    2. Leave it to the job: The job records the best-practice answer and goes on.

    Recommendation: Decide the question: only a person can answer it.

    Evidence

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/p3-lowscope/k8ssource/agentstatus/newtype/chorevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions