Skip to content

Pass --kubeconfig to all kubectl subprocess invocations #794

@coderabbitai

Description

@coderabbitai

Description

Currently, kubectl commands invoked via subprocess do not receive the --kubeconfig flag, causing them to fall back to default kubeconfig resolution ($HOME/.kube/config or KUBECONFIG env var). This creates inconsistency when KubernetesSystem.kube_config_path points to a non-default location: the Kubernetes Python client API uses the configured path (via load_kube_config()), but kubectl subprocesses may target a different cluster.

Affected Code

All kubectl invocations in src/cloudai/systems/kubernetes/kubernetes_system.py:

  • kubectl exec (line ~313)
  • kubectl get pods (line ~255)
  • kubectl cp (line ~325)
  • kubectl delete dgd (line ~488)

Proposed Solution

Add --kubeconfig flag with the resolved kube_config_path value to all kubectl subprocess commands to ensure consistency with the Python API client configuration.

Example:

kubectl_cmd = ["kubectl", "--kubeconfig", str(self.kube_config_path), "exec", "-n", self.default_namespace, ...]

Context

Identified during review of PR #793: #793 (comment)

Requested by: @amaslenn

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions