To define a Helm release, use the kubernetes.helm.releases option.
default.nix
{ kubenix ? import ../../../.. }:
kubenix.evalModules.${builtins.currentSystem} {
module = { kubenix, ... }: {
imports = [ kubenix.modules.helm ];
kubernetes.helm.releases.example = {
chart = kubenix.lib.helm.fetch {
repo = "https://charts.bitnami.com/bitnami";
chart = "nginx";
version = "15.0.1";
sha256 = "sKVqx99O4SNIq5y8Qo/b/2xIqXqSsZJzrgnYYz/0TKg=";
};
# arbitrary attrset passed as values to the helm release
values.replicaCount = 2;
};
};
}
Fetch and render the chart just as we did with plain manifests:
nix eval -f . --json config.kubernetes.generated
patching #
A common issue with Helm charts is the need to template everything under the sun. Kubenix solves this issue by merging configuration during evaluation.
For example, to patch the deployment created by the release above:
{
# define a resource with the same name
kubernetes.resources.deployments.nginx = {
# be sure to match the corresponding namespace as well
metadata.namespace = "default";
# here we can configure anything and are no longer bound by `values.yaml`
spec.template.spec.containers.nginx.env = [{
name = "MY_VARIABLE";
value = "100";
}];
};
}