Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add spartakus as component #2784

Merged
merged 13 commits into from
Mar 24, 2019
13 changes: 13 additions & 0 deletions bootstrap/cmd/kfctl/cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ or a <name>. If just <name> a directory <name> will be created in the current di
"want to use to login and variable %s to the password you want to use.",
kftypes.KUBEFLOW_USERNAME, kftypes.KUBEFLOW_PASSWORD)
}

useIstio := initCfg.GetBool(string(kftypes.USE_ISTIO))
disableUsageReport := initCfg.GetBool(string(kftypes.DISABLE_USAGE_REPORT))

options := map[string]interface{}{
string(kftypes.PLATFORM): platform,
Expand All @@ -72,6 +74,7 @@ or a <name>. If just <name> a directory <name> will be created in the current di
string(kftypes.SKIP_INIT_GCP_PROJECT): init_gcp,
string(kftypes.USE_BASIC_AUTH): useBasicAuth,
string(kftypes.USE_ISTIO): useIstio,
string(kftypes.DISABLE_USAGE_REPORT): disableUsageReport,
}
kfApp, kfAppErr := coordinator.NewKfApp(options)
if kfAppErr != nil || kfApp == nil {
Expand Down Expand Up @@ -169,4 +172,14 @@ func init() {
log.Errorf("couldn't set flag --%v: %v", string(kftypes.USE_ISTIO), bindErr)
return
}

// Skip usage report
initCmd.Flags().Bool(string(kftypes.DISABLE_USAGE_REPORT), false,
string(kftypes.DISABLE_USAGE_REPORT)+" disable anonymous usage reporting.")
bindErr = initCfg.BindPFlag(string(kftypes.DISABLE_USAGE_REPORT),
initCmd.Flags().Lookup(string(kftypes.DISABLE_USAGE_REPORT)))
if bindErr != nil {
log.Errorf("couldn't set flag --%v: %v", string(kftypes.DISABLE_USAGE_REPORT), bindErr)
return
}
}
8 changes: 8 additions & 0 deletions bootstrap/config/kfctl_basic_auth.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ components:
- pipeline
- profiles
- pytorch-operator
- spartakus
- tensorboard
- tf-job-operator
componentParams:
Expand Down Expand Up @@ -74,4 +75,11 @@ componentParams:
value: <deployName>-storage-metadata-store
- name: minioPd
value: <deployName>-storage-artifact-store
spartakus:
- name: usageId
value: <randomly-generated-id>
initRequired: true
- name: reportUsage
value: "true"
initRequired: true
platform: gcp
8 changes: 8 additions & 0 deletions bootstrap/config/kfctl_iap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ components:
- pipeline
- profiles
- pytorch-operator
- spartakus
- tensorboard
- tf-job-operator
componentParams:
Expand Down Expand Up @@ -71,4 +72,11 @@ componentParams:
value: <deployName>-storage-metadata-store
- name: minioPd
value: <deployName>-storage-artifact-store
spartakus:
- name: usageId
value: <randomly-generated-id>
initRequired: true
- name: reportUsage
value: "true"
initRequired: true
platform: gcp
1 change: 1 addition & 0 deletions bootstrap/pkg/apis/apps/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ const (
OAUTH_ID CliOption = "oauth_id"
OAUTH_SECRET CliOption = "oauth_secret"
DELETE_STORAGE CliOption = "delete_storage"
DISABLE_USAGE_REPORT CliOption = "disable_usage_report"
)

//
Expand Down
45 changes: 45 additions & 0 deletions bootstrap/pkg/kfapp/coordinator/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,42 @@ func getPackageManager(packagemanager string, kfdef *kfdefs.KfDef) (kftypes.KfAp
}
}

// Helper function to filter out spartakus.
func filterSpartakus(components []string) []string {
ret := []string{}
for _, comp := range components {
if comp != "spartakus" {
ret = append(ret, comp)
}
}
return ret
}

// Helper function to print out warning message if using usage reporting.
func usageReportWarn(components []string) {
msg := "\n" +
"****************************************************************\n" +
"Notice anonymous usage reporting enabled using spartakus\n" +
"To disable it\n" +
"If you have already deployed it run the following commands:\n" +
" cd $(pwd)\n" +
" ks delete default -c spartakus\n" +
" kubectl -n ${K8S_NAMESPACE} delete deploy -l app=spartakus\n" +
"\n" +
"Then run the following command to remove it from your ksonnet app:\n" +
" ks component rm spartakus\n" +
"\n" +
"For more info: https://www.kubeflow.org/docs/guides/usage-reporting/\n" +
"****************************************************************\n" +
"\n"
for _, comp := range components {
if comp == "spartakus" {
log.Warnf(msg)
return
}
}
}

// NewKfApp is called from the Init subcommand and will create a directory based on
// the path/name argument given to the Init subcommand
func NewKfApp(options map[string]interface{}) (kftypes.KfApp, error) {
Expand Down Expand Up @@ -242,6 +278,12 @@ func NewKfApp(options map[string]interface{}) (kftypes.KfApp, error) {
if specErr != nil {
log.Errorf("couldn't unmarshal app.yaml. Error: %v", specErr)
}
disableUsageReport := options[string(kftypes.DISABLE_USAGE_REPORT)].(bool)
if disableUsageReport {
kfDef.Spec.Components = filterSpartakus(kfDef.Spec.Components)
delete(kfDef.Spec.ComponentParams, "spartakus")
}

kfDef.Name = appName
kfDef.Spec.AppDir = appDir
kfDef.Spec.Platform = options[string(kftypes.PLATFORM)].(string)
Expand Down Expand Up @@ -451,6 +493,9 @@ func (kfapp *coordinator) Generate(resources kftypes.ResourceEnum) error {
return nil
}

// Print out warning message if using usage reporting component.
usageReportWarn(kfapp.KfDef.Spec.Components)

switch resources {
case kftypes.ALL:
if err := platform(); err != nil {
Expand Down
11 changes: 11 additions & 0 deletions bootstrap/pkg/kfapp/gcp/gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,16 @@ import (
rbacv1 "k8s.io/api/rbac/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clientset "k8s.io/client-go/kubernetes"
"math/rand"
"net/http"
"os"
"os/exec"
"path"
"path/filepath"
"regexp"
"strconv"
"strings"
"time"
)

// TODO: golint complains that we should not use all capital var name.
Expand Down Expand Up @@ -845,6 +848,14 @@ func (gcp *Gcp) Generate(resources kftypes.ResourceEnum) error {
gcp.Spec.ComponentParams["pipeline"] = setNameVal(gcp.Spec.ComponentParams["pipeline"], "mysqlPd", gcp.Name+"-storage-metadata-store", false)
gcp.Spec.ComponentParams["pipeline"] = setNameVal(gcp.Spec.ComponentParams["pipeline"], "minioPd", gcp.Name+"-storage-artifact-store", false)

for _, comp := range gcp.Spec.Components {
if comp == "spartakus" {
rand.Seed(time.Now().UnixNano())
gcp.Spec.ComponentParams["spartakus"] = setNameVal(gcp.Spec.ComponentParams["spartakus"],
"usageId", strconv.Itoa(rand.Int()), true)
}
}

if gcp.Spec.UseIstio {
gcp.Spec.ComponentParams["iap-ingress"] = setNameVal(gcp.Spec.ComponentParams["iap-ingress"], "useIstio", "true", false)
}
Expand Down
1 change: 1 addition & 0 deletions testing/kfctl/kfctl_go_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def test_build_kfctl_go(app_path, project):
# username and password are passed as env vars and won't appear in the logs
run_with_retries([kfctl_path, "init", app_path, "-V", "--platform=gcp",
"--use_basic_auth", "--skip-init-gcp-project",
"--disable_usage_report",
"--project=" + project], cwd=parent_dir)

# TODO(jlewi): We need to specify a valid email otherwise we get an error
Expand Down