Skip to content

Commit 673e198

Browse files
authored
Support customizing the nginx config with values (grafana#213)
Signed-off-by: Tom Hayward <[email protected]>
1 parent 76f2d3c commit 673e198

File tree

5 files changed

+29
-0
lines changed

5 files changed

+29
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* [FEATURE] Add autoscaler for queriers #190
77
* [FEATURE] Add autoscaler for distributors #189
88
* [FEATURE] Add autoscaler for ingesters #182
9+
* [ENHANCEMENT] Support customizing the nginx config with values #213
910
* [ENHANCEMENT] Upgrade to Cortex v1.10.0 #204
1011
* [ENHANCEMENT] Populate config.querier.store_gateway_addresses automatically based on other config #201
1112
* [ENHANCEMENT] Graceful shutdown of ingesters #195

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,9 @@ Kubernetes: `^1.19.0-0`
591591
| nginx.&ZeroWidthSpace;config.&ZeroWidthSpace;basicAuthSecretName | string | `""` | (optional) Name of basic auth secret. In order to use this option, a secret with htpasswd formatted contents at the key ".htpasswd" must exist. For example: apiVersion: v1 kind: Secret metadata: name: my-secret namespace: <same as cortex installation> stringData: .htpasswd: | user1:$apr1$/woC1jnP$KAh0SsVn5qeSMjTtn0E9Q0 user2:$apr1$QdR8fNLT$vbCEEzDj7LyqCMyNpSoBh/ Please note that the use of basic auth will not identify organizations the way X-Scope-OrgID does. Thus, the use of basic auth alone will not prevent one tenant from viewing the metrics of another. To ensure tenants are scoped appropriately, explicitly set the `X-Scope-OrgID` header in the nginx config. Example setHeaders: X-Scope-Org-Id: $remote_user |
592592
| nginx.&ZeroWidthSpace;config.&ZeroWidthSpace;client_max_body_size | string | `"1M"` | |
593593
| nginx.&ZeroWidthSpace;config.&ZeroWidthSpace;dnsResolver | string | `"kube-dns.kube-system.svc.cluster.local"` | |
594+
| nginx.&ZeroWidthSpace;config.&ZeroWidthSpace;httpSnippet | string | `""` | arbitrary snippet to inject in the http { } section of the nginx config |
595+
| nginx.&ZeroWidthSpace;config.&ZeroWidthSpace;mainSnippet | string | `""` | arbitrary snippet to inject in the top section of the nginx config |
596+
| nginx.&ZeroWidthSpace;config.&ZeroWidthSpace;serverSnippet | string | `""` | arbitrary snippet to inject in the server { } section of the nginx config |
594597
| nginx.&ZeroWidthSpace;config.&ZeroWidthSpace;setHeaders | object | `{}` | |
595598
| nginx.&ZeroWidthSpace;containerSecurityContext.&ZeroWidthSpace;enabled | bool | `true` | |
596599
| nginx.&ZeroWidthSpace;containerSecurityContext.&ZeroWidthSpace;readOnlyRootFilesystem | bool | `false` | |

ci/test-values.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ querier:
6969
enabled: true
7070
nginx:
7171
replicas: 1
72+
config:
73+
httpSnippet: |-
74+
# http snippet
75+
mainSnippet: |-
76+
# main snippet
77+
serverSnippet: |-
78+
# server snippet
7279
runtimeconfigmap:
7380
annotations:
7481
foo: bar

templates/nginx/nginx-config.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ data:
1818
worker_connections 4096; ## Default: 1024
1919
}
2020
21+
{{- with .Values.nginx.config.mainSnippet }}
22+
{{ tpl . $ | nindent 4 }}
23+
{{- end }}
24+
2125
http {
2226
default_type application/octet-stream;
2327
client_max_body_size {{.Values.nginx.config.client_max_body_size}};
@@ -29,6 +33,10 @@ data:
2933
tcp_nopush on;
3034
resolver {{ default (printf "kube-dns.kube-system.svc.%s" .Values.clusterDomain ) .Values.nginx.config.dnsResolver }};
3135
36+
{{- with .Values.nginx.config.httpSnippet }}
37+
{{ tpl . $ | nindent 6 }}
38+
{{- end }}
39+
3240
server { # simple reverse-proxy
3341
listen {{ .Values.nginx.http_listen_port }};
3442
proxy_connect_timeout 300s;
@@ -45,6 +53,10 @@ data:
4553
auth_basic_user_file /etc/apache2/.htpasswd;
4654
{{- end }}
4755
56+
{{- with .Values.nginx.config.serverSnippet }}
57+
{{ tpl . $ | nindent 8 }}
58+
{{- end }}
59+
4860
location = /healthz {
4961
# auth_basic off is not set here, even when a basic auth directive is
5062
# included in the server block, as Nginx's NGX_HTTP_REWRITE_PHASE

values.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,6 +1162,12 @@ nginx:
11621162
dnsResolver: kube-dns.kube-system.svc.cluster.local
11631163
## ref: http://nginx.org/en/docs/http/ngx_http_core_module.html#client_max_body_size
11641164
client_max_body_size: 1M
1165+
# -- arbitrary snippet to inject in the http { } section of the nginx config
1166+
httpSnippet: ""
1167+
# -- arbitrary snippet to inject in the top section of the nginx config
1168+
mainSnippet: ""
1169+
# -- arbitrary snippet to inject in the server { } section of the nginx config
1170+
serverSnippet: ""
11651171
setHeaders: {}
11661172
# -- (optional) List of [auth tenants](https://cortexmetrics.io/docs/guides/auth/) to set in the nginx config
11671173
auth_orgs: []

0 commit comments

Comments
 (0)