Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[traffic-proxy] Update traffic-proxy chart configuration and nginx template #518

Merged
merged 9 commits into from
Oct 18, 2024
22 changes: 15 additions & 7 deletions charts/traffic-proxy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,21 @@ See the [documentation](https://docs.2gis.com/en/on-premise/traffic-proxy) to le

### Proxy server settings

| Name | Description | Value |
| --------------------- | --------------------------------------------------------------------------------------- | ------ |
| `proxy.host` | URL for the proxy server to serve, ex: https://traffic0.edromaps.2gis.com. **Required** | `""` |
| `proxy.listen` | Port for the proxy server to listen. | `8080` |
| `proxy.cache.enabled` | If caching should be enabled for the proxy server. | `true` |
| `proxy.cache.age` | Cache validity period. | `1m` |
| `proxy.cache.size` | Maximum cache size. | `32m` |
| Name | Description | Value |
| -------------------------- | --------------------------------------------------------------------------------------- | ------- |
| `proxy.host` | URL for the proxy server to serve, ex: https://traffic0.edromaps.2gis.com. **Required** | `""` |
| `proxy.listen` | Port for the proxy server to listen. | `8080` |
| `proxy.cache.enabled` | If caching should be enabled for the proxy server. | `true` |
| `proxy.cache.age` | Cache validity period. | `1m` |
| `proxy.cache.size` | Maximum cache size. | `32m` |
| `proxy.worker.processes` | Number of worker processes. | `2` |
| `proxy.worker.connections` | Number of worker connections. | `1024` |
| `proxy.log.errorLog.level` | Error log level. | `error` |
| `proxy.log.accessLog` | Access log definition. | `off` |
| `proxy.keepaliveTimeout` | Keepalive timeout. | `65` |
| `proxy.log.customFormats` | List of custom log formats to be used in NGINX configuration | `[]` |
| `proxy.locations` | List of additional location blocks to be included in the NGINX configuration | `[]` |
| `proxy.httpServers` | List of additional server blocks to be included in the NGINX configuration | `{}` |

### Deployment settings

Expand Down
31 changes: 26 additions & 5 deletions charts/traffic-proxy/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ metadata:
{{- include "traffic-proxy.labels" . | nindent 4 }}
data:
nginx.conf: |
worker_processes 2;
worker_processes {{ .Values.proxy.worker.processes }};

pid /run/nginx.pid;

events {
worker_connections 1024;
worker_connections {{ .Values.proxy.worker.connections }};
}

http {
endryhold marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -44,12 +44,19 @@ data:
'"request_id":"$http_x_request_id",'
'"upstream_request_id":"$upstream_http_x_request_id"}';

access_log off;
error_log /dev/stderr error;
{{- if .Values.proxy.log.customFormats }}
{{ range .Values.proxy.log.customFormats }}
log_format {{ .name }} escape={{ .escape }} {{ .format | nindent 36 | trim }};
{{- end }}
{{- end }}
v-a-v marked this conversation as resolved.
Show resolved Hide resolved

access_log {{ required "A valid .Values.proxy.log.accessLog required" .Values.proxy.log.accessLog }};

error_log /dev/stderr {{ required "A valid .Values.proxy.log.errorLog.level required" .Values.proxy.log.errorLog.level }};

sendfile on;
tcp_nopush on;
keepalive_timeout 65;
keepalive_timeout {{ .Values.proxy.keepaliveTimeout }};

{{ if .Values.proxy.cache.enabled }}
proxy_cache_path /var/cache/nginx/trafficcache keys_zone=trafficcache:{{ .Values.proxy.cache.size }};
Expand Down Expand Up @@ -81,5 +88,19 @@ data:
default_type text/html;
return 200 "<!DOCTYPE html><h2>OK</h2>\n";
}

{{ if .Values.proxy.locations }}
{{ range .Values.proxy.locations }}
location {{ .path }} {
{{- .definition | trim | nindent 14}}
}
{{ end }}
{{ end }}
}

{{ if .Values.proxy.httpServers }}
endryhold marked this conversation as resolved.
Show resolved Hide resolved
{{ range .Values.proxy.httpServers }}
{{- . | trim | nindent 6 }}
{{ end }}
{{ end }}
}
46 changes: 46 additions & 0 deletions charts/traffic-proxy/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@
# @param proxy.cache.enabled If caching should be enabled for the proxy server.
# @param proxy.cache.age Cache validity period.
# @param proxy.cache.size Maximum cache size.
# @param proxy.worker.processes Number of worker processes.
# @param proxy.worker.connections Number of worker connections.
# @param proxy.log.errorLog.level Error log level.
dbelyaev-nsk marked this conversation as resolved.
Show resolved Hide resolved
# @param proxy.log.accessLog Access log definition.
# @param proxy.keepaliveTimeout Keepalive timeout.


proxy:
host: ''
Expand All @@ -49,6 +55,46 @@
enabled: true
age: 1m
size: 32m
worker:
processes: 2
connections: 1024
log:
# @param proxy.log.customFormats List of custom log formats to be used in NGINX configuration
customFormats: []
# - name: small
# escape: json
# format: |
# '{"time_local":"$time_local",'
# '"remote_addr":"$remote_addr",'
# '"request":"$request",'
# '"status":"$status",'
# '"host":"$host"}'
errorLog:
level: error

accessLog: off

Check warning on line 75 in charts/traffic-proxy/values.yaml

View workflow job for this annotation

GitHub Actions / lint

75:16 [truthy] truthy value should be one of [false, true]
dbelyaev-nsk marked this conversation as resolved.
Show resolved Hide resolved
# accessLog: '/dev/stdout main'

keepaliveTimeout: 65

# @param proxy.locations List of additional location blocks to be included in the NGINX configuration
locations: []
# - path: /test/
# definition: |
# default_type text/html;
# return 200 "<!DOCTYPE html><h2>test page</h2>\n";

# @param proxy.httpServers List of additional server blocks to be included in the NGINX configuration
httpServers: {}
# examplecfg: |
# server {
# listen 0.0.0.0:8080;

# location / {
# default_type text/html;
# return 200 "<!DOCTYPE html><h2>test page</h2>\n";
# }
# }


# @section Deployment settings
Expand Down
Loading