diff --git a/doc/md/tutorial/_helm-values/examples/02-helm-values.txt b/doc/md/tutorial/_helm-values/examples/02-helm-values.txt index e25c3ae5..38ea9017 100644 --- a/doc/md/tutorial/_helm-values/examples/02-helm-values.txt +++ b/doc/md/tutorial/_helm-values/examples/02-helm-values.txt @@ -58,6 +58,9 @@ 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 @@ -211,10 +214,12 @@ git add . && git commit -m '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 < components/blackbox.cue +cat < config/prometheus/blackbox.cue -- blackbox-common-config-body.cue -- -package holos +package prometheus // Schema Definition #Blackbox: { @@ -225,7 +230,7 @@ package holos } // Concrete values must validate against the schema. -Blackbox: #Blackbox & { +blackbox: #Blackbox & { host: "blackbox" port: 9115 } @@ -240,32 +245,44 @@ patch -p1 < values.patch -- values.patch -- --- a/components/blackbox/values.cue +++ b/components/blackbox/values.cue -@@ -1,6 +1,8 @@ +@@ -1,6 +1,11 @@ package holos ++// Import common blackbox configuration ++import "holos.example/config/prometheus" ++ Helm: Values: { -+ fullnameOverride: Blackbox.host ++ 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 +194,7 @@ Helm: Values: { +@@ -192,7 +197,7 @@ Helm: Values: { annotations: {} labels: {} type: "ClusterIP" - port: 9115 -+ port: Blackbox.port ++ port: prometheus.blackbox.port ipDualStack: { enabled: false ipFamilies: ["IPv6", "IPv4"] --- a/components/prometheus/values.cue +++ b/components/prometheus/values.cue -@@ -1083,7 +1083,7 @@ Helm: Values: { +@@ -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: "\(Blackbox.host):\(Blackbox.port)" ++ replacement: "\(prometheus.blackbox.host):\(prometheus.blackbox.port)" }, { source_labels: ["__param_target"] target_label: "instance" diff --git a/doc/md/tutorial/_helm-values/script-01-holos-version/output.txt b/doc/md/tutorial/_helm-values/script-01-holos-version/output.txt index d88fa7ff..0c9e4563 100644 --- a/doc/md/tutorial/_helm-values/script-01-holos-version/output.txt +++ b/doc/md/tutorial/_helm-values/script-01-holos-version/output.txt @@ -1 +1 @@ -0.102.4 +0.102.5 diff --git a/doc/md/tutorial/_helm-values/script-02-helm-values/blackbox-common-config-body.cue b/doc/md/tutorial/_helm-values/script-02-helm-values/blackbox-common-config-body.cue index a1c6f7a3..a3becc88 100644 --- a/doc/md/tutorial/_helm-values/script-02-helm-values/blackbox-common-config-body.cue +++ b/doc/md/tutorial/_helm-values/script-02-helm-values/blackbox-common-config-body.cue @@ -1,4 +1,4 @@ -package holos +package prometheus // Schema Definition #Blackbox: { @@ -9,7 +9,7 @@ package holos } // Concrete values must validate against the schema. -Blackbox: #Blackbox & { +blackbox: #Blackbox & { host: "blackbox" port: 9115 } diff --git a/doc/md/tutorial/_helm-values/script-02-helm-values/blackbox-common-config-git-output.txt b/doc/md/tutorial/_helm-values/script-02-helm-values/blackbox-common-config-git-output.txt index 73e91d13..ad2beecf 100644 --- a/doc/md/tutorial/_helm-values/script-02-helm-values/blackbox-common-config-git-output.txt +++ b/doc/md/tutorial/_helm-values/script-02-helm-values/blackbox-common-config-git-output.txt @@ -1,3 +1,3 @@ -[main ffea4dd] add blackbox configuration +[main 884be5f] add blackbox configuration 1 file changed, 15 insertions(+) - create mode 100644 components/blackbox.cue + create mode 100644 config/prometheus/blackbox.cue diff --git a/doc/md/tutorial/_helm-values/script-02-helm-values/blackbox-common-config-header.sh b/doc/md/tutorial/_helm-values/script-02-helm-values/blackbox-common-config-header.sh index 6e14b326..da96194a 100644 --- a/doc/md/tutorial/_helm-values/script-02-helm-values/blackbox-common-config-header.sh +++ b/doc/md/tutorial/_helm-values/script-02-helm-values/blackbox-common-config-header.sh @@ -1 +1 @@ -cat < components/blackbox.cue +cat < config/prometheus/blackbox.cue diff --git a/doc/md/tutorial/_helm-values/script-02-helm-values/common-config-git-output.txt b/doc/md/tutorial/_helm-values/script-02-helm-values/common-config-git-output.txt index 844bcea7..a0ceaa48 100644 --- a/doc/md/tutorial/_helm-values/script-02-helm-values/common-config-git-output.txt +++ b/doc/md/tutorial/_helm-values/script-02-helm-values/common-config-git-output.txt @@ -1,2 +1,3 @@ -[main a4bc817] integrate blackbox and prometheus together - 2 files changed, 4 insertions(+), 2 deletions(-) +[main 209de0b] integrate blackbox and prometheus together + 3 files changed, 1348 insertions(+), 2 deletions(-) + create mode 100644 components/prometheus/values.cue.orig diff --git a/doc/md/tutorial/_helm-values/script-02-helm-values/import-values-git-output.txt b/doc/md/tutorial/_helm-values/script-02-helm-values/import-values-git-output.txt index 32afb75d..7b6f201c 100644 --- a/doc/md/tutorial/_helm-values/script-02-helm-values/import-values-git-output.txt +++ b/doc/md/tutorial/_helm-values/script-02-helm-values/import-values-git-output.txt @@ -1,4 +1,4 @@ -[main d8046af] import values +[main 7c2a61e] import values 2 files changed, 1815 insertions(+) create mode 100644 components/blackbox/values.cue create mode 100644 components/prometheus/values.cue diff --git a/doc/md/tutorial/_helm-values/script-02-helm-values/import-values-render-output.txt b/doc/md/tutorial/_helm-values/script-02-helm-values/import-values-render-output.txt index 5267c235..166041c2 100644 --- a/doc/md/tutorial/_helm-values/script-02-helm-values/import-values-render-output.txt +++ b/doc/md/tutorial/_helm-values/script-02-helm-values/import-values-render-output.txt @@ -1,3 +1,3 @@ -rendered blackbox in 161.782375ms -rendered prometheus in 203.388ms -rendered platform in 203.481459ms +rendered blackbox in 168.983792ms +rendered prometheus in 206.797625ms +rendered platform in 207.001459ms diff --git a/doc/md/tutorial/_helm-values/script-02-helm-values/mkdir-common-config.sh b/doc/md/tutorial/_helm-values/script-02-helm-values/mkdir-common-config.sh new file mode 100644 index 00000000..466ed222 --- /dev/null +++ b/doc/md/tutorial/_helm-values/script-02-helm-values/mkdir-common-config.sh @@ -0,0 +1 @@ +mkdir -p config/prometheus diff --git a/doc/md/tutorial/_helm-values/script-02-helm-values/register-components-git-commit-output.txt b/doc/md/tutorial/_helm-values/script-02-helm-values/register-components-git-commit-output.txt index 4c02d00a..d83050a1 100644 --- a/doc/md/tutorial/_helm-values/script-02-helm-values/register-components-git-commit-output.txt +++ b/doc/md/tutorial/_helm-values/script-02-helm-values/register-components-git-commit-output.txt @@ -1,4 +1,4 @@ -[main 8971a74] add blackbox and prometheus +[main 4bebc8b] add blackbox and prometheus 5 files changed, 1550 insertions(+) create mode 100644 components/blackbox/blackbox.cue create mode 100644 components/prometheus/prometheus.cue diff --git a/doc/md/tutorial/_helm-values/script-02-helm-values/register-components-output.txt b/doc/md/tutorial/_helm-values/script-02-helm-values/register-components-output.txt index 647252df..2bd3f80b 100644 --- a/doc/md/tutorial/_helm-values/script-02-helm-values/register-components-output.txt +++ b/doc/md/tutorial/_helm-values/script-02-helm-values/register-components-output.txt @@ -1,3 +1,3 @@ -rendered blackbox in 1.324044833s -rendered prometheus in 1.336657625s -rendered platform in 1.33672525s +rendered blackbox in 1.108670875s +rendered prometheus in 1.114354292s +rendered platform in 1.114471791s diff --git a/doc/md/tutorial/_helm-values/script-02-helm-values/reviewing-changes-git-output.txt b/doc/md/tutorial/_helm-values/script-02-helm-values/reviewing-changes-git-output.txt index 2b67df3f..89c34515 100644 --- a/doc/md/tutorial/_helm-values/script-02-helm-values/reviewing-changes-git-output.txt +++ b/doc/md/tutorial/_helm-values/script-02-helm-values/reviewing-changes-git-output.txt @@ -1,2 +1,2 @@ -[main 1200227] render integrated blackbox and prometheus manifests +[main 09736f1] render integrated blackbox and prometheus manifests 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/doc/md/tutorial/_helm-values/script-02-helm-values/values.patch b/doc/md/tutorial/_helm-values/script-02-helm-values/values.patch index 49fa4ce1..7dc60539 100644 --- a/doc/md/tutorial/_helm-values/script-02-helm-values/values.patch +++ b/doc/md/tutorial/_helm-values/script-02-helm-values/values.patch @@ -1,31 +1,43 @@ --- a/components/blackbox/values.cue +++ b/components/blackbox/values.cue -@@ -1,6 +1,8 @@ +@@ -1,6 +1,11 @@ package holos ++// Import common blackbox configuration ++import "holos.example/config/prometheus" ++ Helm: Values: { -+ fullnameOverride: Blackbox.host ++ 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 +194,7 @@ Helm: Values: { +@@ -192,7 +197,7 @@ Helm: Values: { annotations: {} labels: {} type: "ClusterIP" - port: 9115 -+ port: Blackbox.port ++ port: prometheus.blackbox.port ipDualStack: { enabled: false ipFamilies: ["IPv6", "IPv4"] --- a/components/prometheus/values.cue +++ b/components/prometheus/values.cue -@@ -1083,7 +1083,7 @@ Helm: Values: { +@@ -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: "\(Blackbox.host):\(Blackbox.port)" ++ replacement: "\(prometheus.blackbox.host):\(prometheus.blackbox.port)" }, { source_labels: ["__param_target"] target_label: "instance" diff --git a/doc/md/tutorial/helm-values.mdx b/doc/md/tutorial/helm-values.mdx index d2bbe216..156fed37 100644 --- a/doc/md/tutorial/helm-values.mdx +++ b/doc/md/tutorial/helm-values.mdx @@ -180,12 +180,15 @@ import ImportValuesGitOutput from '!!raw-loader!./_helm-values/script-02-helm-va ### Managing Common Configuration To manage shared configuration for both Helm charts, define a structure that -holds the common configuration values. Place this configuration in the -`components` directory to ensure it is accessible to all components. +holds the common configuration values. Create a `config` directory at the root +of the repository, and place the configuration file there to ensure it is +accessible to all components. +import BlackboxCommonConfigMkdir from '!!raw-loader!./_helm-values/script-02-helm-values/mkdir-common-config.sh'; import BlackboxCommonConfigHeader from '!!raw-loader!./_helm-values/script-02-helm-values/blackbox-common-config-header.sh'; import BlackboxCommonConfigBody from '!!raw-loader!./_helm-values/script-02-helm-values/blackbox-common-config-body.cue'; +{BlackboxCommonConfigMkdir} {BlackboxCommonConfigHeader} {BlackboxCommonConfigBody} {EofTrailer} @@ -214,10 +217,12 @@ import BlackboxCommonConfigGitOutput from '!!raw-loader!./_helm-values/script-02 ### Using Common Configuration Across Components Referencing common configuration across multiple components is straightforward -and reliable using Holos and CUE. +and reliable using Holos and CUE. Configuration can be imported where necessary +following [CUE module standards], which are similar to Golang. To apply the common configuration, patch the two `values.cue` files, or manually -edit them to reference `Blackbox.host` and `Blackbox.port`. +edit them to import the configuration and reference `prometheus.blackbox.host` +and `prometheus.blackbox.port`. import CommonConfigPatchCommand from '!!raw-loader!./_helm-values/script-02-helm-values/common-config-patch.sh'; import CommonConfigPatchDiff from '!!raw-loader!./_helm-values/script-02-helm-values/values.patch'; @@ -327,7 +332,7 @@ service endpoint. [prometheus]: https://github.com/prometheus-community/helm-charts/tree/prometheus-25.27.0/charts/prometheus [blackbox]: https://github.com/prometheus-community/helm-charts/tree/prometheus-blackbox-exporter-9.0.1/charts/prometheus-blackbox-exporter [httpbin]: https://github.com/mccutchen/go-httpbin/tree/v2.15.0 - +[CUE module standards]: https://cuelang.org/docs/concept/modules-packages-instances/ [Config Schema]: #config-schema [Technical Overview]: ./overview.mdx diff --git a/doc/md/tutorial/helm-values_test.go b/doc/md/tutorial/helm-values_test.go index bb3e9769..b4fd0ca2 100644 --- a/doc/md/tutorial/helm-values_test.go +++ b/doc/md/tutorial/helm-values_test.go @@ -23,7 +23,7 @@ func TestMain(m *testing.M) { // Run these with go test -v to see the verbose names func TestHelmValues(t *testing.T) { - t.Run("AddOnPromoter", func(t *testing.T) { + t.Run("TestHelmValues", func(t *testing.T) { // Get an ordered list of test script files. dir := "_helm-values" for _, file := range sortedTestScripts(t, filepath.Join(dir, "examples")) {