Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leverage Bitnami common chart helpers #184

Merged
merged 3 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions charts/netbox/Chart.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions 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
version: 5.0.0-beta0
appVersion: "v3.6.4"
type: application
kubeVersion: ^1.25.0-0
Expand All @@ -16,12 +16,17 @@ maintainers:
- name: Chris Boot
url: https://github.com/bootc
dependencies:
- name: common
repository: oci://registry-1.docker.io/bitnamicharts
version: ^2.19.1
tags:
- bitnami-common
- name: postgresql
version: 13.x.x
version: ^13.4.6
repository: oci://registry-1.docker.io/bitnamicharts
condition: postgresql.enabled
- name: redis
version: 18.x.x
version: ^18.19.4
repository: oci://registry-1.docker.io/bitnamicharts
condition: redis.enabled
annotations:
Expand Down
8 changes: 4 additions & 4 deletions charts/netbox/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ NetBox should be available at the following URL(s) shortly:
{{- else if contains "NodePort" .Values.service.type }}
Get the application URL by running these commands:

export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "netbox.fullname" . }})
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "common.names.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -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 {{ .Release.Namespace }} {{ include "netbox.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "common.names.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo http://$SERVICE_IP:{{ .Values.service.port }}

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 {{ .Release.Namespace }} svc -w {{ include "netbox.fullname" . }}'
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} 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 {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "netbox.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -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 }}
62 changes: 5 additions & 57 deletions charts/netbox/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -1,63 +1,11 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "netbox.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- 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).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "netbox.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "netbox.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "netbox.labels" -}}
helm.sh/chart: {{ include "netbox.chart" . }}
{{ include "netbox.selectorLabels" . }}
app.kubernetes.io/version: {{ .Values.image.tag | default .Chart.AppVersion | quote }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- with .Values.commonLabels }}
{{ toYaml . }}
{{- end }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "netbox.selectorLabels" -}}
app.kubernetes.io/name: {{ include "netbox.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "netbox.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "netbox.fullname" .) .Values.serviceAccount.name }}
{{- default (include "common.names.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
Expand All @@ -72,7 +20,7 @@ Name of the Secret that contains the PostgreSQL password
{{- else if .Values.externalDatabase.existingSecretName }}
{{- .Values.externalDatabase.existingSecretName }}
{{- else }}
{{- .Values.existingSecret | default (include "netbox.fullname" .) }}
{{- .Values.existingSecret | default (include "common.names.fullname" .) }}
{{- end }}
{{- end }}

Expand All @@ -98,7 +46,7 @@ Name of the Secret that contains the Redis tasks password
{{- else if .Values.tasksRedis.existingSecretName }}
{{- .Values.tasksRedis.existingSecretName }}
{{- else }}
{{- .Values.existingSecret | default (include "netbox.fullname" .) }}
{{- .Values.existingSecret | default (include "common.names.fullname" .) }}
{{- end }}
{{- end }}

Expand All @@ -124,7 +72,7 @@ Name of the Secret that contains the Redis cache password
{{- else if .Values.cachingRedis.existingSecretName }}
{{- .Values.cachingRedis.existingSecretName }}
{{- else }}
{{- .Values.existingSecret | default (include "netbox.fullname" .) }}
{{- .Values.existingSecret | default (include "common.names.fullname" .) }}
{{- end }}
{{- end }}

Expand All @@ -149,7 +97,7 @@ Volumes that need to be mounted for .Values.extraConfig entries
- name: extra-config-{{ $index }}
{{- if $config.values }}
configMap:
name: {{ include "netbox.fullname" $ }}
name: {{ include "common.names.fullname" $ }}
items:
- key: extra-{{ $index }}.yaml
path: extra-{{ $index }}.yaml
Expand Down
4 changes: 2 additions & 2 deletions charts/netbox/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "netbox.fullname" . }}
name: {{ include "common.names.fullname" . }}
{{- with .Values.commonAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "netbox.labels" . | nindent 4 }}
{{- include "common.labels.standard" . | nindent 4 }}
data:
configuration.py: |-
import re
Expand Down
16 changes: 8 additions & 8 deletions charts/netbox/templates/cronjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ include "netbox.fullname" . }}-housekeeping
name: {{ include "common.names.fullname" . }}-housekeeping
{{- with .Values.commonAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "netbox.labels" . | nindent 4 }}
{{- include "common.labels.standard" . | nindent 4 }}
app.kubernetes.io/component: housekeeping
spec:
concurrencyPolicy: {{ .Values.housekeeping.concurrencyPolicy }}
Expand All @@ -19,7 +19,7 @@ spec:
jobTemplate:
metadata:
labels:
{{- include "netbox.labels" . | nindent 8 }}
{{- include "common.labels.standard" . | nindent 8 }}
spec:
template:
metadata:
Expand All @@ -28,7 +28,7 @@ spec:
{{- toYaml . | nindent 12 }}
{{- end }}
labels:
{{- include "netbox.selectorLabels" . | nindent 12 }}
{{- include "common.labels.matchLabels" . | nindent 12 }}
app.kubernetes.io/component: housekeeping
{{- with .Values.housekeeping.podLabels }}
{{- toYaml . | nindent 12 }}
Expand Down Expand Up @@ -101,12 +101,12 @@ spec:
volumes:
- name: config
configMap:
name: {{ include "netbox.fullname" . }}
name: {{ include "common.names.fullname" . }}
- name: secrets
projected:
sources:
- secret:
name: {{ .Values.existingSecret | default (include "netbox.fullname" .) | quote }}
name: {{ .Values.existingSecret | default (include "common.names.fullname" .) | quote }}
items:
# Used by our configuration
- key: email_password
Expand Down Expand Up @@ -139,14 +139,14 @@ spec:
- name: media
{{- if .Values.persistence.enabled }}
persistentVolumeClaim:
claimName: {{ .Values.persistence.existingClaim | default (printf "%s-media" (include "netbox.fullname" .)) }}
claimName: {{ .Values.persistence.existingClaim | default (printf "%s-media" (include "common.names.fullname" .)) }}
{{- else }}
emptyDir: {}
{{- end }}
{{- if .Values.reportsPersistence.enabled }}
- name: reports
persistentVolumeClaim:
claimName: {{ .Values.reportsPersistence.existingClaim | default (printf "%s-reports" (include "netbox.fullname" .)) }}
claimName: {{ .Values.reportsPersistence.existingClaim | default (printf "%s-reports" (include "common.names.fullname" .)) }}
{{- end }}
{{- with .Values.housekeeping.extraVolumes }}
{{- toYaml . | nindent 10 }}
Expand Down
16 changes: 8 additions & 8 deletions charts/netbox/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "netbox.fullname" . }}
name: {{ include "common.names.fullname" . }}
{{- with .Values.commonAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "netbox.labels" . | nindent 4 }}
{{- include "common.labels.standard" . | nindent 4 }}
app.kubernetes.io/component: netbox
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "netbox.selectorLabels" . | nindent 6 }}
{{- include "common.labels.matchLabels" . | nindent 6 }}
app.kubernetes.io/component: netbox
{{ if .Values.updateStrategy -}}
strategy:
Expand All @@ -32,7 +32,7 @@ spec:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "netbox.selectorLabels" . | nindent 8 }}
{{- include "common.labels.matchLabels" . | nindent 8 }}
app.kubernetes.io/component: netbox
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
Expand Down Expand Up @@ -164,12 +164,12 @@ spec:
volumes:
- name: config
configMap:
name: {{ include "netbox.fullname" . }}
name: {{ include "common.names.fullname" . }}
- name: secrets
projected:
sources:
- secret:
name: {{ .Values.existingSecret | default (include "netbox.fullname" .) | quote }}
name: {{ .Values.existingSecret | default (include "common.names.fullname" .) | quote }}
items:
# Used by netbox-docker entry scripts
- key: superuser_password
Expand Down Expand Up @@ -210,14 +210,14 @@ spec:
- name: media
{{- if .Values.persistence.enabled }}
persistentVolumeClaim:
claimName: {{ .Values.persistence.existingClaim | default (printf "%s-media" (include "netbox.fullname" .)) }}
claimName: {{ .Values.persistence.existingClaim | default (printf "%s-media" (include "common.names.fullname" .)) }}
{{- else }}
emptyDir: {}
{{- end }}
{{- if .Values.reportsPersistence.enabled }}
- name: reports
persistentVolumeClaim:
claimName: {{ .Values.reportsPersistence.existingClaim | default (printf "%s-reports" (include "netbox.fullname" .)) }}
claimName: {{ .Values.reportsPersistence.existingClaim | default (printf "%s-reports" (include "common.names.fullname" .)) }}
{{- end }}
{{- with .Values.extraVolumes }}
{{- toYaml . | nindent 6 }}
Expand Down
6 changes: 3 additions & 3 deletions charts/netbox/templates/hpa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "netbox.fullname" . }}
name: {{ include "common.names.fullname" . }}
{{- with .Values.commonAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "netbox.labels" . | nindent 4 }}
{{- include "common.labels.standard" . | nindent 4 }}
app.kubernetes.io/component: netbox
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "netbox.fullname" . }}
name: {{ include "common.names.fullname" . }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
Expand Down
4 changes: 2 additions & 2 deletions charts/netbox/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "netbox.fullname" . -}}
{{- $fullName := include "common.names.fullname" . -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "netbox.labels" . | nindent 4 }}
{{- include "common.labels.standard" . | nindent 4 }}
{{- if or .Values.commonAnnotations .Values.ingress.annotations }}
annotations:
{{- with .Values.ingress.annotations }}
Expand Down
4 changes: 2 additions & 2 deletions charts/netbox/templates/pvc-media.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: {{ include "netbox.fullname" . }}-media
name: {{ include "common.names.fullname" . }}-media
{{- with .Values.commonAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "netbox.labels" . | nindent 4 }}
{{- include "common.labels.standard" . | nindent 4 }}
spec:
accessModes:
- {{ .Values.persistence.accessMode | quote }}
Expand Down
4 changes: 2 additions & 2 deletions charts/netbox/templates/pvc-reports.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: {{ include "netbox.fullname" . }}-reports
name: {{ include "common.names.fullname" . }}-reports
{{- with .Values.commonAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "netbox.labels" . | nindent 4 }}
{{- include "common.labels.standard" . | nindent 4 }}
spec:
accessModes:
- {{ .Values.reportsPersistence.accessMode | quote }}
Expand Down
Loading
Loading