Skip to content

Commit

Permalink
[traffic-proxy] Update traffic-proxy chart configuration and nginx te…
Browse files Browse the repository at this point in the history
…mplate (#518)

* Update traffic-proxy chart configuration and nginx template

* Add customizable server section

* Update charts/traffic-proxy/templates/configmap.yaml

Co-authored-by: Voronkov Alexander <[email protected]>

* Update charts/traffic-proxy/templates/configmap.yaml

Co-authored-by: Voronkov Alexander <[email protected]>

* Change log configuration

* Change README

* lint fix

* Delete duplicate field description in traffic-proxy

* Fix configmap spaces. Add loglevel field allowed values

---------

Co-authored-by: Sergey Vlasov <[email protected]>
Co-authored-by: Voronkov Alexander <[email protected]>
  • Loading branch information
3 people authored Oct 18, 2024
1 parent 7160161 commit 94ee0e9
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 12 deletions.
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. Allowed values: `debug`, `info`, `notice`, `warn`, `error`, `crit`, `alert`, `emerg`. | `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 {
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 }}
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 }}
{{ 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 @@ podLabels: {}
# @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. Allowed values: `debug`, `info`, `notice`, `warn`, `error`, `crit`, `alert`, `emerg`.
# @param proxy.log.accessLog Access log definition.
# @param proxy.keepaliveTimeout Keepalive timeout.


proxy:
host: ''
Expand All @@ -49,6 +55,46 @@ proxy:
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
# 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

0 comments on commit 94ee0e9

Please sign in to comment.