Skip to content

Commit

Permalink
Merge pull request #364 from netbox-community/feat/structure
Browse files Browse the repository at this point in the history
  • Loading branch information
RangerRick authored Oct 2, 2024
2 parents a99b177 + 1ef8383 commit c112bd5
Show file tree
Hide file tree
Showing 18 changed files with 171 additions and 202 deletions.
2 changes: 1 addition & 1 deletion charts/netbox/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: netbox
version: 5.0.0-beta.112
version: 5.0.0-beta.113
appVersion: "v4.1.2"
type: application
kubeVersion: ^1.25.0-0
Expand Down
2 changes: 1 addition & 1 deletion charts/netbox/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ To access Netbox site from outside the cluster follow the steps below.

You have configured NetBox to use an ingress controller, exposing the following URL(s):

{{ range $host := .Values.ingress.hosts }}
{{- range $host := .Values.ingress.hosts }}
{{- range .paths }}
- http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }}
{{- end }}
Expand Down
4 changes: 2 additions & 2 deletions charts/netbox/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ Volumes that need to be mounted for .Values.extraConfig entries
secret:
{{- toYaml $config.secret | nindent 4 }}
{{- end }}
{{ end -}}
{{- end }}
{{- end }}

{{/*
Expand All @@ -127,7 +127,7 @@ Volume mounts for .Values.extraConfig entries
- name: extra-config-{{ $index }}
mountPath: /run/config/extra/{{ $index }}
readOnly: true
{{ end -}}
{{- end }}
{{- end }}

{{/*
Expand Down
61 changes: 29 additions & 32 deletions charts/netbox/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ data:
ALLOWED_HOSTS_INCLUDES_POD_ID: {{ .Values.allowedHostsIncludesPodIP }}
DATABASE:
{{ if .Values.postgresql.enabled -}}
{{- if .Values.postgresql.enabled }}
HOST: {{ include "postgresql.v1.primary.fullname" .Subcharts.postgresql | quote }}
USER: {{ include "postgresql.v1.username" .Subcharts.postgresql | quote }}
NAME: {{ include "postgresql.v1.database" .Subcharts.postgresql | quote }}
Expand Down Expand Up @@ -163,55 +163,52 @@ data:
DATETIME_FORMAT: {{ .Values.dateTimeFormat | quote }}
SHORT_DATETIME_FORMAT: {{ .Values.shortDateTimeFormat | quote }}
{{- range .Values.remoteAuth.backends }}
{{- if eq . "netbox.authentication.LDAPBackend" }}

{{- if has "netbox.authentication.LDAPBackend" .Values.remoteAuth.backends }}
ldap_config.py: |-
{{ $.Files.Get "files/ldap_config.py" | nindent 4 }}
{{ .Files.Get "files/ldap_config.py" | nindent 4 }}
ldap.yaml: |-
AUTH_LDAP_SERVER_URI: {{ $.Values.remoteAuth.ldap.serverUri | quote }}
AUTH_LDAP_BIND_DN: {{ $.Values.remoteAuth.ldap.bindDn | quote }}
AUTH_LDAP_START_TLS: {{ toJson $.Values.remoteAuth.ldap.startTls }}
LDAP_IGNORE_CERT_ERRORS: {{ toJson $.Values.remoteAuth.ldap.ignoreCertErrors }}
{{- if $.Values.remoteAuth.ldap.caCertData }}
AUTH_LDAP_SERVER_URI: {{ .Values.remoteAuth.ldap.serverUri | quote }}
AUTH_LDAP_BIND_DN: {{ .Values.remoteAuth.ldap.bindDn | quote }}
AUTH_LDAP_START_TLS: {{ toJson .Values.remoteAuth.ldap.startTls }}
LDAP_IGNORE_CERT_ERRORS: {{ toJson .Values.remoteAuth.ldap.ignoreCertErrors }}
{{- if .Values.remoteAuth.ldap.caCertData }}
LDAP_CA_CERT_FILE: /etc/netbox/config/ldap/ldap_ca.crt
{{- end }}
AUTH_LDAP_USER_DN_TEMPLATE: {{ default nil $.Values.remoteAuth.ldap.userDnTemplate }}
AUTH_LDAP_USER_SEARCH_BASEDN: {{ $.Values.remoteAuth.ldap.userSearchBaseDn | quote }}
AUTH_LDAP_USER_SEARCH_ATTR: {{ $.Values.remoteAuth.ldap.userSearchAttr | quote }}
AUTH_LDAP_GROUP_SEARCH_BASEDN: {{ $.Values.remoteAuth.ldap.groupSearchBaseDn | quote }}
AUTH_LDAP_GROUP_SEARCH_CLASS: {{ $.Values.remoteAuth.ldap.groupSearchClass | quote }}
AUTH_LDAP_GROUP_TYPE: {{ $.Values.remoteAuth.ldap.groupType | quote }}
AUTH_LDAP_FIND_GROUP_PERMS: {{ toJson $.Values.remoteAuth.ldap.findGroupPerms }}
AUTH_LDAP_MIRROR_GROUPS: {{ toJson $.Values.remoteAuth.ldap.mirrorGroups }}
AUTH_LDAP_MIRROR_GROUPS_EXCEPT: {{ toJson $.Values.remoteAuth.ldap.mirrorGroupsExcept }}
AUTH_LDAP_CACHE_TIMEOUT: {{ int $.Values.remoteAuth.ldap.cacheTimeout }}
AUTH_LDAP_USER_DN_TEMPLATE: {{ default nil .Values.remoteAuth.ldap.userDnTemplate }}
AUTH_LDAP_USER_SEARCH_BASEDN: {{ .Values.remoteAuth.ldap.userSearchBaseDn | quote }}
AUTH_LDAP_USER_SEARCH_ATTR: {{ .Values.remoteAuth.ldap.userSearchAttr | quote }}
AUTH_LDAP_GROUP_SEARCH_BASEDN: {{ .Values.remoteAuth.ldap.groupSearchBaseDn | quote }}
AUTH_LDAP_GROUP_SEARCH_CLASS: {{ .Values.remoteAuth.ldap.groupSearchClass | quote }}
AUTH_LDAP_GROUP_TYPE: {{ .Values.remoteAuth.ldap.groupType | quote }}
AUTH_LDAP_FIND_GROUP_PERMS: {{ toJson .Values.remoteAuth.ldap.findGroupPerms }}
AUTH_LDAP_MIRROR_GROUPS: {{ toJson .Values.remoteAuth.ldap.mirrorGroups }}
AUTH_LDAP_MIRROR_GROUPS_EXCEPT: {{ toJson .Values.remoteAuth.ldap.mirrorGroupsExcept }}
AUTH_LDAP_CACHE_TIMEOUT: {{ int .Values.remoteAuth.ldap.cacheTimeout }}
AUTH_LDAP_REQUIRE_GROUP_LIST: {{ toJson $.Values.remoteAuth.ldap.requireGroupDn }}
AUTH_LDAP_IS_ADMIN_LIST: {{ toJson $.Values.remoteAuth.ldap.isAdminDn }}
AUTH_LDAP_IS_SUPERUSER_LIST: {{ toJson $.Values.remoteAuth.ldap.isSuperUserDn }}
AUTH_LDAP_REQUIRE_GROUP_LIST: {{ toJson .Values.remoteAuth.ldap.requireGroupDn }}
AUTH_LDAP_IS_ADMIN_LIST: {{ toJson .Values.remoteAuth.ldap.isAdminDn }}
AUTH_LDAP_IS_SUPERUSER_LIST: {{ toJson .Values.remoteAuth.ldap.isSuperUserDn }}
# Populate the Django user from the LDAP directory.
AUTH_LDAP_USER_ATTR_MAP:
first_name: {{ $.Values.remoteAuth.ldap.attrFirstName | quote }}
last_name: {{ $.Values.remoteAuth.ldap.attrLastName | quote }}
email: {{ $.Values.remoteAuth.ldap.attrMail | quote }}
first_name: {{ .Values.remoteAuth.ldap.attrFirstName | quote }}
last_name: {{ .Values.remoteAuth.ldap.attrLastName | quote }}
email: {{ .Values.remoteAuth.ldap.attrMail | quote }}
{{- if $.Values.remoteAuth.ldap.caCertData }}
ldap_ca.crt: {{- toYaml $.Values.remoteAuth.ldap.caCertData | indent 4 }}
{{- end }}
{{- if .Values.remoteAuth.ldap.caCertData }}
ldap_ca.crt: {{- toYaml .Values.remoteAuth.ldap.caCertData | indent 4 }}
{{- end }}
{{- end }}
{{- if .Values.overrideUnitConfig }}

{{- if .Values.overrideUnitConfig }}
nginx-unit.json: |-
{{- toPrettyJson .Values.overrideUnitConfig | nindent 4 }}
{{- end }}

{{- range $index, $config := .Values.extraConfig -}}
{{- if $config.values }}

extra-{{ $index }}.yaml: |-
{{- toYaml $config.values | nindent 4 }}
{{- end }}
{{ end -}}
{{- end }}
10 changes: 3 additions & 7 deletions charts/netbox/templates/cronjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,18 @@ spec:
mountPath: /etc/netbox/config/configuration.py
subPath: configuration.py
readOnly: true
{{- range .Values.remoteAuth.backends }}
{{- if eq . "netbox.authentication.LDAPBackend" }}
{{- if has "netbox.authentication.LDAPBackend" .Values.remoteAuth.backends }}
- name: config
mountPath: /etc/netbox/config/ldap/ldap_config.py
subPath: ldap_config.py
readOnly: true
{{- if $.Values.remoteAuth.ldap.caCertData }}
{{- if .Values.remoteAuth.ldap.caCertData }}
- name: config
mountPath: /etc/netbox/config/ldap/ldap_ca.crt
subPath: ldap_ca.crt
readOnly: true
{{- end }}
{{- end }}
{{- end }}
- name: config
mountPath: /run/config/netbox
readOnly: true
Expand Down Expand Up @@ -125,12 +123,10 @@ spec:
path: email_password
- key: secret_key
path: secret_key
{{- range .Values.remoteAuth.backends }}
{{- if eq . "netbox.authentication.LDAPBackend" }}
{{- if has "netbox.authentication.LDAPBackend" .Values.remoteAuth.backends }}
- key: ldap_bind_password
path: ldap_bind_password
{{- end }}
{{- end }}
- secret:
name: {{ include "netbox.postgresql.secret" . | quote }}
items:
Expand Down
14 changes: 5 additions & 9 deletions charts/netbox/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ spec:
matchLabels:
{{- include "common.labels.matchLabels" . | nindent 6 }}
app.kubernetes.io/component: netbox
{{ if .Values.updateStrategy -}}
{{- if .Values.updateStrategy }}
strategy:
{{- toYaml .Values.updateStrategy | nindent 4 }}
{{ end -}}
{{- end }}
template:
metadata:
annotations:
Expand Down Expand Up @@ -154,20 +154,18 @@ spec:
mountPath: /etc/netbox/config/configuration.py
subPath: configuration.py
readOnly: true
{{- range .Values.remoteAuth.backends }}
{{- if eq . "netbox.authentication.LDAPBackend" }}
{{- if has "netbox.authentication.LDAPBackend" .Values.remoteAuth.backends }}
- name: config
mountPath: /etc/netbox/config/ldap/ldap_config.py
subPath: ldap_config.py
readOnly: true
{{- if $.Values.remoteAuth.ldap.caCertData }}
{{- if .Values.remoteAuth.ldap.caCertData }}
- name: config
mountPath: /etc/netbox/config/ldap/ldap_ca.crt
subPath: ldap_ca.crt
readOnly: true
{{- end }}
{{- end }}
{{- end }}
- name: config
mountPath: /run/config/netbox
readOnly: true
Expand Down Expand Up @@ -225,12 +223,10 @@ spec:
path: email_password
- key: secret_key
path: secret_key
{{- range .Values.remoteAuth.backends }}
{{- if eq . "netbox.authentication.LDAPBackend" }}
{{- if has "netbox.authentication.LDAPBackend" .Values.remoteAuth.backends }}
- key: ldap_bind_password
path: ldap_bind_password
{{- end }}
{{- end }}
- secret:
name: {{ include "common.secrets.name" (dict "existingSecret" .Values.superuser.existingSecret "defaultNameSuffix" "superuser" "context" $) }}
items:
Expand Down
File renamed without changes.
14 changes: 0 additions & 14 deletions charts/netbox/templates/postgresql-secret.yaml

This file was deleted.

28 changes: 0 additions & 28 deletions charts/netbox/templates/pvc-media.yaml

This file was deleted.

28 changes: 0 additions & 28 deletions charts/netbox/templates/pvc-reports.yaml

This file was deleted.

28 changes: 0 additions & 28 deletions charts/netbox/templates/pvc-scripts.yaml

This file was deleted.

66 changes: 66 additions & 0 deletions charts/netbox/templates/pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }}
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: {{ printf "%s-media" (include "common.names.fullname" .) | trunc 63 | trimSuffix "-" }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
accessModes:
- {{ .Values.persistence.accessMode | quote }}
resources:
requests:
storage: {{ .Values.persistence.size | quote }}
{{- if .Values.persistence.selector }}
selector: {{- include "common.tplvalues.render" (dict "value" .Values.persistence.selector "context" $) | nindent 4 }}
{{- end }}
{{- include "common.storage.class" (dict "persistence" .Values.persistence "global" .Values.global) | nindent 2 }}
{{- end }}
{{- if and .Values.reportsPersistence.enabled (not .Values.reportsPersistence.existingClaim) }}
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: {{ printf "%s-reports" (include "common.names.fullname" .) | trunc 63 | trimSuffix "-" }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
accessModes:
- {{ .Values.reportsPersistence.accessMode | quote }}
resources:
requests:
storage: {{ .Values.reportsPersistence.size | quote }}
{{- if .Values.reportsPersistence.selector }}
selector: {{- include "common.tplvalues.render" (dict "value" .Values.reportsPersistence.selector "context" $) | nindent 4 }}
{{- end }}
{{- include "common.storage.class" (dict "persistence" .Values.reportsPersistence "global" .Values.global) | nindent 2 }}
{{- end }}
{{- if and .Values.scriptsPersistence.enabled (not .Values.scriptsPersistence.existingClaim) }}
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: {{ printf "%s-scripts" (include "common.names.fullname" .) | trunc 63 | trimSuffix "-" }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
accessModes:
- {{ .Values.scriptsPersistence.accessMode | quote }}
resources:
requests:
storage: {{ .Values.scriptsPersistence.size | quote }}
{{- if .Values.scriptsPersistence.selector }}
selector: {{- include "common.tplvalues.render" (dict "value" .Values.scriptsPersistence.selector "context" $) | nindent 4 }}
{{- end }}
{{- include "common.storage.class" (dict "persistence" .Values.scriptsPersistence "global" .Values.global) | nindent 2 }}
{{- end }}
Loading

0 comments on commit c112bd5

Please sign in to comment.