feat(workbench): add Kubernetes autoscaling and capacity probes (closes #304)#334
Merged
Merged
Conversation
#304) - Add WorkbenchKubernetesConfig dataclass to config.py with fields for namespace, node_pool_profiles, max_sessions, profile_cpu_limit, and profile_memory_limit_gib; wire it into WorkbenchConfig.from_dict - Add src/vip/clients/kubernetes.py: read-only KubernetesClient using the kubernetes SDK with lazy import (RuntimeError on missing package); exposes node_count, running_session_pods, pod_node_pool, resource_quota, and pod_resource_limits - Add test_session_capacity_k8s.feature with six Gherkin scenarios: autoscaler adds a node, session lands after scale-up, session count respects max, quick-succession sessions reach Active, profile routes to correct node pool, and profile enforces CPU/memory limits - Add step definitions test_session_capacity_k8s.py for all six scenarios; each scenario skips cleanly when [workbench.kubernetes] is absent - Move shared '@given("Workbench is accessible and I am logged in")' step to workbench/conftest.py so both capacity feature files use it without duplicate registration - Add kubernetes_client session fixture to src/vip_tests/conftest.py - Add selftests/test_workbench_kubernetes_config.py covering defaults, from_dict, load_config integration, and repr - Document new [workbench.kubernetes] block in vip.toml.example Implements the plan from #311 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: ian-flores <18703558+ian-flores@users.noreply.github.com>
Co-authored-by: ian-flores <18703558+ian-flores@users.noreply.github.com>
ian-flores
approved these changes
Jun 2, 2026
Collaborator
ian-flores
left a comment
There was a problem hiding this comment.
CI green. Conflict resolved by keeping both job_timeout (from #336) and kubernetes fields in WorkbenchConfig.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #304
Implements the plan from #311
What changed and why
This PR adds Kubernetes-specific session capacity and autoscaling tests to VIP's Workbench test suite, as requested in #304. A Posit customer running Kubernetes-backed Workbench flagged six scenarios around autoscaling boundaries, capacity limits, and resource profile enforcement that weren't covered by the existing
test_session_capacity.feature.New files
src/vip/clients/kubernetes.pyRead-only
KubernetesClientusing thekubernetesPython SDK. Credentials are inherited from the ambient environment (~/.kube/config,KUBECONFIGenv var, or in-cluster service account) — no separate credential fields invip.toml. The SDK import is lazy: if the package isn't installed, aRuntimeErrorwith a clear install hint is raised, and the corresponding test scenarios skip viapytest.skip.src/vip_tests/workbench/test_session_capacity_k8s.featureSix Gherkin scenarios with the
@workbenchtag:src/vip_tests/workbench/test_session_capacity_k8s.pyStep definitions for all six scenarios. Every scenario that needs cluster config gates on
@given("the Kubernetes cluster is configured"), which skips cleanly when[workbench.kubernetes]is absent orenabled = false.selftests/test_workbench_kubernetes_config.pyConfig-layer selftests covering
WorkbenchKubernetesConfigdefaults,from_dict,load_configintegration with a real TOML file, and thereprofWorkbenchConfig.Modified files
src/vip/config.pyAdds
WorkbenchKubernetesConfigdataclass with fields:enabled,namespace,node_pool_profiles(pool→profile mapping),max_sessions,profile_cpu_limit,profile_memory_limit_gib. Wired intoWorkbenchConfig.from_dictunder the[workbench.kubernetes]TOML key.src/vip_tests/workbench/conftest.pyThe shared
@given("Workbench is accessible and I am logged in")step was moved here fromtest_session_capacity.pyso both capacity feature files use it without duplicate step registration.src/vip_tests/conftest.pyAdds a
kubernetes_clientsession fixture (returnsNonewhen K8s is not configured).vip.toml.exampleDocuments the new
[workbench.kubernetes]block with all fields commented out.Scope guards
All new scenarios skip when:
[workbench.kubernetes]is absent orenabled = falsekubernetesPython package is not installednode_pool_profiles,max_sessions) required by a scenario is not setOut of scope (per plan)