/
add-on-kubeflow.go
80 lines (71 loc) · 2.77 KB
/
add-on-kubeflow.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package eksconfig
import (
"errors"
"path/filepath"
"runtime"
"strings"
"github.com/aws/aws-k8s-tester/pkg/timeutil"
)
// AddOnKubeflow defines parameters for EKS cluster
// add-on Kubeflow.
// ref. https://www.kubeflow.org/docs/aws/deploy/install-kubeflow/
type AddOnKubeflow struct {
// Enable is 'true' to create this add-on.
Enable bool `json:"enable"`
// Created is true when the resource has been created.
// Used for delete operations.
Created bool `json:"created" read-only:"true"`
TimeFrameCreate timeutil.TimeFrame `json:"time-frame-create" read-only:"true"`
TimeFrameDelete timeutil.TimeFrame `json:"time-frame-delete" read-only:"true"`
// KfctlPath is the path to download the "kfctl".
KfctlPath string `json:"kfctl-path,omitempty"`
// KfctlDownloadURL is the download URL to download "kfctl" binary from.
// ref. https://github.com/kubeflow/kfctl/releases
KfctlDownloadURL string `json:"kfctl-download-url,omitempty"`
// BaseDir is the base directory where you want to store one or more
// Kubeflow deployments.
BaseDir string `json:"base-dir"`
KfDir string `json:"kf-dir" read-only:"true"`
// KfctlConfigPath is the path to write "kfctl" configuration.
// The existing configuration file is overwritten.
KfctlConfigPath string `json:"kfctl-config-path" read-only:"true"`
}
// EnvironmentVariablePrefixAddOnKubeflow is the environment variable prefix used for "eksconfig".
const EnvironmentVariablePrefixAddOnKubeflow = AWS_K8S_TESTER_EKS_PREFIX + "ADD_ON_KUBEFLOW_"
// IsEnabledAddOnKubeflow returns true if "AddOnKubeflow" is enabled.
// Otherwise, nil the field for "omitempty".
func (cfg *Config) IsEnabledAddOnKubeflow() bool {
if cfg.AddOnKubeflow == nil {
return false
}
if cfg.AddOnKubeflow.Enable {
return true
}
cfg.AddOnKubeflow = nil
return false
}
func getDefaultAddOnKubeflow() *AddOnKubeflow {
addOn := &AddOnKubeflow{
Enable: false,
KfctlPath: "/tmp/kfctl-test-v1.0.2",
KfctlDownloadURL: "https://github.com/kubeflow/kfctl/releases/download/v1.0.2/kfctl_v1.0.2-0-ga476281_linux.tar.gz",
}
if runtime.GOOS == "darwin" {
addOn.KfctlDownloadURL = strings.Replace(addOn.KfctlDownloadURL, "linux", "darwin", -1)
}
return addOn
}
func (cfg *Config) validateAddOnKubeflow() error {
if !cfg.IsEnabledAddOnKubeflow() {
return nil
}
if !cfg.IsEnabledAddOnNodeGroups() && !cfg.IsEnabledAddOnManagedNodeGroups() {
return errors.New("AddOnKubeflow.Enable true but no node group is enabled")
}
if cfg.AddOnKubeflow.BaseDir == "" {
cfg.AddOnKubeflow.BaseDir = filepath.Join(filepath.Dir(cfg.ConfigPath), cfg.Name+"-kubeflow")
}
cfg.AddOnKubeflow.KfDir = filepath.Join(cfg.AddOnKubeflow.BaseDir, cfg.Name)
cfg.AddOnKubeflow.KfctlConfigPath = filepath.Join(cfg.AddOnKubeflow.KfDir, "kfctl_aws.yaml")
return nil
}