Initial attempt at passing the info through the CLI

Signed-off-by: Thomas Newton <thomas.w.newton@gmail.com>
This commit is contained in:
Thomas Newton 2025-04-25 20:49:56 +01:00
parent 634b0c1a9f
commit e7aabc0658
1 changed files with 8 additions and 0 deletions

View File

@ -18,10 +18,12 @@ package controller
import (
"crypto/tls"
"encoding/json"
"flag"
"os"
"slices"
"time"
networkingv1 "k8s.io/api/networking/v1"
// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
// to ensure that exec-entrypoint and run can make use of them.
@ -86,6 +88,7 @@ var (
enableBatchScheduler bool
kubeSchedulerNames []string
defaultBatchScheduler string
ingressTLS []networkingv1.IngressTLS
// Spark web UI service and ingress
enableUIService bool
@ -128,12 +131,16 @@ func init() {
}
func NewStartCommand() *cobra.Command {
var ingressTLSstring string
var command = &cobra.Command{
Use: "start",
Short: "Start controller and webhook",
PreRun: func(_ *cobra.Command, args []string) {
development = viper.GetBool("development")
},
PreRunE: func(_ *cobra.Command, args []string) error {
return json.Unmarshal([]byte(ingressTLSstring), &ingressTLS)
},
Run: func(_ *cobra.Command, args []string) {
sparkoperator.PrintVersion(false)
start()
@ -156,6 +163,7 @@ func NewStartCommand() *cobra.Command {
command.Flags().BoolVar(&enableUIService, "enable-ui-service", true, "Enable Spark Web UI service.")
command.Flags().StringVar(&ingressClassName, "ingress-class-name", "", "Set ingressClassName for ingress resources created.")
command.Flags().StringVar(&ingressURLFormat, "ingress-url-format", "", "Ingress URL format.")
command.Flags().StringVar(&ingressTLSstring, "ingress-tls", "", "JSON format string for the default TLS config on the Spark UI ingresses. e.g. '[{\"hosts\":[\"example.com\"],\"secretName\":\"example-secret\"}]' `ingressTLS` in the SparkApplication spec will override this value.")
command.Flags().BoolVar(&enableLeaderElection, "leader-election", false, "Enable leader election for controller manager. "+
"Enabling this will ensure there is only one active controller manager.")