netbox: Almost complete chart restructuring

This commit is contained in:
Alexander Olofsson 2020-05-04 11:56:49 +02:00
parent 7bbfe76f68
commit 877b8c3f0f
No known key found for this signature in database
GPG key ID: D439C9470CB04C73
13 changed files with 153 additions and 30 deletions

View file

@ -4,4 +4,4 @@ appVersion: "2.8.1"
description: An IP address management (IPAM) and data center infrastructure management (DCIM) tool. description: An IP address management (IPAM) and data center infrastructure management (DCIM) tool.
icon: https://raw.githubusercontent.com/digitalocean/netbox/develop/netbox/project-static/img/netbox.ico icon: https://raw.githubusercontent.com/digitalocean/netbox/develop/netbox/project-static/img/netbox.ico
name: netbox name: netbox
version: 0.5.2 version: 1.0.0

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,9 @@
dependencies:
- name: postgresql
repository: https://charts.bitnami.com/bitnami
version: 8.9.4
- name: redis
repository: https://charts.bitnami.com/bitnami
version: 10.6.12
digest: sha256:501f2da7eac8d6ecf2616fb27c6b26a808515250dc32e38738fa26e8016dfb1f
generated: "2020-05-04T09:41:49.344324356+02:00"

View file

@ -1,4 +1,8 @@
dependencies: dependencies:
- name: postgresql
version: ~8.9.4
repository: https://charts.bitnami.com/bitnami
condition: postgresql.enabled
- name: redis - name: redis
version: 10.3.4 version: ~10.6.12
repository: https://kubernetes-charts.storage.googleapis.com/ repository: https://charts.bitnami.com/bitnami

View file

@ -39,5 +39,21 @@ Create chart name and version as used by the chart label.
Get the correct image tag name Get the correct image tag name
*/}} */}}
{{- define "netbox.imageTag" -}} {{- define "netbox.imageTag" -}}
{{- .Values.image.tag | default (printf "%s-ldap" .Chart.AppVersion) -}} {{- .Values.image.tag | default (printf "v%s-ldap" .Chart.AppVersion) -}}
{{- end -}}
{{/*
Get the installed postgresql fullname
*/}}
{{- define "netbox.postgresql.fullname" -}}
{{- $name := default "postgresql" .Values.postgresql.nameOverride -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Get the installed redis fullname
*/}}
{{- define "netbox.redis.fullname" -}}
{{- $name := default "redis" .Values.redis.nameOverride -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}} {{- end -}}

View file

@ -9,17 +9,28 @@ metadata:
app.kubernetes.io/managed-by: {{ .Release.Service }} app.kubernetes.io/managed-by: {{ .Release.Service }}
helm.sh/chart: {{ include "netbox.chart" . }} helm.sh/chart: {{ include "netbox.chart" . }}
data: data:
DB_NAME: {{ .Values.database.database }} {{- if .Values.database }}
DB_USER: {{ .Values.database.user }} DB_NAME: {{ .Values.database.database | default "netbox" | quote }}
DB_HOST: {{ .Values.database.host }} DB_USER: {{ .Values.database.user | default "netbox" | quote }}
DB_PORT: {{ .Values.database.port | quote }} DB_HOST: {{ .Values.database.host | quote }}
DB_PORT: {{ .Values.database.port | default 5432 | quote }}
{{- else }}
DB_NAME: {{ .Values.postgresql.postgresqlDatabase | quote }}
DB_USER: {{ .Values.postgresql.postgresqlUsername | quote }}
DB_HOST: {{ include "netbox.postgresql.fullname" . }}
DB_PORT: {{ .Values.postgresql.postgresqlPort | default 5432 | quote }}
{{- end }}
REDIS_HOST: {{ include "netbox.redisHost" . }} REDIS_HOST: {{ include "netbox.redisHost" . }}
REDIS_PORT: {{ .Values.redis.redisPort | quote }} REDIS_PORT: {{ .Values.redis.redisPort | quote }}
REDIS_SSL: "false" REDIS_SSL: "false"
SUPERUSER_NAME: {{ .Values.superuser.name }} {{- if .Values.superuser.name }}
SUPERUSER_EMAIL: {{ .Values.superuser.email }} SUPERUSER_NAME: {{ .Values.superuser.name | quote }}
{{- end }}
{{- if .Values.superuser.email }}
SUPERUSER_EMAIL: {{ .Values.superuser.email | quote }}
{{- end }}
{{- range $key, $value := .Values.extraEnv }} {{- range $key, $value := .Values.extraEnv }}
{{ $key }}: {{ $value | quote }} {{ $key }}: {{ $value | quote }}

View file

@ -34,6 +34,24 @@ spec:
- rqworker - rqworker
image: "{{ .Values.image.repository }}:{{ include "netbox.imageTag" . }}" image: "{{ .Values.image.repository }}:{{ include "netbox.imageTag" . }}"
imagePullPolicy: {{ .Values.image.pullPolicy }} imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
- name: REDIS_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "netbox.redis.fullname" . }}
key: redis-password
{{- if .Values.postgresql.enabled }}
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
{{- if .Values.postgresql.existingSecret }}
name: {{ .Values.postgresql.existingSecret }}
key: {{ .Values.postgresql.existingSecretKey }}
{{- else }}
name: {{ include "netbox.postgresql.fullname" . }}
key: postgresql-password
{{- end }}
{{- end }}
envFrom: envFrom:
- configMapRef: - configMapRef:
name: {{ include "netbox.fullname" . }} name: {{ include "netbox.fullname" . }}

View file

@ -1,3 +1,12 @@
{{- if .Values.database }}
{{- if .Values.postgresql.enabled }}
{{- "Both external and internal database enabled, you may want to set postgresql.enabled=false" | fail }}
{{- end }}
{{- else }}
{{- if not .Values.postgresql.enabled }}
{{- "Neither external nor internal database enabled, you may want to set postgresql.enabled=true" | fail }}
{{- end }}
{{- end }}
--- ---
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: Deployment
@ -29,6 +38,33 @@ spec:
- name: {{ .Chart.Name }} - name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ include "netbox.imageTag" . }}" image: "{{ .Values.image.repository }}:{{ include "netbox.imageTag" . }}"
imagePullPolicy: {{ .Values.image.pullPolicy }} imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
{{- if .Values.redis.usePassword }}
- name: REDIS_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "netbox.redis.fullname" . }}
key: redis-password
{{- end }}
{{- if .Values.existingDjangoSecret }}
- name: SECRET_KEY
valueFrom:
secretKeyRef:
name: {{ .Values.existingDjagonSecret }}
key: {{ .Values.existingDjangoSecretKey }}
{{- end }}
{{- if .Values.postgresql.enabled }}
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
{{- if .Values.postgresql.existingSecret }}
name: {{ .Values.postgresql.existingSecret }}
key: {{ .Values.postgresql.existingSecretKey }}
{{- else }}
name: {{ include "netbox.postgresql.fullname" . }}
key: postgresql-password
{{- end }}
{{- end }}
envFrom: envFrom:
- configMapRef: - configMapRef:
name: {{ include "netbox.fullname" . }} name: {{ include "netbox.fullname" . }}
@ -36,7 +72,6 @@ spec:
name: {{ include "netbox.fullname" . }} name: {{ include "netbox.fullname" . }}
resources: resources:
{{- toYaml .Values.resources | nindent 12 }} {{- toYaml .Values.resources | nindent 12 }}
{{- if or .Values.persistence.enabled .Values.extraVolumeMounts }}
volumeMounts: volumeMounts:
- name: netbox-static-files - name: netbox-static-files
mountPath: /opt/netbox/netbox/static mountPath: /opt/netbox/netbox/static
@ -44,14 +79,15 @@ spec:
mountPath: /etc/netbox/config/gunicorn_config.py mountPath: /etc/netbox/config/gunicorn_config.py
subPath: gunicorn_config.py subPath: gunicorn_config.py
readOnly: true readOnly: true
{{- if .Values.useUnixSocket }}
- name: netbox-socket - name: netbox-socket
mountPath: /tmp/netbox mountPath: /tmp/netbox
{{- end }}
- name: data - name: data
mountPath: /etc/netbox/media mountPath: /etc/netbox/media
{{- if .Values.extraVolumeMounts }} {{- with .Values.extraVolumeMounts }}
{{ toYaml .Values.extraVolumeMounts | indent 12 }} {{ toYaml . | nindent 12 }}
{{- end }} {{- end }}
{{- end }}
- name: nginx - name: nginx
image: "nginx:alpine" image: "nginx:alpine"
imagePullPolicy: Always imagePullPolicy: Always
@ -80,8 +116,10 @@ spec:
- name: netbox-static-files - name: netbox-static-files
mountPath: /opt/netbox/netbox/static mountPath: /opt/netbox/netbox/static
readOnly: true readOnly: true
{{- if .Values.useUnixSocket }}
- name: netbox-socket - name: netbox-socket
mountPath: /tmp/netbox mountPath: /tmp/netbox
{{- end }}
{{- with .Values.nodeSelector }} {{- with .Values.nodeSelector }}
nodeSelector: nodeSelector:
{{- toYaml . | nindent 8 }} {{- toYaml . | nindent 8 }}
@ -92,8 +130,10 @@ spec:
name: {{ .Chart.Name }}-config-files name: {{ .Chart.Name }}-config-files
- name: netbox-static-files - name: netbox-static-files
emptyDir: {} emptyDir: {}
{{- if .Values.useUnixSocket }}
- name: netbox-socket - name: netbox-socket
emptyDir: {} emptyDir: {}
{{- end }}
- name: data - name: data
{{- if .Values.persistence.enabled }} {{- if .Values.persistence.enabled }}
persistentVolumeClaim: persistentVolumeClaim:

View file

@ -9,6 +9,7 @@ metadata:
app.kubernetes.io/managed-by: {{ .Release.Service }} app.kubernetes.io/managed-by: {{ .Release.Service }}
helm.sh/chart: {{ include "netbox.chart" . }} helm.sh/chart: {{ include "netbox.chart" . }}
data: data:
{{- if .Values.useUnixSocket }}
gunicorn_config.py: |- gunicorn_config.py: |-
command = '/usr/bin/gunicorn' command = '/usr/bin/gunicorn'
pythonpath = '/opt/netbox/netbox' pythonpath = '/opt/netbox/netbox'
@ -18,6 +19,7 @@ data:
accesslog = '-' accesslog = '-'
capture_output = False capture_output = False
loglevel = 'info' loglevel = 'info'
{{- end }}
nginx.conf: |- nginx.conf: |-
daemon off; daemon off;
worker_processes 1; worker_processes 1;
@ -39,7 +41,11 @@ data:
client_max_body_size 10M; client_max_body_size 10M;
upstream netbox { upstream netbox {
{{- if .Values.useUnixSocket }}
server unix:/tmp/netbox/gunicorn.sock fail_timeout=0; server unix:/tmp/netbox/gunicorn.sock fail_timeout=0;
{{- else }}
server http://localhost:8001 fail_timeout=0;
{{- end }}
} }
server { server {

View file

@ -1,3 +1,4 @@
---
apiVersion: v1 apiVersion: v1
kind: Secret kind: Secret
metadata: metadata:
@ -8,12 +9,23 @@ metadata:
app.kubernetes.io/managed-by: {{ .Release.Service }} app.kubernetes.io/managed-by: {{ .Release.Service }}
helm.sh/chart: {{ include "netbox.chart" . }} helm.sh/chart: {{ include "netbox.chart" . }}
data: data:
{{- if .Values.database }}
DB_PASSWORD: {{ .Values.database.password | b64enc }} DB_PASSWORD: {{ .Values.database.password | b64enc }}
REDIS_PASSWORD: {{ .Values.redis.password | b64enc }} {{- else if .Values.postgresql.postgresqlPassword }}
DB_PASSWORD: {{ .Values.postgresql.postgresqlPassword | b64enc }}
{{- end }}
{{- if .Values.djangoSecret }}
SECRET_KEY: {{ .Values.djangoSecret | b64enc }} SECRET_KEY: {{ .Values.djangoSecret | b64enc }}
{{- else if not .Values.existingDjangoSecret }}
SECRET_KEY: {{ randAlphaNum 50 | b64enc }}
{{- end }}
{{- if .Values.superuser.apiToken }}
SUPERUSER_API_TOKEN: {{ .Values.superuser.apiToken | b64enc }} SUPERUSER_API_TOKEN: {{ .Values.superuser.apiToken | b64enc }}
{{- end }}
{{- if .Values.superuser.password }}
SUPERUSER_PASSWORD: {{ .Values.superuser.password | b64enc }} SUPERUSER_PASSWORD: {{ .Values.superuser.password | b64enc }}
{{- end }}
{{- range $key, $value := .Values.extraSecrets }} {{- range $key, $value := .Values.extraSecrets }}
{{ $key }}: {{ $value | b64enc | quote }} {{ $key }}: {{ $value | b64enc | quote }}

View file

@ -31,21 +31,22 @@ ingress:
# hosts: # hosts:
# - chart-example.local # - chart-example.local
database: # Deprecated database keys
## Database host # database:
host: localhost
## Database port postgresql:
port: 5432 enabled: true
## Database user postgresqlDatabase: netbox
user: netbox postgresqlUsername: netbox
## Database password # The following variables are only used when internal PG is disabled
password: netbox # postgresqlHost: postgres
# postgresqlPassword: postgres
## Database name # postgresqlPort: 5432
database: netbox # When defined the `postgresqlPassword` field is ignored
# existingSecret: secret-name
# existingSecretKey: postgresql-password
redis: redis:
cluster: cluster:
@ -56,10 +57,16 @@ redis:
slave: slave:
persistence: persistence:
enabled: false enabled: false
password: netbox # password: netbox
redisPort: 6379 redisPort: 6379
djangoSecret: '' # NB; Not specifying a key or existing secret will cause it to regenerate on
# every upgrade
# djangoSecret: ''
# existingDjangoSecret: netbox-django-secret
# existingDjangoSecretKey: secret_key
useUnixSocket: true
extraEnv: {} extraEnv: {}
# EMAIL_SERVER: localhost # EMAIL_SERVER: localhost