GoogleContainerTools / skaffold

Easy and Repeatable Kubernetes Development
https://skaffold.dev/
Apache License 2.0
14.93k stars 1.62k forks source link

Add support for `helm template` flags #8439

Open davegallant opened 1 year ago

davegallant commented 1 year ago

Expected behavior

There does not seem to be a way to pass --no-hooks to helm releases.

Being able to pass this flag to helm template would make renders (and therefore kubectl diff) much more readable.

For example, support for template flags may help:

deploy:
  helm:
    flags:
      template: ["--no-hooks"]

Actual behavior

skaffold render uses helm template and all hooks are displayed.

Information

apiVersion: skaffold/v3
kind: Config
metadata:
  name: third-party
deploy:
  helm:
    flags:
      upgrade: ["--atomic"]
    releases:
    - name: prometheus
      repo: https://prometheus-community.github.io/helm-charts
      remoteChart: kube-prometheus-stack
      version: 45.0.0
      namespace: monitoring
      createNamespace: true
      wait: true
      upgradeOnChange: true

Steps to reproduce the behavior

  1. Use skaffold.yaml above.
  2. skaffold deploy
  3. skaffold render | kubectl diff -f -
  4. Resources from helm hooks (such as Batch jobs) show up in every diff
chronicc commented 1 year ago

Another use case where the template flag is required is when the helm chart requires a specific minimal kubernetes version. For example Keda 2.10.2 requires at least kubernetes version 1.24.0.

The default kubernetes version for helm 3.11.3 seems to be 1.20.0. This causes the Helm chart to not be rendered but throwing following error:

skaffold deploy -m keda
std out err: %!(EXTRA *errors.errorString=Error: chart requires kubeVersion: >=v1.24.0-0 which is incompatible with Kubernetes v1.20.0

Use --debug flag to render out invalid YAML
)

Skaffold file:

apiVersion: skaffold/v4beta2
kind: Config
metadata:
  name: keda

manifests:
  helm:
    releases:
      - name: keda
        repo: https://kedacore.github.io/charts
        remoteChart: keda
        upgradeOnChange: true
        wait: true
        version: 2.10.2
zevisert commented 9 months ago

Is there any known workaround for this? Otherwise I could submit a PR for this, it seems like it could be easy to extend the existing HelmDeployFlags that exists in skaffold's schema currently under manifests.helm.flags and deploy.helm.flags, although I don't think a deploy.helm.flags.template would ever make sense anyway

djcprinse commented 1 month ago

Another use case for helm template flags could resolve the issues I am facing with skaffold v2 in issues/9488.

With the helm template flag --dry-run=server our use case with the lookup function would work. Simply using the helm commands that skaffold executes with the extra flag seems to resolve our issues.