Skip to content

Commit

Permalink
Apply kubeconfig option to internal kubectl-attach command
Browse files Browse the repository at this point in the history
  • Loading branch information
ssup2 committed Mar 24, 2021
1 parent c080bf4 commit 2342d44
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/cmd/kpexec/kpexec.go
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ func (o *Options) Run(args []string, argsLenAtDash int) error {

// Attach cnsenter pod
if (o.tty || o.stdin) && tPod.Status.Phase == corev1.PodRunning {
if err := attachPod(o.cnsPodNamespace, cnsPodName, "cnsenter", o.tty, o.stdin); err == nil {
if err := attachPod(o.kubeconfig, o.cnsPodNamespace, cnsPodName, "cnsenter", o.tty, o.stdin); err == nil {
return nil
}

Expand Down Expand Up @@ -528,9 +528,9 @@ func getRandomString(n int) string {
return string(s)
}

func attachPod(podNs, podName, contName string, tty, stdin bool) error {
func attachPod(kubeconfig, podNs, podName, contName string, tty, stdin bool) error {
// Set kubectl attach args
args := []string{"attach", "--namespace", podNs, podName, "--container", contName}
args := []string{"--kubeconfig", kubeconfig, "attach", "--namespace", podNs, podName, "--container", contName}
if tty {
args = append(args, "--tty")
}
Expand Down

0 comments on commit 2342d44

Please sign in to comment.