Skip to main content
Version: v1alpha5

Helm Values

Overview

Holos makes it easier to integrate multiple Helm charts together. Holos adds valuable capabilities to Helm and Kustomize.

  1. Inject the same value into two or more charts to integrate them safer than Helm alone.
  2. Add strong type checking and validation of constraints for Helm input values.
  3. Implementation of the rendered manifests pattern.

We'll manage the prometheus and blackbox Helm Charts in this tutorial. Unfortunately, the upstream values.yaml files are misconfigured by default. Prometheus tries to connect to Blackbox at the wrong host and port.

tip

Holos and CUE makes it easy to fix this problem by integrating them correctly. The integrated charts will stay in lock step over time.

The Code

Generating the structure

Use holos to generate a minimal platform directory structure. First, create and cd into a blank directory. Then use the holos init platform command.

mkdir holos-helm-values-tutorial
cd holos-helm-values-tutorial
holos init platform v1alpha5

Make a commit to track changes.

git init . && git add . && git commit -m initial

Managing the Components

Create the prometheus and blackbox component directories, then add each of the following file contents.

mkdir -p components/prometheus components/blackbox
touch components/prometheus/prometheus.cue
touch components/blackbox/blackbox.cue
components/prometheus/prometheus.cue
package holos

// Produce a helm chart build plan.
holos: Helm.BuildPlan

Helm: #Helm & {
Chart: {
name: "prometheus"
version: "25.27.0"
repository: {
name: "prometheus-community"
url: "https://prometheus-community.github.io/helm-charts"
}
}
}

Integrating the Components

Integrate the components with the platform by adding the following file to the platform directory.

touch platform/prometheus.cue
package holos

Platform: Components: {
prometheus: {
name: "prometheus"
path: "components/prometheus"
}
blackbox: {
name: "blackbox"
path: "components/blackbox"
}
}

Render the platform.

holos render platform ./platform

Commit the results.

git add . && git commit -m 'add blackbox and prometheus'

Importing Helm Values

Holos renders the helm charts with their default values. We can import these default values into CUE so we can easily work with them as structured data instead of text markup.

holos cue import \
--package holos \
--path 'Helm: Values:' \
--outfile components/prometheus/values.cue \
components/prometheus/vendor/25.27.0/prometheus/values.yaml
holos cue import \
--package holos \
--path 'Helm: Values:' \
--outfile components/blackbox/values.cue \
components/blackbox/vendor/9.0.1/prometheus-blackbox-exporter/values.yaml

These command convert the YAML data into CUE code and nest the values under the Values field of the Holos struct.

important

CUE unifies values.cue with the other *.cue files in the same directory.

Render the platform and commit the results.

holos render platform ./platform
git add . && git commit -m 'import values'

Managing Common Configuration

Define a structure to hold the configuration values we want both helm charts to use. We add this configuration to the components directory so it's in scope for all components.

touch components/blackbox.cue
package holos

// Schema Definition
#Blackbox: {
// host constrained to a lower case dns label
host: string & =~"^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$"
// port constrained to a valid range
port: int & >0 & <=65535
}

// Concrete values must validate against the schema.
Blackbox: #Blackbox & {
host: "blackbox"
port: 9115
}
important
  1. CUE loads and unifies all *.cue files from the root directory containing cue.mod to the leaf component path directory.
  2. CUE validates types and constraints. Validation with CUE is better than languages with only type checking.

Add and commit the configuration.

git add . && git commit -m 'add blackbox configuration'

Referring to Common Configuration

Referencing common configuration from multiple components is easy and safe with Holos and CUE.

Patch the two values.cue files, or edit them by hand, to reference Blackbox.host and Blackbox.port.

patch -p1 < values.patch
important

Both charts now use the same values in lock step. Holos and CUE integrate them safely and easily.

Remove the patch file, then commit the changes.

rm values.patch
git add . && git commit -m 'integrate blackbox and prometheus together'

Reviewing Changes

Holos makes it easy to see and review platform wide changes. Render the platform to see how both prometheus and blackbox change in lock step.

holos render platform ./platform

Changes are easily visible with version control.

git diff

From the diff we know this change will:

  1. Reconfigure the blackbox exporter host from prometheus-blackbox-exporter to blackbox.
  2. Have no effect on the blackbox service port. It was already using the default 9115.
  3. Reconfigure prometheus to query the blackbox exporter at the correct host and port, blackbox:9115.

Without this change prometheus incorrectly assumed blackbox was listening at blackbox on port 80 when it was actually listening at prometheus-blackbox-exporter port 9115. Going forward, changing the blackbox host or port will reconfigure both charts correctly.

Commit the changes and move on to deploying them.

git add . && git commit -m 'render integrated blackbox and prometheus manifests'

Trying Locally

Optionally apply the manifests Holos rendered to a Local Cluster.

Next Steps

In this tutorial we learned how Holos makes it easier to holistically integrate the prometheus and blackbox charts so they're configured in lock step with each other. If we relied on Helm alone, there is no good way to configure both charts to use the same service endpoint.