pulumi / pulumi-kubernetes

A Pulumi resource provider for Kubernetes to manage API resources and workloads in running clusters
https://www.pulumi.com/docs/reference/clouds/kubernetes/
Apache License 2.0
415 stars 115 forks source link

Unable to set Helm values to null in C# #3178

Open mkuennek opened 3 months ago

mkuennek commented 3 months ago

What happened?

I'm trying to install the OpenTelemetry collector using its Helm Chart. The chart's default values setup all three data processing pipelines(logs, traces and metrics). I only want to use traces. When installing this chart using the Helm CLI, I can achieve this by setting null values, e.g.

service:
  pipelines:
    metrics: null

When using the same values file as a FileAsset, setting it using Release.ValueYamlFiles null values are ignored.

I tried to do the same without the yaml and only using C# without any success. How can I achieve this behaviour with Pulumi?

Example

For a reproduction, see https://github.com/mkuennek/PulumiHelm.

Output of pulumi about

❯ pulumi about running 'dotnet build -nologo .' Determining projects to restore...

All projects are up-to-date for restore.

PulumiHelm -> /Users/mkuenneke/Sources/Github/PulumiHelm/bin/Debug/net8.0/PulumiHelm.dll

Build succeeded. 0 Warning(s) 0 Error(s)

Time Elapsed 00:00:00.59

'dotnet build -nologo .' completed successfully Enter your passphrase to unlock config/secrets (set PULUMI_CONFIG_PASSPHRASE or PULUMI_CONFIG_PASSPHRASE_FILE to remember): Enter your passphrase to unlock config/secrets CLI Version 3.129.0 Go Version go1.22.6 Go Compiler gc

Plugins KIND NAME VERSION language dotnet unknown resource kubernetes 4.17.1

Host OS darwin Version 14.6.1 Arch arm64

This project is written in dotnet: executable='/opt/homebrew/bin/dotnet' version='8.0.401'

Current Stack: organization/PulumiHelm/dev

TYPE URN pulumi:pulumi:Stack urn:pulumi:dev::PulumiHelm::pulumi:pulumi:Stack::PulumiHelm-dev pulumi:providers:kubernetes urn:pulumi:dev::PulumiHelm::pulumi:providers:kubernetes::default_4_17_1 kubernetes:helm.sh/v3:Release urn:pulumi:dev::PulumiHelm::kubernetes:helm.sh/v3:Release::otel-collector

Found no pending operations associated with dev

Backend Name Michaels-MBP-2.localdomain URL file://~ User mkuenneke Organizations Token type personal

Dependencies: NAME VERSION Pulumi 3.66.1 Pulumi.Kubernetes 4.17.1

Pulumi locates its logs in /var/folders/v0/cm8hmktx2rvb639v96scp0lw0000gn/T/ by default

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

blampe commented 3 months ago

I think this is a duplicate of https://github.com/pulumi/pulumi-kubernetes/issues/2034 and/or https://github.com/pulumi/pulumi-kubernetes/issues/2997.

The provider currently (unfortunately) ignores null values when handling inputs, which is significant for Helm values.

If you're using v3 Release you can try setting allowNullValues. You might also try metrics: {} but I can't guarantee either of those will work in this case.

As a way of back porting #2997 into v4 we could look into opt-in configuration to change the provider's behavior to respect nulls, but this is not a small change.

mkuennek commented 3 months ago

Thanks for the feedback. I tried allowNullValues but unfortunately it does not help in this case. It only has an effect on value lists but not on dictionary type values.

Currently, I'm using Release v3 but I might give Chart v4 a try or manage this chart using the Helm CLI.

blampe commented 3 months ago

@mkuennek give allowNullValues and metrics: {} a try. IIRC it will respect the empty object but not null.

shamil commented 3 months ago

In v3, we could use null on values to remove default values. However, when migrating to v4, this no longer works, and null no longer has any effect.

mkuennek commented 2 months ago

Thanks for the feedback. I tried allowNullValues but unfortunately it does not help in this case. It only has an effect on value lists but not on dictionary type values.

Currently, I'm using Release v3 but I might give Chart v4 a try or manage this chart using the Helm CLI.

Unfortunately not. I tried a Otel-collector values file like this:

mode: deployment
image:
  repository: otel/opentelemetry-collector-contrib
config:
  receivers:
    jaeger: {}
    prometheus: {}
    zipkin: {}

  service:
    pipelines:
      logs: {}
      metrics: {}
      traces:
        receivers:
          - otlp
        exporters:
          - debug
ports:
  jaeger-compact:
    enabled: false
  jaeger-thrift:
    enabled: false
  jaeger-grpc:
    enabled: false
  zipkin:
    enabled: false

The logs and metrics pipelines were still being created.