Update helm and CLI parsing, including adding annotations

Signed-off-by: Thomas Newton <thomas.w.newton@gmail.com>
This commit is contained in:
Thomas Newton 2025-04-26 12:42:54 +01:00
parent 2802e8474b
commit 1478dcd7df
3 changed files with 28 additions and 13 deletions

View File

@ -72,8 +72,11 @@ spec:
{{- with .Values.controller.uiIngress.ingressClassName }}
- --ingress-class-name={{ . }}
{{- end }}
{{- with .Values.controller.uiIngress.ingressTLS }}
- --ingress-tls={{ . | toJson }}
{{- with .Values.controller.uiIngress.defaultIngressTLS }}
- --default-ingress-tls={{ . | toJson }}
{{- end }}
{{- with .Values.controller.uiIngress.defaultIngressAnnotations }}
- --default-ingress-annotations={{ . | toJson }}
{{- end }}
{{- end }}
{{- if .Values.controller.batchScheduler.enable }}

View File

@ -74,7 +74,13 @@ controller:
urlFormat: ""
# -- Optionally set the ingressClassName.
ingressClassName: ""
ingressTLS: []
defaultIngressTLS: []
# - hosts:
# - "*.example.com"
# secretName: "example-secret"
defaultIngressAnnotations: {}
# key1: value1
# key2: value2
batchScheduler:
# -- Specifies whether to enable batch scheduler for spark jobs scheduling.

View File

@ -86,10 +86,11 @@ var (
workqueueRateLimiterMaxDelay time.Duration
// Batch scheduler
enableBatchScheduler bool
kubeSchedulerNames []string
defaultBatchScheduler string
ingressTLS []networkingv1.IngressTLS
enableBatchScheduler bool
kubeSchedulerNames []string
defaultBatchScheduler string
defaultIngressTLS []networkingv1.IngressTLS
defaultIngressAnnotations map[string]string
// Spark web UI service and ingress
enableUIService bool
@ -132,7 +133,8 @@ func init() {
}
func NewStartCommand() *cobra.Command {
var ingressTLSstring string
var defaultIngressTLSstring string
var defaultIngressAnnotationsString string
var command = &cobra.Command{
Use: "start",
Short: "Start controller and webhook",
@ -140,12 +142,15 @@ func NewStartCommand() *cobra.Command {
development = viper.GetBool("development")
},
PreRunE: func(_ *cobra.Command, args []string) error {
if ingressTLSstring != "" {
err := json.Unmarshal([]byte(ingressTLSstring), &ingressTLS)
if defaultIngressTLSstring != "" {
err := json.Unmarshal([]byte(defaultIngressTLSstring), &defaultIngressTLS)
if err != nil {
return err
}
}
if defaultIngressAnnotationsString != "" {
return json.Unmarshal([]byte(defaultIngressAnnotationsString), &defaultIngressAnnotations)
}
return nil
},
Run: func(_ *cobra.Command, args []string) {
@ -170,7 +175,8 @@ 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().StringVar(&defaultIngressTLSstring, "default-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().StringVar(&defaultIngressAnnotationsString, "default-ingress-annotations", "", "JSON format string for the default ingress annotations for the Spark UI ingresses. e.g. '[{\"cert-manager.io/cluster-issuer\": \"letsencrypt\"}]'. `ingressAnnotations` 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.")
@ -412,13 +418,13 @@ func newSparkApplicationReconcilerOptions() sparkapplication.Options {
sparkExecutorMetrics = metrics.NewSparkExecutorMetrics(metricsPrefix, metricsLabels)
sparkExecutorMetrics.Register()
}
logger.Info("Ingress TLS configuration", "ingressTLS", ingressTLS)
options := sparkapplication.Options{
Namespaces: namespaces,
EnableUIService: enableUIService,
IngressClassName: ingressClassName,
IngressURLFormat: ingressURLFormat,
DefaultIngressTLS: ingressTLS,
DefaultIngressTLS: defaultIngressTLS,
DefaultIngressAnnotations: defaultIngressAnnotations,
DefaultBatchScheduler: defaultBatchScheduler,
DriverPodCreationGracePeriod: driverPodCreationGracePeriod,
SparkApplicationMetrics: sparkApplicationMetrics,