From ed729ae24548fb90731493ad236a5cb74f234dc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Colombaro?= Date: Fri, 6 Sep 2024 13:19:46 +0000 Subject: [PATCH] Append production guidelines to NOTES Fixes #187 --- README.md | 10 +-------- charts/netbox/Chart.yaml | 2 +- charts/netbox/templates/NOTES.txt | 32 ++++++++++++++++++++++++++-- charts/netbox/templates/_helpers.tpl | 28 ++++++++++++++++++++++++ 4 files changed, 60 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 1eac5ac2..3351cbba 100644 --- a/README.md +++ b/README.md @@ -25,17 +25,9 @@ To install the chart with the release name `my-release` and default configuratio helm install my-release --devel oci://ghcr.io/netbox-community/netbox-chart/netbox ``` -The default configuration includes the required PostgreSQL and Redis database -services, but both should be managed externally in production deployments; see below. - ### Production Usage -Always [use an existing Secret](#using-an-existing-secret) and supply all -passwords and secret keys yourself to avoid Helm re-generating any of them for -you. - -We recommend setting both `postgresql.enabled` and `redis.enabled` to -`false` and using a separate external PostgreSQL and Redis instance. This +We recommend using separate external PostgreSQL and Redis instances. This de-couples those services from the chart's bundled versions which may have complex upgrade requirements. A clustered PostgreSQL server (e.g. using Zalando's [Postgres Operator](https://github.com/zalando/postgres-operator)) and Redis diff --git a/charts/netbox/Chart.yaml b/charts/netbox/Chart.yaml index ea0aa0de..76307125 100644 --- a/charts/netbox/Chart.yaml +++ b/charts/netbox/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v2 name: netbox -version: 5.0.0-beta.90 +version: 5.0.0-beta.93 appVersion: "v4.1.0" type: application kubeVersion: ^1.25.0-0 diff --git a/charts/netbox/templates/NOTES.txt b/charts/netbox/templates/NOTES.txt index 7e8eb6fe..cc3d1f30 100644 --- a/charts/netbox/templates/NOTES.txt +++ b/charts/netbox/templates/NOTES.txt @@ -2,20 +2,34 @@ CHART NAME: {{ .Chart.Name }} CHART VERSION: {{ .Chart.Version }} APP VERSION: {{ .Chart.AppVersion }} +** Please be patient while the chart is being deployed ** + +Netbox can be accessed through the following DNS name from within the cluster: + + {{ include "common.names.fullname" . }}.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }} (port {{ .Values.service.port }}) + +To access Netbox site from outside the cluster follow the steps below. + {{- if .Values.ingress.enabled }} -NetBox should be available at the following URL(s) shortly: + +You have configured NetBox to use an ingress controller, exposing the following URL(s): + {{ range $host := .Values.ingress.hosts }} {{- range .paths }} - http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }} + - http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }} {{- end }} {{- end }} + {{- else if contains "NodePort" .Values.service.type }} + Get the application URL by running these commands: export NODE_PORT=$(kubectl get --namespace {{ include "common.names.namespace" . | quote }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "common.names.fullname" . }}) export NODE_IP=$(kubectl get nodes --namespace {{ include "common.names.namespace" . | quote }} -o jsonpath="{.items[0].status.addresses[0].address}") echo http://$NODE_IP:$NODE_PORT + {{- else if contains "LoadBalancer" .Values.service.type }} + Get the application URL by running these commands: export SERVICE_IP=$(kubectl get svc --namespace {{ include "common.names.namespace" . | quote }} {{ include "common.names.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') @@ -23,10 +37,24 @@ Get the application URL by running these commands: NOTE: It may take a few minutes for the LoadBalancer IP to be available. You can watch the status of by running 'kubectl get --namespace {{ include "common.names.namespace" . | quote }} svc -w {{ include "common.names.fullname" . }}' + {{- else if contains "ClusterIP" .Values.service.type }} + Get the application URL by running these commands: export POD_NAME=$(kubectl get pods --namespace {{ include "common.names.namespace" . | quote }} -l "app.kubernetes.io/name={{ include "common.names.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") echo "Visit http://127.0.0.1:8080 to use your application" kubectl port-forward $POD_NAME 8080:8080 + +{{- end }} + +{{- include "netbox.validateValues" . }} +{{- include "common.warnings.rollingTag" .Values.image }} +{{- include "common.warnings.rollingTag" .Values.init.image }} +{{- include "common.warnings.resources" (dict "sections" (list "" "worker") "context" $) }} +{{- $passwordValidationErrors := list -}} +{{- if not .Values.superuser.existingSecret -}} + {{- $superuserPasswordValidationErrors := include "common.validations.values.single.empty" (dict "valueKey" "superuser.password" "secret" (include "common.secrets.name" (dict "defaultNameSuffix" "superuser" "context" .)) "field" "password" "context" $) -}} + {{- $passwordValidationErrors = append $passwordValidationErrors $superuserPasswordValidationErrors -}} {{- end }} +{{- include "common.errors.upgrade.passwords.empty" (dict "validationErrors" $passwordValidationErrors "context" $) -}} diff --git a/charts/netbox/templates/_helpers.tpl b/charts/netbox/templates/_helpers.tpl index 2ffb275b..9b7fa09f 100644 --- a/charts/netbox/templates/_helpers.tpl +++ b/charts/netbox/templates/_helpers.tpl @@ -129,3 +129,31 @@ Volume mounts for .Values.extraConfig entries readOnly: true {{ end -}} {{- end }} + +{{/* +Compile all warnings into a single message. +*/}} +{{- define "netbox.validateValues" -}} +{{- $messages := list -}} +{{- $messages := append $messages (include "netbox.validateValues.postgresql" .) -}} +{{- $messages := without $messages "" -}} +{{- $message := join "\n" $messages -}} +{{- if $message -}} +{{- printf "\nVALUES VALIDATION:\n%s" $message | fail -}} +{{- end -}} +{{- end -}} + +{{/* +Validate values of Netbox Chart - PostgreSQL +*/}} +{{- define "netbox.validateValues.postgresql" -}} +{{- if and (not .Values.postgresql.enabled) (or (empty .Values.externalDatabase.host) (empty .Values.externalDatabase.port) (empty .Values.externalDatabase.database)) -}} +netbox: postgresql + PostgreSQL installation has been disabled but without the required parameters + to use an external database. To use an external database, please ensure you provide + (at least) the following values: + externalDatabase.host=DB_SERVER_HOST + externalDatabase.database=DB_NAME + externalDatabase.port=DB_SERVER_PORT +{{- end -}} +{{- end -}}