From 1d99e0bc6e5f11468e0e047790c1f72bc7edd73d Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 24 Jan 2024 02:39:39 -0500 Subject: [PATCH] fix: guard against missing healthcheck config Also add support for liveness and readiness probes. --- plugins/scheduler-k3s/functions.go | 4 ++-- plugins/scheduler-k3s/templates/chart/deployment.yaml | 10 +++++++++- plugins/scheduler-k3s/triggers.go | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/plugins/scheduler-k3s/functions.go b/plugins/scheduler-k3s/functions.go index fd6bde701..b1442ee0b 100644 --- a/plugins/scheduler-k3s/functions.go +++ b/plugins/scheduler-k3s/functions.go @@ -115,7 +115,7 @@ type WaitForPodToExistInput struct { LabelSelector string } -func applyClusterIssuers(ctx context.Context, appName string) error { +func applyClusterIssuers(ctx context.Context) error { chartDir, err := os.MkdirTemp("", "cluster-issuer-chart-") if err != nil { return fmt.Errorf("Error creating cluster-issuer chart directory: %w", err) @@ -126,7 +126,7 @@ func applyClusterIssuers(ctx context.Context, appName string) error { chart := &Chart{ ApiVersion: "v2", AppVersion: "1.0.0", - Name: appName, + Name: "cluster-issuers", Version: "0.0.1", } diff --git a/plugins/scheduler-k3s/templates/chart/deployment.yaml b/plugins/scheduler-k3s/templates/chart/deployment.yaml index f6d36f665..32ea73a85 100644 --- a/plugins/scheduler-k3s/templates/chart/deployment.yaml +++ b/plugins/scheduler-k3s/templates/chart/deployment.yaml @@ -82,10 +82,18 @@ spec: {{- end }} {{- end }} {{- end }} - {{- if $config.healthchecks.startup }} + {{- if and $config.healthchecks $config.healthchecks.startup }} startupProbe: {{ $config.healthchecks.startup | toJson | indent 10 }} {{- end }} + {{- if and $config.healthchecks $config.healthchecks.liveness }} + livenessProbe: + {{ $config.healthchecks.liveness | toJson | indent 10 }} + {{- end }} + {{- if and $config.healthchecks $config.healthchecks.readiness }} + readinessProbe: + {{ $config.healthchecks.readiness | toJson | indent 10 }} + {{- end }} {{- if $.Values.global.image.working_dir }} workingDir: {{ $.Values.global.image.working_dir }} {{- end }} diff --git a/plugins/scheduler-k3s/triggers.go b/plugins/scheduler-k3s/triggers.go index e3498f6a0..1b06dcd18 100644 --- a/plugins/scheduler-k3s/triggers.go +++ b/plugins/scheduler-k3s/triggers.go @@ -222,7 +222,7 @@ func TriggerSchedulerDeploy(scheduler string, appName string, imageTag string) e return fmt.Errorf("Error loading environment for deployment: %w", err) } - err = applyClusterIssuers(ctx, appName) + err = applyClusterIssuers(ctx) if err != nil { return fmt.Errorf("Error applying cluster issuers: %w", err) }