Skip to content

Commit 6f05284

Browse files
committed
Break out openfaas-ce app and support values.yaml files overrides
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
1 parent c70d903 commit 6f05284

15 files changed

+326
-91
lines changed

cmd/apps/chart_app.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ before using the generic helm chart installer command.`,
3636

3737
chartCmd.Flags().StringP("namespace", "n", "default", "The namespace to install the chart")
3838
chartCmd.Flags().String("repo", "", "The chart repo to install from")
39-
chartCmd.Flags().String("values-file", "", "Give the values.yaml file to use from the upstream chart repo")
39+
chartCmd.Flags().StringArrayP("values", "f", []string{"values.yaml"}, "Give the values.yaml file to use from the upstream chart repo")
4040
chartCmd.Flags().String("repo-name", "", "Chart name")
4141
chartCmd.Flags().String("repo-url", "", "Chart repo")
4242

@@ -119,8 +119,10 @@ before using the generic helm chart installer command.`,
119119
}
120120
}
121121

122+
valuesFlag, _ := chartCmd.Flags().GetStringArray("values")
123+
122124
err = helm.Helm3Upgrade(chartRepoName, namespace,
123-
"values.yaml",
125+
valuesFlag,
124126
defaultVersion,
125127
setMap,
126128
false)

cmd/apps/confluentkafka.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func MakeInstallConfluentPlatformKafka() *cobra.Command {
112112
appOpts.
113113
WithKubeconfigPath(kubeConfigPath).
114114
WithOverrides(overrides).
115-
WithValuesFile("values.yaml").
115+
WithValuesFiles([]string{"values.yaml"}).
116116
WithHelmURL("https://confluentinc.github.io/cp-helm-charts/").
117117
WithHelmRepo("confluentinc/cp-helm-charts").
118118
WithHelmUpdateRepo(updateRepo).

cmd/apps/crossplane_app.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ schedule workloads to any Kubernetes cluster`,
9797
}
9898

9999
err = helm.Helm3Upgrade("crossplane-alpha/crossplane",
100-
namespace, "values.yaml", "", values, wait)
100+
namespace, []string{"values.yaml"}, "", values, wait)
101101
if err != nil {
102102
return err
103103
}

cmd/apps/inletsoperator_app.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ IngressController`,
213213
}
214214

215215
err = helm.Helm3Upgrade("inlets/inlets-operator",
216-
namespace, "values.yaml", "", overrides, wait)
216+
namespace, []string{"values.yaml"}, "", overrides, wait)
217217
if err != nil {
218218
return err
219219
}

cmd/apps/mongodb_app.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func MakeInstallMongoDB() *cobra.Command {
9696
}
9797

9898
err = helm.Helm3Upgrade("bitnami/mongodb",
99-
namespace, "values.yaml", defaultVersion, overrides, wait)
99+
namespace, []string{"values.yaml"}, defaultVersion, overrides, wait)
100100
if err != nil {
101101
return fmt.Errorf("unable to mongodb chart with helm %s", err)
102102
}

cmd/apps/of_loki.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func MakeInstallOpenFaaSLoki() *cobra.Command {
5959

6060
// The default options includes the `values.yaml` file but this is already
6161
// implied when using the OCI chart.
62-
lokiOptions.Helm.ValuesFile = ""
62+
lokiOptions.Helm.ValuesFiles = []string{}
6363

6464
_, err := apps.MakeInstallChart(lokiOptions)
6565
if err != nil {

cmd/apps/openfaas_app.go

Lines changed: 72 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ func MakeInstallOpenFaaS() *cobra.Command {
4242
openfaas.Flags().String("pull-policy", "IfNotPresent", "Pull policy for OpenFaaS core services")
4343
openfaas.Flags().String("function-pull-policy", "Always", "Pull policy for functions")
4444

45-
openfaas.Flags().Bool("operator", false, "Create OpenFaaS Operator")
45+
openfaas.Flags().Bool("operator", true, "Create OpenFaaS Operator")
4646
openfaas.Flags().Bool("clusterrole", false, "Create a ClusterRole for OpenFaaS instead of a limited scope Role")
4747
openfaas.Flags().Bool("direct-functions", false, "Invoke functions directly from the gateway, or load-balance via endpoint IPs when set to false")
48-
openfaas.Flags().Bool("autoscaler", false, "Deploy OpenFaaS with the autoscaler enabled")
49-
openfaas.Flags().Bool("jetstream", false, "Deploy OpenFaaS with jetstream queue mode")
50-
openfaas.Flags().Bool("dashboard", false, "Deploy OpenFaaS with the dashboard enabled")
48+
openfaas.Flags().Bool("autoscaler", true, "Deploy OpenFaaS with the autoscaler enabled")
49+
openfaas.Flags().String("queue-mode", "static", "Configure the consumer mode for the queue-worker: \"static\" or \"function\"")
50+
openfaas.Flags().Bool("dashboard", true, "Deploy OpenFaaS with the dashboard enabled")
5151

5252
openfaas.Flags().Int("queue-workers", 1, "Replicas of queue-worker for HA")
5353
openfaas.Flags().Int("max-inflight", 1, "Max tasks for queue-worker to process in parallel")
@@ -61,6 +61,8 @@ func MakeInstallOpenFaaS() *cobra.Command {
6161

6262
openfaas.Flags().String("license-file", "", "Path to OpenFaaS Pro license file")
6363

64+
openfaas.Flags().StringArrayP("values", "f", []string{}, "Specify one or more local values.yaml files for overrides.")
65+
6466
openfaas.RunE = func(command *cobra.Command, args []string) error {
6567
appOpts := types.DefaultInstallOptions()
6668

@@ -77,19 +79,17 @@ func MakeInstallOpenFaaS() *cobra.Command {
7779
clusterRole, _ := command.Flags().GetBool("clusterrole")
7880
directFunctions, _ := command.Flags().GetBool("direct-functions")
7981
autoscaler, _ := command.Flags().GetBool("autoscaler")
80-
jetstream, _ := command.Flags().GetBool("jetstream")
8182
dashboard, _ := command.Flags().GetBool("dashboard")
8283
gateways, _ := command.Flags().GetInt("gateways")
8384
maxInflight, _ := command.Flags().GetInt("max-inflight")
8485
queueWorkers, _ := command.Flags().GetInt("queue-workers")
8586
ingressOperator, _ := command.Flags().GetBool("ingress-operator")
8687
lb, _ := command.Flags().GetBool("load-balancer")
88+
queueMode, _ := command.Flags().GetString("queue-mode")
89+
valuesFiles, _ := command.Flags().GetStringArray("values")
8790

8891
overrides := map[string]string{}
8992

90-
arch := k8s.GetNodeArchitecture()
91-
valuesSuffix := getValuesSuffix(arch)
92-
9393
_, err := k8s.KubectlTask("apply", "-f",
9494
"https://raw.githubusercontent.com/openfaas/faas-netes/master/namespaces.yml")
9595

@@ -120,17 +120,14 @@ func MakeInstallOpenFaaS() *cobra.Command {
120120
overrides["gateway.logsProviderURL"] = logUrl
121121
}
122122

123-
// If license file is sent, then we assume to set the --pro flag and create the secret
124-
if len(licenseFile) != 0 {
125-
overrides["openfaasPro"] = "true"
126-
secretData := []types.SecretsData{
127-
{Type: types.FromFileSecret, Key: "license", Value: licenseFile},
128-
}
129-
130-
proLicense := types.NewGenericSecret("openfaas-license", namespace, secretData)
131-
appOpts.WithSecret(proLicense)
123+
overrides["openfaasPro"] = "true"
124+
secretData := []types.SecretsData{
125+
{Type: types.FromFileSecret, Key: "license", Value: licenseFile},
132126
}
133127

128+
proLicense := types.NewGenericSecret("openfaas-license", namespace, secretData)
129+
appOpts.WithSecret(proLicense)
130+
134131
if dashboard {
135132
privateKey, publicKey, err := generateJWTKeyPair()
136133
if err != nil {
@@ -146,49 +143,77 @@ func MakeInstallOpenFaaS() *cobra.Command {
146143
appOpts.WithSecret(dashboardJWT)
147144
}
148145

149-
overrides["clusterRole"] = strconv.FormatBool(clusterRole)
150-
overrides["gateway.directFunctions"] = strconv.FormatBool(directFunctions)
151-
overrides["operator.create"] = strconv.FormatBool(createOperator)
152-
overrides["openfaasImagePullPolicy"] = pullPolicy
153-
overrides["faasnetes.imagePullPolicy"] = functionPullPolicy
154-
overrides["basicAuthPlugin.replicas"] = "1"
155-
overrides["gateway.replicas"] = fmt.Sprintf("%d", gateways)
146+
overrides["jetstreamQueueWorker.mode"] = queueMode
147+
148+
if command.Flags().Changed("clusterrole") {
149+
overrides["clusterRole"] = strconv.FormatBool(clusterRole)
150+
}
151+
152+
if command.Flags().Changed("direct-functions") {
153+
overrides["gateway.directFunctions"] = strconv.FormatBool(directFunctions)
154+
}
155+
156+
if command.Flags().Changed("operator") {
157+
overrides["operator.create"] = strconv.FormatBool(createOperator)
158+
}
159+
160+
if command.Flags().Changed("pull-policy") {
161+
overrides["openfaasImagePullPolicy"] = pullPolicy
162+
overrides["faasnetes.imagePullPolicy"] = functionPullPolicy
163+
}
164+
165+
if command.Flags().Changed("gateways") {
166+
overrides["gateway.replicas"] = fmt.Sprintf("%d", gateways)
167+
}
168+
169+
if command.Flags().Changed("queue-workers") {
170+
overrides["queueWorker.replicas"] = fmt.Sprintf("%d", queueWorkers)
171+
}
172+
173+
if command.Flags().Changed("max-inflight") {
174+
overrides["queueWorker.maxInflight"] = fmt.Sprintf("%d", maxInflight)
175+
}
176+
177+
if command.Flags().Changed("autoscaler") {
178+
overrides["autoscaler.enabled"] = strconv.FormatBool(autoscaler)
179+
}
180+
181+
if command.Flags().Changed("dashboard") {
182+
overrides["dashboard.enabled"] = strconv.FormatBool(dashboard)
183+
}
184+
156185
overrides["ingressOperator.create"] = strconv.FormatBool(ingressOperator)
157-
overrides["queueWorker.replicas"] = fmt.Sprintf("%d", queueWorkers)
158-
overrides["queueWorker.maxInflight"] = fmt.Sprintf("%d", maxInflight)
159-
overrides["autoscaler.enabled"] = strconv.FormatBool(autoscaler)
160-
overrides["dashboard.enabled"] = strconv.FormatBool(dashboard)
161-
overrides["dashboard.publicURL"] = "http://127.0.0.1:8080"
162186

163-
// the value in the template is "basic_auth" not the more usual basicAuth
164-
overrides["basic_auth"] = strconv.FormatBool(basicAuthEnabled)
187+
if command.Flags().Changed("basic-auth") {
188+
overrides["basic_auth"] = strconv.FormatBool(basicAuthEnabled)
189+
}
165190

166191
overrides["serviceType"] = "NodePort"
167192

168193
if lb {
169194
overrides["serviceType"] = "LoadBalancer"
170195
}
171196

172-
if jetstream {
173-
overrides["queueMode"] = "jetstream"
174-
}
175-
176197
customFlags, _ := command.Flags().GetStringArray("set")
177198
if err := config.MergeFlags(overrides, customFlags); err != nil {
178199
return err
179200
}
180201

181202
appOpts.
182203
WithKubeconfigPath(kubeConfigPath).
204+
WithValuesFiles([]string{`https://raw.githubusercontent.com/openfaas/faas-netes/refs/heads/master/chart/openfaas/values-pro.yaml`}).
183205
WithOverrides(overrides).
184-
WithValuesFile(fmt.Sprintf("values%s.yaml", valuesSuffix)).
185206
WithHelmURL("https://openfaas.github.io/faas-netes/").
186207
WithHelmRepo("openfaas/openfaas").
187208
WithHelmUpdateRepo(updateRepo).
188209
WithNamespace(namespace).
189210
WithInstallNamespace(false).
190211
WithWait(wait)
191212

213+
if len(valuesFiles) > 0 {
214+
appOpts.WithValuesFiles(valuesFiles)
215+
}
216+
192217
if _, err := apps.MakeInstallChart(appOpts); err != nil {
193218
return err
194219
}
@@ -238,11 +263,6 @@ func MakeInstallOpenFaaS() *cobra.Command {
238263
return err
239264
}
240265

241-
_, err = cmd.Flags().GetBool("jetstream")
242-
if err != nil {
243-
return err
244-
}
245-
246266
_, err = cmd.Flags().GetBool("dashboard")
247267
if err != nil {
248268
return err
@@ -321,8 +341,14 @@ func generateJWTKeyPair() ([]byte, []byte, error) {
321341
return privOut.Bytes(), pubOut.Bytes(), nil
322342
}
323343

324-
const OpenFaaSInfoMsg = `# Get the faas-cli
325-
curl -SLsf https://cli.openfaas.com | sudo sh
344+
const OpenFaaSInfoMsg = `# You've installed OpenFaaS Pro 👍
345+
# OpenFaaS Standard or for Enterprises is now running (depending on your license)
346+
347+
# Read the EULA before continuing:
348+
https://github.com/openfaas/faas/blob/master/pro/EULA.md
349+
350+
# Get the faas-cli
351+
arkade get faas-cli
326352
327353
# Forward the gateway to your machine
328354
kubectl rollout status -n openfaas deploy/gateway
@@ -332,18 +358,12 @@ kubectl port-forward -n openfaas svc/gateway 8080:8080 &
332358
PASSWORD=$(kubectl get secret -n openfaas basic-auth -o jsonpath="{.data.basic-auth-password}" | base64 --decode; echo)
333359
echo -n $PASSWORD | faas-cli login --username admin --password-stdin
334360
335-
faas-cli store deploy figlet
361+
faas-cli store deploy env
336362
faas-cli list
337-
338-
# For Raspberry Pi
339-
faas-cli store list \
340-
--platform armhf
341-
342-
faas-cli store deploy figlet \
343-
--platform armhf
363+
faas-cli describe env
344364
345365
# Find out more at:
346-
# https://github.com/openfaas/faas`
366+
# https://docs.openfaas.com/`
347367

348368
const openfaasPostInstallMsg = `=======================================================================
349369
= OpenFaaS has been installed. =

0 commit comments

Comments
 (0)