Skip to content

Commit

Permalink
Separate port and extra_config settings from default config
Browse files Browse the repository at this point in the history
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 <juan.osoriorobles@eu.equinix.com>
  • Loading branch information
JAORMX committed Jan 30, 2023
1 parent 5be1851 commit f6535e3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,15 @@ 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 |
| krakend.partialsCopierImage.registry | string | `"docker.io"` | The image registry to use for the partials copier |
| 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 |
Expand Down
6 changes: 3 additions & 3 deletions templates/cm-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ 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 }}",
"plugin": {
"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 }}
21 changes: 11 additions & 10 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f6535e3

Please sign in to comment.