NVIDIA / NVIDIA/cloudai

Pass --kubeconfig to all kubectl subprocess invocations

Open
#794 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Improvement
Dominant language
Python
Stars
99
Forks
62
Avg merge
6d 12h
Merged PRs (30d)
17

Description

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: https://github.com/NVIDIA/cloudai/pull/793#discussion_r2745665546

Requested by: @amaslenn

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read src/cloudai/systems/kubernetes/kubernetes_system.py and inspect the kubectl invocations for exec, get pods, cp, and delete dgd. Verify each subprocess command uses the resolved self.kube_config_path, and consider how existing command construction is covered before confirming all four paths use the same configuration.

Written by the indexing model from the issue text.

Assessment

Tech stack
kubernetes, python
Domain
infrastructure
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
56/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.