From f6535e358b112d8aa08449fffd6e7195bfb49c2b Mon Sep 17 00:00:00 2001 From: Juan Antonio Osorio Date: Sat, 28 Jan 2023 20:40:59 +0200 Subject: [PATCH] Separate port and extra_config settings from default config The port should ideally be set directly via the already existing configuration in the helm chart. Doing it outside is prone to errors. So now the krakend's port is configured via the service's target port, similarly to how the pod's port is configured. The extra config is something folks will want to change often, so we explicitly add a key for people to be able to configure this if they're using the default configuration we ship. Folks can still override this and do it on their own if they override the config key. Signed-off-by: Juan Antonio Osorio --- README.md | 3 ++- templates/cm-config.yaml | 6 +++--- values.yaml | 21 +++++++++++---------- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 6ab0a52..578526d 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,7 @@ please refer to [the official krakend documentation](https://www.krakend.io/docs | krakend.endpoints.image.resources | object | `{"limits":{"cpu":"100m","memory":"128Mi"},"requests":{"cpu":"100m","memory":"128Mi"}}` | The resources to use for the endpoints loader | | krakend.endpoints.image.tag | string | `nil` | The image tag to use for the endpoints loader | | krakend.env | array | `[{"name":"FC_ENABLE","value":"1"},{"name":"FC_SETTINGS","value":"/etc/krakend-src/settings"},{"name":"FC_PARTIALS","value":"/etc/krakend-src/partials"},{"name":"FC_TEMPLATES","value":"/etc/krakend-src/templates"}]` | The environment variables to use for the krakend container. The default is just the ones needed to enable flexible configuration. | +| krakend.extraConfig | object | `{"router":{"@comment":"The health endpoint checks do not show in the logs","logger_skip_paths":["/__health"]}}` | The service-level "extra_config" settings. This will directly be translated to JSON and is added only if you're not fully overriding the configuration via the `config` setting. For more information, see https://www.krakend.io/docs/enterprise/configuration/ | | krakend.partials | Object | `{"input_headers.tmpl":"\"input_headers\": [\n \"Content-Type\",\n \"ClientId\"\n]","rate_limit_backend.tmpl":"\"qos/ratelimit/proxy\": {\n \"max_rate\": 0.5,\n \"capacity\": 1\n}"}` | The default configuration has a partials files that will be used to load several aspects of the configuration. If you want to include expra partials, add or remove them here. | | krakend.partialsCopierImage | object | `{"pullPolicy":"IfNotPresent","registry":"docker.io","repository":"library/alpine","resources":{"limits":{"cpu":"100m","memory":"128Mi"},"requests":{"cpu":"100m","memory":"128Mi"}},"tag":"3.17.1"}` | The default configuration has a partials file that will be used to load several aspects of the configuration. This is done through an initContainer that copies the partials to the /etc/krakend/partials folder. | | krakend.partialsCopierImage.pullPolicy | string | `"IfNotPresent"` | The image pull policy to use for the partials copier | @@ -53,7 +54,7 @@ please refer to [the official krakend documentation](https://www.krakend.io/docs | krakend.partialsCopierImage.repository | string | `"library/alpine"` | The image repository to use for the partials copier | | krakend.partialsCopierImage.resources | object | `{"limits":{"cpu":"100m","memory":"128Mi"},"requests":{"cpu":"100m","memory":"128Mi"}}` | The resources to use for the partials copier | | krakend.partialsCopierImage.tag | string | `"3.17.1"` | The image tag to use for the partials copier | -| krakend.settings | object | `{"service.json":"{\n\t\"port\": 8080,\n\t\"environment\": \"PRODUCTION\",\n\t\"default_host\": \"http://localhost:8080\",\n\t\"timeout\": \"3s\",\n\t\"cache_ttl\": \"3s\",\n\t\"output_encoding\": \"json\",\n\t\"extra_config\": {\n \"router\": {\n \"@comment\": \"The health endpoint checks do not show in the logs\",\n \"logger_skip_paths\": [\n \"/__health\"\n ]\n }\n }\n}"}` | The default configuration has a settings files that will be used to load several aspects of the configuration. | +| krakend.settings | object | `{"service.json":"{\n\t\"environment\": \"PRODUCTION\",\n\t\"default_host\": \"http://localhost:8080\",\n\t\"timeout\": \"3s\",\n\t\"cache_ttl\": \"3s\",\n\t\"output_encoding\": \"json\"\n}"}` | The default configuration has a settings files that will be used to load several aspects of the configuration. | | krakend.templates | object | `{}` | While default configuration does not take into use templates; you may want to add your own templates here. Note that you'd need to set a custom configuration file to use them. | | nameOverride | string | `""` | | | nodeSelector | object | `{}` | The nodeSelector to use for the krakend pod | diff --git a/templates/cm-config.yaml b/templates/cm-config.yaml index 42b1228..96ed923 100644 --- a/templates/cm-config.yaml +++ b/templates/cm-config.yaml @@ -14,7 +14,7 @@ data: "$schema": "https://www.krakend.io/schema/v3.json", "version": 3, "name": "{{ env "SERVICE_NAME" }} ({{ .service.environment }})", - "port": {{ .service.port }}, + "port": `}}{{ .Values.service.targetPort }}{{`, "timeout": "{{ .service.timeout }}", "cache_ttl": "{{ .service.cache_ttl }}", "output_encoding": "{{ .service.output_encoding }}", @@ -22,7 +22,7 @@ data: "pattern":".so", "folder": "/usr/lib/krakend/plugins/" }, - "extra_config": {{ marshal .service.extra_config }}, - "endpoints": {{ include "endpoints.tmpl" }} + "endpoints": {{ include "endpoints.tmpl" }}, + "extra_config": `}}{{ .Values.krakend.extraConfig | toJson }}{{` }`}} {{- end }} \ No newline at end of file diff --git a/values.yaml b/values.yaml index 8b68109..d940c80 100644 --- a/values.yaml +++ b/values.yaml @@ -65,26 +65,27 @@ krakend: settings: service.json: |- { - "port": 8080, "environment": "PRODUCTION", "default_host": "http://localhost:8080", "timeout": "3s", "cache_ttl": "3s", - "output_encoding": "json", - "extra_config": { - "router": { - "@comment": "The health endpoint checks do not show in the logs", - "logger_skip_paths": [ - "/__health" - ] - } - } + "output_encoding": "json" } # -- While default configuration does not take into use # templates; you may want to add your own templates here. # Note that you'd need to set a custom configuration file # to use them. templates: {} + # -- (object) The service-level "extra_config" settings. + # This will directly be translated to JSON and is added only + # if you're not fully overriding the configuration via + # the `config` setting. + # For more information, see https://www.krakend.io/docs/enterprise/configuration/ + extraConfig: + router: + "@comment": "The health endpoint checks do not show in the logs" + logger_skip_paths: + - "/__health" # -- Given that endpoitns is where most of the verbosity # of the configuration is, it's possible to load them # from a configmap or from an image. This section allows