Skip to content

Commit d4c5ca7

Browse files
authored
Merge pull request #199 from LeoColomb/fix/values
Reorder values and their documentation
2 parents abf7e68 + 35c899c commit d4c5ca7

File tree

11 files changed

+886
-429
lines changed

11 files changed

+886
-429
lines changed

README.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ for further information.
9696

9797
* NetBox has been updated to 3.6.4, but older 3.5+ versions should still work (this is not tested or supported, however).
9898
* **Potentially breaking changes:**
99+
* The `extraContainers` setting has been renamed `sidecars` to match conventions.
100+
* The `extraInitContainers` setting has been renamed `initContainers` to match conventions.
101+
* The `metricsEnabled` setting has been renamed `metrics.enabled` to match conventions.
102+
* The `serviceMonitor` setting has been moved to `metrics.serviceMonitor` to match conventions.
99103
* The `jobResultRetention` setting has been renamed `jobRetention` to match the change in NetBox 3.5.
100104
* The `remoteAuth.backend` setting has been renamed `remoteAuth.backends` and is now an array.
101105
* The `remoteAuth.autoCreateUser` setting now defaults to `false`.
@@ -201,7 +205,6 @@ The following table lists the configurable parameters for this chart and their d
201205
| `maxPageSize` | Maximum number of objects that can be returned by a single API call | `1000` |
202206
| `storageBackend` | Django-storages backend class name | `null` |
203207
| `storageConfig` | Django-storages backend configuration | `{}` |
204-
| `metricsEnabled` | Expose Prometheus metrics at the `/metrics` HTTP endpoint | `false` |
205208
| `paginateCount` | The default number of objects to display per page in the web UI | `50` |
206209
| `plugins` | Additional plugins to load into NetBox | `[]` |
207210
| `pluginsConfig` | Configuration for the additional plugins | `{}` |
@@ -256,10 +259,11 @@ The following table lists the configurable parameters for this chart and their d
256259
| `dateFormat` | Django date format for long-form date strings | `"N j, Y"` |
257260
| `shortDateFormat` | Django date format for short-form date strings | `"Y-m-d"` |
258261
| `timeFormat` | Django date format for long-form time strings | `"g:i a"` |
259-
| `serviceMonitor.enabled` | Whether to enable a [ServiceMonitor](https://prometheus-operator.dev/docs/operator/design/#servicemonitor) for Netbox | `false` |
260-
| `serviceMonitor.additionalLabels` | Additonal labels to apply to the ServiceMonitor | `{}` |
261-
| `serviceMonitor.interval` | Interval to scrape metrics. | `1m` |
262-
| `serviceMonitor.scrapeTimeout` | Timeout duration for scraping metrics | `10s` |
262+
| `metrics.enabled` | Expose Prometheus metrics at the `/metrics` HTTP endpoint | `false` |
263+
| `metrics.serviceMonitor.enabled` | Whether to enable a [ServiceMonitor](https://prometheus-operator.dev/docs/operator/design/#servicemonitor) for Netbox | `false` |
264+
| `metrics.serviceMonitor.additionalLabels` | Additonal labels to apply to the ServiceMonitor | `{}` |
265+
| `metrics.serviceMonitor.interval` | Interval to scrape metrics. | `1m` |
266+
| `metrics.serviceMonitor.scrapeTimeout` | Timeout duration for scraping metrics | `10s` |
263267
| `shortTimeFormat` | Django date format for short-form time strings | `"H:i:s"` |
264268
| `dateTimeFormat` | Django date format for long-form date and time strings | `"N j, Y g:i a"` |
265269
| `shortDateTimeFormat` | Django date format for short-form date and time strongs | `"Y-m-d H:i"` |
@@ -376,8 +380,8 @@ The following table lists the configurable parameters for this chart and their d
376380
| `extraEnvs` | Additional environment variables to set in the NetBox container | `[]` |
377381
| `extraVolumeMounts` | Additional volumes to mount in the NetBox container | `[]` |
378382
| `extraVolumes` | Additional volumes to reference in pods | `[]` |
379-
| `extraContainers` | Additional sidecar containers to be added to pods | `[]` |
380-
| `extraInitContainers` | Additional init containers to run before starting main containers | `[]` |
383+
| `sidecars` | Additional sidecar containers to be added to pods | `[]` |
384+
| `initContainers` | Additional init containers to run before starting main containers | `[]` |
381385
| `worker` | Worker specific variables. Most global variables also apply here. | *see `values.yaml`* |
382386
| `housekeeping.enabled` | Whether the [Housekeeping][housekeeping] `CronJob` should be active | `true` |
383387
| `housekeeping.concurrencyPolicy` | ConcurrencyPolicy for the Housekeeping CronJob. | `Forbid` |
@@ -398,8 +402,8 @@ The following table lists the configurable parameters for this chart and their d
398402
| `housekeeping.extraEnvs` | Additional environment variables to set in housekeeping CronJob | `[]` |
399403
| `housekeeping.extraVolumeMounts` | Additional volumes to mount in the housekeeping CronJob | `[]` |
400404
| `housekeeping.extraVolumes` | Additional volumes to reference in housekeeping CronJob pods | `[]` |
401-
| `housekeeping.extraContainers` | Additional sidecar containers to be added to housekeeping CronJob | `[]` |
402-
| `housekeeping.extraInitContainers` | Additional init containers for housekeeping CronJob pods | `[]` |
405+
| `housekeeping.sidecars` | Additional sidecar containers to be added to housekeeping CronJob | `[]` |
406+
| `housekeeping.initContainers` | Additional init containers for housekeeping CronJob pods | `[]` |
403407

404408
[netbox-docker startup scripts]: https://github.com/netbox-community/netbox-docker/tree/master/startup_scripts
405409
[CORS]: https://github.com/ottoyiu/django-cors-headers

charts/netbox/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
apiVersion: v2
22
name: netbox
3-
version: 5.0.0-beta5
3+
version: 5.0.0-beta6
44
appVersion: "v3.7.8"
55
type: application
66
kubeVersion: ^1.25.0-0

charts/netbox/templates/_helpers.tpl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ Return the proper image name
1212
{{- include "common.images.image" (dict "imageRoot" $imageRoot "global" .Values.global) -}}
1313
{{- end -}}
1414

15+
{{/*
16+
Return the proper image name (for the init container image)
17+
*/}}
18+
{{- define "netbox.init.image" -}}
19+
{{- include "common.images.image" (dict "imageRoot" .Values.init.image "global" .Values.global) -}}
20+
{{- end -}}
21+
1522
{{/*
1623
Create the name of the service account to use
1724
*/}}

charts/netbox/templates/configmap.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ data:
145145
STORAGE_BACKEND: {{ .Values.storageBackend | quote }}
146146
STORAGE_CONFIG: {{ toJson .Values.storageConfig }}
147147
{{- end }}
148-
METRICS_ENABLED: {{ toJson .Values.metricsEnabled }}
148+
METRICS_ENABLED: {{ toJson .Values.metrics.enabled }}
149149
PAGINATE_COUNT: {{ int .Values.paginateCount }}
150150
PLUGINS: {{ toJson .Values.plugins }}
151151
PLUGINS_CONFIG: {{ toJson .Values.pluginsConfig }}

charts/netbox/templates/cronjob.yaml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,20 @@ spec:
3333
{{- toYaml . | nindent 12 }}
3434
{{- end }}
3535
spec:
36-
{{- with .Values.imagePullSecrets }}
37-
imagePullSecrets:
38-
{{- toYaml . | nindent 10 }}
39-
{{- end }}
36+
{{- include "common.images.renderPullSecrets" (dict "images" (list .Values.image) "context" $) | nindent 6 }}
4037
serviceAccountName: {{ include "netbox.serviceAccountName" . }}
4138
automountServiceAccountToken: {{ .Values.housekeeping.automountServiceAccountToken }}
4239
securityContext:
4340
{{- toYaml .Values.housekeeping.podSecurityContext | nindent 12 }}
44-
{{- with .Values.housekeeping.extraInitContainers }}
41+
{{- with .Values.housekeeping.initContainers }}
4542
initContainers:
4643
{{- toYaml . | nindent 10 }}
4744
{{- end }}
4845
containers:
4946
- name: {{ .Chart.Name }}-housekeeping
5047
securityContext:
5148
{{- toYaml .Values.housekeeping.securityContext | nindent 14 }}
52-
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
49+
image: {{ include "netbox.image" . | quote }}
5350
command:
5451
- /opt/netbox/venv/bin/python
5552
- /opt/netbox/netbox/manage.py
@@ -91,10 +88,11 @@ spec:
9188
{{- toYaml . | nindent 12 }}
9289
{{- end }}
9390
{{- if .Values.housekeeping.resources }}
94-
resources:
95-
{{- toYaml .Values.housekeeping.resources | nindent 14 }}
91+
resources: {{ toYaml .Values.housekeeping.resources | nindent 14 }}
92+
{{- else if ne .Values.housekeeping.resourcesPreset "none" }}
93+
resources: {{- include "common.resources.preset" (dict "type" .Values.housekeeping.resourcesPreset) | nindent 14 }}
9694
{{- end }}
97-
{{- with .Values.housekeeping.extraContainers }}
95+
{{- with .Values.housekeeping.sidecars }}
9896
{{- toYaml . | nindent 10 }}
9997
{{- end }}
10098
volumes:

charts/netbox/templates/deployment.yaml

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -37,35 +37,34 @@ spec:
3737
{{- toYaml . | nindent 8 }}
3838
{{- end }}
3939
spec:
40-
{{- with .Values.imagePullSecrets }}
41-
imagePullSecrets:
42-
{{- toYaml . | nindent 6 }}
43-
{{- end }}
40+
{{- include "common.images.renderPullSecrets" (dict "images" (list .Values.image) "context" $) | nindent 6 }}
4441
serviceAccountName: {{ include "netbox.serviceAccountName" . }}
4542
automountServiceAccountToken: {{ .Values.automountServiceAccountToken }}
46-
securityContext:
47-
{{- toYaml .Values.podSecurityContext | nindent 8 }}
43+
{{- if .Values.podSecurityContext.enabled }}
44+
securityContext: {{- omit .Values.podSecurityContext "enabled" | toYaml | nindent 8 }}
45+
{{- end }}
4846
initContainers:
4947
- name: init-dirs
50-
image: "{{ .Values.init.image.repository }}:{{ .Values.init.image.tag }}"
51-
imagePullPolicy: {{ .Values.init.image.pullPolicy }}
48+
image: {{ include "netbox.init.image" . | quote }}
49+
imagePullPolicy: {{ .Values.init.image.pullPolicy | quote }}
5250
command: [/bin/sh, -c, mkdir -p /opt/unit/state /opt/unit/tmp]
5351
{{- if .Values.init.resources }}
54-
resources:
55-
{{- toYaml .Values.init.resources | nindent 10 }}
52+
resources: {{- toYaml .Values.init.resources | nindent 11 }}
53+
{{- else if ne .Values.init.resourcesPreset "none" }}
54+
resources: {{- include "common.resources.preset" (dict "type" .Values.init.resourcesPreset) | nindent 10 }}
5655
{{- end }}
57-
securityContext:
58-
{{- toYaml .Values.init.securityContext | nindent 10 }}
56+
securityContext: {{- .Values.init.securityContext | toYaml | nindent 10 }}
5957
volumeMounts:
6058
- name: optunit
6159
mountPath: /opt/unit
62-
{{- with .Values.extraInitContainers }}
63-
{{- toYaml . | nindent 6 }}
60+
{{- if .Values.initContainers }}
61+
{{- include "common.tplvalues.render" (dict "value" .Values.initContainers "context" $) | trim | nindent 6 }}
6462
{{- end }}
6563
containers:
6664
- name: {{ .Chart.Name }}
67-
securityContext:
68-
{{- toYaml .Values.securityContext | nindent 10 }}
65+
{{- if .Values.securityContext.enabled }}
66+
securityContext: {{- omit .Values.securityContext "enabled" | toYaml | nindent 12 }}
67+
{{- end }}
6968
image: {{ include "netbox.image" . | quote }}
7069
imagePullPolicy: {{ .Values.image.pullPolicy }}
7170
env:
@@ -150,14 +149,15 @@ spec:
150149
mountPath: /run/secrets/superuser_api_token
151150
subPath: superuser_api_token
152151
readOnly: true
153-
{{- with .Values.extraVolumeMounts }}
154-
{{- toYaml . | nindent 8 }}
152+
{{- if .Values.extraVolumeMounts }}
153+
{{- include "common.tplvalues.render" (dict "value" .Values.extraVolumeMounts "context" $) | nindent 10 }}
155154
{{- end }}
156155
{{- if .Values.resources }}
157-
resources:
158-
{{- toYaml .Values.resources | nindent 10 }}
156+
resources: {{ toYaml .Values.resources | nindent 12 }}
157+
{{- else if ne .Values.resourcesPreset "none" }}
158+
resources: {{- include "common.resources.preset" (dict "type" .Values.resourcesPreset) | nindent 10 }}
159159
{{- end }}
160-
{{- with .Values.extraContainers }}
160+
{{- with .Values.sidecars }}
161161
{{- toYaml . | nindent 6 }}
162162
{{- end }}
163163
volumes:

charts/netbox/templates/service.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ spec:
3232
externalIPs:
3333
{{- toYaml . | nindent 2 }}
3434
{{- end }}
35-
{{- if .Values.service.externalTrafficPolicy }}
35+
{{- if (or (eq .Values.service.type "LoadBalancer") (eq .Values.service.type "NodePort")) }}
3636
externalTrafficPolicy: {{ .Values.service.externalTrafficPolicy | quote }}
3737
{{- end }}
3838
{{- if .Values.service.ipFamilyPolicy }}

charts/netbox/templates/serviceaccount.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,4 @@ metadata:
1010
{{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.serviceAccount.annotations .Values.commonAnnotations ) "context" . ) }}
1111
annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $) | nindent 4 }}
1212
{{- end }}
13-
{{- with .Values.serviceAccount.imagePullSecrets }}
14-
imagePullSecrets:
15-
{{- toYaml . | nindent 2 }}
16-
{{- end }}
1713
{{- end }}
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
{{- if and .Values.metricsEnabled .Values.serviceMonitor.enabled -}}
1+
{{- if and .Values.metrics.enabled .Values.metrics.serviceMonitor.enabled }}
22
apiVersion: monitoring.coreos.com/v1
33
kind: ServiceMonitor
44
metadata:
55
name: {{ include "common.names.fullname" . }}
66
namespace: {{ include "common.names.namespace" . | quote }}
7-
{{- $labels := include "common.tplvalues.merge" ( dict "values" ( list .Values.serviceMonitor.additionalLabels .Values.commonLabels ) "context" . ) }}
7+
{{- $labels := include "common.tplvalues.merge" ( dict "values" ( list .Values.metrics.serviceMonitor.additionalLabels .Values.commonLabels ) "context" . ) }}
88
labels: {{- include "common.labels.standard" ( dict "customLabels" $labels "context" $ ) | nindent 4 }}
99
{{- if .Values.commonAnnotations }}
1010
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
@@ -19,11 +19,11 @@ spec:
1919
{{- include "common.labels.matchLabels" . | nindent 6 }}
2020
endpoints:
2121
- port: http
22-
path: /metrics
23-
{{- with .Values.serviceMonitor.interval }}
24-
interval: {{ . }}
22+
path: "/metrics"
23+
{{- if .Values.metrics.serviceMonitor.interval }}
24+
interval: {{ .Values.metrics.serviceMonitor.interval }}
2525
{{- end }}
26-
{{- with .Values.serviceMonitor.scrapeTimeout }}
27-
scrapeTimeout: {{ . }}
26+
{{- if .Values.metrics.serviceMonitor.scrapeTimeout }}
27+
scrapeTimeout: {{ .Values.metrics.serviceMonitor.scrapeTimeout }}
2828
{{- end }}
2929
{{- end }}

charts/netbox/templates/worker-deployment.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ spec:
4646
automountServiceAccountToken: {{ .Values.worker.automountServiceAccountToken }}
4747
securityContext:
4848
{{- toYaml .Values.worker.podSecurityContext | nindent 8 }}
49-
{{- with .Values.worker.extraInitContainers }}
49+
{{- with .Values.worker.initContainers }}
5050
initContainers:
5151
{{- toYaml . | nindent 6 }}
5252
{{- end }}
@@ -96,10 +96,11 @@ spec:
9696
{{- toYaml . | nindent 8 }}
9797
{{- end }}
9898
{{- if .Values.worker.resources }}
99-
resources:
100-
{{- toYaml .Values.worker.resources | nindent 10 }}
99+
resources: {{ toYaml .Values.worker.resources | nindent 10 }}
100+
{{- else if ne .Values.worker.resourcesPreset "none" }}
101+
resources: {{- include "common.resources.preset" (dict "type" .Values.worker.resourcesPreset) | nindent 10 }}
101102
{{- end }}
102-
{{- with .Values.worker.extraContainers }}
103+
{{- with .Values.worker.sidecars }}
103104
{{- toYaml . | nindent 6 }}
104105
{{- end }}
105106
volumes:

0 commit comments

Comments
 (0)