-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.go
37 lines (33 loc) · 844 Bytes
/
install.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package mpioperatortracker
import (
_ "embed"
"fmt"
"io/ioutil"
"os"
"github.com/dgruber/drmaa2interface"
"github.com/dgruber/wfl"
)
//go:embed mpi-operator.yaml
var mpiOperatorYaml string
func InstallMPIOperator(kubeconfigPath string) error {
flow := wfl.NewWorkflow(wfl.NewProcessContextByCfg(
wfl.ProcessConfig{
DefaultTemplate: drmaa2interface.JobTemplate{
OutputPath: "/dev/stdout",
ErrorPath: "/dev/stderr",
JobEnvironment: map[string]string{
"KUBECONFIG": kubeconfigPath,
},
},
},
))
file, _ := ioutil.TempFile("", "mpiOperator.yaml")
file.WriteString(mpiOperatorYaml)
file.Close()
defer os.Remove(file.Name())
job := flow.Run("/bin/bash", "-c", `cat `+file.Name()+` | kubectl apply -f -`).Wait()
if job.Success() {
return nil
}
return fmt.Errorf("failed to install MPI Operator")
}