From df2bd058309ac234eebdad3b0682a137e27dfc44 Mon Sep 17 00:00:00 2001 From: Saumit Date: Sat, 4 Oct 2025 01:36:57 +0530 Subject: Add tested Helm chart and configuration files for OpenTelemetry demo services --- astroshop-helm/fraud-detection/.helmignore | 23 ++++++++ astroshop-helm/fraud-detection/Chart.yaml | 22 ++++++++ .../fraud-detection/templates/_helpers.tpl | 62 ++++++++++++++++++++++ .../fraud-detection/templates/deployment.yaml | 62 ++++++++++++++++++++++ .../fraud-detection/templates/serviceaccount.yaml | 12 +++++ astroshop-helm/fraud-detection/values.yaml | 31 +++++++++++ 6 files changed, 212 insertions(+) create mode 100644 astroshop-helm/fraud-detection/.helmignore create mode 100644 astroshop-helm/fraud-detection/Chart.yaml create mode 100644 astroshop-helm/fraud-detection/templates/_helpers.tpl create mode 100644 astroshop-helm/fraud-detection/templates/deployment.yaml create mode 100644 astroshop-helm/fraud-detection/templates/serviceaccount.yaml create mode 100644 astroshop-helm/fraud-detection/values.yaml (limited to 'astroshop-helm/fraud-detection') diff --git a/astroshop-helm/fraud-detection/.helmignore b/astroshop-helm/fraud-detection/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/astroshop-helm/fraud-detection/.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/fraud-detection/Chart.yaml b/astroshop-helm/fraud-detection/Chart.yaml new file mode 100644 index 0000000..da1f476 --- /dev/null +++ b/astroshop-helm/fraud-detection/Chart.yaml @@ -0,0 +1,22 @@ +apiVersion: v2 +name: fraud-detection +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/fraud-detection/templates/_helpers.tpl b/astroshop-helm/fraud-detection/templates/_helpers.tpl new file mode 100644 index 0000000..767b8b3 --- /dev/null +++ b/astroshop-helm/fraud-detection/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "fraud-detection.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 "fraud-detection.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 "fraud-detection.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "fraud-detection.labels" -}} +helm.sh/chart: {{ include "fraud-detection.chart" . }} +{{ include "fraud-detection.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "fraud-detection.selectorLabels" -}} +app.kubernetes.io/name: {{ include "fraud-detection.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "fraud-detection.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "fraud-detection.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/astroshop-helm/fraud-detection/templates/deployment.yaml b/astroshop-helm/fraud-detection/templates/deployment.yaml new file mode 100644 index 0000000..8fdd86a --- /dev/null +++ b/astroshop-helm/fraud-detection/templates/deployment.yaml @@ -0,0 +1,62 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + namespace: {{ .Values.namespace }} + name: {{ include "fraud-detection.fullname" . }} + labels: + app.kubernetes.io/component: fraud-detectionservice + app.kubernetes.io/part-of: opentelemetry-demo + opentelemetry.io/name: {{ .Values.namespace }}-{{ include "fraud-detection.fullname" . }} + {{- include "fraud-detection.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.opentelemetryDemoFrauddetectionservice.replicas }} + revisionHistoryLimit: {{ .Values.opentelemetryDemoFrauddetectionservice.revisionHistoryLimit }} + selector: + matchLabels: + opentelemetry.io/name: {{ .Values.namespace }}-{{ include "fraud-detection.fullname" . }} + {{- include "fraud-detection.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + app.kubernetes.io/component: fraud-detectionservice + app.kubernetes.io/instance: opentelemetry-demo + app.kubernetes.io/name: {{ .Values.namespace }}-{{ include "fraud-detection.fullname" . }} + opentelemetry.io/name: {{ .Values.namespace }}-{{ include "fraud-detection.fullname" . }} + {{- include "fraud-detection.selectorLabels" . | nindent 8 }} + spec: + containers: + - env: + - name: OTEL_SERVICE_NAME + value: {{ quote .Values.opentelemetryDemoFrauddetectionservice.fraudDetectionservice.env.otelServiceName }} + - name: OTEL_COLLECTOR_NAME + value: {{ quote .Values.opentelemetryDemoFrauddetectionservice.fraudDetectionservice.env.otelCollectorName }} + - name: OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE + value: {{ quote .Values.opentelemetryDemoFrauddetectionservice.fraudDetectionservice.env.otelExporterOtlpMetricsTemporalityPreference }} + - name: KAFKA_ADDR + value: {{ quote .Values.opentelemetryDemoFrauddetectionservice.fraudDetectionservice.env.kafkaServiceAddr }} + - name: FLAGD_HOST + value: {{ quote .Values.opentelemetryDemoFrauddetectionservice.fraudDetectionservice.env.flagdHost }} + - name: FLAGD_PORT + value: {{ quote .Values.opentelemetryDemoFrauddetectionservice.fraudDetectionservice.env.flagdPort }} + - name: OTEL_EXPORTER_OTLP_ENDPOINT + value: {{ quote .Values.opentelemetryDemoFrauddetectionservice.fraudDetectionservice.env.otelExporterOtlpEndpoint }} + - name: OTEL_RESOURCE_ATTRIBUTES + value: {{ quote .Values.opentelemetryDemoFrauddetectionservice.fraudDetectionservice.env.otelResourceAttributes }} + - name: KUBERNETES_CLUSTER_DOMAIN + value: {{ quote .Values.kubernetesClusterDomain }} + image: '{{ .Values.opentelemetryDemoFrauddetectionservice.fraudDetectionservice.image.repository }}:{{ .Values.opentelemetryDemoFrauddetectionservice.fraudDetectionservice.image.tag | default .Chart.AppVersion }}' + imagePullPolicy: {{ .Values.opentelemetryDemoFrauddetectionservice.fraudDetectionservice.imagePullPolicy }} + name: fraud-detectionservice + resources: {{- toYaml .Values.opentelemetryDemoFrauddetectionservice.fraudDetectionservice.resources | nindent 10 }} + initContainers: + - command: + - sh + - -c + - until nc -z -v -w30 opentelemetry-demo-kafka 9092; do echo waiting for kafka; sleep 2; done; + env: + - name: KUBERNETES_CLUSTER_DOMAIN + value: {{ quote .Values.kubernetesClusterDomain }} + image: '{{ .Values.opentelemetryDemoFrauddetectionservice.waitForKafka.image.repository }}:{{ .Values.opentelemetryDemoFrauddetectionservice.waitForKafka.image.tag | default .Chart.AppVersion }}' + name: wait-for-kafka + resources: {} + serviceAccountName: {{ .Values.serviceAccount.name }} diff --git a/astroshop-helm/fraud-detection/templates/serviceaccount.yaml b/astroshop-helm/fraud-detection/templates/serviceaccount.yaml new file mode 100644 index 0000000..d7ad9c0 --- /dev/null +++ b/astroshop-helm/fraud-detection/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ .Values.serviceAccount.name }} + namespace: {{ .Values.namespace }} + labels: + opentelemetry.io/name: {{ .Values.serviceAccount.name }} + app.kubernetes.io/instance: {{ .Values.serviceAccount.name }} + app.kubernetes.io/name: {{ .Values.serviceAccount.name }} + app.kubernetes.io/version: {{ quote .Values.serviceAccount.version }} + app.kubernetes.io/part-of: {{ .Values.serviceAccount.partOf }} + {{- include "fraud-detection.labels" . | nindent 4 }} \ No newline at end of file diff --git a/astroshop-helm/fraud-detection/values.yaml b/astroshop-helm/fraud-detection/values.yaml new file mode 100644 index 0000000..c03d736 --- /dev/null +++ b/astroshop-helm/fraud-detection/values.yaml @@ -0,0 +1,31 @@ +namespace: opentelemetry-demo +kubernetesClusterDomain: cluster.local + +serviceAccount: + name: opentelemetry-demo + version: ">=1.32.0-0" + partOf: opentelemetry-demo +opentelemetryDemoFrauddetectionservice: + fraudDetectionservice: + env: + otelServiceName: fraud-detectionservice + flagdHost: opentelemetry-demo-flagd + flagdPort: "8013" + kafkaServiceAddr: opentelemetry-demo-kafka:9092 + 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 + image: + repository: ghcr.io/open-telemetry/demo + tag: 2.1.3-fraud-detection + imagePullPolicy: IfNotPresent + resources: + limits: + memory: 300Mi + replicas: 1 + revisionHistoryLimit: 10 + waitForKafka: + image: + repository: busybox + tag: latest -- cgit v1.2.3