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

Add annotations to all Kubernetes resources #258

Merged
merged 5 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
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" . }}
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" . }}
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" . }}
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" . }}
data:
{{- range $key, $value := .Values.files }}
{{ $key }}: {{ $value.content | quote }}
Expand Down
7 changes: 1 addition & 6 deletions charts/producer-app/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ 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" . }}
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" . }}
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" . }}
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" . }}
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" . }}
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" . }}
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" . }}
type: Opaque
data:
{{- range $key, $value := .Values.secrets }}
Expand Down
28 changes: 28 additions & 0 deletions charts/streams-app/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,31 @@ 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 -}}

{{/*
Define default annotations from .Values.annotations.
This will be used across resources.
*/}}
{{- define "streams-app.annotations" -}}
{{- if or .Values.annotations }}
annotations:
{{- range $key, $value := .Values.annotations }}
{{ $key | quote }}: {{ $value | quote }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Define annotations helper for Deployment.
Includes default annotations and conditionally adds consumerGroup.
Only includes annotations if there is content.
*/}}
{{- define "streams-app.deployment-annotations" -}}
{{- include "streams-app.annotations" . }}
raminqaf marked this conversation as resolved.
Show resolved Hide resolved
{{- if .Values.kafka.applicationId }}
{{- 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" . }}
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.deployment-annotations" . }}
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" . }}
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" . }}
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" . }}
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" . }}
labels:
app: {{ template "streams-app.name" . }}
chart: {{ template "streams-app.chart" . }}
Expand Down
Loading