Skip to main content
Version: v1alpha5

Kustomize

Overview

In the previous tutorial, we learned how Holos simplifies the holistic integration of the prometheus and blackbox charts, ensuring they are configured in sync.

In this tutorial, we'll go a step further by integrating the httpbin service with Prometheus and Blackbox to automatically probe for availability.

We'll also explore how Holos manages kustomize bases, similar to the Helm kind covered in the Helm Values tutorial.

The Code

Generating the structure

Skip this step if you completed the Helm Values tutorial.

Otherwise click the Generate tab to generate a blank platform now.

Managing the Component

Create the httpbin component directory, and add the httpbin.cue and httpbin.yaml files to it for configuration and setup.

mkdir -p components/httpbin

Holos knows the httpbin.yaml file is part of the BuildPlan because of the KustomizeConfig: Files: "httpbin.yaml": _ line in the httpbin.cue.

Register the Components

Register httpbin with the platform by adding the following file to the platform directory.

cat <<EOF > platform/httpbin.cue
package holos

Platform: Components: {
httpbin: {
name: "httpbin"
path: "components/httpbin"
}
}
EOF

Render the platform.

holos render platform

Commit the results.

git add . && git commit -m 'add httpbin'

Inspecting the Build Plan

We can see the BuildPlan exported to holos by the holos: Kustomize.BuildPlan line in httpbin.cue. Holos processes this build plan to produce the fully rendered manifests.

holos cue export --expression holos --out=yaml ./components/httpbin

Transforming Manifests

Review the BuildPlan exported in the previous command:

  1. The File Generator copies the plain httpbin.yaml file into the build.
  2. The Kustomize Transformer uses httpbin.yaml as an input resource.
  3. The final artifact is the output from Kustomize.

This BuildPlan transforms the raw YAML by labeling all of the resources with "app.kubernetes.io/name": "httpbin" using the KustomizeConfig CommonLabels field.

To complete the integration with Prometheus, annotate the Service with prometheus.io/probe: "true". Holos makes this easier with CUE, so there's no need to edit any YAML files manually.

Add a new patches.cue file to the httpbin component with the following content.

cat <<EOF > components/httpbin/patches.cue
package holos

import "encoding/yaml"

// Mix in a Kustomize patch to the configuration.
Kustomize: KustomizeConfig: Kustomization: _patches: {
probe: {
target: kind: "Service"
target: name: "httpbin"
patch: yaml.Marshal([{
op: "add"
path: "/metadata/annotations/prometheus.io~1probe"
value: "true"
}])
}
}
EOF
note

We use a hidden _patches field to easily unify data into a struct, then convert the struct into a list for export.

Reviewing Changes

Render the platform to see the result of the kustomization patch.

holos render platform

Holos is configuring Kustomize to patch the plain httpbin.yaml file with the annotation.

git diff

Add and commit the final changes.

git add . && git commit -m 'annotate httpbin for prometheus probes'

Trying Locally

Optionally, apply the manifests rendered by Holos to a Local Cluster for testing and validation.

Next Steps

In this tutorial, we learned how Holos simplifies managing httpbin, which is distributed as a Kustomize base. We used a Kustomize component similar to the Helm component covered previously. Holos provides a straightforward way to customize any component, demonstrated by patching an annotation onto the httpbin Service.

Continue with the tutorial to learn how Holos facilitates certificate management and makes services accessible outside of a cluster.