summaryrefslogtreecommitdiff
path: root/astroshop-helm/kafka
diff options
context:
space:
mode:
authorSaumit <justsaumit@protonmail.com>2025-10-04 01:36:57 +0530
committerSaumit <justsaumit@protonmail.com>2025-10-04 01:36:57 +0530
commitdf2bd058309ac234eebdad3b0682a137e27dfc44 (patch)
tree39be2243787c3bdd595ae123766565f80a8a039c /astroshop-helm/kafka
parent90a62ae7ea5e745b99d8ac8d08ae837bbaedfce5 (diff)
Add tested Helm chart and configuration files for OpenTelemetry demo services
Diffstat (limited to 'astroshop-helm/kafka')
-rw-r--r--astroshop-helm/kafka/.helmignore23
-rw-r--r--astroshop-helm/kafka/Chart.yaml22
-rw-r--r--astroshop-helm/kafka/templates/_helpers.tpl62
-rw-r--r--astroshop-helm/kafka/templates/deployment.yaml87
-rw-r--r--astroshop-helm/kafka/templates/service.yaml16
-rw-r--r--astroshop-helm/kafka/values.yaml53
6 files changed, 263 insertions, 0 deletions
diff --git a/astroshop-helm/kafka/.helmignore b/astroshop-helm/kafka/.helmignore
new file mode 100644
index 0000000..0e8a0eb
--- /dev/null
+++ b/astroshop-helm/kafka/.helmignore
@@ -0,0 +1,23 @@
+# Patterns to ignore when building packages.
+# This supports shell glob matching, relative path matching, and
+# negation (prefixed with !). Only one pattern per line.
+.DS_Store
+# Common VCS dirs
+.git/
+.gitignore
+.bzr/
+.bzrignore
+.hg/
+.hgignore
+.svn/
+# Common backup files
+*.swp
+*.bak
+*.tmp
+*.orig
+*~
+# Various IDEs
+.project
+.idea/
+*.tmproj
+.vscode/
diff --git a/astroshop-helm/kafka/Chart.yaml b/astroshop-helm/kafka/Chart.yaml
new file mode 100644
index 0000000..b943e05
--- /dev/null
+++ b/astroshop-helm/kafka/Chart.yaml
@@ -0,0 +1,22 @@
+apiVersion: v2
+name: kafka
+description: A Helm chart for Kubernetes
+# A chart can be either an 'application' or a 'library' chart.
+#
+# Application charts are a collection of templates that can be packaged into versioned archives
+# to be deployed.
+#
+# Library charts provide useful utilities or functions for the chart developer. They're included as
+# a dependency of application charts to inject those utilities and functions into the rendering
+# pipeline. Library charts do not define any templates and therefore cannot be deployed.
+type: application
+# This is the chart version. This version number should be incremented each time you make changes
+# to the chart and its templates, including the app version.
+# Versions are expected to follow Semantic Versioning (https://semver.org/)
+version: 0.1.0
+# This is the version number of the application being deployed. This version number should be
+# incremented each time you make changes to the application. Versions are not expected to
+# follow Semantic Versioning. They should reflect the version the application is using.
+# It is recommended to use it with quotes.
+appVersion: "2.1.3"
+namespace: opentelemetry-demo \ No newline at end of file
diff --git a/astroshop-helm/kafka/templates/_helpers.tpl b/astroshop-helm/kafka/templates/_helpers.tpl
new file mode 100644
index 0000000..fb7c47d
--- /dev/null
+++ b/astroshop-helm/kafka/templates/_helpers.tpl
@@ -0,0 +1,62 @@
+{{/*
+Expand the name of the chart.
+*/}}
+{{- define "kafka.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 "kafka.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 "kafka.chart" -}}
+{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
+{{- end }}
+
+{{/*
+Common labels
+*/}}
+{{- define "kafka.labels" -}}
+helm.sh/chart: {{ include "kafka.chart" . }}
+{{ include "kafka.selectorLabels" . }}
+{{- if .Chart.AppVersion }}
+app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
+{{- end }}
+app.kubernetes.io/managed-by: {{ .Release.Service }}
+{{- end }}
+
+{{/*
+Selector labels
+*/}}
+{{- define "kafka.selectorLabels" -}}
+app.kubernetes.io/name: {{ include "kafka.name" . }}
+app.kubernetes.io/instance: {{ .Release.Name }}
+{{- end }}
+
+{{/*
+Create the name of the service account to use
+*/}}
+{{- define "kafka.serviceAccountName" -}}
+{{- if .Values.serviceAccount.create }}
+{{- default (include "kafka.fullname" .) .Values.serviceAccount.name }}
+{{- else }}
+{{- default "default" .Values.serviceAccount.name }}
+{{- end }}
+{{- end }}
diff --git a/astroshop-helm/kafka/templates/deployment.yaml b/astroshop-helm/kafka/templates/deployment.yaml
new file mode 100644
index 0000000..8275b42
--- /dev/null
+++ b/astroshop-helm/kafka/templates/deployment.yaml
@@ -0,0 +1,87 @@
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ namespace: {{ .Values.namespace }}
+ name: {{ include "kafka.fullname" . }}
+ labels:
+ app.kubernetes.io/component: kafka
+ app.kubernetes.io/part-of: opentelemetry-demo
+ opentelemetry.io/name: {{ .Values.namespace }}-{{ include "kafka.fullname" . }}
+ {{- include "kafka.labels" . | nindent 4 }}
+spec:
+ replicas: {{ .Values.opentelemetryDemoKafka.replicas }}
+ revisionHistoryLimit: {{ .Values.opentelemetryDemoKafka.revisionHistoryLimit }}
+ selector:
+ matchLabels:
+ opentelemetry.io/name: {{ .Values.namespace }}-{{ include "kafka.fullname" . }}
+ {{- include "kafka.selectorLabels" . | nindent 6 }}
+ template:
+ metadata:
+ labels:
+ app.kubernetes.io/component: kafka
+ app.kubernetes.io/instance: opentelemetry-demo
+ app.kubernetes.io/name: {{ .Values.namespace }}-{{ include "kafka.fullname" . }}
+ opentelemetry.io/name: {{ .Values.namespace }}-{{ include "kafka.fullname" . }}
+ {{- include "kafka.selectorLabels" . | nindent 8 }}
+ spec:
+ containers:
+ - env:
+ - name: OTEL_SERVICE_NAME
+ valueFrom:
+ fieldRef:
+ apiVersion: v1
+ fieldPath: metadata.labels['app.kubernetes.io/component']
+ - name: OTEL_COLLECTOR_NAME
+ value: {{ quote .Values.opentelemetryDemoKafka.kafka.env.otelCollectorName }}
+ - name: OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE
+ value: {{ quote .Values.opentelemetryDemoKafka.kafka.env.otelExporterOtlpMetricsTemporalityPreference }}
+ - name: KAFKA_ADVERTISED_LISTENERS
+ value: {{ quote .Values.opentelemetryDemoKafka.kafka.env.kafkaAdvertisedListeners }}
+ - name: OTEL_EXPORTER_OTLP_ENDPOINT
+ value: {{ quote .Values.opentelemetryDemoKafka.kafka.env.otelExporterOtlpEndpoint }}
+ - name: KAFKA_HEAP_OPTS
+ value: {{ quote .Values.opentelemetryDemoKafka.kafka.env.kafkaHeapOpts }}
+ - name: OTEL_RESOURCE_ATTRIBUTES
+ value: {{ quote .Values.opentelemetryDemoKafka.kafka.env.otelResourceAttributes }}
+ - name: KUBERNETES_CLUSTER_DOMAIN
+ value: {{ quote .Values.kubernetesClusterDomain }}
+
+ # KRaft mode environment variables
+ - name: KAFKA_PROCESS_ROLES
+ value: {{ quote .Values.opentelemetryDemoKafka.kafka.env.processRoles }}
+ - name: KAFKA_NODE_ID
+ value: {{ quote .Values.opentelemetryDemoKafka.kafka.env.nodeId }}
+ - name: KAFKA_CONTROLLER_QUORUM_VOTERS
+ value: {{ quote .Values.opentelemetryDemoKafka.kafka.env.controllerQuorumVoters }}
+ - name: KAFKA_CONTROLLER_LISTENER_NAMES
+ value: {{ quote .Values.opentelemetryDemoKafka.kafka.env.controllerListenerNames }}
+ - name: KAFKA_LISTENER_SECURITY_PROTOCOL_MAP
+ value: {{ quote .Values.opentelemetryDemoKafka.kafka.env.listenerSecurityProtocolMap }}
+ - name: KAFKA_LISTENERS
+ value: {{ quote .Values.opentelemetryDemoKafka.kafka.env.listeners }}
+ - name: KAFKA_INTER_BROKER_LISTENER_NAME
+ value: {{ quote .Values.opentelemetryDemoKafka.kafka.env.interBrokerListenerName }}
+ - name: KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR
+ value: {{ quote .Values.opentelemetryDemoKafka.kafka.env.offsetsTopicReplicationFactor }}
+ - name: KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR
+ value: {{ quote .Values.opentelemetryDemoKafka.kafka.env.transactionStateLogReplicationFactor }}
+ - name: KAFKA_TRANSACTION_STATE_LOG_MIN_ISR
+ value: {{ quote .Values.opentelemetryDemoKafka.kafka.env.transactionStateLogMinIsr }}
+ - name: KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS
+ value: {{ quote .Values.opentelemetryDemoKafka.kafka.env.groupInitialRebalanceDelayMs }}
+ - name: KAFKA_LOG_DIRS
+ value: {{ quote .Values.opentelemetryDemoKafka.kafka.env.logDirs }}
+ - name: CLUSTER_ID
+ value: {{ quote .Values.opentelemetryDemoKafka.kafka.env.clusterId }}
+
+ image: {{ .Values.opentelemetryDemoKafka.kafka.image.repository }}:{{ .Values.opentelemetryDemoKafka.kafka.image.tag | default .Chart.AppVersion }}
+ imagePullPolicy: {{ .Values.opentelemetryDemoKafka.kafka.imagePullPolicy }}
+ name: kafka
+ ports:
+ - containerPort: 9092
+ name: plaintext
+ - containerPort: 9093
+ name: controller
+ resources: {{- toYaml .Values.opentelemetryDemoKafka.kafka.resources | nindent 10 }}
+ securityContext: {{- toYaml .Values.opentelemetryDemoKafka.kafka.containerSecurityContext | nindent 10 }}
+ serviceAccountName: {{ .Values.serviceAccount.name }} \ No newline at end of file
diff --git a/astroshop-helm/kafka/templates/service.yaml b/astroshop-helm/kafka/templates/service.yaml
new file mode 100644
index 0000000..c580713
--- /dev/null
+++ b/astroshop-helm/kafka/templates/service.yaml
@@ -0,0 +1,16 @@
+apiVersion: v1
+kind: Service
+metadata:
+ name: {{ .Values.namespace }}-{{ include "kafka.fullname" . }}
+ labels:
+ app.kubernetes.io/component: kafka
+ app.kubernetes.io/part-of: opentelemetry-demo
+ opentelemetry.io/name: {{ .Values.namespace }}-{{ include "kafka.fullname" . }}
+ {{- include "kafka.labels" . | nindent 4 }}
+spec:
+ type: {{ .Values.opentelemetryDemoKafka.type }}
+ selector:
+ opentelemetry.io/name: {{ .Values.namespace }}-{{ include "kafka.fullname" . }}
+ {{- include "kafka.selectorLabels" . | nindent 4 }}
+ ports:
+ {{- .Values.opentelemetryDemoKafka.ports | toYaml | nindent 2 }}
diff --git a/astroshop-helm/kafka/values.yaml b/astroshop-helm/kafka/values.yaml
new file mode 100644
index 0000000..58e98de
--- /dev/null
+++ b/astroshop-helm/kafka/values.yaml
@@ -0,0 +1,53 @@
+namespace: opentelemetry-demo
+kubernetesClusterDomain: cluster.local
+
+serviceAccount:
+ name: opentelemetry-demo
+ version: ">=1.32.0-0"
+ partOf: opentelemetry-demo
+
+opentelemetryDemoKafka:
+ kafka:
+ containerSecurityContext:
+ runAsGroup: 1000
+ runAsNonRoot: true
+ runAsUser: 1000
+ env:
+ kafkaAdvertisedListeners: PLAINTEXT://opentelemetry-demo-kafka:9092
+ kafkaHeapOpts: -Xmx400M -Xms400M
+ otelCollectorName: opentelemetry-demo-otelcol
+ otelExporterOtlpEndpoint: http://$(OTEL_COLLECTOR_NAME):4318
+ otelExporterOtlpMetricsTemporalityPreference: cumulative
+ otelResourceAttributes: service.name=$(OTEL_SERVICE_NAME),service.namespace=opentelemetry-demo,service.version=2.1.3
+
+ # KRaft mode configurations
+ processRoles: broker,controller
+ nodeId: 1
+ controllerQuorumVoters: 1@opentelemetry-demo-kafka:9093
+ controllerListenerNames: CONTROLLER
+ listenerSecurityProtocolMap: CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT
+ listeners: PLAINTEXT://:9092,CONTROLLER://:9093
+ interBrokerListenerName: PLAINTEXT
+ offsetsTopicReplicationFactor: 1
+ transactionStateLogReplicationFactor: 1
+ transactionStateLogMinIsr: 1
+ groupInitialRebalanceDelayMs: 0
+ logDirs: /var/lib/kafka/data
+ clusterId: ckjPoprWQzOf0-FuNkGfFQ
+ image:
+ repository: ghcr.io/open-telemetry/demo
+ tag: 2.1.3-kafka
+ imagePullPolicy: IfNotPresent
+ resources:
+ limits:
+ memory: 600Mi
+ ports:
+ - name: plaintext
+ port: 9092
+ targetPort: 9092
+ - name: controller
+ port: 9093
+ targetPort: 9093
+ replicas: 1
+ revisionHistoryLimit: 10
+ type: ClusterIP