Skip to main content
Version: v1alpha5

Hello Holos

Overview

Like a traditional "Hello World" program, we'll start by configuring the podinfo Helm chart to output a greeting from a Kubernetes Service. This introduces the core concept of wrapping Helm charts as Holos Components.

Implementation

Initialize Platform Structure

Create and initialize a minimal platform:

mkdir holos-tutorial && cd holos-tutorial
holos init platform v1alpha5

The resulting directory structure:

holos-tutorial/
├── components/
│   └── podinfo/
│   └── podinfo.cue
├── cue.mod/
├── platform/
│   ├── platform.gen.cue
│   └── podinfo.cue
├── resources.cue
├── schema.cue
└── tags.cue

Create the Component

Configure the podinfo component:

mkdir -p components/podinfo
cat <<EOF > components/podinfo/podinfo.cue
package holos

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

HelmChart: #Helm & {
Name: "podinfo"
Chart: {
version: "6.6.2"
repository: {
name: "podinfo"
url: "https://stefanprodan.github.io/podinfo"
}
}
// Holos marshals Values into values.yaml for Helm.
Values: {
// message is a string with a default value. @tag indicates a value may
// be injected from the platform spec component parameters.
ui: {
message: string | *"Hello World" @tag(greeting, type=string)
}
}
}
EOF
important

Like Go packages, CUE loads all *.cue files in the component directory to define the component.

note

CUE recursively loads *.cue files from the component directory up to the platform root. For example, #Helm referenced on line 6 is defined in root-level schema.cue.

Add to Platform

Register the podinfo component in platform/podinfo.cue:

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

Platform: Components: podinfo: {
name: "podinfo"
path: "components/podinfo"
// Inject a value into the component.
parameters: greeting: "Hello Holos!"
}
EOF
tip

Parameter names are unrestricted, except for the reserved holos_ prefix.

Generate Manifests

Render the podinfo configuration:

holos render platform

Holos executes helm template with locally cached charts to generate:

deploy/components/podinfo/podinfo.gen.yaml
apiVersion: v1
kind: Service
metadata:
labels:
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: podinfo
app.kubernetes.io/version: 6.6.2
helm.sh/chart: podinfo-6.6.2
name: podinfo
spec:
ports:
- name: http
port: 9898
protocol: TCP
targetPort: http
- name: grpc
port: 9999
protocol: TCP
targetPort: grpc
selector:
app.kubernetes.io/name: podinfo
type: ClusterIP

Holos renders the component with the greeting injected from the platform spec.

grep -B2 Hello deploy/components/podinfo/podinfo.gen.yaml
        env:
- name: PODINFO_UI_MESSAGE
value: Hello Holos!

Breaking it down

We run holos render platform because the CUE files in the platform directory export a Platform resource to holos.

important

The platform/ directory is the default entry point to the platform rendering process. Override with --platform <dir>.

Components are the building blocks of a Platform. The platform/podinfo.cue file integrates the podinfo component with the Platform.

Holos requires two fields to integrate a component with the platform:

  1. A unique name for the component.
  2. The component path to the directory containing the CUE files that export a BuildPlan defining the component.

Component parameters are optional and allow re-use of the same component.

Take a look at the other tabs for more detailed sequence diagrams.

Next Steps

We've shown how to integrate one Helm chart into the Platform, but we haven't yet covered multiple Helm charts. Continue with the next tutorial to learn how Holos makes it easy to inject values into multiple components safely and efficiently.