Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions config/custom-environment-variables.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,8 @@
"__name": "OPENTELEMETRY_LOGGING_ENABLED",
"__format": "boolean"
},
"url": "OPENTELEMETRY_LOGGING_URL",
"resourceAttributes": {
"__name": "OPENTELEMETRY_RESOURCE_ATTRIBUTES",
"__format": "json"
}
"url": "OTLP_LOGGER_ENDPOINT_URL",
"resourceAttributes": "OTEL_RESOURCE_ATTRIBUTES"
}
},
"tracing": {
Expand Down
34 changes: 23 additions & 11 deletions helm/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -103,23 +103,35 @@ Returns the cloud provider image pull secret name from global if exists or from
{{- end -}}

{{/*
Returns the tracing url from global if exists or from the chart's values
Returns the tracing url from global if set, otherwise from the chart's values
*/}}
{{- define "mapproxy-api.tracingUrl" -}}
{{- if .Values.global.tracing.url }}
{{- .Values.global.tracing.url -}}
{{- else if .Values.cloudProvider -}}
{{- .Values.env.tracing.url -}}
{{- if .Values.global.telemetry.tracing.url }}
{{- .Values.global.telemetry.tracing.url -}}
{{- else if .Values.telemetry.tracing.url -}}
{{- .Values.telemetry.tracing.url -}}
{{- end -}}
{{- end -}}

{{/*
Returns the tracing url from global if exists or from the chart's values
Returns the opentelemetry logging url from global if set, otherwise from the chart's values
*/}}
{{- define "mapproxy-api.metricsUrl" -}}
{{- if .Values.global.metrics.url }}
{{- .Values.global.metrics.url -}}
{{- else -}}
{{- .Values.env.metrics.url -}}
{{- define "mapproxy-api.opentelemetryLoggingUrl" -}}
{{- if .Values.global.telemetry.logger.opentelemetryOptions.url }}
{{- .Values.global.telemetry.logger.opentelemetryOptions.url -}}
{{- else if .Values.telemetry.logger.opentelemetryOptions.url -}}
{{- .Values.telemetry.logger.opentelemetryOptions.url -}}
{{- end -}}
{{- end -}}

{{/*
Renders a map of resource attributes as key=value,key=value for OTEL_RESOURCE_ATTRIBUTES.
Usage: {{ include "mapproxy-api.otelResourceAttributes" .resourceAttributes }}
*/}}
{{- define "mapproxy-api.otelResourceAttributes" -}}
{{- $attributes := list }}
{{- range $key, $value := . }}
{{- $attributes = append $attributes (printf "%s=%s" $key (toString $value)) }}
{{- end }}
{{- join "," $attributes }}
{{- end -}}
8 changes: 0 additions & 8 deletions helm/templates/_tplValues.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,6 @@ Custom definitions
{{- include "common.tplvalues.merge" ( dict "values" ( list .Values.storage.fs .Values.global.storage.fs ) "context" . ) }}
{{- end -}}

{{- define "common.tracing.merged" -}}
{{- include "common.tplvalues.merge" ( dict "values" ( list .Values.tracing .Values.global.tracing ) "context" . ) }}
{{- end -}}

{{- define "common.openTelemetryOptions.merged" -}}
{{- include "common.tplvalues.merge" ( dict "values" ( list .Values.env.openTelemetryOptions .Values.global.openTelemetryOptions ) "context" . ) }}
{{- end -}}

{{- define "common.redis.merged" -}}
{{- include "common.tplvalues.merge" ( dict "values" ( list .Values.redis .Values.global.redis ) "context" . ) }}
{{- end -}}
36 changes: 22 additions & 14 deletions helm/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{{- $chartName := include "mapproxy-api.name" . -}}
{{- $configmapName := include "configmap.fullname" . }}
{{- $storage := (include "common.storage.merged" .) | fromYaml }}
{{- $tracing := (include "common.tracing.merged" .) | fromYaml }}
{{- $openTelemetryOptions := (include "common.openTelemetryOptions.merged" .) | fromYaml }}
{{- $server := .Values.server -}}
{{- $telemetry := .Values.telemetry -}}
{{- $tracingUrl := include "mapproxy-api.tracingUrl" . -}}
{{- $opentelemetryLoggingUrl := include "mapproxy-api.opentelemetryLoggingUrl" . -}}
{{- $redis := (include "common.redis.merged" .) | fromYaml }}

{{- if .Values.enabled -}}
Expand All @@ -11,21 +13,27 @@ kind: ConfigMap
metadata:
name: {{ $configmapName }}
data:
REQUEST_PAYLOAD_LIMIT: {{ .Values.env.requestPayloadLimit | quote }}
RESPONSE_COMPRESSION_ENABLED: {{ .Values.env.responseCompressionEnabled | quote }}
LOG_LEVEL: {{ .Values.env.logLevel | quote }}
LOG_PRETTY_PRINT_ENABLED: {{ .Values.env.logPrettyPrintEnabled | quote }}
{{- with $openTelemetryOptions }}
{{- with $server }}
REQUEST_PAYLOAD_LIMIT: {{ .requestPayloadLimit | quote }}
RESPONSE_COMPRESSION_ENABLED: {{ .responseCompressionEnabled | quote }}
{{- end }}
{{- with $telemetry }}
LOG_LEVEL: {{ .logger.level | quote }}
LOG_PRETTY_PRINT_ENABLED: {{ .logger.prettyPrint | quote }}
{{- with .logger.opentelemetryOptions }}
OPENTELEMETRY_LOGGING_ENABLED: {{ .enabled | quote }}
{{ if .enabled }}
OPENTELEMETRY_LOGGING_URL: {{ .url | quote }}
OPENTELEMETRY_RESOURCE_ATTRIBUTES: {{ .resourceAttributes | toJson | quote }}
{{- if .enabled }}
OTLP_LOGGER_ENDPOINT_URL: {{ $opentelemetryLoggingUrl | quote }}
{{- if .resourceAttributes }}
OTEL_RESOURCE_ATTRIBUTES: {{ include "mapproxy-api.otelResourceAttributes" .resourceAttributes | quote }}
{{- end }}
{{- end }}
{{- end }}
TELEMETRY_TRACING_ENABLED: {{ .tracing.enabled | quote }}
{{- if .tracing.enabled }}
TELEMETRY_TRACING_URL: {{ $tracingUrl | quote }}
{{- end }}
{{- end }}
TELEMETRY_TRACING_ENABLED: {{ $tracing.enabled | quote }}
{{ if $tracing.enabled }}
TELEMETRY_TRACING_URL: {{ $tracing.url }}
{{ end }}
MAPPROXY_CONFIG_PROVIDER: {{ quote $storage.mapproxyConfigProvider }}
MAPPROXY_CACHE_GRIDS: {{ quote .Values.env.mapproxyCache.grids }}
MAPPROXY_CACHE_UPSCALE_TILES: {{ quote .Values.env.mapproxyCache.upscaleTiles }}
Expand Down
9 changes: 5 additions & 4 deletions helm/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ spec:
- name: {{ $chartName }}
{{- with .Values.image }}
image: {{ $cloudProviderDockerRegistryUrl }}{{ .repository }}:{{ $imageTag }}
imagePullPolicy: {{ .pullPolicy | default "IfNotPresent" }}
{{- end }}
volumeMounts:
{{- if .Values.global.ca.secretName }}
Expand All @@ -84,7 +85,7 @@ spec:
{{- end }}
env:
- name: SERVER_PORT
value: {{ .Values.env.targetPort | quote }}
value: {{ .Values.server.targetPort | quote }}
- name: K8S_POD_UID
valueFrom:
fieldRef:
Expand Down Expand Up @@ -140,13 +141,13 @@ spec:
name: {{ $configmapName }}
ports:
- name: http
containerPort: {{ .Values.env.targetPort }}
protocol: {{ .Values.env.protocol }}
containerPort: {{ .Values.server.targetPort }}
protocol: {{ .Values.server.protocol }}
livenessProbe:
initialDelaySeconds: {{ .Values.initialDelaySeconds }}
httpGet:
path: /liveness
port: {{ .Values.env.targetPort }}
port: {{ .Values.server.targetPort }}
{{- if .Values.resources.enabled }}
resources:
{{- toYaml .Values.resources.value | nindent 12 }}
Expand Down
2 changes: 1 addition & 1 deletion helm/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ spec:
service:
name: {{ $serviceName }}
port:
number: {{ .Values.env.port }}
number: {{ .Values.server.port }}
host: {{ $ingressHost }}
{{- end -}}
6 changes: 3 additions & 3 deletions helm/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ spec:
type: NodePort
{{- end }}
ports:
- port: {{ .Values.env.port }}
targetPort: {{ .Values.env.targetPort }}
protocol: {{ .Values.env.protocol }}
- port: {{ .Values.server.port }}
targetPort: {{ .Values.server.targetPort }}
protocol: {{ .Values.server.protocol }}
name: http
{{- if eq $cloudProviderFlavor "minikube" }}
nodePort: {{ .Values.nodePort }}
Expand Down
49 changes: 30 additions & 19 deletions helm/values.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
global:
cloudProvider: {}
tracing: {}
openTelemetryOptions: {}
telemetry:
tracing: {}
logger:
opentelemetryOptions: {}
environment: ""
storage:
mapproxyConfigProvider: "" # -> 'DB' | 'FS' | 'S3'
Expand Down Expand Up @@ -59,6 +61,7 @@ cloudProvider:
image:
repository: mapproxy-api
tag: 'latest'
pullPolicy: IfNotPresent

storage:
mapproxyConfigProvider: "" # -> 'DB' | 'FS' | 'S3'
Expand All @@ -78,40 +81,48 @@ db:
name: ""
port: 5432
sslEnabled: false
schema: ""
schema: "MapproxyConfig"
dbRejectUnauthorized: false
secrets:
useExternal: false
externalSecretName: ""

configManagement:
offlineMode: false
offlineMode: true
name: 'mapproxy-api'
version: 'latest'
serverUrl: 'http://localhost:8080/api'

tracing:
enabled: false
url: ''
# add pod annotations
# example:
# podAnnotations:
# annotation1: annotation-value-1
# annotation2: annotation-value-2
# add pod annotations
# example:
# podAnnotations:
# annotation1: annotation-value-1
# annotation2: annotation-value-2
podAnnotations: {}

env:
server:
port: 80
targetPort: 8080
protocol: TCP
logLevel: warn
logPrettyPrintEnabled: false
openTelemetryOptions:
enabled: false
url: ''
resourceAttributes: {}
responseCompressionEnabled: true
requestPayloadLimit: 1mb

telemetry:
logger:
level: warn
prettyPrint: false
opentelemetryOptions:
enabled: true
url: http://localhost:4317
# Rendered as OTEL_RESOURCE_ATTRIBUTES in "key=value,key=value" format
# resourceAttributes:
# service.namespace: namespace
# deployment.environment: dev
tracing:
enabled: true
url: http://localhost:55681/v1/traces

env:
mapproxyCache:
grids: WorldCRS84
upscaleTiles: 18
Expand Down
2 changes: 1 addition & 1 deletion src/containerConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const registerExternalValues = async (options?: RegisterOptions): Promise
const mapproxyConfig = configInstance.get('mapproxy') as IMapProxyConfig;
const redisConfig = configInstance.get('redis') as IRedisConfig;

const logger = await jsLogger({ ...loggerConfig, prettyPrint: loggerConfig.prettyPrint, mixin: getOtelMixin() });
const logger = await jsLogger({ ...loggerConfig, mixin: getOtelMixin() });

const tracer = trace.getTracer(SERVICE_NAME);
const metricsRegistry = new Registry();
Expand Down
Loading