diff --git a/cmd/apps/certmanager_app.go b/cmd/apps/certmanager_app.go index e19b8928..9f75d55c 100644 --- a/cmd/apps/certmanager_app.go +++ b/cmd/apps/certmanager_app.go @@ -24,6 +24,7 @@ func MakeInstallCertManager() *cobra.Command { certManager.Flags().StringP("namespace", "n", "cert-manager", "The namespace to install cert-manager") certManager.Flags().Bool("update-repo", true, "Update the helm repo") + certManager.Flags().Bool("helm3", true, "Use helm3, if set to false uses helm2") certManager.RunE = func(command *cobra.Command, args []string) error { kubeConfigPath := getDefaultKubeconfig() @@ -33,7 +34,11 @@ func MakeInstallCertManager() *cobra.Command { } fmt.Printf("Using kubeconfig: %s\n", kubeConfigPath) + helm3, _ := command.Flags().GetBool("helm3") + if helm3 { + fmt.Println("Using helm3") + } namespace, _ := command.Flags().GetString("namespace") if namespace != "cert-manager" { @@ -53,12 +58,12 @@ func MakeInstallCertManager() *cobra.Command { os.Setenv("HELM_HOME", path.Join(userPath, ".helm")) - _, err = helm.TryDownloadHelm(userPath, clientArch, clientOS, false) + _, err = helm.TryDownloadHelm(userPath, clientArch, clientOS, helm3) if err != nil { return err } - err = addHelmRepo("jetstack", "https://charts.jetstack.io", false) + err = addHelmRepo("jetstack", "https://charts.jetstack.io", helm3) if err != nil { return err } @@ -66,7 +71,7 @@ func MakeInstallCertManager() *cobra.Command { updateRepo, _ := certManager.Flags().GetBool("update-repo") if updateRepo { - err = updateHelmRepos(false) + err = updateHelmRepos(helm3) if err != nil { return err } @@ -83,14 +88,7 @@ func MakeInstallCertManager() *cobra.Command { chartPath := path.Join(os.TempDir(), "charts") - err = fetchChart(chartPath, "jetstack/cert-manager", false) - if err != nil { - return err - } - - outputPath := path.Join(chartPath, "cert-manager/rendered") - - err = templateChart(chartPath, "cert-manager", namespace, outputPath, "values.yaml", nil) + err = fetchChart(chartPath, "jetstack/cert-manager", helm3) if err != nil { return err } @@ -104,16 +102,37 @@ func MakeInstallCertManager() *cobra.Command { } if res.ExitCode > 0 { - return fmt.Errorf("Error applying CRD from: %s, error: %s", crdsURL, res.Stderr) + return fmt.Errorf("error applying CRD from: %s, error: %s", crdsURL, res.Stderr) } - applyRes, applyErr := kubectlTask("apply", "-R", "-f", outputPath) - if applyErr != nil { - return applyErr - } + outputPath := path.Join(chartPath, "cert-manager/rendered") + overrides := map[string]string{} + wait := false + + if helm3 { + outputPath := path.Join(chartPath, "cert-manager") + + err := helm3Upgrade(outputPath, "jetstack/cert-manager", namespace, + "values.yaml", + overrides, wait) - if applyRes.ExitCode > 0 { - return fmt.Errorf("Error applying templated YAML files, error: %s", applyRes.Stderr) + if err != nil { + return err + } + } else { + err = templateChart(chartPath, "cert-manager", namespace, outputPath, "values.yaml", nil) + if err != nil { + return err + } + + applyRes, applyErr := kubectlTask("apply", "-R", "-f", outputPath) + if applyErr != nil { + return applyErr + } + + if applyRes.ExitCode > 0 { + return fmt.Errorf("error applying templated YAML files, error: %s", applyRes.Stderr) + } } fmt.Println(certManagerInstallMsg) @@ -134,4 +153,4 @@ kubectl logs -n cert-manager deploy/cert-manager -f` const certManagerInstallMsg = `======================================================================= = cert-manager has been installed. = =======================================================================` + - "\n\n" + CertManagerInfoMsg + "\n\n" + pkg.ThanksForUsing \ No newline at end of file + "\n\n" + CertManagerInfoMsg + "\n\n" + pkg.ThanksForUsing diff --git a/cmd/apps/crossplane_app.go b/cmd/apps/crossplane_app.go index 297d870b..23d22065 100644 --- a/cmd/apps/crossplane_app.go +++ b/cmd/apps/crossplane_app.go @@ -26,7 +26,7 @@ schedule workloads to any Kubernetes cluster`, crossplane.Flags().StringP("namespace", "n", "crossplane-system", "The namespace used for installation") crossplane.Flags().Bool("update-repo", true, "Update the helm repo") - crossplane.Flags().Bool("helm3", false, "Use helm3 instead of the default helm2") + crossplane.Flags().Bool("helm3", false, "Use helm3, if set to false uses helm2") crossplane.RunE = func(command *cobra.Command, args []string) error { kubeConfigPath := getDefaultKubeconfig() @@ -146,4 +146,4 @@ Learn more about Crossplane: https://crossplaneio.github.io/docs/` const crossplaneInstallMsg = `======================================================================= = Crossplane has been installed. = =======================================================================` + - "\n\n" + CrossplanInfoMsg + "\n\n" + pkg.ThanksForUsing \ No newline at end of file + "\n\n" + CrossplanInfoMsg + "\n\n" + pkg.ThanksForUsing diff --git a/cmd/apps/inletsoperator_app.go b/cmd/apps/inletsoperator_app.go index 6679b138..fbc60489 100644 --- a/cmd/apps/inletsoperator_app.go +++ b/cmd/apps/inletsoperator_app.go @@ -34,7 +34,7 @@ func MakeInstallInletsOperator() *cobra.Command { inletsOperator.Flags().Bool("update-repo", true, "Update the helm repo") inletsOperator.Flags().String("pro-client-image", "", "Docker image for inlets-pro's client") - inletsOperator.Flags().Bool("helm3", true, "Use helm3 instead of the default helm2") + inletsOperator.Flags().Bool("helm3", true, "Use helm3, if set to false uses helm2") inletsOperator.Flags().StringArray("set", []string{}, "Use custom flags or override existing flags \n(example --set=image=org/repo:tag)") inletsOperator.RunE = func(command *cobra.Command, args []string) error { diff --git a/cmd/apps/metricsserver_app.go b/cmd/apps/metricsserver_app.go index 74bb7ab5..0d644393 100644 --- a/cmd/apps/metricsserver_app.go +++ b/cmd/apps/metricsserver_app.go @@ -23,7 +23,7 @@ func MakeInstallMetricsServer() *cobra.Command { } metricsServer.Flags().StringP("namespace", "n", "kube-system", "The namespace used for installation") - metricsServer.Flags().Bool("helm3", false, "Use helm3 instead of the default helm2") + metricsServer.Flags().Bool("helm3", false, "Use helm3, if set to false uses helm2") metricsServer.RunE = func(command *cobra.Command, args []string) error { kubeConfigPath := getDefaultKubeconfig() diff --git a/cmd/apps/nginx_app.go b/cmd/apps/nginx_app.go index 019a72a1..5be9880d 100644 --- a/cmd/apps/nginx_app.go +++ b/cmd/apps/nginx_app.go @@ -25,7 +25,7 @@ func MakeInstallNginx() *cobra.Command { nginx.Flags().StringP("namespace", "n", "default", "The namespace used for installation") nginx.Flags().Bool("update-repo", true, "Update the helm repo") nginx.Flags().Bool("host-mode", false, "If we should install nginx-ingress in host mode.") - nginx.Flags().Bool("helm3", true, "Use helm3 instead of the default helm2") + nginx.Flags().Bool("helm3", true, "Use helm3, if set to false uses helm2") nginx.RunE = func(command *cobra.Command, args []string) error { kubeConfigPath := getDefaultKubeconfig() diff --git a/cmd/apps/openfaas_app.go b/cmd/apps/openfaas_app.go index 55b7a6e2..c208daa7 100644 --- a/cmd/apps/openfaas_app.go +++ b/cmd/apps/openfaas_app.go @@ -42,7 +42,7 @@ func MakeInstallOpenFaaS() *cobra.Command { openfaas.Flags().Int("queue-workers", 1, "Replicas of queue-worker") openfaas.Flags().Int("gateways", 1, "Replicas of gateway") - openfaas.Flags().Bool("helm3", false, "Use helm3 instead of the default helm2") + openfaas.Flags().Bool("helm3", false, "Use helm3, if set to false uses helm2") openfaas.Flags().StringArray("set", []string{}, "Use custom flags or override existing flags \n(example --set=gateway.replicas=2)")