How to set null config values in helm charts via pulumi

huangapple go评论81阅读模式
英文:

How to set null config values in helm charts via pulumi

问题

我正在尝试通过 pulumi 和 golang 配置一个 Helm Chart。根据 Helm Chart 文档,可以通过将配置设置为 null 来移除默认组件。我成功在我的 pulumi 脚本中设置了 Helm Chart 的所需配置值,但是无法将配置值设置为 null

更新:

似乎在 pulumi helm chart 资源的自定义抽象层上无法处理配置。我添加了一个最小工作示例,直接使用 helm chart 资源,并且按预期工作:

package main

import (
	helmv3 "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v3"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := helmv3.NewChart(ctx, "otel-collect", helmv3.ChartArgs{
			Chart:   pulumi.String("opentelemetry-collector"),
			Version: pulumi.String("0.31.1"),
			FetchArgs: helmv3.FetchArgs{
				Repo: pulumi.String("https://open-telemetry.github.io/opentelemetry-helm-charts"),
			},
			Values: pulumi.Map{
				"fullnameOverride": pulumi.String("otel-collector"),
				"mode":             pulumi.String("deployment"),
				"config": pulumi.Map{
					"receivers": pulumi.Map{
						"jaeger": pulumi.Map{
							"protocols": pulumi.Map{
								"thrift_compact": nil,
							},
						},
						"prometheus": nil,
					},
					"service": pulumi.Map{
						"pipelines": pulumi.Map{
							"metrics": nil,
						},
					},
				},
			},
		})
		if err != nil {
			return err
		}

		return nil
	})
}

在这种情况下,我想将 prometheus 配置设置为 null,但是当部署此 chart 时,prometheus 的默认值被设置。我还尝试过 "prometheus": pulumi.Any(nil),,但这也不会更改配置。

英文:

I'm trying to configure a helm chart via pulumi and golang. According to the helm chart documentation default components can be removed by setting the config to null. I managed to set the desired config values for the helm chart in my pulumi script, but it's not possible to set config values to null.

Update:

It seems that the custom abstraction layer on top of the pulumi helm chart resource could not handle the config. I have added a minimal working example which uses the helm chart resource directly and its working as expected:

package main

import (
	helmv3 "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v3"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := helmv3.NewChart(ctx, "otel-collect", helmv3.ChartArgs{
			Chart:   pulumi.String("opentelemetry-collector"),
			Version: pulumi.String("0.31.1"),
			FetchArgs: helmv3.FetchArgs{
				Repo: pulumi.String("https://open-telemetry.github.io/opentelemetry-helm-charts"),
			},
			Values: pulumi.Map{
				"fullnameOverride": pulumi.String("otel-collector"),
				"mode":             pulumi.String("deployment"),
				"config": pulumi.Map{
					"receivers": pulumi.Map{
						"jaeger": pulumi.Map{
							"protocols": pulumi.Map{
								"thrift_compact": nil,
							},
						},
						"prometheus": nil,
					},
					"service": pulumi.Map{
						"pipelines": pulumi.Map{
							"metrics": nil,
						},
					},
				},
			},
		})
		if err != nil {
			return err
		}

		return nil
	})
}

In this scenario I want to set the prometheus config to null but when this chart is deployed the default values for prometheus are set. I have also tried "prometheus": pulumi.Any(nil), but this also does not change the config.

答案1

得分: 1

这个问题是由我在pulumi helm资源之上添加的一个抽象层引起的。

英文:

The issue was caused by an abstraction layer I put on top of the pulumi helm resources.

huangapple
  • 本文由 发表于 2022年9月20日 15:26:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/73782993.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定