Repository navigation
Description
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.bodyis text, the low-levelApiClientandRESTClientObjectinterfaces changed, new dependencies aiohttp-retry, lazy-imports and python-dateutil>=3 (the 37 lock has python-dateutil 4.0.0 and drops six). mypy --strictgives 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,ApiExceptionnot exported fromkubernetes.client.rest).- Tests:
tests/support/fakes/kubernetes.py:289callsApiClient().deserialize(...)with nocontent_type, which gives 20 errors intests/k8s/test_kubernetes_contract.py.tests/k8s/test_k8s_pod_log_text.py:60fails because 37 returns decoded log text, so the workaround insrc/devops_cli/k8s/service.py:103-110can go. - Trial on 37.0.2 (
tests/k8s,tests/commands/k8sand 3 more caller files): 1 failed, 20 errors, 1440 passed.
Research of 2026-11-12 (research-python, migration kubernetes).
Proposed Solution & Architectural Design
- Pin
kubernetes37.0.2; fix the 16 mypy errors at their seams (the Protocols ink8s/api.py, the informer, the doctor). - Update the fake's
deserializecall and remove the pod log text workaround. - Run
tests/k8s,tests/commands/k8sand 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
dan-petty commentedon Nov 12, 2026
Both concern the kubernetes Python client integration, but #307 designs a dynamic informer architecture while this candidate bumps the client major version and fixes type and test seams.build(deps): take every safe version update before Renovate (#5102)
devops-cli-service commentedon Nov 15, 2026
Alternatives check: in-use
Reason: The upstream
kubernetesPython client is itself the tool the issue needs, and the project already uses it (pinned at 36.0.3 inpyproject.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)
Covers:
Lacks:
Tools considered:
Searches run:
Sources:
Checked on 2026-11-15. A person decides what this means for the item. The check changes no label and closes no issue.
devops-cli-service commentedon Nov 17, 2026
Status set to Ready at b8c7632 (see proposed design in issue body).
dan-petty commentedon Nov 28, 2026
Already completed by PR #6865 (
5af6f52e0):pyproject.tomlpinskubernetes==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 forkubernetesv37.