Skip to content

Commit 75beccc

Browse files
feat(helm): remove need for Helm deployer's artifactOverrides (#6949)
* refactor: remove vestiges of parsing release info text from helm deployment (#6913) * refactor(testutil): allow tests to check for envvars that should not be set * feat(helm): remove need for Helm deployer's artifactOverrides * Back out changes to v1 schema * pacify golangci-lint * fix mac test and attempt to fix windows * fix lint Co-authored-by: tejal29 <[email protected]>
1 parent 7c2aae6 commit 75beccc

File tree

41 files changed

+377
-815
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+377
-815
lines changed

cmd/skaffold/app/cmd/filter.go

+11
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/runner"
3333
latestV2 "github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest/v2"
3434
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/util"
35+
pkgutil "github.com/GoogleContainerTools/skaffold/pkg/skaffold/util"
3536
)
3637

3738
// for tests
@@ -64,6 +65,16 @@ func runFilter(ctx context.Context, out io.Writer, debuggingFilters bool, buildA
6465
if err != nil {
6566
return fmt.Errorf("loading manifests: %w", err)
6667
}
68+
69+
manifestList, err = manifestList.SetLabels(pkgutil.EnvSliceToMap(opts.CustomLabels, "="))
70+
if err != nil {
71+
return err
72+
}
73+
manifestList, err = manifestList.ReplaceImages(ctx, buildArtifacts)
74+
if err != nil {
75+
return err
76+
}
77+
6778
if debuggingFilters {
6879
// TODO(bdealwis): refactor this code
6980
debugHelpersRegistry, err := config.GetDebugHelpersRegistry(opts.GlobalConfig)

cmd/skaffold/app/cmd/flags.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ var flagRegistry = []Flag{
230230
Value: &opts.CustomLabels,
231231
DefValue: []string{},
232232
FlagAddMethod: "StringSliceVar",
233-
DefinedOn: []string{"dev", "run", "debug", "deploy", "render"},
233+
DefinedOn: []string{"dev", "run", "debug", "deploy", "render", "filter"},
234234
},
235235
{
236236
Name: "toot",

docs/content/en/api/skaffold.swagger.json

+15-15
Large diffs are not rendered by default.

docs/content/en/docs/design/config.md

-2
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ deploy:
6363
chartPath: helm/project
6464
valuesFiles:
6565
- "helm/project/dev-values.yaml"
66-
artifactOverrides:
67-
image: app
6866
```
6967
7068
In this example, the `Dockerfile` for building `app`

docs/content/en/docs/pipeline-stages/deployers/helm.md

+3-173
Original file line numberDiff line numberDiff line change
@@ -18,179 +18,9 @@ To use `helm` with Skaffold, the `helm` binary must be installed on your machine
1818

1919
Skaffold supports projects set up to deploy with Helm, but certain aspects of the project need to be configured correctly in order for Skaffold to work properly. This guide should demystify some of the nuance around using Skaffold with Helm to help you get started quickly.
2020

21-
## Image Configuration
22-
The normal Helm convention for defining image references is through the `values.yaml` file. Often, image information is configured through an `image` stanza in the values file, which might look something like this:
23-
24-
```project_root/values.yaml```
25-
```yaml
26-
image:
27-
repository: gcr.io/my-project/my-image
28-
tag: v1.2.0
29-
pullPolicy: IfNotPresent
30-
```
31-
32-
This image would then be referenced in a templated resource file, maybe like this:
33-
34-
```project_root/templates/deployment.yaml:```
35-
```yaml
36-
spec:
37-
template:
38-
spec:
39-
containers:
40-
- name: {{ .Chart.Name }}
41-
image: {{ .Values.image.repository }}:{{ .Values.image.tag}}
42-
imagePullPolicy: {{ .Values.image.pullPolicy }}
43-
```
44-
45-
**IMPORTANT: To get Skaffold to work with Helm, the `image` key must be configured in the skaffold.yaml.**
46-
47-
Associating the Helm image key allows Skaffold to track the image being built, and then configure Helm to substitute it in the proper resource definitions to be deployed to your cluster. In practice, this looks something like this:
48-
49-
```yaml
50-
build:
51-
artifacts:
52-
- image: gcr.io/my-project/my-image # must match in artifactOverrides
53-
deploy:
54-
helm:
55-
releases:
56-
- name: my-release
57-
artifactOverrides:
58-
image: gcr.io/my-project/my-image # no tag present!
59-
imageStrategy:
60-
helm: {}
61-
```
62-
63-
The `artifactOverrides` binds a Helm value key to a build artifact. The `imageStrategy` configures the image reference strategy for informing Helm of the image reference to a newly built artifact.
64-
65-
### Image reference strategies
66-
67-
Skaffold supports three _image reference strategies_ for Helm:
68-
69-
1. `fqn`: provides a fully-qualified image reference (default);
70-
2. `helm`: provides separate repository and tag portions (shown above);
71-
3. `helm+explicitRegistry`: provides separate registry, repository, and tag portions.
72-
73-
#### `fqn` strategy: single fully-qualified name (default)
74-
75-
With the fully-qualified name strategy, Skaffold configures Helm by setting a key to the fully-tagged image reference.
76-
77-
The `skaffold.yaml` setup:
78-
```yaml
79-
build:
80-
artifacts:
81-
- image: gcr.io/my-project/my-image
82-
deploy:
83-
helm:
84-
releases:
85-
- name: my-chart
86-
chartPath: helm
87-
artifactOverrides:
88-
imageKey: gcr.io/my-project/my-image
89-
imageStrategy:
90-
fqn: {}
91-
```
92-
93-
Note that the `fqn` strategy is the default and the `imageStrategy` can be omitted.
94-
95-
The `values.yaml` (note that Skaffold overrides this value):
96-
```
97-
imageKey: gcr.io/other-project/other-image:latest
98-
```
99-
100-
The chart template:
101-
```yaml
102-
spec:
103-
containers:
104-
- name: {{ .Chart.Name }}
105-
image: "{{.Values.imageKey}}"
106-
```
107-
108-
Skaffold will invoke
109-
```
110-
helm install <chart> <chart-path> --set-string imageKey=gcr.io/my-project/my-image:generatedTag@sha256:digest
111-
```
112-
113-
#### `helm` strategy: split repository and tag
114-
115-
Skaffold can be configured to provide Helm with a separate repository and tag. The key used in the `artifactOverrides` is used as base portion producing two keys `{key}.repository` and `{key}.tag`.
116-
117-
The `skaffold.yaml` setup:
118-
```yaml
119-
build:
120-
artifacts:
121-
- image: gcr.io/my-project/my-image
122-
deploy:
123-
helm:
124-
releases:
125-
- name: my-chart
126-
chartPath: helm
127-
artifactOverrides:
128-
imageKey: gcr.io/my-project/my-image
129-
imageStrategy:
130-
helm: {}
131-
```
132-
133-
The `values.yaml` (note that Skaffold overrides these values):
134-
```
135-
imageKey:
136-
repository: gcr.io/other-project/other-image
137-
tag: latest
138-
```
139-
140-
The chart template:
141-
```yaml
142-
spec:
143-
containers:
144-
- name: {{ .Chart.Name }}
145-
image: "{{.Values.imageKey.repository}}:{{.Values.imageKey.tag}}"
146-
```
147-
148-
Skaffold will invoke
149-
```
150-
helm install <chart> <chart-path> --set-string imageKey.repository=gcr.io/my-project/my-image,imageKey.tag=generatedTag@sha256:digest
151-
```
152-
153-
#### `helm`+`explicitRegistry` strategy: split registry, repository, and tag
154-
155-
Skaffold can also be configured to provide Helm with a separate repository and tag. The key used in the `artifactOverrides` is used as base portion producing three keys: `{key}.registry`, `{key}.repository`, and `{key}.tag`.
156-
157-
The `skaffold.yaml` setup:
158-
```yaml
159-
build:
160-
artifacts:
161-
- image: gcr.io/my-project/my-image
162-
deploy:
163-
helm:
164-
releases:
165-
- name: my-chart
166-
chartPath: helm
167-
artifactOverrides:
168-
imageKey: gcr.io/my-project/my-image
169-
imageStrategy:
170-
helm:
171-
explicitRegistry: true
172-
```
173-
174-
The `values.yaml` (note that Skaffold overrides these values):
175-
```
176-
imageKey:
177-
registry: gcr.io
178-
repository: other-project/other-image
179-
tag: latest
180-
```
181-
182-
The chart template:
183-
```yaml
184-
spec:
185-
containers:
186-
- name: {{ .Chart.Name }}
187-
image: "{{.Values.imageKey.registry}}/{{.Values.imageKey.repository}}:{{.Values.imageKey.tag}}"
188-
```
189-
190-
Skaffold will invoke
191-
```
192-
helm install <chart> <chart-path> --set-string imageKey.registry=gcr.io,imageKey.repository=my-project/my-image,imageKey.tag=generatedTag@sha256:digest
193-
```
21+
{{< alert title="No more `artifactsOverride`" >}}
22+
Skaffold no longer requires the intricate configuring of `artifactsOverride` and image naming strategies.
23+
{{< /alert >}}
19424

19525

19626
### Helm Build Dependencies

docs/content/en/docs/references/api/grpc.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1018,7 +1018,7 @@ For Cancelled Error code, use range 800 to 850.<br>
10181018
| DEPLOY_CLEANUP_ERR | 1003 | Deploy clean up error |
10191019
| DEPLOY_HELM_APPLY_LABELS | 1004 | Unable to apply helm labels. |
10201020
| DEPLOY_HELM_USER_ERR | 1005 | Deploy error due to user deploy config for helm deployer |
1021-
| DEPLOY_NO_MATCHING_BUILD | 1006 | Helm error when no build result is found of value specified in helm `artifactOverrides` |
1021+
| DEPLOY_NO_MATCHING_BUILD | 1006 | An image was referenced with no matching build result |
10221022
| DEPLOY_HELM_VERSION_ERR | 1007 | Unable to get helm client version |
10231023
| DEPLOY_HELM_MIN_VERSION_ERR | 1008 | Helm version not supported. |
10241024
| DEPLOY_KUBECTL_VERSION_ERR | 1109 | Unable to retrieve kubectl version |
@@ -1109,7 +1109,7 @@ Enum for Suggestion codes
11091109
| CHECK_MINIKUBE_STATUS | 202 | Check minikube status |
11101110
| INSTALL_HELM | 203 | Install helm tool |
11111111
| UPGRADE_HELM | 204 | Upgrade helm tool |
1112-
| FIX_SKAFFOLD_CONFIG_HELM_ARTIFACT_OVERRIDES | 205 | Fix helm `releases.artifactOverrides` config to match with `build.artiofacts` |
1112+
| FIX_SKAFFOLD_CONFIG_HELM_ARTIFACT_OVERRIDES | 205 | Fix helm `releases.artifactOverrides` config to match with `build.artifacts` (no longer used in Skaffold v2) |
11131113
| UPGRADE_HELM32 | 206 | Upgrade helm version to v3.2.0 and higher. |
11141114
| FIX_SKAFFOLD_CONFIG_HELM_CREATE_NAMESPACE | 207 | Set `releases.createNamespace` to false. |
11151115
| INVALID_KPT_MANIFESTS | 208 | check the Kptfile validation. |

docs/content/en/docs/tutorials/ci_cd.md

-4
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,6 @@ profiles:
8989
- ./deployment/dev/values.yaml
9090
- ./deployment/dev/secrets.yaml
9191
skipBuildDependencies: true
92-
artifactOverrides:
93-
image: asia.gcr.io/my-project/my-image
94-
imageStrategy:
95-
helm: {}
9692
flags:
9793
upgrade:
9894
- --install

docs/content/en/samples/deployers/helm.yaml

-2
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,3 @@ deploy:
33
releases:
44
- name: skaffold-helm
55
chartPath: skaffold-helm
6-
artifactOverrides:
7-
image: gcr.io/k8s-skaffold/skaffold-helm

examples/helm-deployment/charts/values.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
# This is a YAML-formatted file.
33
# Declare variables to be passed into your templates.
44
replicaCount: 2
5+
image: skaffold-helm:latest

examples/helm-deployment/skaffold.yaml

-2
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,3 @@ deploy:
88
releases:
99
- name: skaffold-helm
1010
chartPath: charts
11-
artifactOverrides:
12-
image: skaffold-helm

integration/examples/helm-deployment-dependencies/README.md

-5
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ This example follows the [helm](../helm-deployment) example, but with a local ch
66

77
The `skipBuildDependencies` option is used to skip the `helm dep build` command. This must be disabled for charts with local dependencies.
88

9-
The image can be passed to the subchart using the standard Helm format of `subchart-name.value`.
10-
119
```yaml
1210
deploy:
1311
helm:
@@ -16,9 +14,6 @@ deploy:
1614
chartPath: skaffold-helm
1715
namespace: skaffold
1816
skipBuildDependencies: true # Skip helm dep build
19-
artifactOverrides :
20-
image: skaffold-helm
21-
"subchart.image": skaffold-helm # Set image for subchart
2217
valuesFiles:
2318
- helm-values-file.yaml
2419
```

integration/examples/helm-deployment-dependencies/skaffold.yaml

-4
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ deploy:
1414
#valuesFiles:
1515
#- helm-skaffold-values.yaml
1616
skipBuildDependencies: true # Skip helm dep build
17-
artifactOverrides:
18-
image: skaffold-helm
19-
skaffold-helm-subchart:
20-
image: skaffold-helm
2117
#recreatePods will pass --recreate-pods to helm upgrade
2218
#recreatePods: true
2319
#overrides builds an override values.yaml file to run with the helm deploy

integration/examples/helm-deployment/charts/values.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
# This is a YAML-formatted file.
33
# Declare variables to be passed into your templates.
44
replicaCount: 2
5+
image: skaffold-helm:latest

integration/examples/helm-deployment/skaffold.yaml

-2
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,3 @@ deploy:
88
releases:
99
- name: skaffold-helm
1010
chartPath: charts
11-
artifactOverrides:
12-
image: skaffold-helm

integration/examples/templated-fields/skaffold.yaml

-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ deploy:
1717
releases:
1818
- name: skaffold-templated
1919
chartPath: charts
20-
artifactOverrides:
21-
image: skaffold-templated
2220
setValueTemplates:
2321
imageRepo: "{{.IMAGE_REPO}}"
2422
imageTag: "{{.IMAGE_TAG}}"

integration/render_test.go

-6
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,6 @@ func TestHelmRender(t *testing.T) {
274274
helmReleases: []latestV2.HelmRelease{{
275275
Name: "gke_loadbalancer",
276276
ChartPath: "testdata/gke_loadbalancer/loadbalancer-helm",
277-
ArtifactOverrides: map[string]string{
278-
"image": "gke-loadbalancer",
279-
},
280277
}},
281278
expectedOut: `---
282279
# Source: loadbalancer-helm/templates/k8s.yaml
@@ -332,9 +329,6 @@ spec:
332329
helmReleases: []latestV2.HelmRelease{{
333330
Name: "skaffold-helm",
334331
ChartPath: "testdata/helm/skaffold-helm",
335-
ArtifactOverrides: map[string]string{
336-
"image": "gcr.io/k8s-skaffold/skaffold-helm",
337-
},
338332
SetValues: map[string]string{
339333
"pullPolicy": "Always",
340334
},

integration/testdata/gke_loadbalancer/skaffold.yaml

-2
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,3 @@ deploy:
1010
# seed test namespace in the release name.
1111
- name: skaffold-helm-{{.TEST_NS}}
1212
chartPath: loadbalancer-helm
13-
artifactOverrides:
14-
image: gke-loadbalancer

pkg/skaffold/deploy/docker/port_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ import (
2020
"strconv"
2121
"testing"
2222

23-
v2 "github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest/v2"
23+
"github.com/docker/docker/api/types/container"
2424

25+
v2 "github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest/v2"
2526
schemautil "github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/util"
2627
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/util"
2728
"github.com/GoogleContainerTools/skaffold/testutil"
28-
"github.com/docker/docker/api/types/container"
2929
)
3030

3131
func TestAllocatePorts(t *testing.T) {

0 commit comments

Comments
 (0)