mirror of
https://github.com/holos-run/holos.git
synced 2026-03-19 00:37:45 +00:00
Compare commits
41 Commits
v0.101.7
...
gl/embed-t
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ae4aad4993 | ||
|
|
410b882d1d | ||
|
|
e2648202dc | ||
|
|
44c2fe220a | ||
|
|
fe1ae2fa80 | ||
|
|
8fbee1cbd9 | ||
|
|
982db2cccc | ||
|
|
e9d1240d63 | ||
|
|
03fa4eaaa2 | ||
|
|
e363f3a597 | ||
|
|
8b49ed93be | ||
|
|
d2be9fe278 | ||
|
|
6ec341bbb1 | ||
|
|
13a4305b78 | ||
|
|
0cfce3a823 | ||
|
|
61d7539e1c | ||
|
|
bf84724137 | ||
|
|
9f0de7555c | ||
|
|
650636f944 | ||
|
|
b28c110694 | ||
|
|
5bb3e90b38 | ||
|
|
6a60b613ff | ||
|
|
5862725bab | ||
|
|
8660826b05 | ||
|
|
449df91e33 | ||
|
|
ac59173b30 | ||
|
|
fb75e560fc | ||
|
|
69a064e3ea | ||
|
|
71b72807bb | ||
|
|
0e4ecf9d13 | ||
|
|
ec2fdadd44 | ||
|
|
38b082095f | ||
|
|
f9346ea7c0 | ||
|
|
0f7010288a | ||
|
|
386fb89cc6 | ||
|
|
c5401d6b02 | ||
|
|
f215405643 | ||
|
|
2c79982bd3 | ||
|
|
e5e4de3073 | ||
|
|
ec462f5f0b | ||
|
|
0e95a2812e |
@@ -37,6 +37,7 @@
|
||||
"blackbox",
|
||||
"buildplan",
|
||||
"buildplans",
|
||||
"Buildx",
|
||||
"builtinpluginloadingoptions",
|
||||
"cachedir",
|
||||
"cadvisor",
|
||||
@@ -84,6 +85,7 @@
|
||||
"destinationrules",
|
||||
"devel",
|
||||
"devicecode",
|
||||
"distroless",
|
||||
"dnsmasq",
|
||||
"dscacheutil",
|
||||
"ecrauthorizationtoken",
|
||||
@@ -281,6 +283,7 @@
|
||||
"serviceentries",
|
||||
"serviceentry",
|
||||
"servicemonitor",
|
||||
"sigstore",
|
||||
"somevalue",
|
||||
"SOMEVAR",
|
||||
"sortoptions",
|
||||
@@ -321,6 +324,7 @@
|
||||
"udev",
|
||||
"uibutton",
|
||||
"Unmarshal",
|
||||
"unshallow",
|
||||
"unstage",
|
||||
"untar",
|
||||
"upbound",
|
||||
|
||||
143
.github/workflows/container.yaml
vendored
Normal file
143
.github/workflows/container.yaml
vendored
Normal file
@@ -0,0 +1,143 @@
|
||||
name: Container
|
||||
|
||||
# Only allow actors with write permission to the repository to trigger this
|
||||
# workflow.
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
git_ref:
|
||||
description: 'Git ref to build (e.g., refs/tags/v1.2.3, refs/heads/main)'
|
||||
required: true
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
buildx:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
attestations: write
|
||||
id-token: write
|
||||
steps:
|
||||
- name: Set tag from trigger event
|
||||
id: opts
|
||||
run: |
|
||||
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
||||
echo "ref=${{ inputs.git_ref }}" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "ref=${GITHUB_REF}" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ steps.opts.outputs.ref }}
|
||||
- name: SHA
|
||||
id: sha
|
||||
run: echo "sha=$(/usr/bin/git log -1 --format='%H')" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
- name: Fetch tags
|
||||
run: git fetch --prune --unshallow --tags
|
||||
- name: Set Tags
|
||||
id: tags
|
||||
run: |
|
||||
echo "detail=$(/usr/bin/git describe --tags HEAD)" >> $GITHUB_OUTPUT
|
||||
echo "suffix=$(test -n "$(git status --porcelain)" && echo '-dirty' || echo '')" >> $GITHUB_OUTPUT
|
||||
echo "tag=$(/usr/bin/git describe --tags HEAD)$(test -n "$(git status --porcelain)" && echo '-dirty' || echo '')" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Login to ghcr.io
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Build and push container images
|
||||
id: build-and-push
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
tags: |
|
||||
ghcr.io/holos-run/holos:${{ steps.tags.outputs.tag }}
|
||||
ghcr.io/holos-run/holos:${{ steps.sha.outputs.sha }}${{ steps.tags.outputs.suffix }}
|
||||
- name: Setup Cosign to sign container images
|
||||
uses: sigstore/cosign-installer@v3.7.0
|
||||
- name: Sign with GitHub OIDC Token
|
||||
env:
|
||||
DIGEST: ${{ steps.build-and-push.outputs.digest }}
|
||||
run: |
|
||||
cosign sign --yes ghcr.io/holos-run/holos:${{ steps.tags.outputs.tag }}@${DIGEST}
|
||||
cosign sign --yes ghcr.io/holos-run/holos:${{ steps.sha.outputs.sha }}${{ steps.tags.outputs.suffix }}@${DIGEST}
|
||||
|
||||
- uses: actions/create-github-app-token@v1
|
||||
id: app-token
|
||||
with:
|
||||
owner: ${{ github.repository_owner }}
|
||||
app-id: ${{ vars.GORELEASER_APP_ID }}
|
||||
private-key: ${{ secrets.GORELEASER_APP_PRIVATE_KEY }}
|
||||
- name: Get GitHub App User ID
|
||||
id: get-user-id
|
||||
run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
|
||||
env:
|
||||
GH_TOKEN: ${{ steps.app-token.outputs.token }}
|
||||
- run: |
|
||||
git config --global user.name '${{ steps.app-token.outputs.app-slug }}[bot]'
|
||||
git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com'
|
||||
- name: Update holos-run/holos-action
|
||||
env:
|
||||
IMAGE: ghcr.io/holos-run/holos:v0.102.1
|
||||
VERSION: ${{ steps.tags.outputs.tag }}
|
||||
USER_ID: ${{ steps.get-user-id.outputs.user-id }}
|
||||
TOKEN: ${{ steps.app-token.outputs.token }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
git clone "https://github.com/holos-run/holos-action"
|
||||
cd holos-action
|
||||
git remote set-url origin https://${USER_ID}:${TOKEN}@github.com/holos-run/holos-action
|
||||
docker pull --quiet "${IMAGE}"
|
||||
docker run -v $(pwd):/app --workdir /app --rm "${IMAGE}" \
|
||||
holos cue export --out yaml action.cue -t "version=${VERSION}" > action.yml
|
||||
git add action.yml
|
||||
git commit -m "ci: update holos to ${VERSION} - https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" || (echo "No changes to commit"; exit 0)
|
||||
git push origin HEAD:main HEAD:v0 HEAD:v1
|
||||
|
||||
- name: Login to quay.io
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: quay.io
|
||||
username: ${{ secrets.QUAY_USER }}
|
||||
password: ${{ secrets.QUAY_TOKEN }}
|
||||
- name: Push to quay.io
|
||||
env:
|
||||
DIGEST: ${{ steps.build-and-push.outputs.digest }}
|
||||
run: |
|
||||
# docker push quay.io/holos-run/holos:${{ steps.tags.outputs.tag }}
|
||||
docker pull --quiet ghcr.io/holos-run/holos:${{ steps.tags.outputs.tag }}@${DIGEST}
|
||||
docker tag ghcr.io/holos-run/holos:${{ steps.tags.outputs.tag }}@${DIGEST} \
|
||||
quay.io/holos-run/holos:${{ steps.tags.outputs.tag }}
|
||||
docker push quay.io/holos-run/holos:${{ steps.tags.outputs.tag }}
|
||||
|
||||
docker pull --quiet ghcr.io/holos-run/holos:${{ steps.sha.outputs.sha }}${{ steps.tags.outputs.suffix }}@${DIGEST}
|
||||
docker tag ghcr.io/holos-run/holos:${{ steps.sha.outputs.sha }}${{ steps.tags.outputs.suffix }}@${DIGEST} \
|
||||
quay.io/holos-run/holos:${{ steps.sha.outputs.sha }}${{ steps.tags.outputs.suffix }}
|
||||
docker push quay.io/holos-run/holos:${{ steps.sha.outputs.sha }}${{ steps.tags.outputs.suffix }}
|
||||
- name: Sign quay.io image
|
||||
env:
|
||||
DIGEST: ${{ steps.build-and-push.outputs.digest }}
|
||||
run: |
|
||||
cosign sign --yes quay.io/holos-run/holos:${{ steps.tags.outputs.tag }}@${DIGEST}
|
||||
cosign sign --yes quay.io/holos-run/holos:${{ steps.sha.outputs.sha }}${{ steps.tags.outputs.suffix }}@${DIGEST}
|
||||
|
||||
outputs:
|
||||
tag: ${{ steps.tags.outputs.tag }}
|
||||
detail: ${{ steps.tags.outputs.detail }}
|
||||
33
.github/workflows/lint.yaml
vendored
33
.github/workflows/lint.yaml
vendored
@@ -1,6 +1,5 @@
|
||||
---
|
||||
# https://github.com/golangci/golangci-lint-action?tab=readme-ov-file#how-to-use
|
||||
name: Lint
|
||||
name: Spelling
|
||||
"on":
|
||||
push:
|
||||
branches:
|
||||
@@ -8,35 +7,11 @@ name: Lint
|
||||
- test
|
||||
pull_request:
|
||||
types: [opened, synchronize]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
name: lint
|
||||
cspell:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: stable
|
||||
|
||||
## Not needed on ubuntu-latest
|
||||
# - name: Install Packages
|
||||
# run: sudo apt update && sudo apt -qq -y install git curl zip unzip tar bzip2 make
|
||||
|
||||
- name: Install Tools
|
||||
run: make tools
|
||||
|
||||
- name: Lint
|
||||
# golangci-lint runs in a separate workflow.
|
||||
run: make lint -o golangci-lint
|
||||
- uses: actions/checkout@v4
|
||||
- run: ./hack/cspell
|
||||
|
||||
8
.github/workflows/test.yaml
vendored
8
.github/workflows/test.yaml
vendored
@@ -28,19 +28,11 @@ jobs:
|
||||
with:
|
||||
go-version: stable
|
||||
|
||||
- name: Install Packages
|
||||
run: sudo apt update && sudo apt -qq -y install git curl zip unzip tar bzip2 make
|
||||
|
||||
- name: Set up Helm
|
||||
uses: azure/setup-helm@v4
|
||||
|
||||
- name: Set up Kubectl
|
||||
uses: azure/setup-kubectl@v4
|
||||
|
||||
- name: Install Tools
|
||||
run: |
|
||||
set -x
|
||||
make tools
|
||||
|
||||
- name: Test
|
||||
run: ./scripts/test
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -12,3 +12,4 @@ tmp/
|
||||
/holos-k3d/
|
||||
/holos-infra/
|
||||
node_modules/
|
||||
.tmp/
|
||||
|
||||
39
Dockerfile
39
Dockerfile
@@ -1,8 +1,31 @@
|
||||
FROM quay.io/holos-run/debian:bullseye AS final
|
||||
USER root
|
||||
WORKDIR /app
|
||||
ADD bin bin
|
||||
RUN chown -R app: /app
|
||||
# Kubernetes requires the user to be numeric
|
||||
USER 8192
|
||||
ENTRYPOINT bin/holos server
|
||||
FROM registry.k8s.io/kubectl:v1.31.0 AS kubectl
|
||||
# https://github.com/GoogleContainerTools/distroless
|
||||
FROM golang:1.23 AS build
|
||||
|
||||
WORKDIR /go/src/app
|
||||
COPY . .
|
||||
|
||||
RUN CGO_ENABLED=0 make install
|
||||
RUN CGO_ENABLED=0 go install sigs.k8s.io/kustomize/kustomize/v5
|
||||
|
||||
# Install helm to /usr/local/bin/helm
|
||||
# https://helm.sh/docs/intro/install/#from-script
|
||||
# https://holos.run/docs/v1alpha5/tutorial/setup/#dependencies
|
||||
RUN curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 \
|
||||
&& chmod 700 get_helm.sh \
|
||||
&& DESIRED_VERSION=v3.16.2 ./get_helm.sh \
|
||||
&& rm -f get_helm.sh
|
||||
|
||||
COPY --from=kubectl /bin/kubectl /usr/local/bin/
|
||||
|
||||
# distroless
|
||||
FROM gcr.io/distroless/static-debian12 AS final
|
||||
COPY --from=build \
|
||||
/go/bin/holos \
|
||||
/go/bin/kustomize \
|
||||
/usr/local/bin/kubectl \
|
||||
/usr/local/bin/helm \
|
||||
/bin/
|
||||
|
||||
# Usage: docker run -v $(pwd):/app --workdir /app --rm -it quay.io/holos-run/holos holos render platform
|
||||
CMD ["/bin/holos"]
|
||||
|
||||
5
Makefile
5
Makefile
@@ -124,6 +124,7 @@ go-deps: ## tool versions pinned in tools.go
|
||||
go install golang.org/x/tools/cmd/godoc
|
||||
go install github.com/princjef/gomarkdoc/cmd/gomarkdoc
|
||||
go install github.com/google/ko
|
||||
go install github.com/stefanprodan/timoni/cmd/timoni@v0.23.0
|
||||
# curl https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | bash
|
||||
|
||||
.PHONY: frontend-deps
|
||||
@@ -154,6 +155,10 @@ website: ## Build website
|
||||
unity: ## https://cuelabs.dev/unity/
|
||||
./scripts/unity
|
||||
|
||||
.PHONY: update-docs
|
||||
update-docs: ## Update doc examples
|
||||
HOLOS_UPDATE_SCRIPTS=1 go test -v ./doc/md/...
|
||||
|
||||
.PHONY: help
|
||||
help: ## Display this help menu.
|
||||
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-20s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
|
||||
|
||||
@@ -119,12 +119,12 @@ here to help.
|
||||
|
||||
Holos is licensed under Apache 2.0 as found in the [LICENSE file](LICENSE).
|
||||
|
||||
[Holos]: https://holos.run
|
||||
[Holos]: https://holos.run/docs/overview/
|
||||
[rendered manifests pattern]: https://akuity.io/blog/the-rendered-manifests-pattern
|
||||
[CUE]: https://cuelang.org/
|
||||
[Discord]: https://discord.gg/JgDVbNpye7
|
||||
[GitHub discussions]: https://github.com/holos-run/holos/discussions
|
||||
[Why CUE for Configuration]: https://holos.run/blog/why-cue-for-configuration/
|
||||
[topics]: https://holos.run/docs/topics/
|
||||
[tutorial]: https://holos.run/docs/overview/
|
||||
[setup]: https://holos.run/docs/setup/
|
||||
[tutorial]: https://holos.run/docs/tutorial/
|
||||
[topics]: https://holos.run/docs/topics/
|
||||
|
||||
@@ -84,6 +84,9 @@ type Helm struct {
|
||||
Chart core.Chart
|
||||
// Values represents data to marshal into a values.yaml for helm.
|
||||
Values core.Values
|
||||
// ValueFiles represents value files for migration from helm value
|
||||
// hierarchies. Use Values instead.
|
||||
ValueFiles []core.ValueFile `json:",omitempty"`
|
||||
// EnableHooks enables helm hooks when executing the `helm template` command.
|
||||
EnableHooks bool `cue:"true | *false"`
|
||||
// Namespace sets the helm chart namespace flag if provided.
|
||||
|
||||
@@ -118,8 +118,12 @@ type Helm struct {
|
||||
// Chart represents a helm chart to manage.
|
||||
Chart Chart `json:"chart" yaml:"chart"`
|
||||
// Values represents values for holos to marshal into values.yaml when
|
||||
// rendering the chart.
|
||||
// rendering the chart. Values follow ValueFiles when both are provided.
|
||||
Values Values `json:"values" yaml:"values"`
|
||||
// ValueFiles represents hierarchial value files passed in order to the helm
|
||||
// template -f flag. Useful for migration from an ApplicationSet. Use Values
|
||||
// instead. ValueFiles precede Values when both are provided.
|
||||
ValueFiles []ValueFile `json:"valueFiles,omitempty" yaml:"valueFiles,omitempty"`
|
||||
// EnableHooks enables helm hooks when executing the `helm template` command.
|
||||
EnableHooks bool `json:"enableHooks,omitempty" yaml:"enableHooks,omitempty"`
|
||||
// Namespace represents the helm namespace flag
|
||||
@@ -130,6 +134,17 @@ type Helm struct {
|
||||
KubeVersion string `json:"kubeVersion,omitempty" yaml:"kubeVersion,omitempty"`
|
||||
}
|
||||
|
||||
// ValueFile represents one Helm value file produced from CUE.
|
||||
type ValueFile struct {
|
||||
// Name represents the file name, e.g. "region-values.yaml"
|
||||
Name string `json:"name" yaml:"name"`
|
||||
// Kind is a discriminator.
|
||||
Kind string `json:"kind" yaml:"kind" cue:"\"Values\""`
|
||||
// Values represents values for holos to marshal into the file name specified
|
||||
// by Name when rendering the chart.
|
||||
Values Values `json:"values,omitempty" yaml:"values,omitempty"`
|
||||
}
|
||||
|
||||
// Values represents [Helm] Chart values generated from CUE.
|
||||
type Values map[string]any
|
||||
|
||||
@@ -263,7 +278,7 @@ type Metadata struct {
|
||||
// Labels represents a resource selector.
|
||||
Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
|
||||
// Annotations represents arbitrary non-identifying metadata. For example
|
||||
// holos uses the `cli.holos.run/description` annotation to log resources in a
|
||||
// holos uses the `app.holos.run/description` annotation to log resources in a
|
||||
// user customized way.
|
||||
Annotations map[string]string `json:"annotations,omitempty" yaml:"annotations,omitempty"`
|
||||
}
|
||||
@@ -320,7 +335,7 @@ type Component struct {
|
||||
// resulting BuildPlan.
|
||||
Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
|
||||
// Annotations represents arbitrary non-identifying metadata. Use the
|
||||
// `cli.holos.run/description` to customize the log message of each BuildPlan.
|
||||
// `app.holos.run/description` to customize the log message of each BuildPlan.
|
||||
Annotations map[string]string `json:"annotations,omitempty" yaml:"annotations,omitempty"`
|
||||
}
|
||||
|
||||
|
||||
63
cmd/cmd.go
Normal file
63
cmd/cmd.go
Normal file
@@ -0,0 +1,63 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"os"
|
||||
"runtime/pprof"
|
||||
"runtime/trace"
|
||||
|
||||
"github.com/holos-run/holos/internal/cli"
|
||||
"github.com/holos-run/holos/internal/holos"
|
||||
)
|
||||
|
||||
// MakeMain makes a main function for the cli or tests.
|
||||
func MakeMain(options ...holos.Option) func() int {
|
||||
return func() (exitCode int) {
|
||||
cfg := holos.New(options...)
|
||||
slog.SetDefault(cfg.Logger())
|
||||
ctx := context.Background()
|
||||
|
||||
if format := os.Getenv("HOLOS_CPU_PROFILE"); format != "" {
|
||||
f, _ := os.Create(fmt.Sprintf(format, os.Getppid(), os.Getpid()))
|
||||
err := pprof.StartCPUProfile(f)
|
||||
defer func() {
|
||||
pprof.StopCPUProfile()
|
||||
f.Close()
|
||||
}()
|
||||
if err != nil {
|
||||
return cli.HandleError(ctx, err, cfg)
|
||||
}
|
||||
}
|
||||
defer memProfile(ctx, cfg)
|
||||
|
||||
if format := os.Getenv("HOLOS_TRACE"); format != "" {
|
||||
f, _ := os.Create(fmt.Sprintf(format, os.Getppid(), os.Getpid()))
|
||||
err := trace.Start(f)
|
||||
defer func() {
|
||||
trace.Stop()
|
||||
f.Close()
|
||||
}()
|
||||
if err != nil {
|
||||
return cli.HandleError(ctx, err, cfg)
|
||||
}
|
||||
}
|
||||
|
||||
feature := &holos.EnvFlagger{}
|
||||
if err := cli.New(cfg, feature).ExecuteContext(ctx); err != nil {
|
||||
return cli.HandleError(ctx, err, cfg)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
func memProfile(ctx context.Context, cfg *holos.Config) {
|
||||
if format := os.Getenv("HOLOS_MEM_PROFILE"); format != "" {
|
||||
f, _ := os.Create(fmt.Sprintf(format, os.Getppid(), os.Getpid()))
|
||||
defer f.Close()
|
||||
if err := pprof.WriteHeapProfile(f); err != nil {
|
||||
_ = cli.HandleError(ctx, err, cfg)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,9 @@ package main
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/holos-run/holos/internal/cli"
|
||||
"github.com/holos-run/holos/cmd"
|
||||
)
|
||||
|
||||
func main() {
|
||||
os.Exit(cli.MakeMain()())
|
||||
os.Exit(cmd.MakeMain()())
|
||||
}
|
||||
|
||||
@@ -6,13 +6,13 @@ import (
|
||||
"testing"
|
||||
|
||||
cue "cuelang.org/go/cmd/cue/cmd"
|
||||
"github.com/holos-run/holos/internal/cli"
|
||||
"github.com/holos-run/holos/cmd"
|
||||
"github.com/rogpeppe/go-internal/testscript"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
os.Exit(testscript.RunMain(m, map[string]func() int{
|
||||
"holos": cli.MakeMain(),
|
||||
"holos": cmd.MakeMain(),
|
||||
"cue": cue.Main,
|
||||
}))
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
# https://github.com/holos-run/holos/issues/330
|
||||
exec holos init platform v1alpha5 --force
|
||||
# Make sure the helm chart works with plain helm
|
||||
exec helm template ./components/capabilities/vendor/0.1.0/capabilities
|
||||
cmp stdout want/helm-template.yaml
|
||||
stdout 'name: has-foo-v1beta1'
|
||||
stdout 'kubeVersion: v'
|
||||
exec holos render platform ./platform
|
||||
# When no capabilities are specified
|
||||
cmp deploy/components/capabilities/capabilities.gen.yaml want/when-no-capabilities-specified.yaml
|
||||
|
||||
@@ -86,6 +86,9 @@ type Helm struct {
|
||||
Chart core.Chart
|
||||
// Values represents data to marshal into a values.yaml for helm.
|
||||
Values core.Values
|
||||
// ValueFiles represents value files for migration from helm value
|
||||
// hierarchies. Use Values instead.
|
||||
ValueFiles []core.ValueFile `json:",omitempty"`
|
||||
// EnableHooks enables helm hooks when executing the `helm template` command.
|
||||
EnableHooks bool `cue:"true | *false"`
|
||||
// Namespace sets the helm chart namespace flag if provided.
|
||||
|
||||
@@ -43,6 +43,7 @@ Package core contains schemas for a [Platform](<#Platform>) and [BuildPlan](<#Bu
|
||||
- [type Resources](<#Resources>)
|
||||
- [type Transformer](<#Transformer>)
|
||||
- [type Validator](<#Validator>)
|
||||
- [type ValueFile](<#ValueFile>)
|
||||
- [type Values](<#Values>)
|
||||
|
||||
|
||||
@@ -188,7 +189,7 @@ type Component struct {
|
||||
// resulting BuildPlan.
|
||||
Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
|
||||
// Annotations represents arbitrary non-identifying metadata. Use the
|
||||
// `cli.holos.run/description` to customize the log message of each BuildPlan.
|
||||
// `app.holos.run/description` to customize the log message of each BuildPlan.
|
||||
Annotations map[string]string `json:"annotations,omitempty" yaml:"annotations,omitempty"`
|
||||
}
|
||||
```
|
||||
@@ -283,8 +284,12 @@ type Helm struct {
|
||||
// Chart represents a helm chart to manage.
|
||||
Chart Chart `json:"chart" yaml:"chart"`
|
||||
// Values represents values for holos to marshal into values.yaml when
|
||||
// rendering the chart.
|
||||
// rendering the chart. Values follow ValueFiles when both are provided.
|
||||
Values Values `json:"values" yaml:"values"`
|
||||
// ValueFiles represents hierarchial value files passed in order to the helm
|
||||
// template -f flag. Useful for migration from an ApplicationSet. Use Values
|
||||
// instead. ValueFiles precede Values when both are provided.
|
||||
ValueFiles []ValueFile `json:"valueFiles,omitempty" yaml:"valueFiles,omitempty"`
|
||||
// EnableHooks enables helm hooks when executing the `helm template` command.
|
||||
EnableHooks bool `json:"enableHooks,omitempty" yaml:"enableHooks,omitempty"`
|
||||
// Namespace represents the helm namespace flag
|
||||
@@ -376,7 +381,7 @@ type Metadata struct {
|
||||
// Labels represents a resource selector.
|
||||
Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
|
||||
// Annotations represents arbitrary non-identifying metadata. For example
|
||||
// holos uses the `cli.holos.run/description` annotation to log resources in a
|
||||
// holos uses the `app.holos.run/description` annotation to log resources in a
|
||||
// user customized way.
|
||||
Annotations map[string]string `json:"annotations,omitempty" yaml:"annotations,omitempty"`
|
||||
}
|
||||
@@ -493,6 +498,23 @@ type Validator struct {
|
||||
}
|
||||
```
|
||||
|
||||
<a name="ValueFile"></a>
|
||||
## type ValueFile {#ValueFile}
|
||||
|
||||
ValueFile represents one Helm value file produced from CUE.
|
||||
|
||||
```go
|
||||
type ValueFile struct {
|
||||
// Name represents the file name, e.g. "region-values.yaml"
|
||||
Name string `json:"name" yaml:"name"`
|
||||
// Kind is a discriminator.
|
||||
Kind string `json:"kind" yaml:"kind" cue:"\"Values\""`
|
||||
// Values represents values for holos to marshal into the file name specified
|
||||
// by Name when rendering the chart.
|
||||
Values Values `json:"values,omitempty" yaml:"values,omitempty"`
|
||||
}
|
||||
```
|
||||
|
||||
<a name="Values"></a>
|
||||
## type Values {#Values}
|
||||
|
||||
|
||||
7
doc/md/tutorial/_cue/examples/01-holos-version.txt
Normal file
7
doc/md/tutorial/_cue/examples/01-holos-version.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
exec bash -c 'bash -euo pipefail $WORK/command.sh 2>&1'
|
||||
cmp stdout $WORK/output.txt
|
||||
|
||||
-- command.sh --
|
||||
holos --version
|
||||
-- output.txt --
|
||||
0.103.0
|
||||
166
doc/md/tutorial/_cue/examples/02-cue.txt
Normal file
166
doc/md/tutorial/_cue/examples/02-cue.txt
Normal file
@@ -0,0 +1,166 @@
|
||||
# Set $HOME because:
|
||||
# - Helm uses it for temporary files
|
||||
# - Git requires it for setting author name/email globally
|
||||
env HOME=$WORK/.tmp
|
||||
chmod 0755 $WORK/update.sh
|
||||
|
||||
# Configure git author for testscript execution
|
||||
exec git config --global user.name 'Holos Docs'
|
||||
exec git config --global user.email 'hello@holos.run'
|
||||
exec git config --global init.defaultBranch main
|
||||
|
||||
# Remove the tutorial directory if it already exists
|
||||
exec rm -rf holos-cue-tutorial
|
||||
|
||||
# Create and change to the tutorial directory, and then initialize the Holos platform
|
||||
exec bash -c 'bash -euo pipefail mkdir-and-init.sh'
|
||||
cd holos-cue-tutorial
|
||||
|
||||
# Create the components directory, then combine and execute the multiline
|
||||
# podinfo component header/body/trailer files
|
||||
exec bash -c 'bash -euo pipefail $WORK/mkdir-components.sh'
|
||||
exec cat $WORK/podinfo-component-header.sh $WORK/podinfo-component-body.cue $WORK/eof-trailer.sh
|
||||
stdin stdout
|
||||
exec bash -xeuo pipefail
|
||||
|
||||
# Combine and execute the multiline platform registration header/body/trailer files.
|
||||
exec cat $WORK/register-components-header.sh $WORK/register-components-body.cue $WORK/eof-trailer.sh
|
||||
stdin stdout
|
||||
exec bash -xeuo pipefail
|
||||
|
||||
# Render and capture output
|
||||
# NOTE: The [net] condition will test whether external network access is available
|
||||
[net] exec bash -c 'bash -euo pipefail $WORK/render.sh 2>&1'
|
||||
[net] stdin stdout
|
||||
exec $WORK/update.sh $WORK/register-components-output.txt
|
||||
|
||||
# Git init and commit
|
||||
exec bash -c 'bash -euo pipefail $WORK/git-init.sh'
|
||||
|
||||
# Combine and execute the mixin component header/body/trailer files
|
||||
exec cat $WORK/mixin-component-header.sh $WORK/mixin-component-body.cue $WORK/eof-trailer.sh
|
||||
stdin stdout
|
||||
exec bash -xeuo pipefail
|
||||
|
||||
# Import CRDs with Timoni
|
||||
exec bash -c 'bash -euo pipefail $WORK/import-crds.sh 2>&1'
|
||||
stdin stdout
|
||||
exec $WORK/update.sh $WORK/timoni-vendor.txt
|
||||
|
||||
# Render platform
|
||||
[net] exec bash -c 'bash -euo pipefail $WORK/render.sh 2>&1'
|
||||
|
||||
# Git diff and capture output
|
||||
exec bash -c 'bash -euo pipefail $WORK/git-diff.sh 2>&1'
|
||||
stdin stdout
|
||||
exec $WORK/update.sh $WORK/git.diff
|
||||
|
||||
# Clean up the tutorial directory and tmp $HOME directory
|
||||
cd $WORK
|
||||
exec rm -rf holos-cue-tutorial
|
||||
exec rm -rf $HOME
|
||||
|
||||
-- update.sh --
|
||||
#! /bin/bash
|
||||
set -euo pipefail
|
||||
[[ -s "$1" ]] && [[ -z "${HOLOS_UPDATE_SCRIPTS:-}" ]] && exit 0
|
||||
cat > "$1"
|
||||
-- mkdir-and-init.sh --
|
||||
mkdir holos-cue-tutorial && cd holos-cue-tutorial
|
||||
holos init platform v1alpha5
|
||||
-- mkdir-components.sh --
|
||||
mkdir -p components/podinfo
|
||||
-- import-crds.sh --
|
||||
timoni mod vendor crds -f https://raw.githubusercontent.com/external-secrets/external-secrets/v0.10.5/deploy/crds/bundle.yaml
|
||||
-- podinfo-component-header.sh --
|
||||
cat <<EOF > components/podinfo/podinfo.cue
|
||||
-- podinfo-component-body.cue --
|
||||
package holos
|
||||
|
||||
// export the component build plan to holos
|
||||
holos: Component.BuildPlan
|
||||
|
||||
// Component is a Helm chart
|
||||
Component: #Helm & {
|
||||
Name: "podinfo"
|
||||
Namespace: "default"
|
||||
// Add metadata.namespace to all resources with kustomize.
|
||||
KustomizeConfig: Kustomization: namespace: Namespace
|
||||
Chart: {
|
||||
version: "6.6.2"
|
||||
repository: {
|
||||
name: "podinfo"
|
||||
url: "https://stefanprodan.github.io/podinfo"
|
||||
}
|
||||
}
|
||||
}
|
||||
-- eof-trailer.sh --
|
||||
EOF
|
||||
-- register-components-header.sh --
|
||||
cat <<EOF > platform/podinfo.cue
|
||||
-- register-components-body.cue --
|
||||
package holos
|
||||
|
||||
Platform: Components: podinfo: {
|
||||
name: "podinfo"
|
||||
path: "components/podinfo"
|
||||
}
|
||||
-- render.sh --
|
||||
holos render platform
|
||||
-- git-init.sh --
|
||||
git init . && git add . && git commit -m initial
|
||||
-- mixin-component-header.sh --
|
||||
cat <<EOF > components/podinfo/mixins.cue
|
||||
-- mixin-component-body.cue --
|
||||
package holos
|
||||
|
||||
// Component fields are unified with podinfo.cue
|
||||
Component: {
|
||||
// Concrete values are defined in podinfo.cue
|
||||
Name: string
|
||||
Namespace: string
|
||||
|
||||
// Resources represents mix-in resources organized as a struct.
|
||||
Resources: ExternalSecret: (Name): {
|
||||
// Name is consistent with the component name.
|
||||
metadata: name: Name
|
||||
// Namespace is consistent with the component namespace.
|
||||
metadata: namespace: Namespace
|
||||
spec: {
|
||||
// Ensure the target secret name is consistent.
|
||||
target: name: metadata.name
|
||||
// Ensure the name in the SecretStore is consistent.
|
||||
dataFrom: [{extract: {key: metadata.name}}]
|
||||
refreshInterval: "30s"
|
||||
secretStoreRef: kind: "SecretStore"
|
||||
secretStoreRef: name: "default"
|
||||
}
|
||||
}
|
||||
}
|
||||
-- git-diff.sh --
|
||||
git diff deploy
|
||||
-- git.diff --
|
||||
diff --git a/deploy/components/podinfo/podinfo.gen.yaml b/deploy/components/podinfo/podinfo.gen.yaml
|
||||
index 6e4aec0..f79e9d0 100644
|
||||
--- a/deploy/components/podinfo/podinfo.gen.yaml
|
||||
+++ b/deploy/components/podinfo/podinfo.gen.yaml
|
||||
@@ -112,3 +112,19 @@ spec:
|
||||
volumes:
|
||||
- emptyDir: {}
|
||||
name: data
|
||||
+---
|
||||
+apiVersion: external-secrets.io/v1beta1
|
||||
+kind: ExternalSecret
|
||||
+metadata:
|
||||
+ name: podinfo
|
||||
+ namespace: default
|
||||
+spec:
|
||||
+ dataFrom:
|
||||
+ - extract:
|
||||
+ key: podinfo
|
||||
+ refreshInterval: 30s
|
||||
+ secretStoreRef:
|
||||
+ kind: SecretStore
|
||||
+ name: default
|
||||
+ target:
|
||||
+ name: podinfo
|
||||
1
doc/md/tutorial/_cue/script-01-holos-version/command.sh
Normal file
1
doc/md/tutorial/_cue/script-01-holos-version/command.sh
Normal file
@@ -0,0 +1 @@
|
||||
holos --version
|
||||
1
doc/md/tutorial/_cue/script-01-holos-version/output.txt
Normal file
1
doc/md/tutorial/_cue/script-01-holos-version/output.txt
Normal file
@@ -0,0 +1 @@
|
||||
0.103.0
|
||||
1
doc/md/tutorial/_cue/script-02-cue/eof-trailer.sh
Normal file
1
doc/md/tutorial/_cue/script-02-cue/eof-trailer.sh
Normal file
@@ -0,0 +1 @@
|
||||
EOF
|
||||
1
doc/md/tutorial/_cue/script-02-cue/git-diff.sh
Normal file
1
doc/md/tutorial/_cue/script-02-cue/git-diff.sh
Normal file
@@ -0,0 +1 @@
|
||||
git diff deploy
|
||||
1
doc/md/tutorial/_cue/script-02-cue/git-init.sh
Normal file
1
doc/md/tutorial/_cue/script-02-cue/git-init.sh
Normal file
@@ -0,0 +1 @@
|
||||
git init . && git add . && git commit -m initial
|
||||
24
doc/md/tutorial/_cue/script-02-cue/git.diff
Normal file
24
doc/md/tutorial/_cue/script-02-cue/git.diff
Normal file
@@ -0,0 +1,24 @@
|
||||
diff --git a/deploy/components/podinfo/podinfo.gen.yaml b/deploy/components/podinfo/podinfo.gen.yaml
|
||||
index 6e4aec0..f79e9d0 100644
|
||||
--- a/deploy/components/podinfo/podinfo.gen.yaml
|
||||
+++ b/deploy/components/podinfo/podinfo.gen.yaml
|
||||
@@ -112,3 +112,19 @@ spec:
|
||||
volumes:
|
||||
- emptyDir: {}
|
||||
name: data
|
||||
+---
|
||||
+apiVersion: external-secrets.io/v1beta1
|
||||
+kind: ExternalSecret
|
||||
+metadata:
|
||||
+ name: podinfo
|
||||
+ namespace: default
|
||||
+spec:
|
||||
+ dataFrom:
|
||||
+ - extract:
|
||||
+ key: podinfo
|
||||
+ refreshInterval: 30s
|
||||
+ secretStoreRef:
|
||||
+ kind: SecretStore
|
||||
+ name: default
|
||||
+ target:
|
||||
+ name: podinfo
|
||||
1
doc/md/tutorial/_cue/script-02-cue/import-crds.sh
Normal file
1
doc/md/tutorial/_cue/script-02-cue/import-crds.sh
Normal file
@@ -0,0 +1 @@
|
||||
timoni mod vendor crds -f https://raw.githubusercontent.com/external-secrets/external-secrets/v0.10.5/deploy/crds/bundle.yaml
|
||||
25
doc/md/tutorial/_cue/script-02-cue/mixin-component-body.cue
Normal file
25
doc/md/tutorial/_cue/script-02-cue/mixin-component-body.cue
Normal file
@@ -0,0 +1,25 @@
|
||||
package holos
|
||||
|
||||
// Component fields are unified with podinfo.cue
|
||||
Component: {
|
||||
// Concrete values are defined in podinfo.cue
|
||||
Name: string
|
||||
Namespace: string
|
||||
|
||||
// Resources represents mix-in resources organized as a struct.
|
||||
Resources: ExternalSecret: (Name): {
|
||||
// Name is consistent with the component name.
|
||||
metadata: name: Name
|
||||
// Namespace is consistent with the component namespace.
|
||||
metadata: namespace: Namespace
|
||||
spec: {
|
||||
// Ensure the target secret name is consistent.
|
||||
target: name: metadata.name
|
||||
// Ensure the name in the SecretStore is consistent.
|
||||
dataFrom: [{extract: {key: metadata.name}}]
|
||||
refreshInterval: "30s"
|
||||
secretStoreRef: kind: "SecretStore"
|
||||
secretStoreRef: name: "default"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
cat <<EOF > components/podinfo/mixins.cue
|
||||
2
doc/md/tutorial/_cue/script-02-cue/mkdir-and-init.sh
Normal file
2
doc/md/tutorial/_cue/script-02-cue/mkdir-and-init.sh
Normal file
@@ -0,0 +1,2 @@
|
||||
mkdir holos-cue-tutorial && cd holos-cue-tutorial
|
||||
holos init platform v1alpha5
|
||||
1
doc/md/tutorial/_cue/script-02-cue/mkdir-components.sh
Normal file
1
doc/md/tutorial/_cue/script-02-cue/mkdir-components.sh
Normal file
@@ -0,0 +1 @@
|
||||
mkdir -p components/podinfo
|
||||
@@ -0,0 +1,19 @@
|
||||
package holos
|
||||
|
||||
// export the component build plan to holos
|
||||
holos: Component.BuildPlan
|
||||
|
||||
// Component is a Helm chart
|
||||
Component: #Helm & {
|
||||
Name: "podinfo"
|
||||
Namespace: "default"
|
||||
// Add metadata.namespace to all resources with kustomize.
|
||||
KustomizeConfig: Kustomization: namespace: Namespace
|
||||
Chart: {
|
||||
version: "6.6.2"
|
||||
repository: {
|
||||
name: "podinfo"
|
||||
url: "https://stefanprodan.github.io/podinfo"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
cat <<EOF > components/podinfo/podinfo.cue
|
||||
@@ -0,0 +1,6 @@
|
||||
package holos
|
||||
|
||||
Platform: Components: podinfo: {
|
||||
name: "podinfo"
|
||||
path: "components/podinfo"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
cat <<EOF > platform/podinfo.cue
|
||||
@@ -0,0 +1,3 @@
|
||||
cached podinfo 6.6.2
|
||||
rendered podinfo in 1.938665041s
|
||||
rendered platform in 1.938759417s
|
||||
1
doc/md/tutorial/_cue/script-02-cue/render.sh
Normal file
1
doc/md/tutorial/_cue/script-02-cue/render.sh
Normal file
@@ -0,0 +1 @@
|
||||
holos render platform
|
||||
17
doc/md/tutorial/_cue/script-02-cue/timoni-vendor.txt
Normal file
17
doc/md/tutorial/_cue/script-02-cue/timoni-vendor.txt
Normal file
@@ -0,0 +1,17 @@
|
||||
3:20PM INF schemas vendored: external-secrets.io/clusterexternalsecret/v1beta1
|
||||
3:20PM INF schemas vendored: external-secrets.io/clustersecretstore/v1alpha1
|
||||
3:20PM INF schemas vendored: external-secrets.io/clustersecretstore/v1beta1
|
||||
3:20PM INF schemas vendored: external-secrets.io/externalsecret/v1alpha1
|
||||
3:20PM INF schemas vendored: external-secrets.io/externalsecret/v1beta1
|
||||
3:20PM INF schemas vendored: external-secrets.io/pushsecret/v1alpha1
|
||||
3:20PM INF schemas vendored: external-secrets.io/secretstore/v1alpha1
|
||||
3:20PM INF schemas vendored: external-secrets.io/secretstore/v1beta1
|
||||
3:20PM INF schemas vendored: generators.external-secrets.io/acraccesstoken/v1alpha1
|
||||
3:20PM INF schemas vendored: generators.external-secrets.io/ecrauthorizationtoken/v1alpha1
|
||||
3:20PM INF schemas vendored: generators.external-secrets.io/fake/v1alpha1
|
||||
3:20PM INF schemas vendored: generators.external-secrets.io/gcraccesstoken/v1alpha1
|
||||
3:20PM INF schemas vendored: generators.external-secrets.io/githubaccesstoken/v1alpha1
|
||||
3:20PM INF schemas vendored: generators.external-secrets.io/password/v1alpha1
|
||||
3:20PM INF schemas vendored: generators.external-secrets.io/uuid/v1alpha1
|
||||
3:20PM INF schemas vendored: generators.external-secrets.io/vaultdynamicsecret/v1alpha1
|
||||
3:20PM INF schemas vendored: generators.external-secrets.io/webhook/v1alpha1
|
||||
4
doc/md/tutorial/_cue/script-02-cue/update.sh
Executable file
4
doc/md/tutorial/_cue/script-02-cue/update.sh
Executable file
@@ -0,0 +1,4 @@
|
||||
#! /bin/bash
|
||||
set -euo pipefail
|
||||
[[ -s "$1" ]] && [[ -z "${HOLOS_UPDATE_SCRIPTS:-}" ]] && exit 0
|
||||
cat > "$1"
|
||||
@@ -0,0 +1,7 @@
|
||||
exec bash -c 'bash -euo pipefail $WORK/command.sh 2>&1'
|
||||
cmp stdout $WORK/output.txt
|
||||
|
||||
-- command.sh --
|
||||
holos --version
|
||||
-- output.txt --
|
||||
0.103.0
|
||||
126
doc/md/tutorial/_hello-holos/examples/02-hello-holos.txt
Normal file
126
doc/md/tutorial/_hello-holos/examples/02-hello-holos.txt
Normal file
@@ -0,0 +1,126 @@
|
||||
# Set $HOME because:
|
||||
# - Helm uses it for temporary files
|
||||
# - Git requires it for setting author name/email globally
|
||||
env HOME=$WORK/.tmp
|
||||
chmod 0755 $WORK/update.sh
|
||||
|
||||
# Configure git author for testscript execution
|
||||
exec git config --global user.name 'Holos Docs'
|
||||
exec git config --global user.email 'hello@holos.run'
|
||||
exec git config --global init.defaultBranch main
|
||||
|
||||
# Remove the tutorial directory if it already exists
|
||||
exec rm -rf holos-tutorial
|
||||
|
||||
# Create and change to the tutorial directory, and then initialize the Holos platform
|
||||
exec bash -c 'bash -euo pipefail $WORK/mkdir-and-init.sh'
|
||||
cd holos-tutorial
|
||||
|
||||
# Create the components directory
|
||||
exec bash -c 'bash -euo pipefail $WORK/mkdir-components.sh'
|
||||
|
||||
# Combine and execute the multiline podinfo component header/body/trailer files
|
||||
exec cat $WORK/podinfo-component-header.sh ../podinfo-component-body.cue ../eof-trailer.sh
|
||||
stdin stdout
|
||||
exec bash -xeuo pipefail
|
||||
|
||||
# Combine and execute the multiline platform registration header/body/trailer files
|
||||
exec cat $WORK/register-podinfo-header.sh ../register-podinfo-body.cue ../eof-trailer.sh
|
||||
stdin stdout
|
||||
exec bash -xeuo pipefail
|
||||
|
||||
# Render the platform, capture stdout, and use update.sh to gate whether the
|
||||
# output file should be updated.
|
||||
#
|
||||
# NOTE: The [net] condition will test whether external network access is available
|
||||
[net] exec bash -c 'bash -euo pipefail $WORK/render.sh 2>&1'
|
||||
[net] stdin stdout
|
||||
exec $WORK/update.sh $WORK/register-components-output.txt
|
||||
|
||||
# Generate and update the tree of the tutorial directory (omitting the cue.mod directory)
|
||||
exec bash -c 'bash -euo pipefail $WORK/tree.sh'
|
||||
stdin stdout
|
||||
exec $WORK/update.sh $WORK/tree.txt
|
||||
|
||||
# Split the rendered manifest into two separate files to display separately
|
||||
exec bash -c 'bash -euo pipefail $WORK/split-rendered-manifest.sh $WORK/holos-tutorial/deploy/components/podinfo/podinfo.gen.yaml $WORK'
|
||||
|
||||
# Grep for the Hello Holos message and write the output file
|
||||
exec bash -c 'bash -euo pipefail $WORK/grep-for-message.sh'
|
||||
stdin stdout
|
||||
exec $WORK/update.sh $WORK/grepped-output.txt
|
||||
|
||||
# Clean up the tutorial directory and tmp $HOME directory
|
||||
cd $WORK
|
||||
exec rm -rf holos-tutorial
|
||||
exec rm -rf $HOME
|
||||
|
||||
-- update.sh --
|
||||
#! /bin/bash
|
||||
set -euo pipefail
|
||||
[[ -s "$1" ]] && [[ -z "${HOLOS_UPDATE_SCRIPTS:-}" ]] && exit 0
|
||||
cat > "$1"
|
||||
-- mkdir-and-init.sh --
|
||||
mkdir holos-tutorial && cd holos-tutorial
|
||||
holos init platform v1alpha5
|
||||
-- tree.sh --
|
||||
tree -L 3 -I cue.mod .
|
||||
-- mkdir-components.sh --
|
||||
mkdir -p components/podinfo
|
||||
-- podinfo-component-header.sh --
|
||||
cat <<EOF > components/podinfo/podinfo.cue
|
||||
-- podinfo-component-body.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-trailer.sh --
|
||||
EOF
|
||||
-- register-podinfo-header.sh --
|
||||
cat <<EOF > platform/podinfo.cue
|
||||
-- register-podinfo-body.cue --
|
||||
package holos
|
||||
|
||||
Platform: Components: podinfo: {
|
||||
name: "podinfo"
|
||||
path: "components/podinfo"
|
||||
// Inject a value into the component.
|
||||
parameters: greeting: "Hello Holos!"
|
||||
}
|
||||
-- render.sh --
|
||||
holos render platform
|
||||
-- register-components-output.txt --
|
||||
cached podinfo 6.6.2
|
||||
rendered podinfo in 1.938665041s
|
||||
rendered platform in 1.938759417s
|
||||
-- podinfo-rendered-path.sh --
|
||||
deploy/components/podinfo/podinfo.gen.yaml
|
||||
-- split-rendered-manifest.sh --
|
||||
awk 'BEGIN {RS="---"} NR==1 {print > "service.yaml"} NR==2 {print > "deployment.yaml"}' $1
|
||||
mv service.yaml $2/rendered-service.yaml
|
||||
mv deployment.yaml $2/rendered-deployment.yaml
|
||||
-- grep-for-message.sh --
|
||||
grep -B2 Hello deploy/components/podinfo/podinfo.gen.yaml
|
||||
-- grepped-output.txt --
|
||||
env:
|
||||
- name: PODINFO_UI_MESSAGE
|
||||
value: Hello Holos!
|
||||
@@ -0,0 +1 @@
|
||||
holos --version
|
||||
@@ -0,0 +1 @@
|
||||
0.103.0
|
||||
@@ -0,0 +1 @@
|
||||
EOF
|
||||
@@ -0,0 +1 @@
|
||||
grep -B2 Hello deploy/components/podinfo/podinfo.gen.yaml
|
||||
@@ -0,0 +1,3 @@
|
||||
env:
|
||||
- name: PODINFO_UI_MESSAGE
|
||||
value: Hello Holos!
|
||||
@@ -0,0 +1,2 @@
|
||||
mkdir holos-tutorial && cd holos-tutorial
|
||||
holos init platform v1alpha5
|
||||
@@ -0,0 +1 @@
|
||||
mkdir -p components/podinfo
|
||||
@@ -0,0 +1,23 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
cat <<EOF > components/podinfo/podinfo.cue
|
||||
@@ -0,0 +1 @@
|
||||
deploy/components/podinfo/podinfo.gen.yaml
|
||||
@@ -0,0 +1,2 @@
|
||||
rendered podinfo in 544.501875ms
|
||||
rendered platform in 544.608125ms
|
||||
@@ -0,0 +1,8 @@
|
||||
package holos
|
||||
|
||||
Platform: Components: podinfo: {
|
||||
name: "podinfo"
|
||||
path: "components/podinfo"
|
||||
// Inject a value into the component.
|
||||
parameters: greeting: "Hello Holos!"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
cat <<EOF > platform/podinfo.cue
|
||||
@@ -0,0 +1 @@
|
||||
holos render platform
|
||||
@@ -0,0 +1,93 @@
|
||||
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
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:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/name: podinfo
|
||||
strategy:
|
||||
rollingUpdate:
|
||||
maxUnavailable: 1
|
||||
type: RollingUpdate
|
||||
template:
|
||||
metadata:
|
||||
annotations:
|
||||
prometheus.io/port: "9898"
|
||||
prometheus.io/scrape: "true"
|
||||
labels:
|
||||
app.kubernetes.io/name: podinfo
|
||||
spec:
|
||||
containers:
|
||||
- command:
|
||||
- ./podinfo
|
||||
- --port=9898
|
||||
- --cert-path=/data/cert
|
||||
- --port-metrics=9797
|
||||
- --grpc-port=9999
|
||||
- --grpc-service-name=podinfo
|
||||
- --level=info
|
||||
- --random-delay=false
|
||||
- --random-error=false
|
||||
env:
|
||||
- name: PODINFO_UI_MESSAGE
|
||||
value: Hello Holos!
|
||||
- name: PODINFO_UI_COLOR
|
||||
value: '#34577c'
|
||||
image: ghcr.io/stefanprodan/podinfo:6.6.2
|
||||
imagePullPolicy: IfNotPresent
|
||||
livenessProbe:
|
||||
exec:
|
||||
command:
|
||||
- podcli
|
||||
- check
|
||||
- http
|
||||
- localhost:9898/healthz
|
||||
failureThreshold: 3
|
||||
initialDelaySeconds: 1
|
||||
periodSeconds: 10
|
||||
successThreshold: 1
|
||||
timeoutSeconds: 5
|
||||
name: podinfo
|
||||
ports:
|
||||
- containerPort: 9898
|
||||
name: http
|
||||
protocol: TCP
|
||||
- containerPort: 9797
|
||||
name: http-metrics
|
||||
protocol: TCP
|
||||
- containerPort: 9999
|
||||
name: grpc
|
||||
protocol: TCP
|
||||
readinessProbe:
|
||||
exec:
|
||||
command:
|
||||
- podcli
|
||||
- check
|
||||
- http
|
||||
- localhost:9898/readyz
|
||||
failureThreshold: 3
|
||||
initialDelaySeconds: 1
|
||||
periodSeconds: 10
|
||||
successThreshold: 1
|
||||
timeoutSeconds: 5
|
||||
resources:
|
||||
limits: null
|
||||
requests:
|
||||
cpu: 1m
|
||||
memory: 16Mi
|
||||
volumeMounts:
|
||||
- mountPath: /data
|
||||
name: data
|
||||
terminationGracePeriodSeconds: 30
|
||||
volumes:
|
||||
- emptyDir: {}
|
||||
name: data
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
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
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
awk 'BEGIN {RS="---"} NR==1 {print > "service.yaml"} NR==2 {print > "deployment.yaml"}' $1
|
||||
mv service.yaml $2/rendered-service.yaml
|
||||
mv deployment.yaml $2/rendered-deployment.yaml
|
||||
@@ -0,0 +1 @@
|
||||
tree -L 3 -I cue.mod .
|
||||
17
doc/md/tutorial/_hello-holos/script-02-hello-holos/tree.txt
Normal file
17
doc/md/tutorial/_hello-holos/script-02-hello-holos/tree.txt
Normal file
@@ -0,0 +1,17 @@
|
||||
.
|
||||
|-- components
|
||||
| `-- podinfo
|
||||
| |-- podinfo.cue
|
||||
| `-- vendor
|
||||
|-- deploy
|
||||
| `-- components
|
||||
| `-- podinfo
|
||||
|-- platform
|
||||
| |-- platform.gen.cue
|
||||
| `-- podinfo.cue
|
||||
|-- platform.metadata.json
|
||||
|-- resources.cue
|
||||
|-- schema.cue
|
||||
`-- tags.cue
|
||||
|
||||
8 directories, 7 files
|
||||
4
doc/md/tutorial/_hello-holos/script-02-hello-holos/update.sh
Executable file
4
doc/md/tutorial/_hello-holos/script-02-hello-holos/update.sh
Executable file
@@ -0,0 +1,4 @@
|
||||
#! /bin/bash
|
||||
set -euo pipefail
|
||||
[[ -s "$1" ]] && [[ -z "${HOLOS_UPDATE_SCRIPTS:-}" ]] && exit 0
|
||||
cat > "$1"
|
||||
@@ -0,0 +1,7 @@
|
||||
exec bash -c 'bash -euo pipefail $WORK/command.sh 2>&1'
|
||||
cmp stdout $WORK/output.txt
|
||||
|
||||
-- command.sh --
|
||||
holos --version
|
||||
-- output.txt --
|
||||
0.103.0
|
||||
374
doc/md/tutorial/_helm-values/examples/02-helm-values.txt
Normal file
374
doc/md/tutorial/_helm-values/examples/02-helm-values.txt
Normal file
@@ -0,0 +1,374 @@
|
||||
# Set $HOME because:
|
||||
# - Helm uses it for temporary files
|
||||
# - Git requires it for setting author name/email globally
|
||||
env HOME=$WORK/.tmp
|
||||
chmod 0755 $WORK/update.sh
|
||||
|
||||
# Configure git author for testscript execution
|
||||
exec git config --global user.name 'Holos Docs'
|
||||
exec git config --global user.email 'hello@holos.run'
|
||||
exec git config --global init.defaultBranch main
|
||||
|
||||
# Remove the tutorial directory if it already exists
|
||||
exec rm -rf holos-helm-values-tutorial
|
||||
|
||||
# Create and change to the tutorial directory, and then initialize the Holos platform
|
||||
exec bash -c 'bash -euo pipefail mkdir-and-init.sh'
|
||||
cd holos-helm-values-tutorial
|
||||
|
||||
# Git init and create the component directories
|
||||
exec bash -c 'bash -euo pipefail $WORK/git-init.sh'
|
||||
exec bash -c 'bash -euo pipefail $WORK/mkdir-components.sh'
|
||||
|
||||
# Combine and execute the multiline prometheus/blackbox component header/body/trailer files
|
||||
exec cat $WORK/prometheus-component-header.sh ../prometheus-component-body.cue ../eof-trailer.sh
|
||||
stdin stdout
|
||||
exec bash -xeuo pipefail
|
||||
exec cat $WORK/blackbox-component-header.sh ../blackbox-component-body.cue ../eof-trailer.sh
|
||||
stdin stdout
|
||||
exec bash -xeuo pipefail
|
||||
|
||||
# Combine and execute the multiline platform registration header/body/trailer files.
|
||||
exec cat $WORK/register-components-header.sh ../register-components-body.cue ../eof-trailer.sh
|
||||
stdin stdout
|
||||
exec bash -xeuo pipefail
|
||||
|
||||
# Render the platform, capture stdout, and use update.sh to gate whether the
|
||||
# output file should be updated.
|
||||
#
|
||||
# NOTE: The [net] condition will test whether external network access is available
|
||||
[net] exec bash -c 'bash -euo pipefail $WORK/render.sh 2>&1'
|
||||
[net] stdin stdout
|
||||
exec $WORK/update.sh $WORK/register-components-output.txt
|
||||
|
||||
# Commit and conditionally update the output file
|
||||
exec bash -c 'bash -euo pipefail $WORK/register-components-git-commit.sh'
|
||||
stdin stdout
|
||||
exec $WORK/update.sh $WORK/register-components-git-commit-output.txt
|
||||
|
||||
# Import values
|
||||
exec bash -c 'bash -euo pipefail $WORK/import-prometheus-values.sh'
|
||||
exec bash -c 'bash -euo pipefail $WORK/import-blackbox-values.sh'
|
||||
|
||||
# Render, update the output file, commit, and update the commit output file.
|
||||
[net] exec bash -c 'bash -euo pipefail $WORK/render.sh 2>&1'
|
||||
[net] stdin stdout
|
||||
exec $WORK/update.sh $WORK/import-values-render-output.txt
|
||||
exec bash -c 'bash -euo pipefail $WORK/import-values-git-commit.sh'
|
||||
stdin stdout
|
||||
exec $WORK/update.sh $WORK/import-values-git-output.txt
|
||||
|
||||
# Create the common configuration path
|
||||
exec bash -c 'bash -euo pipefail $WORK/mkdir-common-config.sh'
|
||||
|
||||
# Combine and execute the common configuration header/body/trailer to write the cue file.
|
||||
exec cat $WORK/blackbox-common-config-header.sh ../blackbox-common-config-body.cue ../eof-trailer.sh
|
||||
stdin stdout
|
||||
exec bash -xeuo pipefail
|
||||
|
||||
# Git commit blackbox common config
|
||||
exec bash -c 'bash -euo pipefail $WORK/blackbox-common-config-git-commit.sh'
|
||||
stdin stdout
|
||||
exec $WORK/update.sh $WORK/blackbox-common-config-git-output.txt
|
||||
|
||||
# Patch the common config values file and write to output file.
|
||||
#
|
||||
# NOTE: Using a symlink here because the patch script references values.patch
|
||||
# within the same directory, but it actually lives one directory up in the
|
||||
# testscript $WORK dir.
|
||||
exec ln -s $WORK/values.patch values.patch
|
||||
exec bash -c 'bash -euo pipefail $WORK/common-config-patch.sh'
|
||||
stdin stdout
|
||||
exec $WORK/update.sh $WORK/common-config-patch.txt
|
||||
|
||||
# Remove patch and commit changes
|
||||
exec bash -c 'bash -euo pipefail $WORK/common-config-rm.sh'
|
||||
exec bash -c 'bash -euo pipefail $WORK/common-config-git.sh'
|
||||
stdin stdout
|
||||
exec $WORK/update.sh $WORK/common-config-git-output.txt
|
||||
|
||||
# Final render and update of output file.
|
||||
[net] exec bash -c 'bash -euo pipefail $WORK/render.sh 2>&1'
|
||||
[net] stdin stdout
|
||||
exec $WORK/update.sh $WORK/reviewing-changes-git-output.txt
|
||||
|
||||
# Git diff and write to output file.
|
||||
exec bash -c 'bash -euo pipefail $WORK/git-diff.sh'
|
||||
stdin stdout
|
||||
exec $WORK/update.sh $WORK/git.diff
|
||||
|
||||
# Final commit and write to output file
|
||||
exec bash -c 'bash -euo pipefail $WORK/reviewing-changes-git-commit.sh'
|
||||
stdin stdout
|
||||
exec $WORK/update.sh $WORK/reviewing-changes-git-output.txt
|
||||
|
||||
# Clean up the tutorial directory and tmp $HOME directory
|
||||
cd $WORK
|
||||
exec rm -rf holos-helm-values-tutorial
|
||||
exec rm -rf $HOME
|
||||
|
||||
-- update.sh --
|
||||
#! /bin/bash
|
||||
set -euo pipefail
|
||||
[[ -s "$1" ]] && [[ -z "${HOLOS_UPDATE_SCRIPTS:-}" ]] && exit 0
|
||||
cat > "$1"
|
||||
-- mkdir-and-init.sh --
|
||||
mkdir holos-helm-values-tutorial
|
||||
cd holos-helm-values-tutorial
|
||||
holos init platform v1alpha5
|
||||
-- git-init.sh --
|
||||
git init . && git add . && git commit -m "initial commit"
|
||||
-- mkdir-components.sh --
|
||||
mkdir -p components/prometheus components/blackbox
|
||||
-- prometheus-component-header.sh --
|
||||
cat <<EOF > components/prometheus/prometheus.cue
|
||||
-- prometheus-component-body.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"
|
||||
}
|
||||
}
|
||||
}
|
||||
-- eof-trailer.sh --
|
||||
EOF
|
||||
-- blackbox-component-header.sh --
|
||||
cat <<EOF > components/blackbox/blackbox.cue
|
||||
-- blackbox-component-body.cue --
|
||||
package holos
|
||||
|
||||
// Produce a helm chart build plan.
|
||||
holos: Helm.BuildPlan
|
||||
|
||||
Helm: #Helm & {
|
||||
Chart: {
|
||||
name: "prometheus-blackbox-exporter"
|
||||
version: "9.0.1"
|
||||
repository: {
|
||||
name: "prometheus-community"
|
||||
url: "https://prometheus-community.github.io/helm-charts"
|
||||
}
|
||||
}
|
||||
}
|
||||
-- register-components-header.sh --
|
||||
cat <<EOF > platform/prometheus.cue
|
||||
-- register-components-body.cue --
|
||||
package holos
|
||||
|
||||
Platform: Components: {
|
||||
prometheus: {
|
||||
name: "prometheus"
|
||||
path: "components/prometheus"
|
||||
}
|
||||
blackbox: {
|
||||
name: "blackbox"
|
||||
path: "components/blackbox"
|
||||
}
|
||||
}
|
||||
-- render.sh --
|
||||
holos render platform
|
||||
-- register-components-output.txt --
|
||||
cached prometheus-blackbox-exporter 9.0.1
|
||||
rendered blackbox in 3.825430417s
|
||||
cached prometheus 25.27.0
|
||||
rendered prometheus in 4.840089667s
|
||||
rendered platform in 4.840137792s
|
||||
-- register-components-git-commit.sh --
|
||||
git add . && git commit -m 'add blackbox and prometheus'
|
||||
-- register-components-git-commit-output.txt --
|
||||
[main b5df111] add blackbox and prometheus
|
||||
5 files changed, 1550 insertions(+)
|
||||
create mode 100644 components/blackbox/blackbox.cue
|
||||
create mode 100644 components/prometheus/prometheus.cue
|
||||
create mode 100644 deploy/components/blackbox/blackbox.gen.yaml
|
||||
create mode 100644 deploy/components/prometheus/prometheus.gen.yaml
|
||||
create mode 100644 platform/prometheus.cue
|
||||
-- import-prometheus-values.sh --
|
||||
holos cue import \
|
||||
--package holos \
|
||||
--path 'Helm: Values:' \
|
||||
--outfile components/prometheus/values.cue \
|
||||
components/prometheus/vendor/25.27.0/prometheus/values.yaml
|
||||
-- import-blackbox-values.sh --
|
||||
holos cue import \
|
||||
--package holos \
|
||||
--path 'Helm: Values:' \
|
||||
--outfile components/blackbox/values.cue \
|
||||
components/blackbox/vendor/9.0.1/prometheus-blackbox-exporter/values.yaml
|
||||
-- import-values-render-output.txt --
|
||||
rendered blackbox in 365.936792ms
|
||||
rendered prometheus in 371.855875ms
|
||||
rendered platform in 372.109916ms
|
||||
-- import-values-git-commit.sh --
|
||||
git add . && git commit -m 'import values'
|
||||
-- import-values-git-output.txt --
|
||||
[main 52e90ea] import values
|
||||
2 files changed, 1815 insertions(+)
|
||||
create mode 100644 components/blackbox/values.cue
|
||||
create mode 100644 components/prometheus/values.cue
|
||||
-- mkdir-common-config.sh --
|
||||
mkdir -p config/prometheus
|
||||
-- blackbox-common-config-header.sh --
|
||||
cat <<EOF > config/prometheus/blackbox.cue
|
||||
-- blackbox-common-config-body.cue --
|
||||
package prometheus
|
||||
|
||||
// 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
|
||||
}
|
||||
-- blackbox-common-config-git-commit.sh --
|
||||
git add . && git commit -m 'add blackbox configuration'
|
||||
-- blackbox-common-config-git-output.txt --
|
||||
[main 1adcd08] add blackbox configuration
|
||||
1 file changed, 15 insertions(+)
|
||||
create mode 100644 components/blackbox.cue
|
||||
-- common-config-patch.sh --
|
||||
patch -p1 < values.patch
|
||||
-- values.patch --
|
||||
--- a/components/blackbox/values.cue
|
||||
+++ b/components/blackbox/values.cue
|
||||
@@ -1,6 +1,11 @@
|
||||
package holos
|
||||
|
||||
+// Import common blackbox configuration
|
||||
+import "holos.example/config/prometheus"
|
||||
+
|
||||
Helm: Values: {
|
||||
+ fullnameOverride: prometheus.blackbox.host
|
||||
+
|
||||
global: {
|
||||
//# Global image registry to use if it needs to be overriden for some specific use cases (e.g local registries, custom images, ...)
|
||||
//#
|
||||
@@ -192,7 +197,7 @@ Helm: Values: {
|
||||
annotations: {}
|
||||
labels: {}
|
||||
type: "ClusterIP"
|
||||
- port: 9115
|
||||
+ port: prometheus.blackbox.port
|
||||
ipDualStack: {
|
||||
enabled: false
|
||||
ipFamilies: ["IPv6", "IPv4"]
|
||||
--- a/components/prometheus/values.cue
|
||||
+++ b/components/prometheus/values.cue
|
||||
@@ -1,5 +1,8 @@
|
||||
package holos
|
||||
|
||||
+// Import common blackbox configuration
|
||||
+import "holos.example/config/prometheus"
|
||||
+
|
||||
Helm: Values: {
|
||||
// yaml-language-server: $schema=values.schema.json
|
||||
// Default values for prometheus.
|
||||
@@ -1083,7 +1086,7 @@ Helm: Values: {
|
||||
target_label: "__param_target"
|
||||
}, {
|
||||
target_label: "__address__"
|
||||
- replacement: "blackbox"
|
||||
+ replacement: "\(prometheus.blackbox.host):\(prometheus.blackbox.port)"
|
||||
}, {
|
||||
source_labels: ["__param_target"]
|
||||
target_label: "instance"
|
||||
-- common-config-patch.txt --
|
||||
patching file 'components/blackbox/values.cue'
|
||||
patching file 'components/prometheus/values.cue'
|
||||
-- common-config-rm.sh --
|
||||
rm values.patch
|
||||
-- common-config-git.sh --
|
||||
git add . && git commit -m 'integrate blackbox and prometheus together'
|
||||
-- common-config-git-output.txt --
|
||||
[main 4221803] integrate blackbox and prometheus together
|
||||
2 files changed, 4 insertions(+), 2 deletions(-)
|
||||
-- reviewing-changes-render-output.txt --
|
||||
rendered blackbox in 374.810666ms
|
||||
rendered prometheus in 382.899334ms
|
||||
rendered platform in 383.270625ms
|
||||
-- git-diff.sh --
|
||||
git diff
|
||||
-- git.diff --
|
||||
diff --git a/deploy/components/blackbox/blackbox.gen.yaml b/deploy/components/blackbox/blackbox.gen.yaml
|
||||
index 3db20cd..5336f44 100644
|
||||
--- a/deploy/components/blackbox/blackbox.gen.yaml
|
||||
+++ b/deploy/components/blackbox/blackbox.gen.yaml
|
||||
@@ -7,7 +7,7 @@ metadata:
|
||||
app.kubernetes.io/name: prometheus-blackbox-exporter
|
||||
app.kubernetes.io/version: v0.25.0
|
||||
helm.sh/chart: prometheus-blackbox-exporter-9.0.1
|
||||
- name: prometheus-blackbox-exporter
|
||||
+ name: blackbox
|
||||
namespace: default
|
||||
---
|
||||
apiVersion: v1
|
||||
@@ -31,7 +31,7 @@ metadata:
|
||||
app.kubernetes.io/name: prometheus-blackbox-exporter
|
||||
app.kubernetes.io/version: v0.25.0
|
||||
helm.sh/chart: prometheus-blackbox-exporter-9.0.1
|
||||
- name: prometheus-blackbox-exporter
|
||||
+ name: blackbox
|
||||
namespace: default
|
||||
---
|
||||
apiVersion: v1
|
||||
@@ -43,7 +43,7 @@ metadata:
|
||||
app.kubernetes.io/name: prometheus-blackbox-exporter
|
||||
app.kubernetes.io/version: v0.25.0
|
||||
helm.sh/chart: prometheus-blackbox-exporter-9.0.1
|
||||
- name: prometheus-blackbox-exporter
|
||||
+ name: blackbox
|
||||
namespace: default
|
||||
spec:
|
||||
ports:
|
||||
@@ -65,7 +65,7 @@ metadata:
|
||||
app.kubernetes.io/name: prometheus-blackbox-exporter
|
||||
app.kubernetes.io/version: v0.25.0
|
||||
helm.sh/chart: prometheus-blackbox-exporter-9.0.1
|
||||
- name: prometheus-blackbox-exporter
|
||||
+ name: blackbox
|
||||
namespace: default
|
||||
spec:
|
||||
replicas: 1
|
||||
@@ -119,8 +119,8 @@ spec:
|
||||
name: config
|
||||
hostNetwork: false
|
||||
restartPolicy: Always
|
||||
- serviceAccountName: prometheus-blackbox-exporter
|
||||
+ serviceAccountName: blackbox
|
||||
volumes:
|
||||
- configMap:
|
||||
- name: prometheus-blackbox-exporter
|
||||
+ name: blackbox
|
||||
name: config
|
||||
diff --git a/deploy/components/prometheus/prometheus.gen.yaml b/deploy/components/prometheus/prometheus.gen.yaml
|
||||
index 9e02bce..ab638f0 100644
|
||||
--- a/deploy/components/prometheus/prometheus.gen.yaml
|
||||
+++ b/deploy/components/prometheus/prometheus.gen.yaml
|
||||
@@ -589,7 +589,7 @@ data:
|
||||
- source_labels:
|
||||
- __address__
|
||||
target_label: __param_target
|
||||
- - replacement: blackbox
|
||||
+ - replacement: blackbox:9115
|
||||
target_label: __address__
|
||||
- source_labels:
|
||||
- __param_target
|
||||
-- reviewing-changes-git-commit.sh --
|
||||
git add . && git commit -m 'render integrated blackbox and prometheus manifests'
|
||||
-- reviewing-changes-git-output.txt --
|
||||
[main 67efe0d] render integrated blackbox and prometheus manifests
|
||||
2 files changed, 7 insertions(+), 7 deletions(-)
|
||||
@@ -0,0 +1 @@
|
||||
holos --version
|
||||
@@ -0,0 +1 @@
|
||||
0.103.0
|
||||
@@ -0,0 +1,15 @@
|
||||
package prometheus
|
||||
|
||||
// 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
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
git add . && git commit -m 'add blackbox configuration'
|
||||
@@ -0,0 +1,3 @@
|
||||
[main 1adcd08] add blackbox configuration
|
||||
1 file changed, 15 insertions(+)
|
||||
create mode 100644 components/blackbox.cue
|
||||
@@ -0,0 +1 @@
|
||||
cat <<EOF > config/prometheus/blackbox.cue
|
||||
@@ -0,0 +1,15 @@
|
||||
package holos
|
||||
|
||||
// Produce a helm chart build plan.
|
||||
holos: Helm.BuildPlan
|
||||
|
||||
Helm: #Helm & {
|
||||
Chart: {
|
||||
name: "prometheus-blackbox-exporter"
|
||||
version: "9.0.1"
|
||||
repository: {
|
||||
name: "prometheus-community"
|
||||
url: "https://prometheus-community.github.io/helm-charts"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
cat <<EOF > components/blackbox/blackbox.cue
|
||||
@@ -0,0 +1,2 @@
|
||||
[main 4221803] integrate blackbox and prometheus together
|
||||
2 files changed, 4 insertions(+), 2 deletions(-)
|
||||
@@ -0,0 +1 @@
|
||||
git add . && git commit -m 'integrate blackbox and prometheus together'
|
||||
@@ -0,0 +1 @@
|
||||
patch -p1 < values.patch
|
||||
@@ -0,0 +1,2 @@
|
||||
patching file 'components/blackbox/values.cue'
|
||||
patching file 'components/prometheus/values.cue'
|
||||
@@ -0,0 +1 @@
|
||||
rm values.patch
|
||||
@@ -0,0 +1 @@
|
||||
EOF
|
||||
@@ -0,0 +1 @@
|
||||
git diff
|
||||
@@ -0,0 +1 @@
|
||||
git init . && git add . && git commit -m "initial commit"
|
||||
64
doc/md/tutorial/_helm-values/script-02-helm-values/git.diff
Normal file
64
doc/md/tutorial/_helm-values/script-02-helm-values/git.diff
Normal file
@@ -0,0 +1,64 @@
|
||||
diff --git a/deploy/components/blackbox/blackbox.gen.yaml b/deploy/components/blackbox/blackbox.gen.yaml
|
||||
index 3db20cd..5336f44 100644
|
||||
--- a/deploy/components/blackbox/blackbox.gen.yaml
|
||||
+++ b/deploy/components/blackbox/blackbox.gen.yaml
|
||||
@@ -7,7 +7,7 @@ metadata:
|
||||
app.kubernetes.io/name: prometheus-blackbox-exporter
|
||||
app.kubernetes.io/version: v0.25.0
|
||||
helm.sh/chart: prometheus-blackbox-exporter-9.0.1
|
||||
- name: prometheus-blackbox-exporter
|
||||
+ name: blackbox
|
||||
namespace: default
|
||||
---
|
||||
apiVersion: v1
|
||||
@@ -31,7 +31,7 @@ metadata:
|
||||
app.kubernetes.io/name: prometheus-blackbox-exporter
|
||||
app.kubernetes.io/version: v0.25.0
|
||||
helm.sh/chart: prometheus-blackbox-exporter-9.0.1
|
||||
- name: prometheus-blackbox-exporter
|
||||
+ name: blackbox
|
||||
namespace: default
|
||||
---
|
||||
apiVersion: v1
|
||||
@@ -43,7 +43,7 @@ metadata:
|
||||
app.kubernetes.io/name: prometheus-blackbox-exporter
|
||||
app.kubernetes.io/version: v0.25.0
|
||||
helm.sh/chart: prometheus-blackbox-exporter-9.0.1
|
||||
- name: prometheus-blackbox-exporter
|
||||
+ name: blackbox
|
||||
namespace: default
|
||||
spec:
|
||||
ports:
|
||||
@@ -65,7 +65,7 @@ metadata:
|
||||
app.kubernetes.io/name: prometheus-blackbox-exporter
|
||||
app.kubernetes.io/version: v0.25.0
|
||||
helm.sh/chart: prometheus-blackbox-exporter-9.0.1
|
||||
- name: prometheus-blackbox-exporter
|
||||
+ name: blackbox
|
||||
namespace: default
|
||||
spec:
|
||||
replicas: 1
|
||||
@@ -119,8 +119,8 @@ spec:
|
||||
name: config
|
||||
hostNetwork: false
|
||||
restartPolicy: Always
|
||||
- serviceAccountName: prometheus-blackbox-exporter
|
||||
+ serviceAccountName: blackbox
|
||||
volumes:
|
||||
- configMap:
|
||||
- name: prometheus-blackbox-exporter
|
||||
+ name: blackbox
|
||||
name: config
|
||||
diff --git a/deploy/components/prometheus/prometheus.gen.yaml b/deploy/components/prometheus/prometheus.gen.yaml
|
||||
index 9e02bce..ab638f0 100644
|
||||
--- a/deploy/components/prometheus/prometheus.gen.yaml
|
||||
+++ b/deploy/components/prometheus/prometheus.gen.yaml
|
||||
@@ -589,7 +589,7 @@ data:
|
||||
- source_labels:
|
||||
- __address__
|
||||
target_label: __param_target
|
||||
- - replacement: blackbox
|
||||
+ - replacement: blackbox:9115
|
||||
target_label: __address__
|
||||
- source_labels:
|
||||
- __param_target
|
||||
@@ -0,0 +1,5 @@
|
||||
holos cue import \
|
||||
--package holos \
|
||||
--path 'Helm: Values:' \
|
||||
--outfile components/blackbox/values.cue \
|
||||
components/blackbox/vendor/9.0.1/prometheus-blackbox-exporter/values.yaml
|
||||
@@ -0,0 +1,5 @@
|
||||
holos cue import \
|
||||
--package holos \
|
||||
--path 'Helm: Values:' \
|
||||
--outfile components/prometheus/values.cue \
|
||||
components/prometheus/vendor/25.27.0/prometheus/values.yaml
|
||||
@@ -0,0 +1 @@
|
||||
git add . && git commit -m 'import values'
|
||||
@@ -0,0 +1,4 @@
|
||||
[main 52e90ea] import values
|
||||
2 files changed, 1815 insertions(+)
|
||||
create mode 100644 components/blackbox/values.cue
|
||||
create mode 100644 components/prometheus/values.cue
|
||||
@@ -0,0 +1,3 @@
|
||||
rendered blackbox in 365.936792ms
|
||||
rendered prometheus in 371.855875ms
|
||||
rendered platform in 372.109916ms
|
||||
@@ -0,0 +1,3 @@
|
||||
mkdir holos-helm-values-tutorial
|
||||
cd holos-helm-values-tutorial
|
||||
holos init platform v1alpha5
|
||||
@@ -0,0 +1 @@
|
||||
mkdir -p config/prometheus
|
||||
@@ -0,0 +1 @@
|
||||
mkdir -p components/prometheus components/blackbox
|
||||
@@ -0,0 +1,15 @@
|
||||
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"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
cat <<EOF > components/prometheus/prometheus.cue
|
||||
@@ -0,0 +1,12 @@
|
||||
package holos
|
||||
|
||||
Platform: Components: {
|
||||
prometheus: {
|
||||
name: "prometheus"
|
||||
path: "components/prometheus"
|
||||
}
|
||||
blackbox: {
|
||||
name: "blackbox"
|
||||
path: "components/blackbox"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
[main b5df111] add blackbox and prometheus
|
||||
5 files changed, 1550 insertions(+)
|
||||
create mode 100644 components/blackbox/blackbox.cue
|
||||
create mode 100644 components/prometheus/prometheus.cue
|
||||
create mode 100644 deploy/components/blackbox/blackbox.gen.yaml
|
||||
create mode 100644 deploy/components/prometheus/prometheus.gen.yaml
|
||||
create mode 100644 platform/prometheus.cue
|
||||
@@ -0,0 +1 @@
|
||||
git add . && git commit -m 'add blackbox and prometheus'
|
||||
@@ -0,0 +1 @@
|
||||
cat <<EOF > platform/prometheus.cue
|
||||
@@ -0,0 +1,5 @@
|
||||
cached prometheus-blackbox-exporter 9.0.1
|
||||
rendered blackbox in 3.825430417s
|
||||
cached prometheus 25.27.0
|
||||
rendered prometheus in 4.840089667s
|
||||
rendered platform in 4.840137792s
|
||||
@@ -0,0 +1 @@
|
||||
holos render platform
|
||||
@@ -0,0 +1 @@
|
||||
git add . && git commit -m 'render integrated blackbox and prometheus manifests'
|
||||
@@ -0,0 +1,2 @@
|
||||
[main 67efe0d] render integrated blackbox and prometheus manifests
|
||||
2 files changed, 7 insertions(+), 7 deletions(-)
|
||||
@@ -0,0 +1,3 @@
|
||||
rendered blackbox in 374.810666ms
|
||||
rendered prometheus in 382.899334ms
|
||||
rendered platform in 383.270625ms
|
||||
4
doc/md/tutorial/_helm-values/script-02-helm-values/update.sh
Executable file
4
doc/md/tutorial/_helm-values/script-02-helm-values/update.sh
Executable file
@@ -0,0 +1,4 @@
|
||||
#! /bin/bash
|
||||
set -euo pipefail
|
||||
[[ -s "$1" ]] && [[ -z "${HOLOS_UPDATE_SCRIPTS:-}" ]] && exit 0
|
||||
cat > "$1"
|
||||
@@ -0,0 +1,43 @@
|
||||
--- a/components/blackbox/values.cue
|
||||
+++ b/components/blackbox/values.cue
|
||||
@@ -1,6 +1,11 @@
|
||||
package holos
|
||||
|
||||
+// Import common blackbox configuration
|
||||
+import "holos.example/config/prometheus"
|
||||
+
|
||||
Helm: Values: {
|
||||
+ fullnameOverride: prometheus.blackbox.host
|
||||
+
|
||||
global: {
|
||||
//# Global image registry to use if it needs to be overriden for some specific use cases (e.g local registries, custom images, ...)
|
||||
//#
|
||||
@@ -192,7 +197,7 @@ Helm: Values: {
|
||||
annotations: {}
|
||||
labels: {}
|
||||
type: "ClusterIP"
|
||||
- port: 9115
|
||||
+ port: prometheus.blackbox.port
|
||||
ipDualStack: {
|
||||
enabled: false
|
||||
ipFamilies: ["IPv6", "IPv4"]
|
||||
--- a/components/prometheus/values.cue
|
||||
+++ b/components/prometheus/values.cue
|
||||
@@ -1,5 +1,8 @@
|
||||
package holos
|
||||
|
||||
+// Import common blackbox configuration
|
||||
+import "holos.example/config/prometheus"
|
||||
+
|
||||
Helm: Values: {
|
||||
// yaml-language-server: $schema=values.schema.json
|
||||
// Default values for prometheus.
|
||||
@@ -1083,7 +1086,7 @@ Helm: Values: {
|
||||
target_label: "__param_target"
|
||||
}, {
|
||||
target_label: "__address__"
|
||||
- replacement: "blackbox"
|
||||
+ replacement: "\(prometheus.blackbox.host):\(prometheus.blackbox.port)"
|
||||
}, {
|
||||
source_labels: ["__param_target"]
|
||||
target_label: "instance"
|
||||
7
doc/md/tutorial/_kustomize/examples/01-holos-version.txt
Normal file
7
doc/md/tutorial/_kustomize/examples/01-holos-version.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
exec bash -c 'bash -euo pipefail $WORK/command.sh 2>&1'
|
||||
cmp stdout $WORK/output.txt
|
||||
|
||||
-- command.sh --
|
||||
holos --version
|
||||
-- output.txt --
|
||||
0.103.0
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user