skaffold render passes incorrect global helm flags to helm dep build
Expected behavior
Helm dependency build worked as expected on skaffold 2.2.0 with the workaround mentioned in https://github.com/GoogleContainerTools/skaffold/issues/5445#issuecomment-1284482680
The fix for that issue was merged and available since skaffold 2.4.0, so I tried to upgrade to the latest version and remove the workaround.
Actual behavior
Skaffold/helm breaks becasue of an error caused by global flags being passed to helm dep build. These flags are valid for helm template, but not helm dep.
I should note here that I am specifying helm global flags as a helm anchor.
Information
- Skaffold version: 2.9.0
- Operating system: macOS 13.5.2
- Installed via: Homebrew
- Contents of skaffold.yaml:
apiVersion: skaffold/v4beta3
kind: Config
metadata:
name: cluster
build:
local:
push: false
.helm_flags: &helm_flags
global:
- "--include-crds"
- "--api-versions"
- "apiregistration.k8s.io/v1"
.helm_release: &helm_release
namespace: default
chartPath: charts/k8s-infra
skipBuildDependencies: false
version: 1.0.0
profiles:
- name: apps
manifests:
helm:
flags: *helm_flags
releases:
- <<: *helm_release
name: trv-data-apps-cluster
valuesFiles:
- charts/k8s-infra/values.yaml
- charts/k8s-infra/values/apps.yaml
Steps to reproduce the behavior
$ skaffold -v debug render --filename ./skaffold.yaml --profile apps --output ./output.yaml --offline=true
...
INFO[0000] Skaffold &{Version:v2.9.0 ConfigVersion:skaffold/v4beta8 GitVersion: GitCommit:6071a3f7574702c8666a243d89254e9b0d8ff4d7 BuildDate:2023-11-07T13:20:11Z GoVersion:go1.21.0 Compiler:gc Platform:darwin/arm64 User:} subtask=-1 task=DevLoop
...
INFO[0000] Building helm dependencies... subtask=0 task=Render
DEBU[0000] Running command: [helm --kube-context CONTEXT dep build charts/k8s-infra --include-crds --api-versions apiregistration.k8s.io/v1] subtask=0 task=Render
INFO[0000] Error: unknown flag: --include-crds subtask=0 task=Render
DEBU[0000] Running command: [tput colors] subtask=-1 task=DevLoop
DEBU[0000] Command output: [256] subtask=-1 task=DevLoop
building helm dependencies: exit status 1
Hey @sumeshpremraj, thanks for opening this issue. I was able to reproduce this. As you mention, the global flags are used in all the Helm commands that Skaffold invoques behind the scene.
I would say then the best option here is to extend the helm.flags property to include something like helm.flags.dep and helm.flags.template to be more granular.
Looks related with https://github.com/GoogleContainerTools/skaffold/issues/8227, something like manifests.helm.flags.template will help for that case