From 7e9f7dbc5daa226f28d1b11e967acaff3395154f Mon Sep 17 00:00:00 2001 From: Max Komarychev Date: Fri, 13 Jun 2025 11:14:43 +0200 Subject: [PATCH] feat(helm): allow using config of a router from a file When config gets large it's easier to manage it as an external file: - lint with external tools - get proper syntax support in editors - share the same config across multiple instances of a router --- helm/cosmo/charts/router/Chart.yaml | 2 +- helm/cosmo/charts/router/README.md | 3 ++- helm/cosmo/charts/router/templates/config-map.yaml | 4 +++- helm/cosmo/charts/router/values.yaml | 5 +++++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/helm/cosmo/charts/router/Chart.yaml b/helm/cosmo/charts/router/Chart.yaml index c77e6b28ff..5c51d2bc7b 100644 --- a/helm/cosmo/charts/router/Chart.yaml +++ b/helm/cosmo/charts/router/Chart.yaml @@ -15,7 +15,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.12.0 +version: 0.13.0 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/helm/cosmo/charts/router/README.md b/helm/cosmo/charts/router/README.md index 5734d8f32b..2bc0ba8503 100644 --- a/helm/cosmo/charts/router/README.md +++ b/helm/cosmo/charts/router/README.md @@ -1,6 +1,6 @@ # router -![Version: 0.12.0](https://img.shields.io/badge/Version-0.12.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.197.1](https://img.shields.io/badge/AppVersion-0.197.1-informational?style=flat-square) +![Version: 0.13.0](https://img.shields.io/badge/Version-0.13.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.197.1](https://img.shields.io/badge/AppVersion-0.197.1-informational?style=flat-square) This is the official Helm Chart for the WunderGraph Cosmo Router. @@ -15,6 +15,7 @@ This is the official Helm Chart for the WunderGraph Cosmo Router. | autoscaling.minReplicas | int | `1` | | | autoscaling.targetCPUUtilizationPercentage | int | `80` | | | commonConfiguration | string | `"version: \"1\"\nlog_level: \"info\""` | You can use this to provide the router configuration via yaml. Values here have precedence over the configurations section. For a full list of available configuration options, see https://cosmo-docs.wundergraph.com/router/configuration This value is processed with the helm `tpl` function allowing referencing of variables and inclusion of templates | +| commonConfigurationPath | string | `""` | Path to a configuration file to embed. If set, this takes precedence over commonConfiguration. The file path is relative to the chart directory and will be processed with the helm `tpl` function. Example: "configs/router-config.yaml" | | commonLabels | object | `{}` | Add labels to all deployed resources | | configuration.cdnUrl | string | `""` | | | configuration.configPath | string | `""` | The path to the router config file. This does not refer to the execution config. See: https://cosmo-docs.wundergraph.com/router/configuration#config-file | diff --git a/helm/cosmo/charts/router/templates/config-map.yaml b/helm/cosmo/charts/router/templates/config-map.yaml index ba5e515d2f..ff2c0ac7d2 100644 --- a/helm/cosmo/charts/router/templates/config-map.yaml +++ b/helm/cosmo/charts/router/templates/config-map.yaml @@ -11,7 +11,9 @@ metadata: data: config.yaml: |- # User-supplied common configuration: - {{- if .Values.commonConfiguration }} + {{- if .Values.commonConfigurationPath }} + {{- tpl (.Files.Get .Values.commonConfigurationPath) . | nindent 4 }} + {{- else if .Values.commonConfiguration }} {{- tpl .Values.commonConfiguration . | nindent 4 }} {{- end }} logLevel: "{{ .Values.configuration.logLevel }}" diff --git a/helm/cosmo/charts/router/values.yaml b/helm/cosmo/charts/router/values.yaml index 399056c1a5..359a773e3f 100644 --- a/helm/cosmo/charts/router/values.yaml +++ b/helm/cosmo/charts/router/values.yaml @@ -198,6 +198,11 @@ commonConfiguration: |- version: "1" log_level: "info" +# -- Path to a configuration file to embed. If set, this takes precedence over commonConfiguration. +# The file path is relative to the chart directory and will be processed with the helm `tpl` function. +# Example: "configs/router-config.yaml" +commonConfigurationPath: "" + # Use this section to pass the graphApiToken or to configure simple settings. configuration: # -- The router token is used to authenticate the router against the controlplane (required)