From 69007093a1dd0e53f99575c76ca626c0a15a8cfc Mon Sep 17 00:00:00 2001 From: Suleiman Dibirov Date: Fri, 6 Sep 2024 17:49:46 +0300 Subject: [PATCH] Added concurrency flag to helm deploy config Signed-off-by: Suleiman Dibirov --- pkg/skaffold/deploy/helm/helm.go | 1 + pkg/skaffold/schema/defaults/defaults.go | 12 ++++++++++++ pkg/skaffold/schema/latest/config.go | 4 ++++ 3 files changed, 17 insertions(+) diff --git a/pkg/skaffold/deploy/helm/helm.go b/pkg/skaffold/deploy/helm/helm.go index e57628c55be..6e9b0610e49 100644 --- a/pkg/skaffold/deploy/helm/helm.go +++ b/pkg/skaffold/deploy/helm/helm.go @@ -263,6 +263,7 @@ func (h *Deployer) Deploy(ctx context.Context, out io.Writer, builds []graph.Art nsMap := map[string]struct{}{} manifests := manifest.ManifestList{} g, ctx := errgroup.WithContext(ctx) + g.SetLimit(*h.Concurrency) var mu sync2.Mutex // Deploy every release diff --git a/pkg/skaffold/schema/defaults/defaults.go b/pkg/skaffold/schema/defaults/defaults.go index 580f3859380..150847cdf31 100644 --- a/pkg/skaffold/schema/defaults/defaults.go +++ b/pkg/skaffold/schema/defaults/defaults.go @@ -46,6 +46,7 @@ func Set(c *latest.SkaffoldConfig) error { defaultToLocalBuild(c) setDefaultTagger(c) setDefaultLogsConfig(c) + setHelmDefaults(c) for _, a := range c.Build.Artifacts { setDefaultWorkspace(a) @@ -113,6 +114,17 @@ func Set(c *latest.SkaffoldConfig) error { return nil } +func setHelmDefaults(c *latest.SkaffoldConfig) { + if c.Deploy.LegacyHelmDeploy == nil { + return + } + + if c.Deploy.LegacyHelmDeploy.Concurrency == nil { + defaultConcurrency := 1 + c.Deploy.LegacyHelmDeploy.Concurrency = &defaultConcurrency + } +} + // SetDefaultRenderer sets the default manifests to rawYaml. func SetDefaultRenderer(c *latest.SkaffoldConfig) { if len(c.Render.Generate.Kpt) > 0 { diff --git a/pkg/skaffold/schema/latest/config.go b/pkg/skaffold/schema/latest/config.go index fa654731042..5deb6b46b7c 100644 --- a/pkg/skaffold/schema/latest/config.go +++ b/pkg/skaffold/schema/latest/config.go @@ -961,6 +961,10 @@ type KubectlFlags struct { // LegacyHelmDeploy *beta* uses the `helm` CLI to apply the charts to the cluster. type LegacyHelmDeploy struct { + // Concurrency is how many packages can be installed concurrently. 0 means "no-limit". + // Defaults to `1`. + Concurrency *int `yaml:"concurrency,omitempty"` + // Releases is a list of Helm releases. Releases []HelmRelease `yaml:"releases,omitempty"`