Skip to content

Commit

Permalink
Add annotations to all Kubernetes resources
Browse files Browse the repository at this point in the history
  • Loading branch information
raminqaf committed Oct 28, 2024
1 parent 8cafb5b commit fd59688
Show file tree
Hide file tree
Showing 21 changed files with 72 additions and 33 deletions.
13 changes: 13 additions & 0 deletions charts/producer-app-cleanup-job/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,16 @@ Create chart name and version as used by the chart label.
{{- define "producer-app.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}


{{/*
Helper function to add annotations to resources
*/}}
{{- define "producer-app.annotations" -}}
{{- if .Values.annotations }}
annotations:
{{- range $key, $value := .Values.annotations }}
{{ $key | quote }}: {{ $value | quote }}
{{- end }}
{{- end }}
{{- end }}
1 change: 1 addition & 0 deletions charts/producer-app-cleanup-job/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "producer-app.name" . }}
{{- include "producer-app.annotations" . | nindent 2 }}
data:
{{- range $key, $value := .Values.files }}
{{ $key }}: {{ $value.content | quote }}
Expand Down
7 changes: 1 addition & 6 deletions charts/producer-app-cleanup-job/templates/job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ apiVersion: batch/v1
kind: Job
metadata:
name: {{ template "producer-app.fullname" . }}
{{- if .Values.annotations }}
annotations:
{{- range $key, $value := .Values.annotations }}
{{ $key | quote }}: {{ $value | quote }}
{{- end }}
{{- end }}
{{- include "producer-app.annotations" . | nindent 2 }}
labels:
app: {{ template "producer-app.name" . }}
chart: {{ template "producer-app.chart" . }}
Expand Down
1 change: 1 addition & 0 deletions charts/producer-app-cleanup-job/templates/secrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: v1
kind: Secret
metadata:
name: {{ template "producer-app.fullname" . }}
{{- include "producer-app.annotations" . | nindent 2 }}
type: Opaque
data:
{{- range $key, $value := .Values.secrets }}
Expand Down
12 changes: 12 additions & 0 deletions charts/producer-app/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,15 @@ Create chart name and version as used by the chart label.
{{- define "producer-app.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Helper function to add annotations to resources
*/}}
{{- define "producer-app.annotations" -}}
{{- if .Values.annotations }}
annotations:
{{- range $key, $value := .Values.annotations }}
{{ $key | quote }}: {{ $value | quote }}
{{- end }}
{{- end }}
{{- end }}
1 change: 1 addition & 0 deletions charts/producer-app/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "producer-app.name" . }}
{{- include "producer-app.annotations" . | nindent 2 }}
data:
{{- range $key, $value := .Values.files }}
{{ $key }}: {{ $value.content | quote }}
Expand Down
8 changes: 2 additions & 6 deletions charts/producer-app/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,8 @@ apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: {{ template "producer-app.fullname" . }}
{{- if .Values.annotations }}
annotations:
{{- range $key, $value := .Values.annotations }}
{{ $key | quote }}: {{ $value | quote }}
{{- end }}
{{- end }}
{{- include "producer-app.annotations" . | nindent 2 }}

labels:
app: {{ template "producer-app.name" . }}
chart: {{ template "producer-app.chart" . }}
Expand Down
7 changes: 1 addition & 6 deletions charts/producer-app/templates/job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,7 @@ kind: Job
{{- end }}
metadata:
name: {{ template "producer-app.fullname" . }}
{{- if .Values.annotations }}
annotations:
{{- range $key, $value := .Values.annotations }}
{{ $key | quote }}: {{ $value | quote }}
{{- end }}
{{- end }}
{{- include "producer-app.annotations" . | nindent 2 }}
labels:
app: {{ template "producer-app.name" . }}
chart: {{ template "producer-app.chart" . }}
Expand Down
1 change: 1 addition & 0 deletions charts/producer-app/templates/secrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: v1
kind: Secret
metadata:
name: {{ template "producer-app.fullname" . }}
{{- include "producer-app.annotations" . | nindent 2 }}
type: Opaque
data:
{{- range $key, $value := .Values.secrets }}
Expand Down
1 change: 1 addition & 0 deletions charts/producer-app/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: v1
kind: Service
metadata:
name: {{ template "producer-app.fullname" . }}
{{- include "producer-app.annotations" . | nindent 2 }}
labels:
app: {{ template "producer-app.name" . }}
chart: {{ template "producer-app.chart" . }}
Expand Down
12 changes: 12 additions & 0 deletions charts/streams-app-cleanup-job/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,15 @@ Create chart name and version as used by the chart label.
{{- define "streams-app.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Helper function to add annotations to resources
*/}}
{{- define "streams-app.annotations" -}}
{{- if .Values.annotations }}
annotations:
{{- range $key, $value := .Values.annotations }}
{{ $key | quote }}: {{ $value | quote }}
{{- end }}
{{- end }}
{{- end }}
1 change: 1 addition & 0 deletions charts/streams-app-cleanup-job/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "streams-app.name" . }}
{{- include "streams-app.annotations" . | nindent 2 }}
data:
{{- range $key, $value := .Values.files }}
{{ $key }}: {{ $value.content | quote }}
Expand Down
7 changes: 1 addition & 6 deletions charts/streams-app-cleanup-job/templates/job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ apiVersion: batch/v1
kind: Job
metadata:
name: {{ template "streams-app.fullname" . }}
{{- if .Values.annotations }}
annotations:
{{- range $key, $value := .Values.annotations }}
{{ $key | quote }}: {{ $value | quote }}
{{- end }}
{{- end }}
{{- include "streams-app.annotations" . | nindent 2 }}
labels:
app: {{ template "streams-app.name" . }}
chart: {{ template "streams-app.chart" . }}
Expand Down
1 change: 1 addition & 0 deletions charts/streams-app-cleanup-job/templates/secrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: v1
kind: Secret
metadata:
name: {{ template "streams-app.fullname" . }}
{{- include "streams-app.annotations" . | nindent 2 }}
type: Opaque
data:
{{- range $key, $value := .Values.secrets }}
Expand Down
17 changes: 17 additions & 0 deletions charts/streams-app/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,20 @@ Create chart name and version as used by the chart label.
{{- define "streams-app.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Helper function to add annotations to resources
*/}}
{{- define "streams-app.annotations" -}}
{{- if or .Values.kafka.applicationId .Values.annotations }}
annotations:
{{- range $key, $value := .Values.annotations }}
{{ $key | quote }}: {{ $value | quote }}
{{- end }}

{{- if and .Values.kafka.applicationId (not .Values.annotations.consumerGroup) }}
consumerGroup: {{ .Values.kafka.applicationId | quote }}
{{- end }}
{{- end }}
{{- end }}

1 change: 1 addition & 0 deletions charts/streams-app/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "streams-app.name" . }}
{{- include "streams-app.annotations" . | nindent 2 }}
data:
{{- range $key, $value := .Values.files }}
{{ $key }}: {{ $value.content | quote }}
Expand Down
10 changes: 1 addition & 9 deletions charts/streams-app/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,7 @@ kind: Deployment
{{- end }}
metadata:
name: {{ template "streams-app.fullname" . }}
{{- if or .Values.kafka.applicationId .Values.annotations }}
annotations:
{{- range $key, $value := .Values.annotations }}
{{ $key | quote }}: {{ $value | quote }}
{{- end }}
{{- if and .Values.kafka.applicationId (not .Values.annotations.consumerGroup) }}
consumerGroup: {{ .Values.kafka.applicationId | quote }}
{{- end }}
{{- end }}
{{- include "streams-app.annotations" . | nindent 2 }}
labels:
app: {{ template "streams-app.name" . }}
chart: {{ template "streams-app.chart" . }}
Expand Down
1 change: 1 addition & 0 deletions charts/streams-app/templates/jmx-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "streams-app.name" . }}-jmx-configmap
{{- include "streams-app.annotations" . | nindent 2 }}
labels:
app: {{ template "streams-app.name" . }}
chart: {{ template "streams-app.chart" . }}
Expand Down
1 change: 1 addition & 0 deletions charts/streams-app/templates/scaled-object.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: {{ template "streams-app.fullname" . }}-so
{{- include "streams-app.annotations" . | nindent 2 }}
spec:
scaleTargetRef:
{{- if .Capabilities.APIVersions.Has "apps/v1" }}
Expand Down
1 change: 1 addition & 0 deletions charts/streams-app/templates/secrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: v1
kind: Secret
metadata:
name: {{ template "streams-app.fullname" . }}
{{- include "streams-app.annotations" . | nindent 2 }}
type: Opaque
data:
{{- range $key, $value := .Values.secrets }}
Expand Down
1 change: 1 addition & 0 deletions charts/streams-app/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: v1
kind: Service
metadata:
name: {{ template "streams-app.fullname" . }}
{{- include "streams-app.annotations" . | nindent 2 }}
labels:
app: {{ template "streams-app.name" . }}
chart: {{ template "streams-app.chart" . }}
Expand Down

0 comments on commit fd59688

Please sign in to comment.