Skip to content

build(deps): move the Kubernetes client to 37 #5095

Done

Description

@dan-petty

Problem or Motivation

pyproject.toml pins the Python client kubernetes 36.0.3. The newest is 37.0.2, a major. The baseline (#5065) keeps 36.0.3. Renovate (#4893) will offer 37, and it needs work:

  • 37.0.0 CHANGELOG, "Breaking Change from upgrading OpenAPI Generator to v7.24.0": pydantic-validated models, delete methods return dicts, ApiException.body is text, the low-level ApiClient and RESTClientObject interfaces changed, new dependencies aiohttp-retry, lazy-imports and python-dateutil>=3 (the 37 lock has python-dateutil 4.0.0 and drops six).
  • mypy --strict gives 16 errors: src/devops_cli/k8s/api.py:141,144,158,164,165,166,187,198; src/devops_cli/k8s/informer.py:102,108,120,122,133; src/devops_cli/k8s/doctor.py:752 (unused ignores, untyped calls, Protocol mismatch for CoreApi, CustomObjectsApi and VersionApi, ApiException not exported from kubernetes.client.rest).
  • Tests: tests/support/fakes/kubernetes.py:289 calls ApiClient().deserialize(...) with no content_type, which gives 20 errors in tests/k8s/test_kubernetes_contract.py. tests/k8s/test_k8s_pod_log_text.py:60 fails because 37 returns decoded log text, so the workaround in src/devops_cli/k8s/service.py:103-110 can go.
  • Trial on 37.0.2 (tests/k8s, tests/commands/k8s and 3 more caller files): 1 failed, 20 errors, 1440 passed.

Research of 2026-11-12 (research-python, migration kubernetes).

Proposed Solution & Architectural Design

  • Pin kubernetes 37.0.2; fix the 16 mypy errors at their seams (the Protocols in k8s/api.py, the informer, the doctor).
  • Update the fake's deserialize call and remove the pod log text workaround.
  • Run tests/k8s, tests/commands/k8s and the k8s contract tests.

Done when mypy strict and the k8s tests pass on 37.

Target Subsystem

Kubernetes & Minikube Automation

Existing Tool Considered

The upstream client. No new code beyond the type fixes.

Source: #4893

Alternatives check of 2026-11-27: in-use.
The repository already uses this tool.
Tool: kubernetes (https://pypi.org/project/kubernetes), Apache-2.0, last activity 2026-11-18, maintained.
Reason: Searches confirm the official Kubernetes Python client on PyPI and GitHub is at the 37 line, Apache-2.0 and maintained; it is the tool the issue pins. The remaining work is project-side type and test fixes, not a missing tool.

Covers:

  • 37.x client release with pydantic-validated models
  • Decoded pod log text from the client
  • Runtime dependencies such as aiohttp-retry and lazy-imports

Lacks:

  • Fixes for the 16 mypy strict seam errors
  • Content type argument in the shared fake deserialize call
  • Removal of the pod log text workaround

Proposed design

Problem statement

pyproject.toml pins the Kubernetes Python client kubernetes 36.0.3. The newest release is 37.0.2, a major with breaking changes. The project must move the pin, fix the type seams, update the test fake, and remove the pod log text workaround. The change is done when mypy strict and the Kubernetes tests pass on 37.

Acceptance criteria

Requirement: Kubernetes client pin

The project SHALL pin the kubernetes client to 37.0.2 in pyproject.toml and uv.lock.

Scenario: Lock check on 37.0.2

  • WHEN uv lock --check runs, and uv pip show kubernetes runs.
  • THEN Both commands exit 0, and uv pip show kubernetes reports Version: 37.0.2.

Requirement: Strict type check

The project SHALL pass mypy --strict on src/devops_cli with kubernetes 37.0.2.

Scenario: Strict type check on 37

  • WHEN uv run mypy --strict src/devops_cli runs.
  • THEN It exits 0 and reports no errors.

Requirement: Fake deserialize content type

The shared Kubernetes fake SHALL pass the application/json content type to ApiClient.deserialize.

Scenario: Contract suite on 37

  • WHEN uv run pytest tests/k8s/test_kubernetes_contract.py runs.
  • THEN It exits 0 with no failures and no errors.

Requirement: Pod log text path

The pod log service SHALL use the client's decoded text, and a test SHALL assert that the local decoding workaround is absent.

Scenario: Pod log text test on 37

  • WHEN uv run pytest tests/k8s/test_k8s_pod_log_text.py runs.
  • THEN It exits 0 and the test asserts the decoded text path with no local workaround.

Requirement: Kubernetes test suites

The Kubernetes test suites SHALL pass on kubernetes 37.0.2.

Scenario: K8s suites on 37

  • WHEN uv run pytest tests/k8s tests/commands/k8s runs.
  • THEN It exits 0 with no failures and no errors.

Existing Tool Considered

kubernetes (https://pypi.org/project/kubernetes), Apache-2.0, maintained, is already in use. It covers the 37.0.2 client, the pydantic-validated models, decoded pod log text, and the new runtime dependencies. It lacks the project-side fixes: the 16 mypy strict errors, the ApiException import move, the fake content_type argument, and the pod log workaround removal.

Key questions

  • Which kubernetes client version should the project pin?: Pin kubernetes 37.0.2. The alternatives check names it as the newest maintained 37 release. [sources: pyproject.toml]
  • Should the project keep the upstream kubernetes client or build its own client?: Keep the upstream kubernetes client. The project already uses it, and it is maintained. The alternatives check gives the verdict in-use. (best practice) [sources: pyproject.toml, src/devops_cli/k8s/api.py]
    • Chosen: Keep the upstream kubernetes client. The project already imports it, and 37.0.2 is the maintained release that brings the needed changes.
    • Rejected: Build a local client wrapper. This adds code to build, keep and fix for no gain over the maintained client.
  • How should the project fix the mypy strict errors at the Kubernetes seams?: Adjust the narrow Protocols and the call sites to the 37 signatures. Do not add casts or new ignores. (best practice) [sources: src/devops_cli/k8s/api.py, pyproject.toml]
    • Chosen: Adjust the Protocols and call sites. The seam already names only the calls the project makes, so it can match the 37 signatures.
    • Rejected: Add casts and ignores. The project uses strict mode and ignore-without-code, so this hides the seam mismatch.
  • Where should the informer import ApiException from on 37?: Import ApiException from kubernetes.client. The API seam already uses k8s_client.ApiException there. The 37 client does not export it from kubernetes.client.rest. (best practice) [sources: src/devops_cli/k8s/informer.py:120, src/devops_cli/k8s/api.py]
    • Chosen: Import from kubernetes.client. The API seam already uses k8s_client.ApiException, and the 37 client keeps that export.
    • Rejected: Import from kubernetes.client.rest. The 37 client no longer exports ApiException there.
  • How should the doctor's unused type ignores be handled on 37?: Remove the ignores that 37 makes unused. Keep only ignores that the strict check still needs. (best practice) [sources: src/devops_cli/k8s/doctor.py:752, pyproject.toml]
    • Chosen: Remove the unused ignores. Strict mode flags an unused ignore, and 37 removes the error that the ignore covered.
    • Rejected: Keep the ignores. The strict check fails on an unused ignore.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    on Nov 12, 2026
  2. added
    type/infra
    scope/deps
    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 15, 2026

    @devops-cli-service
    Contributor

    Alternatives check: in-use

    Reason: The upstream kubernetes Python client is itself the tool the issue needs, and the project already uses it (pinned at 36.0.3 in pyproject.toml); the released 37.0.2 is the maintained, Apache-2.0 package that brings the pydantic-validated models, decoded log text and new dependencies the issue describes. The searches found no other client or library that would replace that bump — what remains is project-side type and test seam fixes that no package supplies.

    The repository already uses this tool.

    Tool: kubernetes (https://pypi.org/project/kubernetes)

    • License: Apache-2.0
    • Last activity: 2026-11-06
    • Maintained: yes

    Covers:

    • Ships the 37 line (latest 37.0.2) with the OpenAPI-Generator v7.24.0 models: pydantic-validated models, dict-returning delete methods, text ApiException.body and the changed ApiClient/RESTClientObject interfaces
    • Returns decoded pod log text, so the workaround in src/devops_cli/k8s/service.py:103-110 can be removed
    • Brings the new runtime dependencies named in the 37.0.0 changelog (aiohttp-retry, lazy-imports, python-dateutil>=3)
    • Is the same client the project already imports, so the change is a version pin plus seam fixes rather than a new integration

    Lacks:

    • Does not fix the project's 16 mypy --strict errors: the Protocols for CoreApi, CustomObjectsApi and VersionApi in src/devops_cli/k8s/api.py, the informer and the doctor calls are project code
    • Does not fix ApiException not being exported from kubernetes.client.rest; the import in project code must move
    • Does not update the test fake: tests/support/fakes/kubernetes.py:289 must pass a content_type to ApiClient().deserialize, and the 20 errors in tests/k8s/test_kubernetes_contract.py follow from that
    • Does not make the failing pod-log-text test pass by itself; the test and the removed workaround need adjusting

    Tools considered:

    Searches run:

    • python kubernetes client library 37.0.0 changelog OpenAPI Generator v7.24.0, results: 5
    • kubernetes Python client 37.0.2 release breaking change pydantic models, results: 5
    • kubernetes-client python github repository release 37.0.2, results: 5
    • lightkube typed Kubernetes client python alternative to kubernetes package, results: 5
    • kubernetes-client python v37.0.0 release notes pydantic, results: 5

    Sources:

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

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

    @devops-cli-service
    Contributor

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

  8. dan-petty commented on Nov 28, 2026

    @dan-petty
    OwnerAuthor

    Already completed by PR #6865 (5af6f52e0): pyproject.toml pins kubernetes==37.0.3, the Kubernetes API seams (k8s/api.py, k8s/doctor.py, k8s/informer.py), tests/support/fakes/kubernetes.py, and the Kubernetes tests and library docs were updated for kubernetes v37.

  9. removed
    status/ready
    on Nov 28, 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/mediumpriority/p2-mediumscope/depssource/agenttype/infravalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions