diff --git a/bootstrap/cmd/kfctl/cmd/root.go b/bootstrap/cmd/kfctl/cmd/root.go index dd68800169a..2c82988151d 100644 --- a/bootstrap/cmd/kfctl/cmd/root.go +++ b/bootstrap/cmd/kfctl/cmd/root.go @@ -43,8 +43,9 @@ func processResourceArg(args []string) (kftypes.ResourceEnum, error) { // rootCmd represents the base command when called without any subcommands var rootCmd = &cobra.Command{ Use: "kfctl", - Short: "A kfdef tool to create kubeflow applications", - Long: `kubeflow kfdef tool`, + Short: "A client CLI to create kubeflow applications", + Long: `A client CLI to create kubeflow applications for specific platforms or 'on-prem' +to an existing k8 cluster.`, } // Execute adds all child commands to the root command and sets flags appropriately. diff --git a/bootstrap/pkg/apis/apps/group.go b/bootstrap/pkg/apis/apps/group.go index bfb24beff93..16216b118d2 100644 --- a/bootstrap/pkg/apis/apps/group.go +++ b/bootstrap/pkg/apis/apps/group.go @@ -51,6 +51,7 @@ const ( DefaultAppLabel = "app.kubernetes.io/name" KUBEFLOW_USERNAME = "KUBEFLOW_USERNAME" KUBEFLOW_PASSWORD = "KUBEFLOW_PASSWORD" + DefaultSwaggerFile = "releasing/releaser/lib/v1.9.7/swagger.json" ) type ResourceEnum string @@ -75,13 +76,11 @@ const ( REPO CliOption = "repo" PROJECT CliOption = "project" APPNAME CliOption = "appname" - APPDIR CliOption = "appDir" DATA CliOption = "Data" ZONE CliOption = "zone" USE_BASIC_AUTH CliOption = "use_basic_auth" OAUTH_ID CliOption = "oauth_id" OAUTH_SECRET CliOption = "oauth_secret" - CONFIG CliOption = "config" ) // diff --git a/bootstrap/pkg/apis/apps/kfdef/v1alpha1/application_types.go b/bootstrap/pkg/apis/apps/kfdef/v1alpha1/application_types.go index 03871f2bc4a..6879773047c 100644 --- a/bootstrap/pkg/apis/apps/kfdef/v1alpha1/application_types.go +++ b/bootstrap/pkg/apis/apps/kfdef/v1alpha1/application_types.go @@ -31,10 +31,9 @@ type KfDefSpec struct { IpName string `json:"ipName,omitempty"` Hostname string `json:"hostname,omitempty"` Zone string `json:"zone,omitempty"` - BasicAuthUsername string `json:"basicAuthUsername,omitempty"` - BasicAuthPassword string `json:"basicAuthPassword,omitempty"` UseBasicAuth bool `json:"useBasicAuth"` SkipInitProject bool `json:"skipInitProject,omitempty"` + ServerVersion string `json:"serverVersion,omitempty"` } var DefaultRegistry = &RegistryConfig{ diff --git a/bootstrap/pkg/apis/apps/kfdef/v1alpha1/zz_generated.deepcopy.go b/bootstrap/pkg/apis/apps/kfdef/v1alpha1/zz_generated.deepcopy.go index 86fe7021cc0..a5e45c5ebdb 100644 --- a/bootstrap/pkg/apis/apps/kfdef/v1alpha1/zz_generated.deepcopy.go +++ b/bootstrap/pkg/apis/apps/kfdef/v1alpha1/zz_generated.deepcopy.go @@ -1,20 +1,18 @@ // +build !ignore_autogenerated -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ +// Copyright 2018 The Kubeflow Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. // Code generated by deepcopy-gen. DO NOT EDIT. diff --git a/bootstrap/pkg/kfapp/coordinator/coordinator.go b/bootstrap/pkg/kfapp/coordinator/coordinator.go index 35b4cecdd61..56e668098c5 100644 --- a/bootstrap/pkg/kfapp/coordinator/coordinator.go +++ b/bootstrap/pkg/kfapp/coordinator/coordinator.go @@ -29,11 +29,11 @@ import ( "github.com/mitchellh/go-homedir" log "github.com/sirupsen/logrus" "io/ioutil" + valid "k8s.io/apimachinery/pkg/api/validation" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "os" "path" "path/filepath" - "regexp" "strings" ) @@ -111,7 +111,7 @@ func downloadToCache(platform string, appDir string, version string, useBasicAut } //TODO see #2629 configPath := filepath.Join(newPath, kftypes.DefaultConfigDir) - if platform == "gcp" { + if platform == kftypes.GCP { if useBasicAuth { configPath = filepath.Join(configPath, kftypes.GcpBasicAuth) } else { @@ -210,11 +210,9 @@ func NewKfApp(options map[string]interface{}) (kftypes.KfApp, error) { appDir = path.Join(appDir, appName) } } - re := regexp.MustCompile(`[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$`) - validName := re.FindString(appName) - if strings.Compare(validName, appName) != 0 { - return nil, fmt.Errorf(`invalid name %v must consist of lower case alphanumeric characters, '-' or '.', -and must start and end with an alphanumeric character`, appName) + errs := valid.NameIsDNSLabel(appName, false) + if errs != nil && len(errs) > 0 { + return nil, fmt.Errorf(`invalid name due to %v`, strings.Join(errs, ", ")) } platform := options[string(kftypes.PLATFORM)].(string) version := options[string(kftypes.VERSION)].(string) diff --git a/bootstrap/pkg/kfapp/gcp/gcp.go b/bootstrap/pkg/kfapp/gcp/gcp.go index 7ead3396d52..7e4a9f94ee5 100644 --- a/bootstrap/pkg/kfapp/gcp/gcp.go +++ b/bootstrap/pkg/kfapp/gcp/gcp.go @@ -880,6 +880,8 @@ func (gcp *Gcp) gcpInitProject() error { func (gcp *Gcp) Init(resources kftypes.ResourceEnum) error { cacheDir := path.Join(gcp.Spec.AppDir, kftypes.DefaultCacheDir) newPath := filepath.Join(cacheDir, gcp.Spec.Version) + swaggerFile := filepath.Join(newPath, kftypes.DefaultSwaggerFile) + gcp.Spec.ServerVersion = "file:" + swaggerFile gcp.Spec.Repo = path.Join(newPath, "kubeflow") createConfigErr := gcp.writeConfigFile() if createConfigErr != nil { diff --git a/bootstrap/pkg/kfapp/ksonnet/ksonnet.go b/bootstrap/pkg/kfapp/ksonnet/ksonnet.go index 61bcfaf9c26..bc31e66f6b6 100644 --- a/bootstrap/pkg/kfapp/ksonnet/ksonnet.go +++ b/bootstrap/pkg/kfapp/ksonnet/ksonnet.go @@ -446,8 +446,10 @@ func (ksApp *ksApp) initKs() error { os.RemoveAll(newRoot) } ksApp.KsEnvName = KsEnvName - // We hard code the K8s spec because we won't have a cluster to talk to when calling init. - k8sSpec := "version:v1.11.7" + k8sSpec := ksApp.Spec.ServerVersion + if k8sSpec == "" { + k8sSpec = kftypes.GetServerVersion(kftypes.GetClientset(kftypes.GetConfig())) + } options := map[string]interface{}{ actions.OptionFs: afero.NewOsFs(), actions.OptionName: ksApp.KsName,