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 }} {{- with .Values.controller.uiIngress.ingressClassName }}
- --ingress-class-name={{ . }} - --ingress-class-name={{ . }}
{{- end }} {{- end }}
{{- with .Values.controller.uiIngress.ingressTLS }} {{- with .Values.controller.uiIngress.defaultIngressTLS }}
- --ingress-tls={{ . | toJson }} - --default-ingress-tls={{ . | toJson }}
{{- end }}
{{- with .Values.controller.uiIngress.defaultIngressAnnotations }}
- --default-ingress-annotations={{ . | toJson }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- if .Values.controller.batchScheduler.enable }} {{- if .Values.controller.batchScheduler.enable }}

View File

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

View File

@ -86,10 +86,11 @@ var (
workqueueRateLimiterMaxDelay time.Duration workqueueRateLimiterMaxDelay time.Duration
// Batch scheduler // Batch scheduler
enableBatchScheduler bool enableBatchScheduler bool
kubeSchedulerNames []string kubeSchedulerNames []string
defaultBatchScheduler string defaultBatchScheduler string
ingressTLS []networkingv1.IngressTLS defaultIngressTLS []networkingv1.IngressTLS
defaultIngressAnnotations map[string]string
// Spark web UI service and ingress // Spark web UI service and ingress
enableUIService bool enableUIService bool
@ -132,7 +133,8 @@ func init() {
} }
func NewStartCommand() *cobra.Command { func NewStartCommand() *cobra.Command {
var ingressTLSstring string var defaultIngressTLSstring string
var defaultIngressAnnotationsString string
var command = &cobra.Command{ var command = &cobra.Command{
Use: "start", Use: "start",
Short: "Start controller and webhook", Short: "Start controller and webhook",
@ -140,12 +142,15 @@ func NewStartCommand() *cobra.Command {
development = viper.GetBool("development") development = viper.GetBool("development")
}, },
PreRunE: func(_ *cobra.Command, args []string) error { PreRunE: func(_ *cobra.Command, args []string) error {
if ingressTLSstring != "" { if defaultIngressTLSstring != "" {
err := json.Unmarshal([]byte(ingressTLSstring), &ingressTLS) err := json.Unmarshal([]byte(defaultIngressTLSstring), &defaultIngressTLS)
if err != nil { if err != nil {
return err return err
} }
} }
if defaultIngressAnnotationsString != "" {
return json.Unmarshal([]byte(defaultIngressAnnotationsString), &defaultIngressAnnotations)
}
return nil return nil
}, },
Run: func(_ *cobra.Command, args []string) { 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().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(&ingressClassName, "ingress-class-name", "", "Set ingressClassName for ingress resources created.")
command.Flags().StringVar(&ingressURLFormat, "ingress-url-format", "", "Ingress URL format.") 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. "+ command.Flags().BoolVar(&enableLeaderElection, "leader-election", false, "Enable leader election for controller manager. "+
"Enabling this will ensure there is only one active 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 = metrics.NewSparkExecutorMetrics(metricsPrefix, metricsLabels)
sparkExecutorMetrics.Register() sparkExecutorMetrics.Register()
} }
logger.Info("Ingress TLS configuration", "ingressTLS", ingressTLS)
options := sparkapplication.Options{ options := sparkapplication.Options{
Namespaces: namespaces, Namespaces: namespaces,
EnableUIService: enableUIService, EnableUIService: enableUIService,
IngressClassName: ingressClassName, IngressClassName: ingressClassName,
IngressURLFormat: ingressURLFormat, IngressURLFormat: ingressURLFormat,
DefaultIngressTLS: ingressTLS, DefaultIngressTLS: defaultIngressTLS,
DefaultIngressAnnotations: defaultIngressAnnotations,
DefaultBatchScheduler: defaultBatchScheduler, DefaultBatchScheduler: defaultBatchScheduler,
DriverPodCreationGracePeriod: driverPodCreationGracePeriod, DriverPodCreationGracePeriod: driverPodCreationGracePeriod,
SparkApplicationMetrics: sparkApplicationMetrics, SparkApplicationMetrics: sparkApplicationMetrics,