diff --git a/charts/producer-app-cleanup-job/templates/_helpers.tpl b/charts/producer-app-cleanup-job/templates/_helpers.tpl index 62aa7f71..2aee4cbd 100644 --- a/charts/producer-app-cleanup-job/templates/_helpers.tpl +++ b/charts/producer-app-cleanup-job/templates/_helpers.tpl @@ -3,9 +3,8 @@ Expand the name of the chart. */}} {{- define "producer-app.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} -{{- end -}} - +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} {{/* Create a default fully qualified app name. @@ -13,21 +12,44 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this If release name contains chart name it will be used as a full name. */}} {{- define "producer-app.fullname" -}} -{{- if .Values.fullnameOverride -}} -{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} -{{- else -}} -{{- $name := default .Values.nameOverride -}} -{{- printf "%s" $name | trunc 63 | trimSuffix "-" -}} -{{- end -}} -{{- end -}} +{{- 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 "producer-app.chart" -}} -{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} -{{- end -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "producer-app.labels" -}} +helm.sh/chart: {{ include "producer-app.chart" . }} +{{ include "producer-app.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} +{{/* +Selector labels +*/}} +{{- define "producer-app.selectorLabels" -}} +app.kubernetes.io/name: {{ include "producer-app.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} {{/* Helper function to add annotations to resources diff --git a/charts/producer-app-cleanup-job/templates/configmap.yaml b/charts/producer-app-cleanup-job/templates/configmap.yaml index 80de6dab..53e81a72 100644 --- a/charts/producer-app-cleanup-job/templates/configmap.yaml +++ b/charts/producer-app-cleanup-job/templates/configmap.yaml @@ -2,8 +2,13 @@ apiVersion: v1 kind: ConfigMap metadata: - name: {{ template "producer-app.name" . }} + name: {{ include "producer-app.fullname" . }} {{- include "producer-app.annotations" . }} + labels: + {{- include "producer-app.labels" . | nindent 4 }} + {{- range $key, $value := .Values.labels }} + {{ $key | quote }}: {{ $value | quote }} + {{- end }} data: {{- range $key, $value := .Values.files }} {{ $key }}: {{ $value.content | quote }} diff --git a/charts/producer-app-cleanup-job/templates/job.yaml b/charts/producer-app-cleanup-job/templates/job.yaml index 5a59b8ec..721a9369 100644 --- a/charts/producer-app-cleanup-job/templates/job.yaml +++ b/charts/producer-app-cleanup-job/templates/job.yaml @@ -2,14 +2,12 @@ apiVersion: batch/v1 kind: Job metadata: - name: {{ template "producer-app.fullname" . }} + name: {{ include "producer-app.fullname" . }} {{- include "producer-app.annotations" . }} labels: - app: {{ template "producer-app.name" . }} - chart: {{ template "producer-app.chart" . }} - release: {{ .Release.Name }} + {{- include "producer-app.labels" . | nindent 4 }} {{- range $key, $value := .Values.labels }} - {{ $key }}: {{ $value }} + {{ $key | quote }}: {{ $value | quote }} {{- end }} spec: ttlSecondsAfterFinished: 30 @@ -22,8 +20,7 @@ spec: {{- end }} {{- end }} labels: - app: {{ template "producer-app.name" . }} - release: {{ .Release.Name }} + {{- include "producer-app.labels" . | nindent 8 }} {{- range $key, $value := .Values.podLabels }} {{ $key }}: {{ $value }} {{- end }} @@ -45,7 +42,7 @@ spec: {{- toYaml .Values.imagePullSecrets | nindent 8 }} {{- end }} containers: - - name: {{ template "producer-app.name" . }} + - name: "kafka-app" image: "{{ .Values.image }}:{{ .Values.imageTag }}" imagePullPolicy: "{{ .Values.imagePullPolicy }}" resources: @@ -79,7 +76,7 @@ spec: - name: "{{ $key }}" valueFrom: secretKeyRef: - name: {{ template "producer-app.fullname" $ }} + name: {{ include "producer-app.fullname" . }} key: "{{ $key }}" {{- end }} {{- range $key, $value := .Values.secretRefs }} @@ -123,7 +120,7 @@ spec: {{- if .Values.files }} - name: config configMap: - name: {{ template "producer-app.name" . }} + name: {{ include "producer-app.fullname" . }} {{- end }} {{- range .Values.secretFilesRefs }} - name: {{ .volume }} diff --git a/charts/producer-app-cleanup-job/templates/secrets.yaml b/charts/producer-app-cleanup-job/templates/secrets.yaml index ed82c698..0e84804e 100644 --- a/charts/producer-app-cleanup-job/templates/secrets.yaml +++ b/charts/producer-app-cleanup-job/templates/secrets.yaml @@ -2,8 +2,13 @@ apiVersion: v1 kind: Secret metadata: - name: {{ template "producer-app.fullname" . }} + name: {{ include "producer-app.fullname" . }} {{- include "producer-app.annotations" . }} + labels: + {{- include "producer-app.labels" . | nindent 4 }} + {{- range $key, $value := .Values.labels }} + {{ $key | quote }}: {{ $value | quote }} + {{- end }} type: Opaque data: {{- range $key, $value := .Values.secrets }} diff --git a/charts/producer-app-cleanup-job/values.yaml b/charts/producer-app-cleanup-job/values.yaml index 7851d2d8..f7143098 100644 --- a/charts/producer-app-cleanup-job/values.yaml +++ b/charts/producer-app-cleanup-job/values.yaml @@ -1,4 +1,5 @@ -nameOverride: bakdata-producer-app-job +nameOverride: "" +fullnameOverride: "" image: producerApp imageTag: latest diff --git a/charts/producer-app/README.md b/charts/producer-app/README.md index 3870c527..55223569 100644 --- a/charts/producer-app/README.md +++ b/charts/producer-app/README.md @@ -11,13 +11,14 @@ Alternatively, a YAML file that specifies the values for the parameters can be p ### Job | Parameter | Description | Default | -| ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------ | -| `nameOverride` | The name of the Kubernetes deployment. | `bakdata-producer-app` | +|------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------| +| `nameOverride` | The name of the chart. | | +| `fullnameOverride` | The full qualified app name. | | | `resources` | See https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ | see [values.yaml](values.yaml) for details | | `annotations` | Map of custom annotations to attach to the deployment. | `{}` | | `labels` | Map of custom labels to attach to the deployment. | `{}` | | `tolerations` | Array containing taint references. When defined, pods can run on nodes, which would otherwise deny scheduling. Further information can be found in the [Kubernetes documentation](https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/) | `{}` | -| `affinity` | Map to configure [pod affinities](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity). | `{}` | +| `affinity` | Map to configure [pod affinities](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity). | `{}` | | `deployment` | Deploy the producer as a Kubernetes Deployment (thereby ignoring Job-related configurations) | false | | `restartPolicy` | [Restart policy](https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#restart-policy) to use for the job. | `OnFailure` | | `schedule` | Cron expression to denote a schedule this producer app should be run on. It will then be deployed as a [CronJob](https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/) instead of a [Job](https://kubernetes.io/docs/concepts/workloads/controllers/job/). | | diff --git a/charts/producer-app/templates/_helpers.tpl b/charts/producer-app/templates/_helpers.tpl index fab64375..2aee4cbd 100644 --- a/charts/producer-app/templates/_helpers.tpl +++ b/charts/producer-app/templates/_helpers.tpl @@ -3,8 +3,8 @@ Expand the name of the chart. */}} {{- define "producer-app.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} -{{- end -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} {{/* Create a default fully qualified app name. @@ -12,20 +12,44 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this If release name contains chart name it will be used as a full name. */}} {{- define "producer-app.fullname" -}} -{{- if .Values.fullnameOverride -}} -{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} -{{- else -}} -{{- $name := default .Values.nameOverride -}} -{{- printf "%s" $name | trunc 63 | trimSuffix "-" -}} -{{- end -}} -{{- end -}} +{{- 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 "producer-app.chart" -}} -{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} -{{- end -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "producer-app.labels" -}} +helm.sh/chart: {{ include "producer-app.chart" . }} +{{ include "producer-app.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "producer-app.selectorLabels" -}} +app.kubernetes.io/name: {{ include "producer-app.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} {{/* Helper function to add annotations to resources diff --git a/charts/producer-app/templates/pod.yaml b/charts/producer-app/templates/_pod.yaml similarity index 95% rename from charts/producer-app/templates/pod.yaml rename to charts/producer-app/templates/_pod.yaml index e490e9ed..3e460371 100644 --- a/charts/producer-app/templates/pod.yaml +++ b/charts/producer-app/templates/_pod.yaml @@ -11,9 +11,8 @@ metadata: {{- end }} {{- end }} labels: - app: {{ template "producer-app.name" . }} + {{- include "producer-app.labels" . | nindent 4 }} streams-bootstrap/kind: {{ .Chart.Name }} - release: {{ .Release.Name }} {{- range $key, $value := .Values.podLabels }} {{ $key }}: {{ $value }} {{- end }} @@ -37,7 +36,7 @@ spec: {{- toYaml .Values.imagePullSecrets | nindent 8 }} {{- end }} containers: - - name: {{ template "producer-app.name" . }} + - name: "kafka-app" image: "{{ .Values.image }}:{{ .Values.imageTag }}" imagePullPolicy: "{{ .Values.imagePullPolicy }}" resources: @@ -69,7 +68,7 @@ spec: - name: "{{ $key }}" valueFrom: secretKeyRef: - name: {{ template "producer-app.fullname" $ }} + name: {{ include "producer-app.fullname" . }} key: "{{ $key }}" {{- end }} {{- range $key, $value := .Values.secretRefs }} @@ -129,7 +128,7 @@ spec: {{- if .Values.files }} - name: config configMap: - name: {{ template "producer-app.name" . }} + name: {{ include "producer-app.fullname" . }} {{- end }} {{- range .Values.secretFilesRefs }} - name: {{ .volume }} diff --git a/charts/producer-app/templates/configmap.yaml b/charts/producer-app/templates/configmap.yaml index 80de6dab..53e81a72 100644 --- a/charts/producer-app/templates/configmap.yaml +++ b/charts/producer-app/templates/configmap.yaml @@ -2,8 +2,13 @@ apiVersion: v1 kind: ConfigMap metadata: - name: {{ template "producer-app.name" . }} + name: {{ include "producer-app.fullname" . }} {{- include "producer-app.annotations" . }} + labels: + {{- include "producer-app.labels" . | nindent 4 }} + {{- range $key, $value := .Values.labels }} + {{ $key | quote }}: {{ $value | quote }} + {{- end }} data: {{- range $key, $value := .Values.files }} {{ $key }}: {{ $value.content | quote }} diff --git a/charts/producer-app/templates/deployment.yaml b/charts/producer-app/templates/deployment.yaml index 345b9dc6..7082b51a 100644 --- a/charts/producer-app/templates/deployment.yaml +++ b/charts/producer-app/templates/deployment.yaml @@ -7,22 +7,19 @@ apiVersion: apps/v1beta1 {{- end }} kind: Deployment metadata: - name: {{ template "producer-app.fullname" . }} + name: {{ include "producer-app.fullname" . }} {{- include "producer-app.annotations" . }} labels: - app: {{ template "producer-app.name" . }} - chart: {{ template "producer-app.chart" . }} + {{- include "producer-app.labels" . | nindent 4 }} streams-bootstrap/kind: {{ .Chart.Name }} - release: {{ .Release.Name }} {{- range $key, $value := .Values.labels }} - {{ $key }}: {{ $value }} + {{ $key | quote }}: {{ $value | quote }} {{- end }} spec: replicas: {{ .Values.replicaCount }} selector: matchLabels: - app: {{ template "producer-app.name" . }} - release: {{ .Release.Name }} + {{- include "producer-app.selectorLabels" . | nindent 6 }} template: {{ include "producer-app.podTemplate" . | indent 4 }} {{- end }} diff --git a/charts/producer-app/templates/job.yaml b/charts/producer-app/templates/job.yaml index 7d56d830..705110bc 100644 --- a/charts/producer-app/templates/job.yaml +++ b/charts/producer-app/templates/job.yaml @@ -12,15 +12,13 @@ apiVersion: batch/v1 kind: Job {{- end }} metadata: - name: {{ template "producer-app.fullname" . }} + name: {{ include "producer-app.fullname" . }} {{- include "producer-app.annotations" . }} labels: - app: {{ template "producer-app.name" . }} - chart: {{ template "producer-app.chart" . }} + {{- include "producer-app.labels" . | nindent 4 }} streams-bootstrap/kind: {{ .Chart.Name }} - release: {{ .Release.Name }} {{- range $key, $value := .Values.labels }} - {{ $key }}: {{ $value }} + {{ $key | quote }}: {{ $value | quote }} {{- end }} spec: {{- if .Values.schedule }} @@ -30,6 +28,14 @@ spec: failedJobsHistoryLimit: {{ .Values.failedJobsHistoryLimit }} concurrencyPolicy: Replace jobTemplate: + metadata: + {{- include "producer-app.annotations" . | indent 4 }} + labels: + {{- include "producer-app.labels" . | nindent 8 }} + streams-bootstrap/kind: {{ .Chart.Name }} + {{- range $key, $value := .Values.labels }} + {{ $key | quote }}: {{ $value | quote }} + {{- end }} spec: {{- if .Values.ttlSecondsAfterFinished }} ttlSecondsAfterFinished: {{ .Values.ttlSecondsAfterFinished }} diff --git a/charts/producer-app/templates/secrets.yaml b/charts/producer-app/templates/secrets.yaml index ed82c698..0e84804e 100644 --- a/charts/producer-app/templates/secrets.yaml +++ b/charts/producer-app/templates/secrets.yaml @@ -2,8 +2,13 @@ apiVersion: v1 kind: Secret metadata: - name: {{ template "producer-app.fullname" . }} + name: {{ include "producer-app.fullname" . }} {{- include "producer-app.annotations" . }} + labels: + {{- include "producer-app.labels" . | nindent 4 }} + {{- range $key, $value := .Values.labels }} + {{ $key | quote }}: {{ $value | quote }} + {{- end }} type: Opaque data: {{- range $key, $value := .Values.secrets }} diff --git a/charts/producer-app/templates/service.yaml b/charts/producer-app/templates/service.yaml index fa4ca75a..dad7a7cd 100644 --- a/charts/producer-app/templates/service.yaml +++ b/charts/producer-app/templates/service.yaml @@ -2,19 +2,16 @@ apiVersion: v1 kind: Service metadata: - name: {{ template "producer-app.fullname" . }} + name: {{ include "producer-app.fullname" . }} {{- include "producer-app.annotations" . }} labels: - app: {{ template "producer-app.name" . }} - chart: {{ template "producer-app.chart" . }} - release: {{ .Release.Name }} + {{- include "producer-app.labels" . | nindent 4 }} {{- range $key, $value := .Values.service.labels }} {{ $key }}: {{ $value }} {{- end }} spec: selector: - app: {{ template "producer-app.name" . }} - release: {{ .Release.Name }} + {{- include "producer-app.selectorLabels" . | nindent 4 }} ports: {{- range .Values.ports }} {{- if .servicePort }} diff --git a/charts/producer-app/values.yaml b/charts/producer-app/values.yaml index 56a091bf..ba8db243 100644 --- a/charts/producer-app/values.yaml +++ b/charts/producer-app/values.yaml @@ -1,4 +1,5 @@ -nameOverride: bakdata-producer-app +nameOverride: "" +fullnameOverride: "" image: producerApp imageTag: latest diff --git a/charts/streams-app-cleanup-job/templates/_helpers.tpl b/charts/streams-app-cleanup-job/templates/_helpers.tpl index efecc7d0..a69ba62a 100644 --- a/charts/streams-app-cleanup-job/templates/_helpers.tpl +++ b/charts/streams-app-cleanup-job/templates/_helpers.tpl @@ -3,9 +3,8 @@ Expand the name of the chart. */}} {{- define "streams-app.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} -{{- end -}} - +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} {{/* Create a default fully qualified app name. @@ -13,20 +12,47 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this If release name contains chart name it will be used as a full name. */}} {{- define "streams-app.fullname" -}} -{{- if .Values.fullnameOverride -}} -{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} -{{- else -}} -{{- $name := default .Values.nameOverride -}} -{{- printf "%s" $name | trunc 63 | trimSuffix "-" -}} -{{- end -}} -{{- end -}} +{{- 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 "streams-app.chart" -}} -{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} -{{- end -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "streams-app.labels" -}} +helm.sh/chart: {{ include "streams-app.chart" . }} +{{ include "streams-app.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- range $key, $value := .Values.labels }} +{{ $key | quote }}: {{ $value | quote }} +{{- end }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "streams-app.selectorLabels" -}} +app.kubernetes.io/name: {{ include "streams-app.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} {{/* Helper function to add annotations to resources diff --git a/charts/streams-app-cleanup-job/templates/configmap.yaml b/charts/streams-app-cleanup-job/templates/configmap.yaml index 03f0db84..24085899 100644 --- a/charts/streams-app-cleanup-job/templates/configmap.yaml +++ b/charts/streams-app-cleanup-job/templates/configmap.yaml @@ -2,8 +2,13 @@ apiVersion: v1 kind: ConfigMap metadata: - name: {{ template "streams-app.name" . }} + name: {{ include "streams-app.fullname" . }} {{- include "streams-app.annotations" . }} + labels: + {{- include "streams-app.labels" . | nindent 4 }} + {{- range $key, $value := .Values.labels }} + {{ $key | quote }}: {{ $value | quote }} + {{- end }} data: {{- range $key, $value := .Values.files }} {{ $key }}: {{ $value.content | quote }} diff --git a/charts/streams-app-cleanup-job/templates/job.yaml b/charts/streams-app-cleanup-job/templates/job.yaml index d03a5f01..b947c260 100644 --- a/charts/streams-app-cleanup-job/templates/job.yaml +++ b/charts/streams-app-cleanup-job/templates/job.yaml @@ -2,14 +2,12 @@ apiVersion: batch/v1 kind: Job metadata: - name: {{ template "streams-app.fullname" . }} + name: {{ include "streams-app.fullname" . }} {{- include "streams-app.annotations" . }} labels: - app: {{ template "streams-app.name" . }} - chart: {{ template "streams-app.chart" . }} - release: {{ .Release.Name }} + {{- include "streams-app.labels" . | nindent 4 }} {{- range $key, $value := .Values.labels }} - {{ $key }}: {{ $value }} + {{ $key | quote }}: {{ $value | quote }} {{- end }} spec: ttlSecondsAfterFinished: 30 @@ -22,8 +20,7 @@ spec: {{- end }} {{- end }} labels: - app: {{ template "streams-app.name" . }} - release: {{ .Release.Name }} + {{- include "streams-app.labels" . | nindent 8 }} {{- range $key, $value := .Values.podLabels }} {{ $key }}: {{ $value }} {{- end }} @@ -45,7 +42,7 @@ spec: {{- toYaml .Values.imagePullSecrets | nindent 8 }} {{- end }} containers: - - name: {{ template "streams-app.name" . }} + - name: "kafka-app" image: "{{ .Values.image }}:{{ .Values.imageTag }}" imagePullPolicy: "{{ .Values.imagePullPolicy }}" resources: @@ -108,7 +105,7 @@ spec: - name: "{{ $key }}" valueFrom: secretKeyRef: - name: {{ template "streams-app.fullname" $ }} + name: {{ include "streams-app.fullname" . }} key: "{{ $key }}" {{- end }} {{- range $key, $value := .Values.secretRefs }} @@ -152,7 +149,7 @@ spec: {{- if .Values.files }} - name: config configMap: - name: {{ template "streams-app.name" . }} + name: {{ include "streams-app.fullname" . }} {{- end }} {{- range .Values.secretFilesRefs }} - name: {{ .volume }} diff --git a/charts/streams-app-cleanup-job/templates/secrets.yaml b/charts/streams-app-cleanup-job/templates/secrets.yaml index 8c818c94..48e1d453 100644 --- a/charts/streams-app-cleanup-job/templates/secrets.yaml +++ b/charts/streams-app-cleanup-job/templates/secrets.yaml @@ -2,8 +2,13 @@ apiVersion: v1 kind: Secret metadata: - name: {{ template "streams-app.fullname" . }} + name: {{ include "streams-app.fullname" . }} {{- include "streams-app.annotations" . }} + labels: + {{- include "streams-app.labels" . | nindent 4 }} + {{- range $key, $value := .Values.labels }} + {{ $key | quote }}: {{ $value | quote }} + {{- end }} type: Opaque data: {{- range $key, $value := .Values.secrets }} diff --git a/charts/streams-app-cleanup-job/values.yaml b/charts/streams-app-cleanup-job/values.yaml index 4a019581..7e4b87a5 100644 --- a/charts/streams-app-cleanup-job/values.yaml +++ b/charts/streams-app-cleanup-job/values.yaml @@ -1,4 +1,5 @@ -nameOverride: bakdata-streams-app-job +nameOverride: "" +fullnameOverride: "" image: streamsApp imageTag: latest diff --git a/charts/streams-app/README.md b/charts/streams-app/README.md index bf44c98d..7563d517 100644 --- a/charts/streams-app/README.md +++ b/charts/streams-app/README.md @@ -11,8 +11,9 @@ Alternatively, a YAML file that specifies the values for the parameters can be p ### Deployment | Parameter | Description | Default | -| ------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------ | -| `nameOverride` | The name of the Kubernetes deployment. | `bakdata-streams-app` | +|---------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------| +| `nameOverride` | The name of the chart. | | +| `fullnameOverride` | The full qualified app name. | | | `replicaCount` | The number of Kafka Streams replicas. | `1` | | `resources` | See https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ | see [values.yaml](values.yaml) for details | | `annotations` | Map of custom annotations to attach to the deployment. | `{}` | diff --git a/charts/streams-app/templates/_helpers.tpl b/charts/streams-app/templates/_helpers.tpl index 4ab36d95..2c37b413 100644 --- a/charts/streams-app/templates/_helpers.tpl +++ b/charts/streams-app/templates/_helpers.tpl @@ -3,9 +3,8 @@ Expand the name of the chart. */}} {{- define "streams-app.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} -{{- end -}} - +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} {{/* Create a default fully qualified app name. @@ -13,20 +12,44 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this If release name contains chart name it will be used as a full name. */}} {{- define "streams-app.fullname" -}} -{{- if .Values.fullnameOverride -}} -{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} -{{- else -}} -{{- $name := default .Values.nameOverride -}} -{{- printf "%s" $name | trunc 63 | trimSuffix "-" -}} -{{- end -}} -{{- end -}} +{{- 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 "streams-app.chart" -}} -{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} -{{- end -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "streams-app.labels" -}} +helm.sh/chart: {{ include "streams-app.chart" . }} +{{ include "streams-app.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "streams-app.selectorLabels" -}} +app.kubernetes.io/name: {{ include "streams-app.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} {{/* Define default annotations from .Values.annotations. diff --git a/charts/streams-app/templates/configmap.yaml b/charts/streams-app/templates/configmap.yaml index 03f0db84..24085899 100644 --- a/charts/streams-app/templates/configmap.yaml +++ b/charts/streams-app/templates/configmap.yaml @@ -2,8 +2,13 @@ apiVersion: v1 kind: ConfigMap metadata: - name: {{ template "streams-app.name" . }} + name: {{ include "streams-app.fullname" . }} {{- include "streams-app.annotations" . }} + labels: + {{- include "streams-app.labels" . | nindent 4 }} + {{- range $key, $value := .Values.labels }} + {{ $key | quote }}: {{ $value | quote }} + {{- end }} data: {{- range $key, $value := .Values.files }} {{ $key }}: {{ $value.content | quote }} diff --git a/charts/streams-app/templates/deployment.yaml b/charts/streams-app/templates/deployment.yaml index e418633f..1b403914 100644 --- a/charts/streams-app/templates/deployment.yaml +++ b/charts/streams-app/templates/deployment.yaml @@ -14,19 +14,17 @@ kind: StatefulSet kind: Deployment {{- end }} metadata: - name: {{ template "streams-app.fullname" . }} + name: {{ include "streams-app.fullname" . }} {{- include "streams-app.deployment-annotations" . }} labels: - app: {{ template "streams-app.name" . }} - chart: {{ template "streams-app.chart" . }} + {{- include "streams-app.labels" . | nindent 4 }} streams-bootstrap/kind: {{ .Chart.Name }} - release: {{ .Release.Name }} {{- range $key, $value := .Values.labels }} - {{ $key }}: {{ $value }} + {{ $key | quote }}: {{ $value | quote }} {{- end }} spec: {{- if .Values.statefulSet }} - serviceName: {{ template "streams-app.name" . }} + serviceName: {{ include "streams-app.fullname" . }} podManagementPolicy: Parallel {{- end }} {{- if (not .Values.autoscaling.enabled) }} @@ -34,8 +32,7 @@ spec: {{- end }} selector: matchLabels: - app: {{ template "streams-app.name" . }} - release: {{ .Release.Name }} + {{- include "streams-app.selectorLabels" . | nindent 6 }} template: metadata: {{- if or .Values.podAnnotations .Values.files }} @@ -48,9 +45,8 @@ spec: {{- end }} {{- end }} labels: - app: {{ template "streams-app.name" . }} + {{- include "streams-app.labels" . | nindent 8 }} streams-bootstrap/kind: {{ .Chart.Name }} - release: {{ .Release.Name }} {{- range $key, $value := .Values.podLabels }} {{ $key }}: {{ $value }} {{- end }} @@ -75,7 +71,7 @@ spec: {{- toYaml .Values.imagePullSecrets | nindent 8 }} {{- end }} containers: - - name: {{ template "streams-app.name" . }} + - name: "kafka-app" image: "{{ .Values.image }}:{{ .Values.imageTag }}" imagePullPolicy: "{{ .Values.imagePullPolicy }}" resources: @@ -152,7 +148,7 @@ spec: - name: "{{ $key }}" valueFrom: secretKeyRef: - name: {{ template "streams-app.fullname" $ }} + name: {{ include "streams-app.fullname" . }} key: "{{ $key }}" {{- end }} {{- range $key, $value := .Values.secretRefs }} @@ -202,7 +198,7 @@ spec: mountPath: /tmp/kafka-streams {{- end }} {{- end }} - {{- if or (.Values.prometheus.jmx.enabled) (.Values.ports) }} + {{- if or (.Values.jmx.enabled) (.Values.ports) }} ports: {{- range .Values.ports }} - containerPort: {{ .containerPort }} @@ -248,12 +244,12 @@ spec: {{- if .Values.prometheus.jmx.enabled }} - name: jmx-config configMap: - name: {{ template "streams-app.name" . }}-jmx-configmap + name: {{ include "streams-app.fullname" . }}-jmx {{- end }} {{- if .Values.files }} - name: config configMap: - name: {{ template "streams-app.name" . }} + name: {{ include "streams-app.fullname" . }} {{- end }} {{- range .Values.secretFilesRefs }} - name: {{ .volume }} diff --git a/charts/streams-app/templates/jmx-configmap.yaml b/charts/streams-app/templates/jmx-configmap.yaml index 53dd2c79..d4764388 100644 --- a/charts/streams-app/templates/jmx-configmap.yaml +++ b/charts/streams-app/templates/jmx-configmap.yaml @@ -2,13 +2,13 @@ apiVersion: v1 kind: ConfigMap metadata: - name: {{ template "streams-app.name" . }}-jmx-configmap + name: {{ include "streams-app.fullname" . }}-jmx {{- include "streams-app.annotations" . }} labels: - app: {{ template "streams-app.name" . }} - chart: {{ template "streams-app.chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} + {{- include "streams-app.labels" . | nindent 4 }} + {{- range $key, $value := .Values.labels }} + {{ $key | quote }}: {{ $value | quote }} + {{- end }} data: jmx-kafka-streams-app-prometheus.yml: |+ jmxUrl: service:jmx:rmi:///jndi/rmi://localhost:{{ .Values.jmx.port }}/jmxrmi diff --git a/charts/streams-app/templates/scaled-object.yaml b/charts/streams-app/templates/scaled-object.yaml index 1eca859e..a6fa4838 100644 --- a/charts/streams-app/templates/scaled-object.yaml +++ b/charts/streams-app/templates/scaled-object.yaml @@ -6,8 +6,13 @@ apiVersion: keda.sh/v1alpha1 kind: ScaledObject metadata: - name: {{ template "streams-app.fullname" . }}-so + name: {{ include "streams-app.fullname" . }}-so {{- include "streams-app.annotations" . }} + labels: + {{- include "streams-app.labels" . | nindent 4 }} + {{- range $key, $value := .Values.labels }} + {{ $key | quote }}: {{ $value | quote }} + {{- end }} spec: scaleTargetRef: {{- if .Capabilities.APIVersions.Has "apps/v1" }} @@ -20,7 +25,7 @@ spec: {{- else }} kind: Deployment {{- end }} - name: {{ template "streams-app.fullname" . }} + name: {{ include "streams-app.fullname" . }} pollingInterval: {{ .Values.autoscaling.pollingInterval }} cooldownPeriod: {{ .Values.autoscaling.cooldownPeriod }} minReplicaCount: {{ .Values.autoscaling.minReplicas }} diff --git a/charts/streams-app/templates/secrets.yaml b/charts/streams-app/templates/secrets.yaml index 8c818c94..48e1d453 100644 --- a/charts/streams-app/templates/secrets.yaml +++ b/charts/streams-app/templates/secrets.yaml @@ -2,8 +2,13 @@ apiVersion: v1 kind: Secret metadata: - name: {{ template "streams-app.fullname" . }} + name: {{ include "streams-app.fullname" . }} {{- include "streams-app.annotations" . }} + labels: + {{- include "streams-app.labels" . | nindent 4 }} + {{- range $key, $value := .Values.labels }} + {{ $key | quote }}: {{ $value | quote }} + {{- end }} type: Opaque data: {{- range $key, $value := .Values.secrets }} diff --git a/charts/streams-app/templates/service.yaml b/charts/streams-app/templates/service.yaml index 596d7f1e..ddc709ed 100644 --- a/charts/streams-app/templates/service.yaml +++ b/charts/streams-app/templates/service.yaml @@ -2,19 +2,16 @@ apiVersion: v1 kind: Service metadata: - name: {{ template "streams-app.fullname" . }} + name: {{ include "streams-app.fullname" . }} {{- include "streams-app.annotations" . }} labels: - app: {{ template "streams-app.name" . }} - chart: {{ template "streams-app.chart" . }} - release: {{ .Release.Name }} + {{- include "streams-app.labels" . | nindent 4 }} {{- range $key, $value := .Values.service.labels }} {{ $key }}: {{ $value }} {{- end }} spec: selector: - app: {{ template "streams-app.name" . }} - release: {{ .Release.Name }} + {{- include "streams-app.selectorLabels" . | nindent 4 }} ports: {{- range .Values.ports }} {{- if .servicePort }} diff --git a/charts/streams-app/values.yaml b/charts/streams-app/values.yaml index 2c6eec6c..5d2b6f5f 100644 --- a/charts/streams-app/values.yaml +++ b/charts/streams-app/values.yaml @@ -1,4 +1,5 @@ -nameOverride: bakdata-streams-app +nameOverride: "" +fullnameOverride: "" replicaCount: 1