helm_release.md

April 10, 2025 ยท View on GitHub

helm_release

helm_release(name, chart, create_namespace, kubernetes_context, namespace, namespace_dep,
             release_name, remote_chart, set, values, values_yaml, version, wait)

Installs or upgrades a helm release of a chart in to a cluster using helm binary.

To load the rule use:

load("//helm:defs.bzl", "helm_release")

This rule builds an executable. Use run instead of build to execute it.

helm_release(
  name = "install",
  remote_chart = "oci://docker.pkg.dev/helm-charts/test_helm_chart",
  version = "0.7.5",
  namespace = "myapp",
  release_name = "helm-release-name",
  values = ["additional_values.yaml"],
)

helm_release(
  name = "install",
  chart = ":chart",
  namespace = "myapp",
  release_name = "helm-release-name",
  values = glob(["charts/myapp/values.yaml"]),
)

Example of use providing a kubernetes context config:

helm_release(
    name = "chart_install",
    chart = ":chart",
    release_name = "release-name",
    values = glob(["charts/myapp/values.yaml"]),
    kubernetes_context = "mm-k8s-context",
)

Example of use decryptying sops secrets:


sops_decrypt(
  name = "secret",
  srcs = ["secrets.yaml"],
)

helm_release(
    name = "chart_install",
    chart = ":chart",
    release_name = "release-name",
    values = glob(["charts/myapp/values.yaml"]) + [":secret"],
)

Example of use with k8s_namespace annotated with a GCP SA:

k8s_namespace(
  name = "test-namespace",
  namespace_name = "test-namespace",
  kubernetes_sa = "test-kubernetes-sa",
  kubernetes_context = "mm-k8s-context",
)

helm_release(
    name = "chart_install",
    chart = ":chart",
    namespace_dep = ":test-namespace",
    release_name = "release-name",
    values = glob(["charts/myapp/values.yaml"]),
)

ATTRIBUTES

NameDescriptionTypeMandatoryDefault
nameA unique name for this target.Namerequired
chartThe packaged chart archive to be published. It can be a reference to a helm_chart rule or a reference to a helm archived file. To specify a helm chart from a remote repository use remote_chart instead.LabeloptionalNone
create_namespaceA flag to indicate helm binary to create the kubernetes namespace if it is not already present in the cluster.BooleanoptionalTrue
kubernetes_contextThe name of the kubeconfig context to use.StringoptionalNone
namespaceThe namespace literal where to install the helm release. Set to "" to use namespace from current kube contextStringoptional""
namespace_depA reference to a k8s_namespace rule from where to extract the namespace to be used to install the release.Namespace where this release is installed to. Must be a label to a k8s_namespace rule. It takes precedence over namespaceLabeloptionalNone
release_nameThe name of the helm release to be installed or upgraded.Stringrequired
remote_chartHelm registry url of the chart to be installed. If chart attribute is also providedd, remote_chart has preference.Stringoptional""
setA dictionary of key value pairs consisting on yaml paths and values to be replaced in the chart via --set helm option before installing it: "yaml.path": "value"Dictionary: String -> Stringoptional{}
valuesA list of value files to be provided to helm install command through -f flag.List of labelsoptional[]
values_yaml[Deprecated] Use values attr insteadList of labelsoptional[]
versionChart version to be installed in a kubernetes cluster. This option will only be used if the remote_chart attribute is used.Stringoptional""
waitHelm flag to wait for all resources to be created to exit.BooleanoptionalTrue