Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 1, 2025

Setting full pod_spec_kwargs for common Kubernetes configurations (affinity, tolerations) is verbose and error-prone. This adds shortcut parameters that expand to the full spec.

Changes

  • New KubernetesTerminal parameters:

    • affinity_mode: Preset for node affinity ("same_host" schedules on host from env var)
    • affinity_hostname_key: Env var name for hostname lookup (default: "HOSTNAME")
    • tolerations_preset: Single string or list ("spot", "azure_spot", "critical")
  • Helper functions:

    • _build_pod_spec_from_shortcuts(): Generates pod spec from shortcuts
    • _deep_merge_dicts(): Merges shortcut spec with explicit pod_spec_kwargs (explicit wins)
  • Preset registries: AFFINITY_PRESETS, TOLERATION_PRESETS for extensibility

Example

Before:

terminal = KubernetesTerminal(
    pod_spec_kwargs={
        "affinity": {
            "nodeAffinity": {
                "requiredDuringSchedulingIgnoredDuringExecution": {
                    "nodeSelectorTerms": [{"matchExpressions": [{"key": "kubernetes.io/hostname", "operator": "In", "values": ["{{HOSTNAME}}"]}]}]
                }
            }
        },
        "tolerations": [{"key": "kubernetes.azure.com/scalesetpriority", "operator": "Equal", "value": "spot", "effect": "NoSchedule"}],
    }
)

After:

terminal = KubernetesTerminal(
    affinity_mode="same_host",
    tolerations_preset="spot",
)

Shortcuts and explicit pod_spec_kwargs can be combined; explicit values override shortcuts.

Original prompt

This section details on the original issue you should resolve

<issue_title>Provide more convenient settings for Kubernetes</issue_title>
<issue_description>At the moment, have to set the full pod_spec_kwargs is a bit annoying. We can support commonly used settings (eg., affinity_mode: "in_host"), etc. </issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits December 1, 2025 19:33
Co-authored-by: chisingh <3340274+chisingh@users.noreply.github.com>
Co-authored-by: chisingh <3340274+chisingh@users.noreply.github.com>
Copilot AI changed the title [WIP] Add convenient settings for Kubernetes pod specifications Add convenient shortcut parameters for Kubernetes pod spec configuration Dec 1, 2025
Copilot AI requested a review from chisingh December 1, 2025 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide more convenient settings for Kubernetes

3 participants