--- slug: hello-holos title: Hello Holos description: Configure a simple Hello World service with Holos. sidebar_position: 30 --- import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import RenderingOverview from '@site/src/diagrams/rendering-overview.mdx'; import PlatformSequence from '@site/src/diagrams/render-platform-sequence.mdx'; import ComponentSequence from '@site/src/diagrams/render-component-sequence.mdx'; import CodeBlock from '@theme/CodeBlock'; # Hello Holos ## Overview Like a traditional "Hello World" program, we'll start by configuring the [podinfo Helm chart][podinfo] to output a greeting from a Kubernetes Service. This introduces the core concept of wrapping Helm charts as Holos Components. ## Implementation ### Holos Version Ensure you have a current version of `holos` installed. This document was tested with the following version. import HolosVersionCommand from '!!raw-loader!./_hello-holos/script-01-holos-version/command.sh'; import HolosVersionOutput from '!!raw-loader!./_hello-holos/script-01-holos-version/output.txt'; {HolosVersionCommand} {HolosVersionOutput} ### Initialize Platform Structure Create and initialize a minimal platform: import MkdirAndInit from '!!raw-loader!./_hello-holos/script-02-hello-holos/mkdir-and-init.sh'; import TreeOutput from '!!raw-loader!./_hello-holos/script-02-hello-holos/tree.txt'; {MkdirAndInit} For reference, the directory structure you will attain by the end of this tutorial is listed below (NOTE: we have omitted the `cue.mod` directory for brevity): {TreeOutput}
{TreeOutput}
- **Line 1** The platform root is the `holos-tutorial` directory we created. - **Line 2** This tutorial places components in `components/`. They may reside anywhere. - **Line 3** A component is a collection of `*.cue` files at a path. - **Line 4** We'll create this file and configure the podinfo helm chart in the next section. - **Line 5** The `vendor` directory contains a cached copy of the Helm chart that was fetched for the component. - **Line 6** Rendered manifests are placed within the `deploy` directory following the structure of the `components/` directory. - **Line 9** The platform directory is the **main entrypoint** for the `holos render platform` command. - **Line 10** `platform.gen.cue` is initialized by `holos init platform` and contains the Platform spec. - **Line 11** `podinfo.cue` integrates podinfo with the platform by adding the component to the platform spec. We'll add ths file after the next section. - **Line 13** `resources.cue` Defines the Kubernetes resources available to manage in CUE. - **Line 14** `schema.cue` Defines the configuration common to all component kinds. - **Line 15** `tags.cue` Defines where component parameter values are injected into the overall platform configuration. We don't need to be concerned with this file until we cover component parameters. - **Lines 9-15** Initialized by `holos init platform`, user editable after initialization.
### Create the Component Configure the `podinfo` component: import MkdirComponents from '!!raw-loader!./_hello-holos/script-02-hello-holos/mkdir-components.sh'; import PodinfoHeader from '!!raw-loader!./_hello-holos/script-02-hello-holos/podinfo-component-header.sh'; import PodinfoBody from '!!raw-loader!./_hello-holos/script-02-hello-holos/podinfo-component-body.cue'; import EofTrailer from '!!raw-loader!./_hello-holos/script-02-hello-holos/eof-trailer.sh'; {MkdirComponents} {PodinfoHeader} {PodinfoBody} {EofTrailer} :::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`: import RegisterPodinfoHeader from '!!raw-loader!./_hello-holos/script-02-hello-holos/register-podinfo-header.sh'; import RegisterPodinfoBody from '!!raw-loader!./_hello-holos/script-02-hello-holos/register-podinfo-body.cue'; {RegisterPodinfoHeader} {RegisterPodinfoBody} {EofTrailer} :::tip Parameter names are unrestricted, except for the reserved `holos_` prefix. ::: ## Generate Manifests Render the `podinfo` configuration: import RenderCommand from '!!raw-loader!./_hello-holos/script-02-hello-holos/render.sh'; import RegisterComponentsOutput from '!!raw-loader!./_hello-holos/script-02-hello-holos/register-components-output.txt'; {RenderCommand} {RegisterComponentsOutput} Holos executes `helm template` with locally cached charts to generate: import PodinfoRenderedPath from '!!raw-loader!./_hello-holos/script-02-hello-holos/podinfo-rendered-path.sh'; import RenderedService from '!!raw-loader!./_hello-holos/script-02-hello-holos/rendered-service.yaml'; import RenderedDeployment from '!!raw-loader!./_hello-holos/script-02-hello-holos/rendered-deployment.yaml'; {PodinfoRenderedPath} {RenderedService} {RenderedDeployment} Holos renders the component with the greeting injected from the platform spec. import GrepForMessage from '!!raw-loader!./_hello-holos/script-02-hello-holos/grep-for-message.sh'; import GreppedOutput from '!!raw-loader!./_hello-holos/script-02-hello-holos/grepped-output.txt'; {GrepForMessage} {GreppedOutput} ## 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 `. ::: 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. [podinfo]: https://github.com/stefanprodan/podinfo [CUE Module]: https://cuelang.org/docs/reference/modules/ [CUE Tags]: https://cuelang.org/docs/howto/inject-value-into-evaluation-using-tag-attribute/ [Platform]: ../api/author.md#Platform