Skip to content

Commit

Permalink
Merge pull request #192 from LeoColomb/feat/namespace-labels-anno
Browse files Browse the repository at this point in the history
Add standard namespace and metadata
  • Loading branch information
RangerRick authored May 2, 2024
2 parents d2d13c0 + 81f8902 commit a4063b6
Show file tree
Hide file tree
Showing 15 changed files with 77 additions and 102 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-beta1
version: 5.0.0-beta2
appVersion: "v3.6.4"
type: application
kubeVersion: ^1.25.0-0
Expand Down
10 changes: 5 additions & 5 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 "common.names.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
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 {{ .Release.Namespace }} {{ include "common.names.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
export SERVICE_IP=$(kubectl get svc --namespace {{ include "common.names.namespace" . | quote }} {{ 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 "common.names.fullname" . }}'
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 {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "common.names.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
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 }}
9 changes: 4 additions & 5 deletions charts/netbox/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "common.names.fullname" . }}
{{- with .Values.commonAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
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 }}
labels:
{{- include "common.labels.standard" . | nindent 4 }}
data:
configuration.py: |-
import re
Expand Down
13 changes: 6 additions & 7 deletions charts/netbox/templates/cronjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ include "common.names.fullname" . }}-housekeeping
{{- with .Values.commonAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "common.labels.standard" . | nindent 4 }}
name: {{ printf "%s-housekeeping" (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 }}
app.kubernetes.io/component: housekeeping
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
concurrencyPolicy: {{ .Values.housekeeping.concurrencyPolicy }}
failedJobsHistoryLimit: {{ .Values.housekeeping.failedJobsHistoryLimit }}
Expand Down
11 changes: 5 additions & 6 deletions charts/netbox/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "common.names.fullname" . }}
{{- with .Values.commonAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "common.labels.standard" . | nindent 4 }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
app.kubernetes.io/component: netbox
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
Expand Down
11 changes: 5 additions & 6 deletions charts/netbox/templates/hpa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "common.names.fullname" . }}
{{- with .Values.commonAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "common.labels.standard" . | nindent 4 }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
app.kubernetes.io/component: netbox
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
scaleTargetRef:
apiVersion: apps/v1
Expand Down
20 changes: 7 additions & 13 deletions charts/netbox/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "common.names.fullname" . -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "common.labels.standard" . | nindent 4 }}
{{- if or .Values.commonAnnotations .Values.ingress.annotations }}
annotations:
{{- with .Values.ingress.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.commonAnnotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
name: {{ include "common.names.fullname" . }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- if or .Values.service.annotations .Values.commonAnnotations }}
{{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.ingress.annotations .Values.commonAnnotations ) "context" . ) }}
annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $) | nindent 4 }}
{{- end }}
spec:
ingressClassName: {{ .Values.ingress.className }}
Expand All @@ -38,7 +32,7 @@ spec:
pathType: Prefix
backend:
service:
name: {{ $fullName }}
name: {{ include "common.names.fullname" . }}
port:
name: http
{{- else }}
Expand Down
11 changes: 5 additions & 6 deletions charts/netbox/templates/pvc-media.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: {{ include "common.names.fullname" . }}-media
{{- with .Values.commonAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
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 }}
labels:
{{- include "common.labels.standard" . | nindent 4 }}
spec:
accessModes:
- {{ .Values.persistence.accessMode | quote }}
Expand Down
11 changes: 5 additions & 6 deletions charts/netbox/templates/pvc-reports.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: {{ include "common.names.fullname" . }}-reports
{{- with .Values.commonAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
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 }}
labels:
{{- include "common.labels.standard" . | nindent 4 }}
spec:
accessModes:
- {{ .Values.reportsPersistence.accessMode | quote }}
Expand Down
11 changes: 5 additions & 6 deletions charts/netbox/templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ include "common.names.fullname" . }}
{{- with .Values.commonAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
name: {{ include "common.secrets.name" (dict "context" $) }}
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 }}
labels:
{{- include "common.labels.standard" . | nindent 4 }}
type: Opaque
data:
{{ if and (not .Values.postgresql.enabled) (not .Values.externalDatabase.existingSecretName) -}}
Expand Down
15 changes: 5 additions & 10 deletions charts/netbox/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,11 @@ apiVersion: v1
kind: Service
metadata:
name: {{ include "common.names.fullname" . }}
labels:
{{- include "common.labels.standard" . | nindent 4 }}
{{- if or .Values.commonAnnotations .Values.service.annotations }}
annotations:
{{- with .Values.service.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.commonAnnotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- if or .Values.service.annotations .Values.commonAnnotations }}
{{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.service.annotations .Values.commonAnnotations ) "context" . ) }}
annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $) | nindent 4 }}
{{- end }}
spec:
type: {{ .Values.service.type }}
Expand Down
13 changes: 4 additions & 9 deletions charts/netbox/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,11 @@ kind: ServiceAccount
automountServiceAccountToken: {{ .Values.serviceAccount.automountServiceAccountToken }}
metadata:
name: {{ include "netbox.serviceAccountName" . }}
labels:
{{- include "common.labels.standard" . | nindent 4 }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- if or .Values.commonAnnotations .Values.serviceAccount.annotations }}
annotations:
{{- with .Values.serviceAccount.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.commonAnnotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.serviceAccount.annotations .Values.commonAnnotations ) "context" . ) }}
annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $) | nindent 4 }}
{{- end }}
{{- with .Values.serviceAccount.imagePullSecrets }}
imagePullSecrets:
Expand Down
16 changes: 8 additions & 8 deletions charts/netbox/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "common.names.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "common.labels.standard" . | nindent 4 }}
{{- with .Values.serviceMonitor.additionalLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
namespace: {{ include "common.names.namespace" . | quote }}
{{- $labels := include "common.tplvalues.merge" ( dict "values" ( list .Values.serviceMonitor.additionalLabels .Values.commonLabels ) "context" . ) }}
labels: {{- include "common.labels.standard" ( dict "customLabels" $labels "context" $ ) | nindent 4 }}
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
jobLabel: {{ .Release.Name }}
jobLabel: {{ include "common.names.fullname" . }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
- {{ include "common.names.namespace" . | quote }}
selector:
matchLabels:
{{- include "common.labels.matchLabels" . | nindent 6 }}
Expand Down
13 changes: 6 additions & 7 deletions charts/netbox/templates/worker-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "common.names.fullname" . }}-worker
{{- with .Values.commonAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "common.labels.standard" . | nindent 4 }}
name: {{ printf "%s-worker" (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 }}
app.kubernetes.io/component: worker
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
{{- if not .Values.worker.autoscaling.enabled }}
replicas: {{ .Values.worker.replicaCount }}
Expand Down
13 changes: 6 additions & 7 deletions charts/netbox/templates/worker-hpa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "common.names.fullname" . }}-worker
{{- with .Values.commonAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "common.labels.standard" . | nindent 4 }}
name: {{ printf "%s-worker" (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 }}
app.kubernetes.io/component: worker
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
scaleTargetRef:
apiVersion: apps/v1
Expand Down

0 comments on commit a4063b6

Please sign in to comment.