diff --git a/package.json b/package.json index 520c7757..40c3e235 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "venona", - "version": "0.15.1", + "version": "0.16.0", "description": "Codefresh agent to run on Codefresh's runtime environment and execute pipeline", "main": "index.js", "scripts": { diff --git a/venonactl/Makefile b/venonactl/Makefile new file mode 100644 index 00000000..1b7f9b33 --- /dev/null +++ b/venonactl/Makefile @@ -0,0 +1,5 @@ +.PHONY: build +build: build-local + +build-local: + sh ./hack/build.sh \ No newline at end of file diff --git a/venonactl/cmd/cmdutils.go b/venonactl/cmd/cmdutils.go new file mode 100644 index 00000000..527fd9aa --- /dev/null +++ b/venonactl/cmd/cmdutils.go @@ -0,0 +1,152 @@ +package cmd + +import ( + "fmt" + "os" + "os/user" + "path" + "strings" + + "github.com/codefresh-io/go-sdk/pkg/codefresh" + sdkUtils "github.com/codefresh-io/go-sdk/pkg/utils" + "github.com/codefresh-io/venona/venonactl/pkg/certs" + runtimectl "github.com/codefresh-io/venona/venonactl/pkg/operators" + "github.com/codefresh-io/venona/venonactl/pkg/store" + "github.com/sirupsen/logrus" +) + +var ( + version = "dev" + commit = "none" + date = "unknown" + // set to false by default, when running hack/build.sh will change to true + // to prevent version checking during development + localDevFlow = "false" + + verbose bool + + configPath string + cfAPIHost string + cfAPIToken string + cfContext string + + kubeConfigPath string + + skipVerionCheck bool +) + +func buildBasicStore() { + s := store.GetStore() + s.Version = &store.Version{ + Current: &store.CurrentVersion{ + Version: version, + Commit: commit, + Date: date, + }, + } + + s.Image = &store.Image{ + Name: "codefresh/venona", + } + + s.Mode = store.ModeInCluster + + s.ServerCert = &certs.ServerCert{} + + s.AppName = store.ApplicationName + + if skipVerionCheck || localDevFlow == "true" { + latestVersion := &store.LatestVersion{ + Version: store.DefaultVersion, + IsDefault: true, + } + s.Version.Latest = latestVersion + logrus.WithFields(logrus.Fields{ + "Default-Version": store.DefaultVersion, + "Image-Tag": s.Version.Current.Version, + }).Debug("Skipping version check") + } else { + latestVersion := &store.LatestVersion{ + Version: store.GetLatestVersion(), + IsDefault: false, + } + s.Image.Tag = latestVersion.Version + s.Version.Latest = latestVersion + res, _ := store.IsRunningLatestVersion() + // the local version and the latest version not match + // make sure the command is no venonactl version + if !res { + logrus.WithFields(logrus.Fields{ + "Local-Version": s.Version.Current.Version, + "Latest-Version": s.Version.Latest.Version, + }).Info("New version is avaliable, please update") + } + } +} + +func extendStoreWithCodefershClient() error { + s := store.GetStore() + if configPath == "" { + configPath = fmt.Sprintf("%s/.cfconfig", os.Getenv("HOME")) + } + + if cfAPIHost == "" && cfAPIToken == "" { + context, err := sdkUtils.ReadAuthContext(configPath, cfContext) + if err != nil { + return err + } + cfAPIHost = context.URL + cfAPIToken = context.Token + + logrus.WithFields(logrus.Fields{ + "Context-Name": context.Name, + "Codefresh-Host": cfAPIHost, + }).Debug("Using codefresh context") + } else { + logrus.Debug("Using creentials from environment variables") + } + + client := codefresh.New(&codefresh.ClientOptions{ + Auth: codefresh.AuthOptions{ + Token: cfAPIToken, + }, + Host: cfAPIHost, + }) + s.CodefreshAPI = &store.CodefreshAPI{ + Host: cfAPIHost, + Token: cfAPIToken, + Client: client, + } + + return nil +} + +func extendStoreWithKubeClient() { + s := store.GetStore() + if kubeConfigPath == "" { + currentUser, _ := user.Current() + if currentUser != nil { + kubeConfigPath = path.Join(currentUser.HomeDir, ".kube", "config") + logrus.WithFields(logrus.Fields{ + "Kube-Config-Path": kubeConfigPath, + }).Debug("Path to kubeconfig not set, using default") + } + } + + s.KubernetesAPI = &store.KubernetesAPI{ + ConfigPath: kubeConfigPath, + } +} + +func prepareLogger() { + if verbose == true { + logrus.SetLevel(logrus.DebugLevel) + } +} + +func isUsingDefaultStorageClass(sc string) bool { + if sc == "" { + return true + } + return strings.HasPrefix(sc, runtimectl.DefaultStorageClassNamePrefix) +} diff --git a/venonactl/cmd/delete.go b/venonactl/cmd/delete.go index d40bc5c0..f2b4456f 100644 --- a/venonactl/cmd/delete.go +++ b/venonactl/cmd/delete.go @@ -34,9 +34,13 @@ type DeletionError struct { name string } -var ( +var deleteCmdOptions struct { + kube struct { + inCluster bool + context string + } revertTo string -) +} // deleteCmd represents the status command var deleteCmd = &cobra.Command{ @@ -50,27 +54,27 @@ var deleteCmd = &cobra.Command{ }, Run: func(cmd *cobra.Command, args []string) { s := store.GetStore() + prepareLogger() + buildBasicStore() + extendStoreWithCodefershClient() + extendStoreWithKubeClient() var errors []DeletionError - contextName := "" - kubeContextFlag := cmd.Flag("kube-context-name") - if kubeContextFlag != nil { - contextName = kubeContextFlag.Value.String() - } - s.KubernetesAPI.InCluster = inCluster + s.KubernetesAPI.InCluster = deleteCmdOptions.kube.inCluster for _, name := range args { re, err := s.CodefreshAPI.Client.RuntimeEnvironments().Get(name) errors = collectError(errors, err, name, "Get Runtime-Environment from Codefresh") - if revertTo != "" { - _, err := s.CodefreshAPI.Client.RuntimeEnvironments().Default(revertTo) - errors = collectError(errors, err, name, fmt.Sprintf("Revert Runtime-Environment to: %s", revertTo)) + if deleteCmdOptions.revertTo != "" { + _, err := s.CodefreshAPI.Client.RuntimeEnvironments().Default(deleteCmdOptions.revertTo) + errors = collectError(errors, err, name, fmt.Sprintf("Revert Runtime-Environment to: %s", deleteCmdOptions.revertTo)) } deleted, err := s.CodefreshAPI.Client.RuntimeEnvironments().Delete(name) errors = collectError(errors, err, name, "Delete Runtime-Environment from Codefresh") if deleted { - if contextName == "" { - contextName = re.RuntimeScheduler.Cluster.ClusterProvider.Selector + contextName := re.RuntimeScheduler.Cluster.ClusterProvider.Selector + if contextName != "" { + contextName = deleteCmdOptions.kube.context } s.KubernetesAPI.ContextName = contextName s.KubernetesAPI.Namespace = re.RuntimeScheduler.Cluster.Namespace @@ -83,6 +87,18 @@ var deleteCmd = &cobra.Command{ }) continue } + if isUsingDefaultStorageClass(re.RuntimeScheduler.Pvcs.Dind.StorageClassName) { + err = runtimectl.GetOperator(runtimectl.VolumeProvisionerOperatorType).Delete() + if err != nil { + errors = append(errors, DeletionError{ + err: err, + name: name, + operation: "Delete volume provisioner related components", + }) + continue + } + } + if re.Metadata.Agent { err = runtimectl.GetOperator(runtimectl.VenonaOperatorType).Delete() if err != nil { @@ -94,6 +110,7 @@ var deleteCmd = &cobra.Command{ continue } } + logrus.Infof("Deleted %s", name) } @@ -113,9 +130,9 @@ var deleteCmd = &cobra.Command{ func init() { rootCmd.AddCommand(deleteCmd) - deleteCmd.Flags().String("kube-context-name", "", "Set name to overwrite the context name saved in Codefresh") - deleteCmd.Flags().StringVar(&revertTo, "revert-to", "", "Set to the name of the runtime-environment to set as default") - deleteCmd.Flags().BoolVar(&inCluster, "in-cluster", false, "Set flag if venona is been installed from inside a cluster") + deleteCmd.Flags().StringVar(&deleteCmdOptions.kube.context, "kube-context-name", "", "Set name to overwrite the context name saved in Codefresh") + deleteCmd.Flags().StringVar(&deleteCmdOptions.revertTo, "revert-to", "", "Set to the name of the runtime-environment to set as default") + deleteCmd.Flags().BoolVar(&deleteCmdOptions.kube.inCluster, "in-cluster", false, "Set flag if venona is been installed from inside a cluster") } func collectError(errors []DeletionError, err error, reName string, op string) []DeletionError { diff --git a/venonactl/cmd/install.go b/venonactl/cmd/install.go index 44576c2c..ae386088 100644 --- a/venonactl/cmd/install.go +++ b/venonactl/cmd/install.go @@ -32,17 +32,23 @@ import ( "github.com/spf13/viper" ) -var ( - clusterName string - dryRun bool - skipRuntimeInstallation bool - installOnlyRuntimeEnvironment bool +var installCmdOptions struct { + dryRun bool + clusterNameInCodefresh string + kube struct { + namespace string + inCluster bool + context string + } + storageClass string + venona struct { + version string + } setDefaultRuntime bool - - kubeNamespace string - kubeContextName string - inCluster bool -) + installOnlyRuntimeEnvironment bool + skipRuntimeInstallation bool + runtimeEnvironmentName string +} // installCmd represents the install command var installCmd = &cobra.Command{ @@ -50,54 +56,62 @@ var installCmd = &cobra.Command{ Short: "Install Codefresh's runtime-environment", Run: func(cmd *cobra.Command, args []string) { s := store.GetStore() + prepareLogger() + buildBasicStore() + extendStoreWithCodefershClient() + extendStoreWithKubeClient() - if kubeContextName == "" { + if installCmdOptions.kube.context == "" { config := clientcmd.GetConfigFromFileOrDie(s.KubernetesAPI.ConfigPath) - kubeContextName = config.CurrentContext + installCmdOptions.kube.context = config.CurrentContext logrus.WithFields(logrus.Fields{ - "Kube-Context-Name": kubeContextName, + "Kube-Context-Name": installCmdOptions.kube.context, }).Debug("Kube Context is not set, using current context") } - if kubeNamespace == "" { - kubeNamespace = "default" + if installCmdOptions.kube.namespace == "" { + installCmdOptions.kube.namespace = "default" } - s.KubernetesAPI.InCluster = inCluster + s.KubernetesAPI.InCluster = installCmdOptions.kube.inCluster - s.KubernetesAPI.ContextName = kubeContextName - s.KubernetesAPI.Namespace = kubeNamespace + s.KubernetesAPI.ContextName = installCmdOptions.kube.context + s.KubernetesAPI.Namespace = installCmdOptions.kube.namespace - version := cmd.Flag("venona-version").Value.String() - if dryRun == true { - s.DryRun = dryRun + if installCmdOptions.dryRun { + s.DryRun = installCmdOptions.dryRun logrus.Info("Running in dry-run mode") } - if version != "" { + if installCmdOptions.venona.version != "" { + version := installCmdOptions.venona.version logrus.WithFields(logrus.Fields{ "venona-Version": version, }).Info("venona version set by user") s.Image.Tag = version s.Version.Latest.Version = version } - s.ClusterInCodefresh = clusterName - if installOnlyRuntimeEnvironment == true && skipRuntimeInstallation == true { + s.ClusterInCodefresh = installCmdOptions.clusterNameInCodefresh + if installCmdOptions.installOnlyRuntimeEnvironment == true && installCmdOptions.skipRuntimeInstallation == true { internal.DieOnError(fmt.Errorf("Cannot use both flags skip-runtime-installation and only-runtime-environment")) } - if installOnlyRuntimeEnvironment == true { - installRuntimeEnvironment() + if installCmdOptions.installOnlyRuntimeEnvironment == true { + registerRuntimeEnvironment() return - } else if skipRuntimeInstallation == true { - runtimeEnvironmentName := cmd.Flag("runtime-environment").Value.String() - if runtimeEnvironmentName == "" { + } else if installCmdOptions.skipRuntimeInstallation == true { + if installCmdOptions.runtimeEnvironmentName == "" { internal.DieOnError(fmt.Errorf("runtime-environment flag is required when using flag skip-runtime-installation")) } - s.RuntimeEnvironment = runtimeEnvironmentName + s.RuntimeEnvironment = installCmdOptions.runtimeEnvironmentName logrus.Info("Skipping installation of runtime environment, installing venona only") installvenona() } else { - installRuntimeEnvironment() + registerRuntimeEnvironment() installvenona() } + if isUsingDefaultStorageClass(installCmdOptions.storageClass) { + configureVolumeProvisioner() + } else { + logrus.Info("Non default StorageClass is set, skipping installation of volume provisioner") + } logrus.Info("Installation completed Successfully\n") }, } @@ -108,36 +122,62 @@ func init() { viper.BindEnv("kube-namespace", "KUBE_NAMESPACE") viper.BindEnv("kube-context", "KUBE_CONTEXT") - installCmd.Flags().StringVar(&clusterName, "cluster-name", "", "cluster name (if not passed runtime-environment will be created cluster-less)") - installCmd.Flags().String("venona-version", "", "Version of venona to install (default is the latest)") - installCmd.Flags().BoolVar(&skipRuntimeInstallation, "skip-runtime-installation", false, "Set flag if you already have a configured runtime-environment, add --runtime-environment flag with name") - installCmd.Flags().String("runtime-environment", "", "if --skip-runtime-installation set, will try to configure venona on current runtime-environment") - installCmd.Flags().BoolVar(&installOnlyRuntimeEnvironment, "only-runtime-environment", false, "Set to true to onlky configure namespace as runtime-environment for Codefresh") - installCmd.Flags().BoolVar(&dryRun, "dry-run", false, "Set to true to simulate installation") - installCmd.Flags().StringVar(&kubeNamespace, "kube-namespace", viper.GetString("kube-namespace"), "Name of the namespace on which venona should be installed [$KUBE_NAMESPACE]") - installCmd.Flags().StringVar(&kubeContextName, "kube-context-name", viper.GetString("kube-context"), "Name of the kubernetes context on which venona should be installed (default is current-context) [$KUBE_CONTEXT]") - installCmd.Flags().BoolVar(&setDefaultRuntime, "set-default", false, "Mark the install runtime-environment as default one after installation") - installCmd.Flags().BoolVar(&inCluster, "in-cluster", false, "Set flag if venona is been installed from inside a cluster") + installCmd.Flags().StringVar(&installCmdOptions.clusterNameInCodefresh, "cluster-name", "", "cluster name (if not passed runtime-environment will be created cluster-less)") + installCmd.Flags().StringVar(&installCmdOptions.venona.version, "venona-version", "", "Version of venona to install (default is the latest)") + installCmd.Flags().StringVar(&installCmdOptions.runtimeEnvironmentName, "runtime-environment", "", "if --skip-runtime-installation set, will try to configure venona on current runtime-environment") + installCmd.Flags().StringVar(&installCmdOptions.kube.namespace, "kube-namespace", viper.GetString("kube-namespace"), "Name of the namespace on which venona should be installed [$KUBE_NAMESPACE]") + installCmd.Flags().StringVar(&installCmdOptions.kube.context, "kube-context-name", viper.GetString("kube-context"), "Name of the kubernetes context on which venona should be installed (default is current-context) [$KUBE_CONTEXT]") + installCmd.Flags().StringVar(&installCmdOptions.storageClass, "storage-class", "", "Set a name of your custom storage class, note: this will not install volume provisioning components") + + installCmd.Flags().BoolVar(&installCmdOptions.skipRuntimeInstallation, "skip-runtime-installation", false, "Set flag if you already have a configured runtime-environment, add --runtime-environment flag with name") + installCmd.Flags().BoolVar(&installCmdOptions.kube.inCluster, "in-cluster", false, "Set flag if venona is been installed from inside a cluster") + installCmd.Flags().BoolVar(&installCmdOptions.installOnlyRuntimeEnvironment, "only-runtime-environment", false, "Set to true to onlky configure namespace as runtime-environment for Codefresh") + installCmd.Flags().BoolVar(&installCmdOptions.dryRun, "dry-run", false, "Set to true to simulate installation") + installCmd.Flags().BoolVar(&installCmdOptions.setDefaultRuntime, "set-default", false, "Mark the install runtime-environment as default one after installation") } -func installRuntimeEnvironment() { - cfAPI := codefresh.New() - err := cfAPI.Validate() +func registerRuntimeEnvironment() { + s := store.GetStore() + registerWithAgent := true + name := s.KubernetesAPI.ContextName + if s.ClusterInCodefresh != "" { + registerWithAgent = false + name = s.ClusterInCodefresh + } + opt := &codefresh.APIOptions{ + Logger: logrus.New(), + CodefreshHost: s.CodefreshAPI.Host, + CodefreshToken: s.CodefreshAPI.Token, + ClusterName: name, + ClusterNamespace: s.KubernetesAPI.Namespace, + RegisterWithAgent: registerWithAgent, + MarkAsDefault: installCmdOptions.setDefaultRuntime, + StorageClass: installCmdOptions.storageClass, + IsDefaultStorageClass: isUsingDefaultStorageClass(installCmdOptions.storageClass), + } + cf := codefresh.NewCodefreshAPI(opt) + + cert, err := cf.Sign() internal.DieOnError(err) - - err = cfAPI.Sign() + err = cf.Validate() internal.DieOnError(err) err = runtimectl.GetOperator(runtimectl.RuntimeEnvironmentOperatorType).Install() internal.DieOnError(err) - err = cfAPI.Register(&codefresh.RegisterOptions{ - MarkDefaultRuntime: setDefaultRuntime, - }) + re, err := cf.Register() internal.DieOnError(err) + + s.RuntimeEnvironment = re.Metadata.Name + s.ServerCert = cert } func installvenona() { err := runtimectl.GetOperator(runtimectl.VenonaOperatorType).Install() internal.DieOnError(err) } + +func configureVolumeProvisioner() { + err := runtimectl.GetOperator(runtimectl.VolumeProvisionerOperatorType).Install() + internal.DieOnError(err) +} diff --git a/venonactl/cmd/root.go b/venonactl/cmd/root.go index 5c64090f..bb42858f 100644 --- a/venonactl/cmd/root.go +++ b/venonactl/cmd/root.go @@ -17,152 +17,16 @@ limitations under the License. */ import ( - "fmt" - "os" - "os/user" - "path" - "strings" - "github.com/spf13/viper" "github.com/codefresh-io/venona/venonactl/internal" - "github.com/sirupsen/logrus" - - "github.com/codefresh-io/go-sdk/pkg/codefresh" - sdkUtils "github.com/codefresh-io/go-sdk/pkg/utils" - "github.com/codefresh-io/venona/venonactl/pkg/certs" - "github.com/codefresh-io/venona/venonactl/pkg/store" "github.com/spf13/cobra" ) -var verbose bool -var skipVerionCheck bool - -// variables been set with ldflags flag -var ( - version = "dev" - commit = "none" - date = "unknown" - // set to false by default, when running hack/build.sh will change to true - // to prevent version checking during development - localDevFlow = "false" - - configPath string - cfAPIHost string - cfAPIToken string - cfContext string - - kubeConfigPath string -) - var rootCmd = &cobra.Command{ - Use: "venonactl", + Use: "venona", Short: "A command line application for Codefresh", - - PersistentPreRunE: func(cmd *cobra.Command, args []string) error { - fullPath := cmd.CommandPath() - isVersionTarget := strings.Index(fullPath, "version") != -1 - if verbose == true { - logrus.SetLevel(logrus.DebugLevel) - } - - s := store.GetStore() - s.Version = &store.Version{ - Current: &store.CurrentVersion{ - Version: version, - Commit: commit, - Date: date, - }, - } - - s.Image = &store.Image{ - Name: "codefresh/venona", - } - - if skipVerionCheck || localDevFlow == "true" { - latestVersion := &store.LatestVersion{ - Version: store.DefaultVersion, - IsDefault: true, - } - s.Version.Latest = latestVersion - logrus.WithFields(logrus.Fields{ - "Default-Version": store.DefaultVersion, - "Image-Tag": s.Version.Current.Version, - }).Debug("Skipping version check") - } else { - latestVersion := &store.LatestVersion{ - Version: store.GetLatestVersion(), - IsDefault: false, - } - s.Image.Tag = latestVersion.Version - s.Version.Latest = latestVersion - res, _ := store.IsRunningLatestVersion() - // the local version and the latest version not match - // make sure the command is no venonactl version - if !res && !isVersionTarget { - logrus.WithFields(logrus.Fields{ - "Local-Version": s.Version.Current.Version, - "Latest-Version": s.Version.Latest.Version, - }).Info("New version is avaliable, please update") - } - } - - if isVersionTarget { - return nil - } - - if configPath == "" { - configPath = fmt.Sprintf("%s/.cfconfig", os.Getenv("HOME")) - } - - if cfAPIHost == "" && cfAPIToken == "" { - context, err := sdkUtils.ReadAuthContext(configPath, cfContext) - if err != nil { - return err - } - cfAPIHost = context.URL - cfAPIToken = context.Token - - logrus.WithFields(logrus.Fields{ - "Context-Name": context.Name, - "Codefresh-Host": cfAPIHost, - }).Debug("Using codefresh context") - } else { - logrus.Debug("Using creentials from environment variables") - } - client := codefresh.New(&codefresh.ClientOptions{ - Auth: codefresh.AuthOptions{ - Token: cfAPIToken, - }, - Host: cfAPIHost, - }) - - if kubeConfigPath == "" { - currentUser, _ := user.Current() - if currentUser != nil { - kubeConfigPath = path.Join(currentUser.HomeDir, ".kube", "config") - logrus.WithFields(logrus.Fields{ - "Kube-Config-Path": kubeConfigPath, - }).Debug("Path to kubeconfig not set, using default") - } - } - - s.AppName = store.ApplicationName - s.KubernetesAPI = &store.KubernetesAPI{ - ConfigPath: kubeConfigPath, - } - s.ClusterInCodefresh = clusterName - s.CodefreshAPI = &store.CodefreshAPI{ - Host: cfAPIHost, - Token: cfAPIToken, - Client: client, - } - s.Mode = store.ModeInCluster - s.ServerCert = &certs.ServerCert{} - - return nil - }, } // Execute - execute the root command @@ -185,6 +49,7 @@ func init() { rootCmd.PersistentFlags().StringVar(&cfContext, "context", "", "Name of the context from --cfconfig (default is current-context)") rootCmd.PersistentFlags().StringVar(&kubeConfigPath, "kube-config-path", viper.GetString("kubeconfig"), "Path to kubeconfig file (default is $HOME/.kube/config) [$KUBECONFIG]") + rootCmd.PersistentFlags().BoolVar(&verbose, "verbose", false, "Print logs") rootCmd.PersistentFlags().BoolVar(&skipVerionCheck, "skip-version-check", false, "Do not compare current Venona's version with latest") diff --git a/venonactl/cmd/status.go b/venonactl/cmd/status.go index 03ad8784..6744d5ff 100644 --- a/venonactl/cmd/status.go +++ b/venonactl/cmd/status.go @@ -30,19 +30,26 @@ import ( "github.com/spf13/cobra" ) +var statusCmdOpt struct { + kube struct { + context string + } + dryRun bool +} + // statusCmd represents the status command var statusCmd = &cobra.Command{ Use: "status [name]", Short: "Get status of Codefresh's runtime-environment", Long: "Pass the name of the runtime environment to see more details information about the underlying resources", Run: func(cmd *cobra.Command, args []string) { + prepareLogger() + buildBasicStore() + extendStoreWithCodefershClient() + extendStoreWithKubeClient() + s := store.GetStore() table := internal.CreateTable() - contextName := "" - kubeContextFlag := cmd.Flag("kube-context-name") - if kubeContextFlag != nil { - contextName = kubeContextFlag.Value.String() - } // When requested status for specific runtime if len(args) > 0 { name := args[0] @@ -62,7 +69,7 @@ var statusCmd = &cobra.Command{ table.Append([]string{re.Metadata.Name, message, time}) table.Render() fmt.Println() - printTableWithKubernetesRelatedResources(re, contextName) + printTableWithKubernetesRelatedResources(re, statusCmdOpt.kube.context) } else { logrus.Warnf("Runtime-Environment %s has not Venona's agent", name) } @@ -114,5 +121,5 @@ func printTableWithKubernetesRelatedResources(re *codefresh.RuntimeEnvironment, func init() { rootCmd.AddCommand(statusCmd) - statusCmd.Flags().String("kube-context-name", "", "Set name to overwrite the context name saved in Codefresh") + statusCmd.Flags().StringVar(&statusCmdOpt.kube.context, "kube-context-name", "", "Set name to overwrite the context name saved in Codefresh") } diff --git a/venonactl/cmd/upgrade.go b/venonactl/cmd/upgrade.go index af688c0c..3ab6c9c0 100644 --- a/venonactl/cmd/upgrade.go +++ b/venonactl/cmd/upgrade.go @@ -19,11 +19,21 @@ limitations under the License. import ( "errors" + "github.com/codefresh-io/venona/venonactl/internal" "github.com/codefresh-io/venona/venonactl/pkg/operators" + runtimectl "github.com/codefresh-io/venona/venonactl/pkg/operators" "github.com/codefresh-io/venona/venonactl/pkg/store" + "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) +var upgradeCmdOpt struct { + kube struct { + context string + } + dryRun bool +} + // upgradeCmd represents the upgrade command var upgradeCmd = &cobra.Command{ Use: "upgrade [name]", @@ -40,18 +50,32 @@ var upgradeCmd = &cobra.Command{ }, Run: func(cmd *cobra.Command, args []string) { s := store.GetStore() - kubeContextFlag := cmd.Flag("kube-context-name") + prepareLogger() + buildBasicStore() + extendStoreWithCodefershClient() + extendStoreWithKubeClient() + re, _ := s.CodefreshAPI.Client.RuntimeEnvironments().Get(args[0]) contextName := re.RuntimeScheduler.Cluster.ClusterProvider.Selector - if kubeContextFlag != nil { - contextName = kubeContextFlag.Value.String() + if upgradeCmdOpt.kube.context != "" { + contextName = upgradeCmdOpt.kube.context } s.KubernetesAPI.ContextName = contextName s.KubernetesAPI.Namespace = re.RuntimeScheduler.Cluster.Namespace - operators.GetOperator(operators.VenonaOperatorType).Upgrade() + if upgradeCmdOpt.dryRun { + logrus.Info("Running in dry-run mode") + } else { + operators.GetOperator(operators.VenonaOperatorType).Upgrade() + if isUsingDefaultStorageClass(re.RuntimeScheduler.Pvcs.Dind.StorageClassName) { + err := runtimectl.GetOperator(runtimectl.VolumeProvisionerOperatorType).Delete() + internal.DieOnError(err) + } + } }, } func init() { rootCmd.AddCommand(upgradeCmd) + upgradeCmd.Flags().StringVar(&upgradeCmdOpt.kube.context, "kube-context-name", "", "Set name to overwrite the context name saved in Codefresh") + upgradeCmd.Flags().BoolVar(&upgradeCmdOpt.dryRun, "dry-run", false, "Set to to actually upgrade the kubernetes components") } diff --git a/venonactl/cmd/version.go b/venonactl/cmd/version.go index d070e472..9d527ae8 100644 --- a/venonactl/cmd/version.go +++ b/venonactl/cmd/version.go @@ -29,6 +29,7 @@ var versionCmd = &cobra.Command{ Short: "Print Venona version", Run: func(cmd *cobra.Command, args []string) { s := store.GetStore() + buildBasicStore() fmt.Printf("Date: %s\n", s.Version.Current.Date) fmt.Printf("Commit: %s\n", s.Version.Current.Commit) fmt.Printf("Local Version: %s\n", s.Version.Current.Version) diff --git a/venonactl/go.mod b/venonactl/go.mod index 31543fdf..679e71c4 100644 --- a/venonactl/go.mod +++ b/venonactl/go.mod @@ -3,7 +3,7 @@ module github.com/codefresh-io/venona/venonactl require ( contrib.go.opencensus.io/exporter/ocagent v0.4.3 // indirect github.com/Azure/go-autorest v11.4.0+incompatible // indirect - github.com/codefresh-io/go-sdk v0.8.1 + github.com/codefresh-io/go-sdk v0.10.0 github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect github.com/dustin/go-humanize v1.0.0 github.com/gogo/protobuf v1.2.0 // indirect diff --git a/venonactl/go.sum b/venonactl/go.sum index c5321883..6d171e8a 100644 --- a/venonactl/go.sum +++ b/venonactl/go.sum @@ -14,8 +14,8 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24 github.com/census-instrumentation/opencensus-proto v0.1.0-0.20181214143942-ba49f56771b8 h1:gUqsFVdUKoRHNg8fkFd8gB5OOEa/g5EwlAHznb4zjbI= github.com/census-instrumentation/opencensus-proto v0.1.0-0.20181214143942-ba49f56771b8/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/codefresh-io/go-sdk v0.8.1 h1:kNzn9FIQIhwi7GLNVD38QdbOSmO7kJv1xBupvHjZbZ0= -github.com/codefresh-io/go-sdk v0.8.1/go.mod h1:U8c2f9/Vb2SXFbeKHSzofUOp3N78pDC3YdshFsUfdgc= +github.com/codefresh-io/go-sdk v0.10.0 h1:xgfkapCLrx2FHofWq9LRsH0bLcNgwPZWQZTttCvMUng= +github.com/codefresh-io/go-sdk v0.10.0/go.mod h1:U8c2f9/Vb2SXFbeKHSzofUOp3N78pDC3YdshFsUfdgc= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= diff --git a/venonactl/pkg/codefresh/cfapi.go b/venonactl/pkg/codefresh/cfapi.go index e340becf..7c358fd4 100644 --- a/venonactl/pkg/codefresh/cfapi.go +++ b/venonactl/pkg/codefresh/cfapi.go @@ -20,83 +20,89 @@ import ( "bytes" "fmt" - "github.com/sirupsen/logrus" - - "github.com/codefresh-io/venona/venonactl/pkg/store" - "archive/zip" "github.com/codefresh-io/go-sdk/pkg/codefresh" "github.com/codefresh-io/venona/venonactl/pkg/certs" - runtimectl "github.com/codefresh-io/venona/venonactl/pkg/operators" -) - -const ( - // DefaultURL - by default it is Codefresh Production - DefaultURL = "https://g.codefresh.io" - - codefreshAgent = "venona-ctl" - userAgent = "venona-ctl" ) type ( - // CfAPI struct to call Codefresh API - CfAPI struct { + API interface { + RuntimeEnvironmentRegistrator } - RegisterOptions struct { - MarkDefaultRuntime bool + APIOptions struct { + Logger logger + CodefreshHost string + CodefreshToken string + ClusterName string + ClusterNamespace string + RegisterWithAgent bool + MarkAsDefault bool + StorageClass string + IsDefaultStorageClass bool } -) -// New - constructs CfAPI -func New() *CfAPI { - return &CfAPI{} -} + RuntimeEnvironmentRegistrator interface { + Validate() error + Sign() (*certs.ServerCert, error) + Register() (*codefresh.RuntimeEnvironment, error) + } -// Validate calls codefresh API to validate runtimectlConfig -func (u *CfAPI) Validate() error { - logrus.Debug("Calling codefresh.Validate") - cf := store.GetStore().CodefreshAPI.Client - s := store.GetStore() - opt := &codefresh.ValidateRuntimeOptions{ - Namespace: s.KubernetesAPI.Namespace, + api struct { + logger logger + codefresh codefresh.Codefresh + clustername string + clusternamespace string + registerWithAgent bool + markAsDefault bool + storageClass string + isDefaultStorageClass bool } - if s.ClusterInCodefresh != "" { - opt.Cluster = s.ClusterInCodefresh - } else { - opt.Cluster = s.KubernetesAPI.ContextName + + logger interface { + Debug(args ...interface{}) + Debugf(format string, args ...interface{}) } - err := cf.RuntimeEnvironments().Validate(opt) +) - if err != nil { - return fmt.Errorf("Validation failed with error: %s", err.Error()) +// NewCodefreshAPI - creates new codefresh api +func NewCodefreshAPI(opt *APIOptions) API { + return &api{ + logger: opt.Logger, + codefresh: codefresh.New(&codefresh.ClientOptions{ + Auth: codefresh.AuthOptions{ + Token: opt.CodefreshToken, + }, + Host: opt.CodefreshHost, + }), + clustername: opt.ClusterName, + clusternamespace: opt.ClusterNamespace, + registerWithAgent: opt.RegisterWithAgent, + storageClass: opt.StorageClass, + isDefaultStorageClass: opt.IsDefaultStorageClass, } +} - logrus.Debug("Finished validation") - return nil +func (a *api) Validate() error { + a.logger.Debug("Validating runtime-environment") + opt := codefresh.ValidateRuntimeOptions{ + Cluster: a.clustername, + Namespace: a.clusternamespace, + } + return a.codefresh.RuntimeEnvironments().Validate(&opt) } -// Sign calls codefresh API to sign certificates -func (u *CfAPI) Sign() error { - logrus.Debug("Entering codefresh.Sign") - s := store.GetStore() +func (a *api) Sign() (*certs.ServerCert, error) { + a.logger.Debug("Signing runtime-environment") serverCert, err := certs.NewServerCert() if err != nil { - return err + return nil, err } + certExtraSANs := fmt.Sprintf("IP:127.0.0.1,DNS:dind,DNS:*.dind.%s,DNS:*.dind.%s.svc,DNS:*.cf-cd.com,DNS:*.codefresh.io", a.clusternamespace, a.clusternamespace) + a.logger.Debugf("certExtraSANs = %s", certExtraSANs) - logrus.Debug("Generated ServerCerts Csr") - - var certExtraSANs string - if "kubernetesDind" == runtimectl.TypeKubernetesDind { - namespace := s.KubernetesAPI.Namespace - certExtraSANs = fmt.Sprintf("IP:127.0.0.1,DNS:dind,DNS:*.dind.%s,DNS:*.dind.%s.svc,DNS:*.cf-cd.com,DNS:*.codefresh.io", namespace, namespace) - } else { - certExtraSANs = "IP:127.0.0.1,DNS:*.cf-cd.com,DNS:*.codefresh.io" - } - logrus.Debugf("certExtraSANs = %s", certExtraSANs) - byteArray, err := store.GetStore().CodefreshAPI.Client.RuntimeEnvironments().SignCertificate(&codefresh.SignCertificatesOptions{ + byteArray, err := a.codefresh.RuntimeEnvironments().SignCertificate(&codefresh.SignCertificatesOptions{ AltName: certExtraSANs, CSR: serverCert.Csr, }) @@ -104,7 +110,7 @@ func (u *CfAPI) Sign() error { respBodyReaderAt := bytes.NewReader(byteArray) zipReader, err := zip.NewReader(respBodyReaderAt, int64(len(byteArray))) if err != nil { - return err + return nil, err } for _, zf := range zipReader.File { buf := new(bytes.Buffer) @@ -117,7 +123,7 @@ func (u *CfAPI) Sign() error { } else if zf.Name == "cf-server-cert.pem" { serverCert.Cert = buf.String() } else { - logrus.Debugf("Warning: Unknown filename in sign responce %s", zf.Name) + a.logger.Debugf("Warning: Unknown filename in sign responce %s", zf.Name) } } @@ -136,49 +142,38 @@ func (u *CfAPI) Sign() error { missingCerts += " ca" } if missingCerts != "" { - return fmt.Errorf("Failed to to generate and sign certificates: %s is missing", missingCerts) + return nil, fmt.Errorf("Failed to to generate and sign certificates: %s is missing", missingCerts) } - s.ServerCert = serverCert - return nil + + // update store with certs + return serverCert, nil } -// Register calls codefresh API to register runtimectl environment -func (u *CfAPI) Register(opt *RegisterOptions) error { - logrus.Debug("Entering codefresh.Register") - s := store.GetStore() +func (a *api) Register() (*codefresh.RuntimeEnvironment, error) { + a.logger.Debug("Registering runtime-environment") options := &codefresh.CreateRuntimeOptions{ - Namespace: s.KubernetesAPI.Namespace, + Namespace: a.clusternamespace, + HasAgent: a.registerWithAgent, + Cluster: a.clustername, } - if s.ClusterInCodefresh == "" { - options.HasAgent = true - options.Cluster = s.KubernetesAPI.ContextName - } else { - options.HasAgent = false - options.Cluster = s.ClusterInCodefresh + options.StorageClass = fmt.Sprintf("%s-%s", a.storageClass, a.clusternamespace) + if !a.isDefaultStorageClass { + options.StorageClass = a.storageClass } - cf := s.CodefreshAPI.Client - logrus.WithFields(logrus.Fields{ - "Options-Has-Agent": options.HasAgent, - "Options-Cluster": options.Cluster, - "Options-Namespace": options.Namespace, - }).Debug("Registering runtime environmnet") - re, err := cf.RuntimeEnvironments().Create(options) + re, err := a.codefresh.RuntimeEnvironments().Create(options) if err != nil { - return err + return nil, err } - s.RuntimeEnvironment = re.Metadata.Name - logrus.Debugf("Created with name: %s", re.Metadata.Name) - - if opt.MarkDefaultRuntime { - logrus.Debug("Setting runtime as deault") - _, err := cf.RuntimeEnvironments().Default(re.Metadata.Name) + if a.markAsDefault { + a.logger.Debug("Setting runtime as deault") + _, err := a.codefresh.RuntimeEnvironments().Default(re.Metadata.Name) if err != nil { - return err + return nil, err } } - return nil + return re, nil } diff --git a/venonactl/pkg/operators/operator.go b/venonactl/pkg/operators/operator.go index 37e61c2d..10122e62 100644 --- a/venonactl/pkg/operators/operator.go +++ b/venonactl/pkg/operators/operator.go @@ -3,6 +3,8 @@ package operators const ( RuntimeEnvironmentOperatorType = "runtime-environment" VenonaOperatorType = "venona" + VolumeProvisionerOperatorType = "volume-provisioner" + DefaultStorageClassNamePrefix = "dind-local-volumes-venona" ) type ( @@ -23,5 +25,9 @@ func GetOperator(t string) Operator { return &RuntimeEnvironmentOperator{} } + if t == VolumeProvisionerOperatorType { + return &VolumeProvisionerOperator{} + } + return nil } diff --git a/venonactl/pkg/operators/volume-provisioner.go b/venonactl/pkg/operators/volume-provisioner.go new file mode 100644 index 00000000..083455f8 --- /dev/null +++ b/venonactl/pkg/operators/volume-provisioner.go @@ -0,0 +1,180 @@ +/* +Copyright 2019 The Codefresh 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. +*/ + +package operators + +import ( + "fmt" + "regexp" + + "github.com/codefresh-io/venona/venonactl/internal" + "github.com/sirupsen/logrus" + + "github.com/codefresh-io/venona/venonactl/pkg/obj/kubeobj" + "github.com/codefresh-io/venona/venonactl/pkg/store" + templates "github.com/codefresh-io/venona/venonactl/pkg/templates/kubernetes" + "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// VolumeProvisionerOperator installs assets on Kubernetes Dind runtimectl Env +type VolumeProvisionerOperator struct { +} + +const ( + VolumeInstallPattern = ".*.vp.yaml" +) + +// Install runtimectl environment +func (u *VolumeProvisionerOperator) Install() error { + s := store.GetStore() + templatesMap := templates.TemplatesMap() + kubeObjects, err := KubeObjectsFromTemplates(templatesMap, s.BuildValues()) + if err != nil { + return err + } + + kubeClientset, err := NewKubeClientset(s) + if err != nil { + internal.DieOnError(fmt.Errorf("Cannot create kubernetes clientset: %v\n ", err)) + } + namespace := s.KubernetesAPI.Namespace + var createErr error + var kind, name string + for fileName, obj := range kubeObjects { + match, _ := regexp.MatchString(VolumeInstallPattern, fileName) + if match != true { + logrus.WithFields(logrus.Fields{ + "Operator": VolumeProvisionerOperatorType, + "Pattern": venonaInstallPattern, + }).Debugf("Skipping installation of %s: pattern not match", fileName) + continue + } + if store.GetStore().DryRun == true { + logrus.WithFields(logrus.Fields{ + "File-Name": fileName, + "Operator": VolumeProvisionerOperatorType, + }).Debugf("%v", obj) + continue + } + name, kind, createErr = kubeobj.CreateObject(kubeClientset, obj, namespace) + + if createErr == nil { + logrus.Debugf("%s \"%s\" created\n ", kind, name) + } else if statusError, errIsStatusError := createErr.(*errors.StatusError); errIsStatusError { + if statusError.ErrStatus.Reason == metav1.StatusReasonAlreadyExists { + logrus.Debugf("%s \"%s\" already exists\n", kind, name) + } else { + logrus.Debugf("%s \"%s\" failed: %v ", kind, name, statusError) + return statusError + } + } else { + logrus.Debugf("%s \"%s\" failed: %v ", kind, name, createErr) + return createErr + } + } + + return nil +} + +func (u *VolumeProvisionerOperator) Status() ([][]string, error) { + s := store.GetStore() + templatesMap := templates.TemplatesMap() + kubeObjects, err := KubeObjectsFromTemplates(templatesMap, s.BuildValues()) + if err != nil { + return nil, err + } + + kubeClientset, err := NewKubeClientset(s) + if err != nil { + logrus.Errorf("Cannot create kubernetes clientset: %v\n ", err) + return nil, err + } + namespace := s.KubernetesAPI.Namespace + var getErr error + var kind, name string + var rows [][]string + for fileName, obj := range kubeObjects { + match, _ := regexp.MatchString(VolumeInstallPattern, fileName) + if match != true { + logrus.WithFields(logrus.Fields{ + "Operator": VolumeProvisionerOperatorType, + "Pattern": VolumeInstallPattern, + }).Debugf("Skipping status check of %s: pattern not match", fileName) + continue + } + name, kind, getErr = kubeobj.CheckObject(kubeClientset, obj, namespace) + if getErr == nil { + rows = append(rows, []string{kind, name, StatusInstalled}) + } else if statusError, errIsStatusError := getErr.(*errors.StatusError); errIsStatusError { + rows = append(rows, []string{kind, name, StatusNotInstalled, statusError.ErrStatus.Message}) + } else { + logrus.Debugf("%s \"%s\" failed: %v ", kind, name, getErr) + return nil, getErr + } + } + + return rows, nil +} + +func (u *VolumeProvisionerOperator) Delete() error { + s := store.GetStore() + templatesMap := templates.TemplatesMap() + kubeObjects, err := KubeObjectsFromTemplates(templatesMap, s.BuildValues()) + if err != nil { + return err + } + + kubeClientset, err := NewKubeClientset(s) + if err != nil { + logrus.Errorf("Cannot create kubernetes clientset: %v\n ", err) + return err + } + namespace := s.KubernetesAPI.Namespace + var kind, name string + var deleteError error + for fileName, obj := range kubeObjects { + match, _ := regexp.MatchString(VolumeInstallPattern, fileName) + if match != true { + logrus.WithFields(logrus.Fields{ + "Operator": VolumeProvisionerOperatorType, + "Pattern": VolumeInstallPattern, + }).Debugf("Skipping deletion of %s: pattern not match", fileName) + continue + } + kind, name, deleteError = kubeobj.DeleteObject(kubeClientset, obj, namespace) + if deleteError == nil { + logrus.Debugf("%s \"%s\" deleted\n ", kind, name) + } else if statusError, errIsStatusError := deleteError.(*errors.StatusError); errIsStatusError { + if statusError.ErrStatus.Reason == metav1.StatusReasonAlreadyExists { + logrus.Debugf("%s \"%s\" already exists\n", kind, name) + } else if statusError.ErrStatus.Reason == metav1.StatusReasonNotFound { + logrus.Debugf("%s \"%s\" not found\n", kind, name) + } else { + logrus.Errorf("%s \"%s\" failed: %v ", kind, name, statusError) + return statusError + } + } else { + logrus.Errorf("%s \"%s\" failed: %v ", kind, name, deleteError) + return deleteError + } + } + return nil +} + +func (u *VolumeProvisionerOperator) Upgrade() error { + return nil +} diff --git a/venonactl/pkg/templates/kubernetes/cluster-role-binding.dind-volume-provisioner.re.yaml b/venonactl/pkg/templates/kubernetes/cluster-role-binding.dind-volume-provisioner.vp.yaml similarity index 100% rename from venonactl/pkg/templates/kubernetes/cluster-role-binding.dind-volume-provisioner.re.yaml rename to venonactl/pkg/templates/kubernetes/cluster-role-binding.dind-volume-provisioner.vp.yaml diff --git a/venonactl/pkg/templates/kubernetes/cluster-role.dind-volume-provisioner.re.yaml b/venonactl/pkg/templates/kubernetes/cluster-role.dind-volume-provisioner.vp.yaml similarity index 100% rename from venonactl/pkg/templates/kubernetes/cluster-role.dind-volume-provisioner.re.yaml rename to venonactl/pkg/templates/kubernetes/cluster-role.dind-volume-provisioner.vp.yaml diff --git a/venonactl/pkg/templates/kubernetes/daemonset.dind-lv-monitor.re.yaml b/venonactl/pkg/templates/kubernetes/daemonset.dind-lv-monitor.vp.yaml similarity index 100% rename from venonactl/pkg/templates/kubernetes/daemonset.dind-lv-monitor.re.yaml rename to venonactl/pkg/templates/kubernetes/daemonset.dind-lv-monitor.vp.yaml diff --git a/venonactl/pkg/templates/kubernetes/deployment.dind-volume-provisioner.re.yaml b/venonactl/pkg/templates/kubernetes/deployment.dind-volume-provisioner.vp.yaml similarity index 100% rename from venonactl/pkg/templates/kubernetes/deployment.dind-volume-provisioner.re.yaml rename to venonactl/pkg/templates/kubernetes/deployment.dind-volume-provisioner.vp.yaml diff --git a/venonactl/pkg/templates/kubernetes/service-account.dind-volume-provisioner.re.yaml b/venonactl/pkg/templates/kubernetes/service-account.dind-volume-provisioner.vp.yaml similarity index 100% rename from venonactl/pkg/templates/kubernetes/service-account.dind-volume-provisioner.re.yaml rename to venonactl/pkg/templates/kubernetes/service-account.dind-volume-provisioner.vp.yaml diff --git a/venonactl/pkg/templates/kubernetes/storageclass.dind-local-volume-provisioner.re.yaml b/venonactl/pkg/templates/kubernetes/storageclass.dind-local-volume-provisioner.vp.yaml similarity index 100% rename from venonactl/pkg/templates/kubernetes/storageclass.dind-local-volume-provisioner.re.yaml rename to venonactl/pkg/templates/kubernetes/storageclass.dind-local-volume-provisioner.vp.yaml diff --git a/venonactl/pkg/templates/kubernetes/templates.go b/venonactl/pkg/templates/kubernetes/templates.go index 4cf73595..ea7b249a 100644 --- a/venonactl/pkg/templates/kubernetes/templates.go +++ b/venonactl/pkg/templates/kubernetes/templates.go @@ -6,7 +6,7 @@ package kubernetes func TemplatesMap() map[string]string { templatesMap := make(map[string]string) -templatesMap["cluster-role-binding.dind-volume-provisioner.re.yaml"] = `--- +templatesMap["cluster-role-binding.dind-volume-provisioner.vp.yaml"] = `--- kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1beta1 metadata: @@ -36,7 +36,7 @@ roleRef: name: system:discovery apiGroup: rbac.authorization.k8s.io` -templatesMap["cluster-role.dind-volume-provisioner.re.yaml"] = `kind: ClusterRole +templatesMap["cluster-role.dind-volume-provisioner.vp.yaml"] = `kind: ClusterRole apiVersion: rbac.authorization.k8s.io/v1beta1 metadata: name: volume-provisioner-{{ .AppName }}-{{ .Namespace }} @@ -84,7 +84,7 @@ data: ` -templatesMap["daemonset.dind-lv-monitor.re.yaml"] = `apiVersion: extensions/v1beta1 +templatesMap["daemonset.dind-lv-monitor.vp.yaml"] = `apiVersion: extensions/v1beta1 kind: DaemonSet metadata: name: dind-lv-monitor-{{ .AppName }} @@ -144,7 +144,7 @@ spec: path: /var/lib/codefresh/codefresh/dind-volumes ` -templatesMap["deployment.dind-volume-provisioner.re.yaml"] = `apiVersion: extensions/v1beta1 +templatesMap["deployment.dind-volume-provisioner.vp.yaml"] = `apiVersion: extensions/v1beta1 kind: Deployment metadata: name: dind-volume-provisioner-{{ .AppName }} @@ -309,7 +309,7 @@ metadata: data: codefresh.token: {{ .AgentToken }}` -templatesMap["service-account.dind-volume-provisioner.re.yaml"] = `--- +templatesMap["service-account.dind-volume-provisioner.vp.yaml"] = `--- apiVersion: v1 kind: ServiceAccount metadata: @@ -325,7 +325,7 @@ metadata: name: {{ .AppName }} namespace: {{ .Namespace }}` -templatesMap["storageclass.dind-local-volume-provisioner.re.yaml"] = `--- +templatesMap["storageclass.dind-local-volume-provisioner.vp.yaml"] = `--- kind: StorageClass apiVersion: storage.k8s.io/v1 metadata: