Skip to content

Commit 82c4bb6

Browse files
[nginx] add predefined configmaps (CloudPirates-io#154)
* add external configmaps * fix linting * Update CHANGELOG.md Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> --------- Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 18e3d95 commit 82c4bb6

File tree

8 files changed

+118
-44
lines changed

8 files changed

+118
-44
lines changed

charts/nginx/CHANGELOG.md

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,5 @@
11
# Changelog
22

3-
## 0.1.6 (2025-09-11)
3+
## 0.1.7 (2025-09-24)
44

5-
* [nginx]: Implement fix ([#79](https://github.com/CloudPirates-io/helm-charts/pull/79))
6-
7-
## <small>0.1.3 (2025-09-08)</small>
8-
9-
* add artifacthub-repo id ([ee4f192](https://github.com/CloudPirates-io/helm-charts/commit/ee4f192))
10-
* bump version to 0.1.2 ([f75a781](https://github.com/CloudPirates-io/helm-charts/commit/f75a781))
11-
* fix containerport and change ingress host-pathtype ([60e3223](https://github.com/CloudPirates-io/helm-charts/commit/60e3223))
12-
* Update appVersion ([933ba01](https://github.com/CloudPirates-io/helm-charts/commit/933ba01))
13-
* update chart-icon ([7ed7c8e](https://github.com/CloudPirates-io/helm-charts/commit/7ed7c8e))
14-
* add hpa feature ([e5eab56](https://github.com/CloudPirates-io/helm-charts/commit/e5eab56))
15-
* Bump nginx to latest version + alpine ([8b0fc57](https://github.com/CloudPirates-io/helm-charts/commit/8b0fc57))
16-
* fix linting ([11d72e9](https://github.com/CloudPirates-io/helm-charts/commit/11d72e9))
17-
* Initial commit to add Nginx ([1579cc4](https://github.com/CloudPirates-io/helm-charts/commit/1579cc4))
18-
* make nginx work ([097d204](https://github.com/CloudPirates-io/helm-charts/commit/097d204))
19-
* Update CHANGELOG.md ([d0f0153](https://github.com/CloudPirates-io/helm-charts/commit/d0f0153))
20-
* Update CHANGELOG.md ([4ff2bbc](https://github.com/CloudPirates-io/helm-charts/commit/4ff2bbc))
21-
* Update CHANGELOG.md ([a13f40d](https://github.com/CloudPirates-io/helm-charts/commit/a13f40d))
22-
* Update CHANGELOG.md ([19e5317](https://github.com/CloudPirates-io/helm-charts/commit/19e5317))
23-
* Update readme ([e09a5a3](https://github.com/CloudPirates-io/helm-charts/commit/e09a5a3))
5+
* [nginx] add external configmaps ([#5](https://github.com/mmz-srf/cloudpirates-helm-charts/pull/5))

charts/nginx/Chart.yaml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,23 @@ apiVersion: v2
22
name: nginx
33
description: Nginx is a high-performance HTTP server and reverse proxy.
44
type: application
5-
6-
version: 0.1.6
5+
version: 0.1.7
76
appVersion: "1.29.1"
8-
97
keywords:
108
- nginx
119
- web server
1210
- http
1311
- reverse proxy
1412
- load balancer
1513
- proxy
16-
1714
home: https://www.cloudpirates.io
18-
1915
sources:
2016
- https://github.com/CloudPirates-io/helm-charts/tree/main/charts/nginx
21-
2217
maintainers:
2318
- name: CloudPirates GmbH & Co. KG
2419
url: https://www.cloudpirates.io
25-
2620
dependencies:
2721
- name: common
2822
version: "1.x.x"
2923
repository: oci://registry-1.docker.io/cloudpirates
30-
3124
icon: https://a.storyblok.com/f/143071/512x512/9fcd98c061/nginx-logo.svg

charts/nginx/README.md

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,45 @@ The following table lists the configurable parameters of the Nginx chart and the
139139

140140
### Nginx Configuration Parameters
141141

142-
| Parameter | Description | Default |
143-
| --------------------- | --------------------------------------------------------- | ------- |
144-
| `config` | Custom NGINX configuration file (nginx.conf) | `""` |
145-
| `serverConfig` | Custom server block to be added to NGINX configuration | `""` |
146-
| `streamServerConfig` | Custom stream server block to be added to NGINX config | `""` |
147-
142+
Existing Configmaps are prioritized over inline configuration. Inline configuration will trigger a pod restart if changed.
143+
144+
| Parameter | Description | Default |
145+
| ------------------------------------- | ----------------------------------------------------------- | ------- |
146+
| `config` | Custom NGINX configuration file (nginx.conf) | `""` |
147+
| `existingConfigConfigmap` | Name of an existing ConfigMap containing nginx.conf | `""` |
148+
| `serverConfig` | Custom server block to be added to NGINX configuration | `""` |
149+
| `existingServerConfigConfigmap` | Name of an existing ConfigMap containing server-config.conf | `""` |
150+
| `streamServerConfig` | Custom stream server block to be added to NGINX config | `""` |
151+
| `existingStreamServerConfigConfigmap` | Name of an existing ConfigMap containing stream-server-config.conf | `""` |
152+
153+
Example of an existing external `config`:
154+
```yaml
155+
apiVersion: v1
156+
kind: ConfigMap
157+
metadata:
158+
name: example-nginx-config
159+
data:
160+
nginx.conf: |-
161+
user nginx;
162+
worker_processes 1;
163+
error_log /var/log/nginx/error.log warn;
164+
pid /run/nginx.pid;
165+
166+
events {
167+
worker_connections 1024;
168+
}
169+
http {
170+
include /etc/nginx/mime.types;
171+
default_type application/octet-stream;
172+
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
173+
'$status $body_bytes_sent "$http_referer" '
174+
'"$http_user_agent" "$http_x_forwarded_for"';
175+
access_log /var/log/nginx/access.log main;
176+
sendfile on;
177+
keepalive_timeout 65;
178+
include /etc/nginx/conf.d/*.conf;
179+
}
180+
```
148181

149182
### Container Port Parameters
150183

charts/nginx/templates/_helpers.tpl

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,38 @@ Create the name of the service account to use
6363
{{- else }}
6464
{{- default "default" .Values.serviceAccount.name }}
6565
{{- end }}
66-
{{- end }}
66+
{{- end }}
67+
68+
69+
{{/*
70+
Return the custom NGINX config configmap.
71+
*/}}
72+
{{- define "nginx.configConfigmapName" -}}
73+
{{- if .Values.existingConfigConfigmap -}}
74+
{{- printf "%s" (tpl .Values.existingConfigConfigmap $) -}}
75+
{{- else -}}
76+
{{- include "common.fullname" . -}}
77+
{{- end -}}
78+
{{- end -}}
79+
80+
{{/*
81+
Return the custom NGINX server config configmap.
82+
*/}}
83+
{{- define "nginx.serverConfigConfigmapName" -}}
84+
{{- if .Values.existingServerConfigConfigmap -}}
85+
{{- printf "%s" (tpl .Values.existingServerConfigConfigmap $) -}}
86+
{{- else -}}
87+
{{- include "common.fullname" . -}}
88+
{{- end -}}
89+
{{- end -}}
90+
91+
{{/*
92+
Return the custom NGINX stream server config configmap.
93+
*/}}
94+
{{- define "nginx.streamServerConfigConfigmapName" -}}
95+
{{- if .Values.existingStreamServerConfigConfigmap -}}
96+
{{- printf "%s" (tpl .Values.existingStreamServerConfigConfigmap $) -}}
97+
{{- else -}}
98+
{{- include "common.fullname" . -}}
99+
{{- end -}}
100+
{{- end -}}

charts/nginx/templates/configmap.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if or .Values.serverConfig .Values.streamServerConfig }}
1+
{{- if or .Values.config .Values.serverConfig .Values.streamServerConfig }}
22
apiVersion: v1
33
kind: ConfigMap
44
metadata:

charts/nginx/templates/deployment.yaml

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,19 @@ spec:
148148
- name: static-site
149149
mountPath: /usr/share/nginx/html
150150
{{- end }}
151-
{{- if .Values.config }}
151+
{{- if or .Values.config .Values.existingConfigConfigmap }}
152152
- name: nginx-config
153-
mountPath: /etc/nginx/conf.d
153+
mountPath: /etc/nginx/nginx.conf
154+
subPath: nginx.conf
154155
{{- end }}
155-
{{- if or .Values.serverConfig .Values.streamServerConfig }}
156+
{{- if or .Values.serverConfig .Values.existingServerConfigConfigmap }}
156157
- name: nginx-server-config
157158
mountPath: /etc/nginx/conf.d
158159
{{- end }}
160+
{{- if or .Values.streamServerConfig .Values.existingStreamServerConfigConfigmap }}
161+
- name: stream-server-config
162+
mountPath: /etc/nginx/conf.d
163+
{{- end }}
159164
{{- if .Values.extraVolumeMounts }}
160165
{{- toYaml .Values.extraVolumeMounts | nindent 12 }}
161166
{{- end }}
@@ -220,15 +225,29 @@ spec:
220225
path: stream-server-config.conf
221226
{{- end }}
222227
{{- end }}
223-
{{- if or .Values.serverConfig .Values.streamServerConfig }}
228+
{{- if or .Values.config .Values.existingConfigConfigmap }}
224229
- name: nginx-config
225230
configMap:
226-
name: {{ include "nginx.fullname" . }}
227-
{{- if .Values.serverConfig }}
231+
name: {{ include "nginx.configConfigmapName" . }}
228232
items:
229233
- key: nginx.conf
230234
path: nginx.conf
231-
{{- end }}
235+
{{- end }}
236+
{{- if or .Values.serverConfig .Values.existingServerConfigConfigmap }}
237+
- name: server-config
238+
configMap:
239+
name: {{ include "nginx.serverConfigConfigmapName" . }}
240+
items:
241+
- key: server-config.conf
242+
path: server-config.conf
243+
{{- end }}
244+
{{- if or .Values.streamServerConfig .Values.existingStreamServerConfigConfigmap }}
245+
- name: stream-server-config
246+
configMap:
247+
name: {{ include "nginx.streamServerConfigConfigmapName" . }}
248+
items:
249+
- key: stream-server-config.conf
250+
path: stream-server-config.conf
232251
{{- end }}
233252
{{- if .Values.extraVolumes }}
234253
{{- toYaml .Values.extraVolumes | nindent 8 }}

charts/nginx/values.schema.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,10 @@
184184
"extraVolumeMounts": { "type": "array", "items": { "type": "object" } },
185185
"extraObjects": { "type": "array", "items": { "type": "object" } },
186186
"config": { "type": "string" },
187+
"existingConfigConfigmap": { "type": "string" },
187188
"serverConfig": { "type": "string" },
188-
"streamServerConfig": { "type": "string" }
189+
"existingServerConfigConfigmap": { "type": "string" },
190+
"streamServerConfig": { "type": "string" },
191+
"existingStreamServerConfigmap": { "type": "string" }
189192
}
190193
}

charts/nginx/values.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,9 @@ extraObjects: []
258258
##
259259
config: ""
260260

261+
## @param existingConfigConfigmap Name of an existing ConfigMap containing nginx.conf
262+
existingConfigConfigmap: ""
263+
261264
## @param serverConfig Custom server block to be added to NGINX configuration
262265
## PHP-FPM example server block:
263266
## serverConfig: |-
@@ -275,6 +278,10 @@ config: ""
275278
## }
276279
##
277280
serverConfig: ""
281+
282+
## @param existingServerConfigConfigmap Name of an existing ConfigMap containing server-config.conf
283+
existingServerConfigConfigmap: ""
284+
278285
## @param streamServerConfig Custom stream server block to be added to NGINX configuration
279286
## streamServerConfig: |-
280287
## server {
@@ -283,3 +290,6 @@ serverConfig: ""
283290
## }
284291
##
285292
streamServerConfig: ""
293+
294+
## @param existingStreamServerConfigmap Name of an existing ConfigMap containing stream-server-config.conf
295+
existingStreamServerConfigConfigmap: ""

0 commit comments

Comments
 (0)