Skip to main content
Version: v1alpha5

Kustomize

Overview

In the previous 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.

This tutorial goes further by integrating the httpbin service with prometheus and blackbox to automatically probe for availability.

We'll 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.

mkdir -p components/httpbin
touch components/httpbin/httpbin.cue
touch components/httpbin/httpbin.yaml

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

Integrating the Components

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

touch platform/httpbin.cue
package holos

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

Render the platform.

holos render platform ./platform

Commit the results.

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

Inspecting the BuildPlan

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

Reviewing 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. We still need to integrate httpbin with prometheus. Annotate the Service with prometheus.io/probe: "true" to complete the integration. Holos makes this easier with CUE. We don't need to edit any yaml files.

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

touch components/httpbin/patches.cue
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 ./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 Holos rendered to a Local Cluster.

Next Steps

We learned how Holos makes it easier to manage httpbin, distributed as a Kustomize base, using a kustomize Component similar to the helm component we saw previously. Holos offers a clear way to kustomize any component, patching an annotation onto the httpbin Service in this example.

Continue on with the tutorial to explore how Holos makes it easier to manage certificates and make services accessible outside of a cluster.