mirror of
https://github.com/harivansh-afk/agentikube.git
synced 2026-04-20 10:01:23 +00:00
init
This commit is contained in:
commit
0595d93c49
28 changed files with 1763 additions and 0 deletions
24
internal/kube/exec.go
Normal file
24
internal/kube/exec.go
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
package kube
|
||||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
// Exec runs kubectl exec to attach an interactive terminal to the specified
|
||||
// pod. If command is empty, it defaults to /bin/sh.
|
||||
func Exec(namespace, podName string, command []string) error {
|
||||
if len(command) == 0 {
|
||||
command = []string{"/bin/sh"}
|
||||
}
|
||||
|
||||
args := []string{"exec", "-it", "-n", namespace, podName, "--"}
|
||||
args = append(args, command...)
|
||||
|
||||
cmd := exec.Command("kubectl", args...)
|
||||
cmd.Stdin = os.Stdin
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
|
||||
return cmd.Run()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue