diff --git a/cmd/kbench.go b/cmd/kbench.go index 39d272f..dc85a57 100644 --- a/cmd/kbench.go +++ b/cmd/kbench.go @@ -21,10 +21,10 @@ import ( "encoding/json" "flag" "fmt" - "k-bench/pkg/prometheus" + //"k-bench/pkg/prometheus" "k-bench/util" - "k8s.io/client-go/dynamic" - "k8s.io/client-go/kubernetes" + //"k8s.io/client-go/dynamic" + //"k8s.io/client-go/kubernetes" "os" "os/signal" "path/filepath" @@ -150,10 +150,10 @@ func main() { } if configWithPrometheus != nil { - client, _ := kubernetes.NewForConfig(config) - dynClient, _ := dynamic.NewForConfig(config) - pc := prometheus.NewPrometheusController(client, &dynClient, config, configWithPrometheus) - pc.EnablePrometheus() + // client, _ := kubernetes.NewForConfig(config) + // dynClient, _ := dynamic.NewForConfig(config) + // pc := prometheus.NewPrometheusController(client, &dynClient, config, configWithPrometheus) + // pc.EnablePrometheus() } // Sort the config files by the lightness of workload, from light to heavy. @@ -192,7 +192,7 @@ func main() { //Run each workload(specified by its config file) one after another in the sorted order for _, testConfig := range testConfigs { fmt.Printf("Running workload, please check kbench log for details... \n") - util.Run(config, testConfig, outDir) + util.Run(config, testConfig, outDir, *kubeconfig) time.Sleep(time.Duration(testConfig.SleepTimeAfterRun) * time.Millisecond) } diff --git a/manager/manager.go b/manager/manager.go index 94207a9..469ac20 100644 --- a/manager/manager.go +++ b/manager/manager.go @@ -132,6 +132,7 @@ type ActionSpec struct { type RunSpec struct { RunCommand string ActionFilter ActionSpec + KubeConfigfile string } type CopySpec struct { @@ -139,6 +140,7 @@ type CopySpec struct { LocalPath string ContainerPath string Upload bool + KubeConfigfile string ActionFilter ActionSpec } diff --git a/manager/pod_manager.go b/manager/pod_manager.go index f86e048..423d0ce 100644 --- a/manager/pod_manager.go +++ b/manager/pod_manager.go @@ -544,7 +544,7 @@ func (mgr *PodManager) Run(n interface{}) error { return err } - exec.Stream(remotecommand.StreamOptions{ + exec.StreamWithContext(context.Background(), remotecommand.StreamOptions{ Stdin: nil, Stdout: &mystdout, Stderr: &mystderr, @@ -606,7 +606,7 @@ func (mgr *PodManager) Copy(n interface{}) error { toPath += mgr.startTimestamp + "/" + pod.Name fromPath = pod.Namespace + "/" + pod.Name + ":" + s.ContainerPath } - args := []string{"cp", fromPath, toPath} + args := []string{"cp", fromPath, toPath,"--kubeconfig",s.KubeConfigfile} copyr, copye := osexec.Command("kubectl", args...).CombinedOutput() if copye != nil { log.Errorf("Error copying file(s) for pod: %v", pod.Name) diff --git a/util/driver_util.go b/util/driver_util.go index de91e34..96c01c7 100644 --- a/util/driver_util.go +++ b/util/driver_util.go @@ -40,7 +40,8 @@ func checkAndRunPod( kubeConfig *restclient.Config, op WcpOp, opIdx int, - maxClients map[string]int) string { + maxClients map[string]int, + kubeConfigfile string) string { if len(op.Pod.Actions) > 0 { var podMgr *manager.PodManager @@ -57,7 +58,7 @@ func checkAndRunPod( log.Infof("Performing pod actions in operation %v", opIdx) for i := 0; i < op.Pod.Count; i++ { - go runPodActions(podMgr, op.Pod, opIdx, i) + go runPodActions(podMgr, op.Pod, opIdx, i, kubeConfigfile) wg.Add(1) } @@ -313,7 +314,8 @@ func runPodActions( mgr *manager.PodManager, podConfig PodConfig, opNum int, - tid int) { + tid int, + kubeConfigfile string) { // Get default pod name (used when filtering not specified or applicable) podName := mgr.GetResourceName(podConfig.PodNamePrefix, opNum, tid) @@ -409,7 +411,7 @@ func runPodActions( podName, tid, opNum, ns, lk, lv, runSpec.MatchGoroutine, runSpec.MatchOperation, manager.POD} ae := mgr.ActionFuncs[manager.RUN_ACTION](mgr, - manager.RunSpec{runSpec.Command, as}) + manager.RunSpec{runSpec.Command, as, kubeConfigfile}) if ae != nil { log.Error(ae) } @@ -425,7 +427,7 @@ func runPodActions( *outDir, copySpec.LocalPath, copySpec.ContainerPath, - copySpec.Upload, as}) + copySpec.Upload, kubeConfigfile, as}) if ae != nil { log.Error(ae) } diff --git a/util/testdriver.go b/util/testdriver.go index eab0b91..0c8ab02 100644 --- a/util/testdriver.go +++ b/util/testdriver.go @@ -74,7 +74,7 @@ var outDir *string var mgrs map[string]manager.Manager func Run(kubeConfig *restclient.Config, - testConfig TestConfig, outputDir *string) error { + testConfig TestConfig, outputDir *string, kubeConfigfile string) error { outDir = outputDir wcpOps := testConfig.Operations @@ -221,7 +221,7 @@ func Run(kubeConfig *restclient.Config, opIdx += startIdx // Check and run if valid pod config is found - lastPodAction := checkAndRunPod(kubeConfig, op, opIdx, maxClients) + lastPodAction := checkAndRunPod(kubeConfig, op, opIdx, maxClients, kubeConfigfile) // Check and run if valid deployment config is found lastDepAction := checkAndRunDeployment(kubeConfig, op, opIdx, maxClients)