Skip to content

Commit f8ed52e

Browse files
ixxeL2097Frederic Spiers
andauthored
chore(helm): updated timings for readinessProbe and failTimeout nginx (#58) (#61)
Co-authored-by: Frederic Spiers <[email protected]>
1 parent cee71ec commit f8ed52e

File tree

3 files changed

+101
-25
lines changed

3 files changed

+101
-25
lines changed

helm/ggbridge/README.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ A Helm chart for installing ggbridge
2727
| client.readinessProbe.exec.command[3] | string | `"http://127.0.0.1:9081/healthz"` | |
2828
| client.readinessProbe.failureThreshold | int | `3` | |
2929
| client.readinessProbe.initialDelaySeconds | int | `10` | |
30-
| client.readinessProbe.periodSeconds | int | `6` | |
30+
| client.readinessProbe.periodSeconds | int | `7` | |
3131
| client.readinessProbe.successThreshold | int | `1` | |
3232
| client.readinessProbe.timeoutSeconds | int | `5` | |
3333
| client.reverseTunnels.health.enabled | bool | `true` | Enable server to client health tunnel |
@@ -75,13 +75,17 @@ A Helm chart for installing ggbridge
7575
| podSecurityContext.enabled | bool | `true` | Enable Pod security Context in deployments |
7676
| proxy.affinity | object | `{}` | Affinity for pod assignment |
7777
| proxy.annotations | object | `{}` | Set proxy annotations |
78-
| proxy.config | object | `{"server":{"proxyConnectTimeout":"10s","proxyTimeout":"600s"},"upstream":{"failTimeout":"60s","maxFails":1}}` | Nginx configuration |
79-
| proxy.config.server | object | `{"proxyConnectTimeout":"10s","proxyTimeout":"600s"}` | Nginx server configuration |
80-
| proxy.config.server.proxyConnectTimeout | string | `"10s"` | Nginx proxy timeout for TCP handshake |
81-
| proxy.config.server.proxyTimeout | string | `"600s"` | Nginx proxy timeout for data exchange |
82-
| proxy.config.upstream | object | `{"failTimeout":"60s","maxFails":1}` | Nginx upstream configuration |
83-
| proxy.config.upstream.failTimeout | string | `"60s"` | Time during which the specified number of unsuccessful attempts must happen to mark the server as unavailable |
84-
| proxy.config.upstream.maxFails | int | `1` | Maximum number of unsuccessful attempts to communicate with the server |
78+
| proxy.config | object | `{"server":{"customDirectives":[],"proxyConnectTimeout":"30s","proxyTimeout":"1800s"},"upstream":{"backupMode":false,"downServers":[],"failTimeout":"120s","healthLoadBalancing":true,"maxFails":2}}` | Nginx configuration |
79+
| proxy.config.server | object | `{"customDirectives":[],"proxyConnectTimeout":"30s","proxyTimeout":"1800s"}` | Nginx server section configuration |
80+
| proxy.config.server.customDirectives | list | `[]` | custom parameters to add to the 'server' section of nginx.conf you need to choose which section it applies to can be "health", "socks", "web" or "tls" |
81+
| proxy.config.server.proxyConnectTimeout | string | `"30s"` | Nginx connection proxy timeout |
82+
| proxy.config.server.proxyTimeout | string | `"1800s"` | Nginx global proxy timeout |
83+
| proxy.config.upstream | object | `{"backupMode":false,"downServers":[],"failTimeout":"120s","healthLoadBalancing":true,"maxFails":2}` | Nginx upstream configuration |
84+
| proxy.config.upstream.backupMode | bool | `false` | Enable backup mode, will switch from round robin to backup setting for upstream servers |
85+
| proxy.config.upstream.downServers | list | `[]` | List of server proxy to disable in nginx conf For example [1,2] will mark proxy-1 and proxy-2 as down |
86+
| proxy.config.upstream.failTimeout | string | `"120s"` | Time during which the specified number of unsuccessful attempts must happen to mark the server as unavailable |
87+
| proxy.config.upstream.healthLoadBalancing | bool | `true` | Enable load balancing for health upstream (when false, only use the server with weight 100) |
88+
| proxy.config.upstream.maxFails | int | `2` | Maximum number of unsuccessful attempts to communicate with the server |
8589
| proxy.labels | object | `{}` | Set proxy labels |
8690
| proxy.logLevel | string | `"notice"` | Set nginx sidecar container and proxy pod log level (default: notice) |
8791
| proxy.networkPolicy.allowExternal | bool | `true` | When true, server will accept connections from any source |
@@ -99,7 +103,7 @@ A Helm chart for installing ggbridge
99103
| proxy.readinessProbe.exec.command[4] | string | `"http://127.0.0.1:9081/healthz"` | |
100104
| proxy.readinessProbe.failureThreshold | int | `3` | |
101105
| proxy.readinessProbe.initialDelaySeconds | int | `10` | |
102-
| proxy.readinessProbe.periodSeconds | int | `6` | |
106+
| proxy.readinessProbe.periodSeconds | int | `7` | |
103107
| proxy.readinessProbe.successThreshold | int | `1` | |
104108
| proxy.readinessProbe.timeoutSeconds | int | `5` | |
105109
| proxy.replicaCount | int | `1` | Number of pods for each deployment |

helm/ggbridge/files/proxy/nginx.conf

Lines changed: 59 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,16 @@
88
{{- $logLevel := $context.Values.proxy.logLevel -}}
99
{{- $maxFails := $context.Values.proxy.config.upstream.maxFails | default 1 -}}
1010
{{- $failTimeout := $context.Values.proxy.config.upstream.failTimeout | default "60s" -}}
11+
{{- $healthLoadBalancing := $context.Values.proxy.config.upstream.healthLoadBalancing -}}
1112
{{- $proxyTimeout := $context.Values.proxy.config.server.proxyTimeout | default "600s" -}}
1213
{{- $proxyConnectTimeout := $context.Values.proxy.config.server.proxyConnectTimeout | default "10s" -}}
14+
{{- $customDirectivesConfig := $context.Values.proxy.config.server.customDirectives | default list -}}
15+
{{- $downServers := $context.Values.proxy.config.upstream.downServers | default list -}}
16+
{{- $backupMode := $context.Values.proxy.config.upstream.backupMode | default false -}}
17+
18+
{{- $currentIndex := $index | int -}}
19+
{{- $healthProxyTimeout := "600s" -}}
20+
{{- $healthProxyConnectTimeout := "5s" -}}
1321

1422
load_module "/usr/lib/nginx/modules/ngx_stream_module.so";
1523

@@ -33,22 +41,66 @@ stream {
3341
resolver {{ printf "kube-dns.kube-system.svc.%s" $clusterDomain }} valid=30s;
3442
resolver_timeout 5s;
3543

36-
{{ range $tunnel, $config := $ports }}
44+
{{- range $tunnel, $config := $ports }}
3745
upstream {{ $tunnel }} {
38-
{{- range $idx := until ($context.Values.deploymentCount | int) }}
39-
{{- $indexProxyFullname := printf "%s-proxy-%d" $fullname ($idx | int) }}
40-
{{- $weight := ternary 100 1 (eq $idx $index) }}
41-
{{ printf "server %s:%d weight=%d max_fails=%v fail_timeout=%s;" (printf "%s.%s.svc.%s" $indexProxyFullname $releaseNamespace $clusterDomain) ($config.port | int) $weight $maxFails $failTimeout }}
46+
{{- if and (eq $tunnel "health") (not $healthLoadBalancing) }}
47+
{{- $indexProxyFullname := printf "%s-proxy-%d" $fullname $currentIndex }}
48+
{{- $isDown := false }}
49+
{{- range $downServers }}
50+
{{- if eq (. | int) ($currentIndex | int) }}
51+
{{- $isDown = true }}
52+
{{- end }}
53+
{{- end }}
54+
server {{ printf "%s.%s.svc.%s" $indexProxyFullname $releaseNamespace $clusterDomain }}:{{ $config.port }} max_fails={{ $maxFails }} fail_timeout={{ $failTimeout }}{{- if $isDown }} down{{- end }};
55+
{{- else }}
56+
{{- range $idx := until ($context.Values.deploymentCount | int) }}
57+
{{- $indexProxyFullname := printf "%s-proxy-%d" $fullname $idx }}
58+
{{- $isDown := false }}
59+
{{- range $downServers }}
60+
{{- if eq (. | int) ($idx | int) }}
61+
{{- $isDown = true }}
62+
{{- end }}
63+
{{- end }}
64+
{{- if $backupMode }}
65+
{{- if eq $idx $currentIndex }}
66+
server {{ printf "%s.%s.svc.%s" $indexProxyFullname $releaseNamespace $clusterDomain }}:{{ $config.port }} max_fails={{ $maxFails }} fail_timeout={{ $failTimeout }}{{- if $isDown }} down{{- end }};
67+
{{- else }}
68+
server {{ printf "%s.%s.svc.%s" $indexProxyFullname $releaseNamespace $clusterDomain }}:{{ $config.port }} max_fails={{ $maxFails }} fail_timeout={{ $failTimeout }}{{- if $isDown }} down{{- end }} backup;
69+
{{- end }}
70+
{{- else }}
71+
{{- $weight := ternary 100 1 (eq $idx $currentIndex) }}
72+
server {{ printf "%s.%s.svc.%s" $indexProxyFullname $releaseNamespace $clusterDomain }}:{{ $config.port }} weight={{ $weight }} max_fails={{ $maxFails }} fail_timeout={{ $failTimeout }}{{- if $isDown }} down{{- end }};
73+
{{- end }}
74+
{{- end }}
4275
{{- end }}
4376
}
44-
{{ end }}
77+
{{- end }}
4578

4679
{{ range $tunnel, $config := $ports }}
4780
server {
4881
listen {{ $config.containerPort }};
4982
proxy_pass {{ $tunnel }};
83+
{{- if eq $tunnel "health" }}
84+
proxy_timeout {{ $healthProxyTimeout }};
85+
proxy_connect_timeout {{ $healthProxyConnectTimeout }};
86+
{{- else }}
5087
proxy_timeout {{ $proxyTimeout }};
5188
proxy_connect_timeout {{ $proxyConnectTimeout }};
89+
{{- end }}
90+
{{- range $customDirectivesConfig }}
91+
{{- $applyTo := .applyTo }}
92+
{{- $shouldApply := false }}
93+
{{- if kindIs "slice" $applyTo }}
94+
{{- if has $tunnel $applyTo }}
95+
{{- $shouldApply = true }}
96+
{{- end }}
97+
{{- end }}
98+
{{- if $shouldApply }}
99+
{{- range .directives }}
100+
{{ . }}
101+
{{- end }}
102+
{{- end }}
103+
{{- end }}
52104
}
53-
{{ end }}
105+
{{- end }}
54106
}

helm/ggbridge/values.yaml

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ client:
300300
- -grace-period=60
301301
- http://127.0.0.1:9081/healthz
302302
initialDelaySeconds: 10
303-
periodSeconds: 6
303+
periodSeconds: 7
304304
timeoutSeconds: 5
305305
successThreshold: 1
306306
failureThreshold: 3
@@ -397,18 +397,38 @@ proxy:
397397

398398
# -- Nginx configuration
399399
config:
400-
# -- Nginx server configuration
400+
# -- Nginx server section configuration
401401
server:
402-
# -- Nginx proxy timeout for data exchange
403-
proxyTimeout: 600s
404-
# -- Nginx proxy timeout for TCP handshake
405-
proxyConnectTimeout: 10s
402+
# -- Nginx global proxy timeout
403+
proxyTimeout: 1800s
404+
# -- Nginx connection proxy timeout
405+
proxyConnectTimeout: 30s
406+
# -- custom parameters to add to the 'server' section of nginx.conf
407+
# you need to choose which section it applies to
408+
# can be "health", "socks", "web" or "tls"
409+
customDirectives: []
410+
# - directives:
411+
# - "proxy_responses 1;"
412+
# - "proxy_bind $remote_addr transparent;"
413+
# applyTo: ["health", "socks", "web", "tls"]
414+
# - directives:
415+
# - "proxy_protocol on;"
416+
# - "proxy_socket_keepalive on;"
417+
# applyTo: ["tls"]
418+
406419
# -- Nginx upstream configuration
407420
upstream:
408421
# -- Maximum number of unsuccessful attempts to communicate with the server
409-
maxFails: 1
422+
maxFails: 2
410423
# -- Time during which the specified number of unsuccessful attempts must happen to mark the server as unavailable
411-
failTimeout: 60s
424+
failTimeout: 120s
425+
# -- Enable load balancing for health upstream (when false, only use the server with weight 100)
426+
healthLoadBalancing: true
427+
# -- List of server proxy to disable in nginx conf
428+
# For example [1,2] will mark proxy-1 and proxy-2 as down
429+
downServers: []
430+
# -- Enable backup mode, will switch from round robin to backup setting for upstream servers
431+
backupMode: false
412432

413433
# -- Set the Proxy DNS resolver
414434
resolver: kube-dns.kube-system.svc.cluster.local
@@ -676,7 +696,7 @@ proxy:
676696
- -grace-period=60
677697
- http://127.0.0.1:9081/healthz
678698
initialDelaySeconds: 10
679-
periodSeconds: 6
699+
periodSeconds: 7
680700
timeoutSeconds: 5
681701
successThreshold: 1
682702
failureThreshold: 3

0 commit comments

Comments
 (0)