From 7705a2c2a80b5053baa818c699dfc0823a0faa69 Mon Sep 17 00:00:00 2001 From: Alexander Olofsson Date: Tue, 21 May 2019 17:47:36 +0200 Subject: [PATCH] Update netbox chart --- charts/funkwhale/templates/ingress.yaml | 2 +- charts/netbox/requirements.lock | 6 + charts/netbox/requirements.yaml | 4 + charts/netbox/templates/_helpers.tpl | 4 + charts/netbox/templates/configuration.yaml | 14 ++- charts/netbox/templates/deployment-front.yaml | 103 ++++++++++++++++++ charts/netbox/templates/deployment.yaml | 53 +++------ charts/netbox/templates/ingress.yaml | 8 +- charts/netbox/templates/secrets.yaml | 9 +- charts/netbox/templates/service-api.yaml | 21 ++++ .../{service.yaml => service-front.yaml} | 2 + .../netbox/templates/worker-deployment.yaml | 56 +++++----- charts/netbox/values.yaml | 81 +++++++++----- 13 files changed, 262 insertions(+), 101 deletions(-) create mode 100644 charts/netbox/requirements.lock create mode 100644 charts/netbox/requirements.yaml create mode 100644 charts/netbox/templates/deployment-front.yaml create mode 100644 charts/netbox/templates/service-api.yaml rename charts/netbox/templates/{service.yaml => service-front.yaml} (86%) diff --git a/charts/funkwhale/templates/ingress.yaml b/charts/funkwhale/templates/ingress.yaml index cee5848..68927d2 100644 --- a/charts/funkwhale/templates/ingress.yaml +++ b/charts/funkwhale/templates/ingress.yaml @@ -28,7 +28,7 @@ spec: - host: {{ .Values.ingress.host | quote }} http: paths: - - path: + - path: / backend: serviceName: {{ $fullName }}-front servicePort: http diff --git a/charts/netbox/requirements.lock b/charts/netbox/requirements.lock new file mode 100644 index 0000000..fbe7115 --- /dev/null +++ b/charts/netbox/requirements.lock @@ -0,0 +1,6 @@ +dependencies: +- name: redis + repository: https://kubernetes-charts.storage.googleapis.com/ + version: 7.1.1 +digest: sha256:5a2449433325c0e819134bdcd7bd7ab463975b9b529c8516a9ff030547140bf6 +generated: 2019-05-21T09:47:18.817171504+02:00 diff --git a/charts/netbox/requirements.yaml b/charts/netbox/requirements.yaml new file mode 100644 index 0000000..62f4546 --- /dev/null +++ b/charts/netbox/requirements.yaml @@ -0,0 +1,4 @@ +dependencies: + - name: redis + version: 7.1.1 + repository: https://kubernetes-charts.storage.googleapis.com/ diff --git a/charts/netbox/templates/_helpers.tpl b/charts/netbox/templates/_helpers.tpl index 9e0a4b8..dc85616 100644 --- a/charts/netbox/templates/_helpers.tpl +++ b/charts/netbox/templates/_helpers.tpl @@ -6,6 +6,10 @@ Expand the name of the chart. {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} {{- end -}} +{{- define "netbox.redisHost" -}} +{{ template "netbox.fullname" . }}-redis-master +{{- end -}} + {{/* Create a default fully qualified app name. We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). diff --git a/charts/netbox/templates/configuration.yaml b/charts/netbox/templates/configuration.yaml index 38858c8..ecb2ad2 100644 --- a/charts/netbox/templates/configuration.yaml +++ b/charts/netbox/templates/configuration.yaml @@ -8,6 +8,18 @@ metadata: app.kubernetes.io/instance: {{ .Release.Name }} app.kubernetes.io/managed-by: {{ .Release.Service }} data: -{{- range $key, $value := .Values.env.configuration }} + DB_NAME: {{ .Values.database.database }} + DB_USER: {{ .Values.database.user }} + DB_HOST: {{ .Values.database.host }} + DB_PORT: {{ .Values.database.port | quote }} + + REDIS_HOST: {{ include "netbox.redisHost" . }} + REDIS_PORT: {{ .Values.redis.redisPort | quote }} + REDIS_SSL: "false" + + SUPERUSER_NAME: {{ .Values.superuser.name }} + SUPERUSER_EMAIL: {{ .Values.superuser.email }} + +{{- range $key, $value := .Values.extraEnv }} {{ $key }}: {{ $value | quote }} {{- end }} diff --git a/charts/netbox/templates/deployment-front.yaml b/charts/netbox/templates/deployment-front.yaml new file mode 100644 index 0000000..0de61e6 --- /dev/null +++ b/charts/netbox/templates/deployment-front.yaml @@ -0,0 +1,103 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "netbox.fullname" . }}-front + labels: + app.kubernetes.io/name: {{ include "netbox.name" . }} + helm.sh/chart: {{ include "netbox.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + com.digitalocean.netbox/component: front +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app.kubernetes.io/name: {{ include "netbox.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + com.digitalocean.netbox/component: front + template: + metadata: + labels: + app.kubernetes.io/name: {{ include "netbox.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + com.digitalocean.netbox/component: front + spec: + initContainers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + command: + - sh + - -c + - | + cp /etc/netbox-nginx/* /tmp/netbox-nginx + sed -e 's!http://netbox:8001!http://{{ include "netbox.fullname" . }}-api:8001!' -i /tmp/netbox-nginx/nginx.conf + cp -r /opt/netbox/netbox/project-static/* \ + /usr/local/lib/python3.6/site-packages/django/contrib/admin/static/* \ + /usr/local/lib/python3.6/site-packages/debug_toolbar/static/* \ + /usr/local/lib/python3.6/site-packages/django_tables2/static/* \ + /usr/local/lib/python3.6/site-packages/drf_yasg/static/* \ + /usr/local/lib/python3.6/site-packages/mptt/static/* \ + /usr/local/lib/python3.6/site-packages/rest_framework/static/* \ + /tmp/netbox-static + resources: + {{- toYaml .Values.resources | nindent 12 }} + volumeMounts: + - name: netbox-nginx-config + mountPath: /tmp/netbox-nginx + - name: netbox-static-files + mountPath: /tmp/netbox-static + # - name: netbox-configuration + # path: /etc/netbox/config + # readOnly: true + # - name: netbox-initializers + # path: /opt/netbox/initializers + # readOnly: true + # - name: netbox-startup-scripts + # path: /opt/netbox/startup_scripts + # readOnly: true + # - name: netbox-reports + # path: /opt/netbox/reports + # readOnly: true + containers: + - name: nginx + image: "nginx:alpine" + imagePullPolicy: Always + command: + - nginx + - -c + - /etc/netbox-nginx/nginx.conf + ports: + - name: http + containerPort: 8080 + protocol: TCP + livenessProbe: + tcpSocket: + port: http + readinessProbe: + tcpSocket: + port: http + volumeMounts: + - name: netbox-nginx-config + mountPath: /etc/netbox-nginx + readOnly: true + - name: netbox-static-files + mountPath: /opt/netbox/netbox/static + readOnly: true + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + volumes: + - name: netbox-nginx-config + emptyDir: {} + - name: netbox-static-files + emptyDir: {} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/charts/netbox/templates/deployment.yaml b/charts/netbox/templates/deployment.yaml index e759934..a2e5269 100644 --- a/charts/netbox/templates/deployment.yaml +++ b/charts/netbox/templates/deployment.yaml @@ -7,17 +7,23 @@ metadata: helm.sh/chart: {{ include "netbox.chart" . }} app.kubernetes.io/instance: {{ .Release.Name }} app.kubernetes.io/managed-by: {{ .Release.Service }} + com.digitalocean.netbox/component: api spec: replicas: {{ .Values.replicaCount }} selector: matchLabels: app.kubernetes.io/name: {{ include "netbox.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} + com.digitalocean.netbox/component: api template: metadata: + annotations: + checksum/config: {{ include (print $.Template.BasePath "/configuration.yaml") . | sha256sum }} + checksum/secrets: {{ include (print $.Template.BasePath "/secrets.yaml") . | sha256sum }} labels: app.kubernetes.io/name: {{ include "netbox.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} + com.digitalocean.netbox/component: api spec: containers: - name: {{ .Chart.Name }} @@ -28,20 +34,22 @@ spec: name: {{ include "netbox.fullname" . }} - secretRef: name: {{ include "netbox.fullname" . }} - livenessProbe: - httpGet: - path: / - port: 8001 + # livenessProbe: + # httpGet: + # path: / + # port: api + # initialDelaySeconds: 50 + # failureThreshold: 5 readinessProbe: tcpSocket: - port: 8001 + port: api + ports: + - name: api + containerPort: 8001 + protocol: TCP resources: {{- toYaml .Values.resources | nindent 12 }} - volumeMounts: - - name: netbox-nginx-config - mountPath: /etc/netbox-nginx - - name: netbox-static-files - mountPath: /opt/netbox/netbox/static + volumeMounts: [] # - name: netbox-configuration # path: /etc/netbox/config # readOnly: true @@ -54,27 +62,6 @@ spec: # - name: netbox-reports # path: /opt/netbox/reports # readOnly: true - - name: nginx - image: "nginx:alpine" - imagePullPolicy: Always - ports: - - name: http - containerPort: 8080 - protocol: TCP - livenessProbe: - httpGet: - path: / - port: http - readinessProbe: - tcpSocket: - port: http - volumeMounts: - - name: netbox-nginx-config - mountPath: /etc/netbox-nginx - readOnly: true - - name: netbox-static-files - mountPath: /opt/netbox/netbox/static - readOnly: true {{- with .Values.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} @@ -92,10 +79,6 @@ spec: # - name: netbox-startup-scripts # configMap: # name: {{ .Chart.Name }}-startup-scripts - - name: netbox-nginx-config - emptyDir: {} - - name: netbox-static-files - emptyDir: {} - name: netbox-media-files emptyDir: {} {{- with .Values.affinity }} diff --git a/charts/netbox/templates/ingress.yaml b/charts/netbox/templates/ingress.yaml index 9c57362..42f2ac7 100644 --- a/charts/netbox/templates/ingress.yaml +++ b/charts/netbox/templates/ingress.yaml @@ -25,15 +25,11 @@ spec: {{- end }} {{- end }} rules: - {{- range .Values.ingress.hosts }} - - host: {{ .host | quote }} + - host: {{ .Values.ingress.host | quote }} http: paths: - {{- range .paths }} - - path: {{ . }} + - path: / backend: serviceName: {{ $fullName }} servicePort: http - {{- end }} - {{- end }} {{- end }} diff --git a/charts/netbox/templates/secrets.yaml b/charts/netbox/templates/secrets.yaml index 55efbea..11fd916 100644 --- a/charts/netbox/templates/secrets.yaml +++ b/charts/netbox/templates/secrets.yaml @@ -8,6 +8,13 @@ metadata: app.kubernetes.io/instance: {{ .Release.Name }} app.kubernetes.io/managed-by: {{ .Release.Service }} data: -{{- range $key, $value := .Values.env.secrets }} + DB_PASSWORD: {{ .Values.database.password | b64enc }} + REDIS_PASSWORD: {{ .Values.redis.password | b64enc }} + SECRET_KEY: {{ .Values.djangoSecret | b64enc }} + + SUPERUSER_API_TOKEN: {{ .Values.superuser.apiToken | b64enc }} + SUPERUSER_PASSWORD: {{ .Values.superuser.password | b64enc }} + +{{- range $key, $value := .Values.extraSecrets }} {{ $key }}: {{ $value | b64enc | quote }} {{- end }} diff --git a/charts/netbox/templates/service-api.yaml b/charts/netbox/templates/service-api.yaml new file mode 100644 index 0000000..cd87b12 --- /dev/null +++ b/charts/netbox/templates/service-api.yaml @@ -0,0 +1,21 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "netbox.fullname" . }}-api + labels: + app.kubernetes.io/name: {{ include "netbox.name" . }} + helm.sh/chart: {{ include "netbox.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + com.digitalocean.netbox/component: api +spec: + type: ClusterIP + ports: + - port: 8001 + targetPort: api + protocol: TCP + name: api + selector: + app.kubernetes.io/name: {{ include "netbox.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + com.digitalocean.netbox/component: api diff --git a/charts/netbox/templates/service.yaml b/charts/netbox/templates/service-front.yaml similarity index 86% rename from charts/netbox/templates/service.yaml rename to charts/netbox/templates/service-front.yaml index c3febd7..3abaa09 100644 --- a/charts/netbox/templates/service.yaml +++ b/charts/netbox/templates/service-front.yaml @@ -7,6 +7,7 @@ metadata: helm.sh/chart: {{ include "netbox.chart" . }} app.kubernetes.io/instance: {{ .Release.Name }} app.kubernetes.io/managed-by: {{ .Release.Service }} + com.digitalocean.netbox/component: front spec: type: {{ .Values.service.type }} ports: @@ -17,3 +18,4 @@ spec: selector: app.kubernetes.io/name: {{ include "netbox.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} + com.digitalocean.netbox/component: front diff --git a/charts/netbox/templates/worker-deployment.yaml b/charts/netbox/templates/worker-deployment.yaml index 5594f67..a835acf 100644 --- a/charts/netbox/templates/worker-deployment.yaml +++ b/charts/netbox/templates/worker-deployment.yaml @@ -31,41 +31,41 @@ spec: - rqworker envFrom: - configMapRef: - name: {{ include "netbox.fullname" . }} + name: {{ include "netbox.fullname" . }} - secretRef: - name: {{ include "netbox.fullname" . }} + name: {{ include "netbox.fullname" . }} resources: {{- toYaml .Values.worker.resources | nindent 12 }} - volumeMounts: - - name: netbox-configuration - path: /etc/netbox/config - readOnly: true - - name: netbox-initializers - path: /opt/netbox/initializers - readOnly: true - - name: netbox-startup-scripts - path: /opt/netbox/startup_scripts - readOnly: true - - name: netbox-reports - path: /opt/netbox/reports - readOnly: true + volumeMounts: [] + # - name: netbox-configuration + # path: /etc/netbox/config + # readOnly: true + # - name: netbox-initializers + # path: /opt/netbox/initializers + # readOnly: true + # - name: netbox-startup-scripts + # path: /opt/netbox/startup_scripts + # readOnly: true + # - name: netbox-reports + # path: /opt/netbox/reports + # readOnly: true {{- with .Values.worker.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} {{- end }} - volumes: - - name: netbox-configuration - configMap: - name: {{ .Chart.Name }}-configuration - - name: netbox-initializers - configMap: - name: {{ .Chart.Name }}-initializers - - name: netbox-reports - configMap: - name: {{ .Chart.Name }}-reports - - name: netbox-startup-scripts - configMap: - name: {{ .Chart.Name }}-startup-scripts + volumes: [] + # - name: netbox-configuration + # configMap: + # name: {{ .Chart.Name }}-configuration + # - name: netbox-initializers + # configMap: + # name: {{ .Chart.Name }}-initializers + # - name: netbox-reports + # configMap: + # name: {{ .Chart.Name }}-reports + # - name: netbox-startup-scripts + # configMap: + # name: {{ .Chart.Name }}-startup-scripts {{- with .Values.worker.affinity }} affinity: {{- toYaml . | nindent 8 }} diff --git a/charts/netbox/values.yaml b/charts/netbox/values.yaml index 85bb3cb..41c6600 100644 --- a/charts/netbox/values.yaml +++ b/charts/netbox/values.yaml @@ -6,37 +6,9 @@ replicaCount: 1 image: repository: netboxcommunity/netbox - tag: v2.5 + tag: develop-2.6-ldap pullPolicy: Always -env: - configuration: - DB_NAME: netbox - DB_USER: netbox - DB_HOST: localhost - EMAIL_SERVER: localhost - EMAIL_PORT: 25 - EMAIL_USERNAME: netbox - EMAIL_TIMEOUT: 5 - EMAIL_FROM: netbox@example.com - MEDIA_ROOT: /opt/netbox/netbox/media - NAPALM_USERNAME: '' - NAPALM_PASSWORD: '' - NAPALM_TIMEOUT: 10 - MAX_PAGE_SIZE: 1000 - REDIS_HOST: redis - SUPERUSER_NAME: admin - SUPERUSER_EMAIL: admin@example.com - WEBHOOKS_ENABLED: true - - secrets: - DB_PASSWORD: netbox - EMAIL_PASSWORD: netbox - REDIS_PASSWORD: redis - SECRET_KEY: 0123456789abcdef0123456789abcdef01234567 - SUPERUSER_PASSWORD: admin - SUPERUSER_API_TOKEN: 0123456789abcdef0123456789abcdef01234567 - nameOverride: "" fullnameOverride: "" @@ -58,6 +30,57 @@ ingress: # hosts: # - chart-example.local +database: + ## Database host + host: localhost + + ## Database port + port: 5432 + + ## Database user + user: netbox + + ## Database password + password: netbox + + ## Database name + database: netbox + +redis: + cluster: + enabled: false + master: + persistence: + enabled: false + slave: + persistence: + enabled: false + password: netbox + redisPort: 6379 + +djangoSecret: '' + +extraEnv: {} + # EMAIL_SERVER: localhost + # EMAIL_PORT: 25 + # EMAIL_USERNAME: netbox + # EMAIL_TIMEOUT: 5 + # EMAIL_FROM: netbox@example.com + # NAPALM_USERNAME: '' + # NAPALM_TIMEOUT: 10 + # MAX_PAGE_SIZE: 1000 + # WEBHOOKS_ENABLED: true + +extraSecrets: {} + # EMAIL_PASSWORD: netbox + # NAPALM_PASSWORD: '' + +superuser: + name: '' + email: '' + apiToken: '' + password: '' + resources: {} # We usually recommend not to specify default resources and to leave this as a conscious # choice for the user. This also increases chances charts run on environments with little