Skip to content

Commit

Permalink
Remote helm charts are no longer upgraded by default (#3274)
Browse files Browse the repository at this point in the history
Added `upgradeOnChange` property to override.
  • Loading branch information
dahovey authored May 29, 2020
1 parent 78d2d2f commit 6b744d5
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 5 deletions.
14 changes: 10 additions & 4 deletions docs/content/en/schemas/v2beta5.json
Original file line number Diff line number Diff line change
Expand Up @@ -1272,8 +1272,8 @@
},
"remote": {
"type": "boolean",
"description": "specifies whether the chart path is remote, or exists on the host filesystem. `remote: true` implies `skipBuildDependencies: true`.",
"x-intellij-html-description": "specifies whether the chart path is remote, or exists on the host filesystem. <code>remote: true</code> implies <code>skipBuildDependencies: true</code>.",
"description": "specifies whether the chart path is remote, or exists on the host filesystem.",
"x-intellij-html-description": "specifies whether the chart path is remote, or exists on the host filesystem.",
"default": "false"
},
"setFiles": {
Expand Down Expand Up @@ -1305,10 +1305,15 @@
},
"skipBuildDependencies": {
"type": "boolean",
"description": "should build dependencies be skipped.",
"x-intellij-html-description": "should build dependencies be skipped.",
"description": "should build dependencies be skipped. Ignored when `remote: true`.",
"x-intellij-html-description": "should build dependencies be skipped. Ignored when <code>remote: true</code>.",
"default": "false"
},
"upgradeOnChange": {
"type": "boolean",
"description": "specifies whether to upgrade helm chart on code changes. Default is `true` when helm chart is local (`remote: false`). Default is `false` if `remote: true`.",
"x-intellij-html-description": "specifies whether to upgrade helm chart on code changes. Default is <code>true</code> when helm chart is local (<code>remote: false</code>). Default is <code>false</code> if <code>remote: true</code>."
},
"useHelmSecrets": {
"type": "boolean",
"description": "instructs skaffold to use secrets plugin on deployment.",
Expand Down Expand Up @@ -1351,6 +1356,7 @@
"skipBuildDependencies",
"useHelmSecrets",
"remote",
"upgradeOnChange",
"overrides",
"packaged",
"imageStrategy"
Expand Down
8 changes: 8 additions & 0 deletions pkg/skaffold/deploy/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,14 @@ func (h *HelmDeployer) deployRelease(ctx context.Context, out io.Writer, r lates

opts.upgrade = false
opts.flags = h.Flags.Install
} else {
if r.UpgradeOnChange != nil && !*r.UpgradeOnChange {
logrus.Infof("Release %s already installed...", releaseName)
return []Artifact{}, nil
} else if r.UpgradeOnChange == nil && r.Remote {
logrus.Infof("Release %s not upgraded as it is remote...", releaseName)
return []Artifact{}, nil
}
}

// Only build local dependencies, but allow a user to skip them.
Expand Down
16 changes: 16 additions & 0 deletions pkg/skaffold/deploy/helm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,15 @@ var testDeployRemoteChart = latest.HelmDeploy{
}},
}

var upgradeOnChangeFalse = false
var testDeployUpgradeOnChange = latest.HelmDeploy{
Releases: []latest.HelmRelease{{
Name: "skaffold-helm-upgradeOnChange",
ChartPath: "examples/test",
UpgradeOnChange: &upgradeOnChangeFalse,
}},
}

var testDeployWithoutTags = latest.HelmDeploy{
Releases: []latest.HelmRelease{{
Name: "skaffold-helm",
Expand Down Expand Up @@ -507,6 +516,13 @@ func TestHelmDeploy(t *testing.T) {
runContext: makeRunContext(testDeploySkipBuildDependencies, false),
builds: testBuilds,
},
{
description: "deploy success when `upgradeOnChange: false` and does not upgrade",
commands: testutil.
CmdRunWithOutput("helm version", version21).
AndRun("helm --kube-context kubecontext get skaffold-helm-upgradeOnChange --kubeconfig kubeconfig"),
runContext: makeRunContext(testDeployUpgradeOnChange, false),
},
{
description: "deploy error remote chart without skipBuildDependencies",
commands: testutil.
Expand Down
7 changes: 6 additions & 1 deletion pkg/skaffold/schema/latest/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -537,15 +537,20 @@ type HelmRelease struct {
RecreatePods bool `yaml:"recreatePods,omitempty"`

// SkipBuildDependencies should build dependencies be skipped.
// Ignored when `remote: true`.
SkipBuildDependencies bool `yaml:"skipBuildDependencies,omitempty"`

// UseHelmSecrets instructs skaffold to use secrets plugin on deployment.
UseHelmSecrets bool `yaml:"useHelmSecrets,omitempty"`

// Remote specifies whether the chart path is remote, or exists on the host filesystem.
// `remote: true` implies `skipBuildDependencies: true`.
Remote bool `yaml:"remote,omitempty"`

// UpgradeOnChange specifies whether to upgrade helm chart on code changes.
// Default is `true` when helm chart is local (`remote: false`).
// Default is `false` if `remote: true`.
UpgradeOnChange *bool `yaml:"upgradeOnChange,omitempty"`

// Overrides are key-value pairs.
// If present, Skaffold will build a Helm `values` file that overrides
// the original and use it to call Helm CLI (`--f` flag).
Expand Down

0 comments on commit 6b744d5

Please sign in to comment.