Skip to content

Commit

Permalink
Add --set flag to apps that missed it
Browse files Browse the repository at this point in the history
There are some helm based apps that didnt have the --set flag, thanks
@rhorridge for the issue #311.

I have checked the apps mentioned and added the flag is required and
tested each one by installing with a --set flag to override an existing
value (if set) and to set a new one.

Everything installed as expected

Signed-off-by: Alistair Hey <alistair@heyal.co.uk>
  • Loading branch information
Waterdrips authored and alexellis committed Jan 21, 2021
1 parent 5adda6b commit f3c641a
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 13 deletions.
13 changes: 12 additions & 1 deletion cmd/apps/crossplane_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ 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().StringArray("set", []string{},
"Use custom flags or override existing flags \n(example --set persistence.enabled=true)")

crossplane.RunE = func(command *cobra.Command, args []string) error {
wait, _ := command.Flags().GetBool("wait")
Expand All @@ -56,6 +58,15 @@ schedule workloads to any Kubernetes cluster`,
return err
}

overrideValues, err := crossplane.Flags().GetStringArray("set")
if err != nil {
return err
}
values := make(map[string]string)
if err := mergeFlags(values, overrideValues); err != nil {
return err
}

clientArch, clientOS := env.GetClientArch()

fmt.Printf("Client: %q, %q\n", clientArch, clientOS)
Expand Down Expand Up @@ -86,7 +97,7 @@ schedule workloads to any Kubernetes cluster`,
}

err = helm.Helm3Upgrade("crossplane-alpha/crossplane",
namespace, "values.yaml", "", map[string]string{}, wait)
namespace, "values.yaml", "", values, wait)
if err != nil {
return err
}
Expand Down
3 changes: 0 additions & 3 deletions cmd/apps/linkerd_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ func MakeInstallLinkerd() *cobra.Command {

arch := k8s.GetNodeArchitecture()
fmt.Printf("Node architecture: %q\n", arch)
// if arch != IntelArch {
// return fmt.Errorf(OnlyIntelArch)
// }

userPath, err := getUserPath()
if err != nil {
Expand Down
11 changes: 11 additions & 0 deletions cmd/apps/metricsserver_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ func MakeInstallMetricsServer() *cobra.Command {
}

metricsServer.Flags().StringP("namespace", "n", "kube-system", "The namespace used for installation")
metricsServer.Flags().StringArray("set", []string{},
"Use custom flags or override existing flags \n(example --set persistence.enabled=true)")

metricsServer.RunE = func(command *cobra.Command, args []string) error {
wait, _ := command.Flags().GetBool("wait")
Expand Down Expand Up @@ -82,6 +84,15 @@ func MakeInstallMetricsServer() *cobra.Command {
break
}

customFlags, err := command.Flags().GetStringArray("set")
if err != nil {
return err
}

if err = config.MergeFlags(overrides, customFlags); err != nil {
return err
}

fmt.Println("Chart path: ", chartPath)

err = helm.Helm3Upgrade("stable/metrics-server", namespace,
Expand Down
11 changes: 8 additions & 3 deletions cmd/apps/redis_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ func MakeInstallRedis() *cobra.Command {

redis.Flags().StringP("namespace", "n", "redis", "The namespace to install redis")
redis.Flags().Bool("update-repo", true, "Update the helm repo")
redis.Flags().StringArray("set", []string{},
"Use custom flags or override existing flags \n(example --set persistence.enabled=true)")

redis.RunE = func(command *cobra.Command, args []string) error {
kubeConfigPath, _ := command.Flags().GetString("kubeconfig")
Expand All @@ -46,9 +48,12 @@ func MakeInstallRedis() *cobra.Command {
"rbac.create": "true",
}

customFlags, _ := command.Flags().GetStringArray("set")
customFlags, err := command.Flags().GetStringArray("set")
if err != nil {
return err
}

if err := config.MergeFlags(overrides, customFlags); err != nil {
if err = config.MergeFlags(overrides, customFlags); err != nil {
return err
}

Expand All @@ -61,7 +66,7 @@ func MakeInstallRedis() *cobra.Command {
WithHelmUpdateRepo(updateRepo).
WithKubeconfigPath(kubeConfigPath)

_, err := apps.MakeInstallChart(redisAppOptions)
_, err = apps.MakeInstallChart(redisAppOptions)
if err != nil {
return err
}
Expand Down
20 changes: 14 additions & 6 deletions cmd/apps/registry_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ package apps

import (
"fmt"
"github.com/alexellis/arkade/pkg/k8s"
"io/ioutil"
"log"
"os"
"path"
"strconv"
"strings"

"github.com/alexellis/arkade/pkg/k8s"

"golang.org/x/crypto/bcrypt"

Expand All @@ -39,10 +37,11 @@ func MakeInstallRegistry() *cobra.Command {
registry.Flags().StringP("password", "p", "", "Password for the registry, leave blank to generate")
registry.Flags().StringP("write-file", "w", "", "Write generated password to this file")
registry.Flags().Bool("persistence", false, "Enable persistence")
registry.Flags().StringArray("set", []string{},
"Use custom flags or override existing flags \n(example --set persistence.enabled=true)")

registry.RunE = func(command *cobra.Command, args []string) error {
kubeConfigPath, _ := command.Flags().GetString("kubeconfig")
fmt.Printf("Using kubeconfig: %s\n", kubeConfigPath)

if err := config.SetKubeconfig(kubeConfigPath); err != nil {
return err
Expand Down Expand Up @@ -113,8 +112,17 @@ func MakeInstallRegistry() *cobra.Command {

overrides := map[string]string{}

overrides["persistence.enabled"] = strings.ToLower(strconv.FormatBool(persistence))
overrides["secrets.htpasswd"] = string(htPasswd)
overrides["persistence.enabled"] = strconv.FormatBool(persistence)
overrides["secrets.htpasswd"] = htPasswd

customFlags, err := command.Flags().GetStringArray("set")
if err != nil {
return err
}

if err = config.MergeFlags(overrides, customFlags); err != nil {
return err
}

arch := k8s.GetNodeArchitecture()
fmt.Printf("Node architecture: %q\n", arch)
Expand Down

0 comments on commit f3c641a

Please sign in to comment.