diff options
| author | Saumit <justsaumit@protonmail.com> | 2025-10-04 01:36:57 +0530 |
|---|---|---|
| committer | Saumit <justsaumit@protonmail.com> | 2025-10-04 01:36:57 +0530 |
| commit | df2bd058309ac234eebdad3b0682a137e27dfc44 (patch) | |
| tree | 39be2243787c3bdd595ae123766565f80a8a039c /astroshop-helm/payment | |
| parent | 90a62ae7ea5e745b99d8ac8d08ae837bbaedfce5 (diff) | |
Add tested Helm chart and configuration files for OpenTelemetry demo services
Diffstat (limited to 'astroshop-helm/payment')
| -rw-r--r-- | astroshop-helm/payment/.helmignore | 23 | ||||
| -rw-r--r-- | astroshop-helm/payment/Chart.yaml | 22 | ||||
| -rw-r--r-- | astroshop-helm/payment/templates/_helpers.tpl | 62 | ||||
| -rw-r--r-- | astroshop-helm/payment/templates/deployment.yaml | 71 | ||||
| -rw-r--r-- | astroshop-helm/payment/templates/service.yaml | 16 | ||||
| -rw-r--r-- | astroshop-helm/payment/values.yaml | 36 |
6 files changed, 230 insertions, 0 deletions
diff --git a/astroshop-helm/payment/.helmignore b/astroshop-helm/payment/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/astroshop-helm/payment/.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/payment/Chart.yaml b/astroshop-helm/payment/Chart.yaml new file mode 100644 index 0000000..ea27b20 --- /dev/null +++ b/astroshop-helm/payment/Chart.yaml @@ -0,0 +1,22 @@ +apiVersion: v2 +name: payment +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/payment/templates/_helpers.tpl b/astroshop-helm/payment/templates/_helpers.tpl new file mode 100644 index 0000000..74b097c --- /dev/null +++ b/astroshop-helm/payment/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "payment.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 "payment.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 "payment.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "payment.labels" -}} +helm.sh/chart: {{ include "payment.chart" . }} +{{ include "payment.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "payment.selectorLabels" -}} +app.kubernetes.io/name: {{ include "payment.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "payment.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "payment.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/astroshop-helm/payment/templates/deployment.yaml b/astroshop-helm/payment/templates/deployment.yaml new file mode 100644 index 0000000..0389eae --- /dev/null +++ b/astroshop-helm/payment/templates/deployment.yaml @@ -0,0 +1,71 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + namespace: {{ .Values.namespace }} + name: {{ include "payment.fullname" . }} + labels: + app.kubernetes.io/component: paymentservice + app.kubernetes.io/part-of: opentelemetry-demo + opentelemetry.io/name: {{ .Values.namespace }}-{{ include "payment.fullname" . }} + {{- include "payment.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.opentelemetryDemoPaymentservice.replicas }} + revisionHistoryLimit: {{ .Values.opentelemetryDemoPaymentservice.revisionHistoryLimit + }} + selector: + matchLabels: + opentelemetry.io/name: {{ .Values.namespace }}-{{ include "payment.fullname" . }} + {{- include "payment.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + app.kubernetes.io/component: paymentservice + app.kubernetes.io/instance: opentelemetry-demo + app.kubernetes.io/name: {{ .Values.namespace }}-{{ include "payment.fullname" . }} + opentelemetry.io/name: {{ .Values.namespace }}-{{ include "payment.fullname" . }} + {{- include "payment.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.opentelemetryDemoPaymentservice.paymentservice.env.otelCollectorName + }} + - name: OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE + value: {{ quote .Values.opentelemetryDemoPaymentservice.paymentservice.env.otelExporterOtlpMetricsTemporalityPreference + }} + - name: PAYMENT_PORT + value: {{ quote .Values.opentelemetryDemoPaymentservice.paymentservice.env.paymentServicePort + }} + - name: FLAGD_HOST + value: {{ quote .Values.opentelemetryDemoPaymentservice.paymentservice.env.flagdHost + }} + - name: FLAGD_PORT + value: {{ quote .Values.opentelemetryDemoPaymentservice.paymentservice.env.flagdPort + }} + - name: OTEL_EXPORTER_OTLP_ENDPOINT + value: {{ quote .Values.opentelemetryDemoPaymentservice.paymentservice.env.otelExporterOtlpEndpoint + }} + - name: OTEL_RESOURCE_ATTRIBUTES + value: {{ quote .Values.opentelemetryDemoPaymentservice.paymentservice.env.otelResourceAttributes + }} + - name: KUBERNETES_CLUSTER_DOMAIN + value: {{ quote .Values.kubernetesClusterDomain }} + image: '{{ .Values.opentelemetryDemoPaymentservice.paymentservice.image.repository + }}:{{ .Values.opentelemetryDemoPaymentservice.paymentservice.image.tag | default + .Chart.AppVersion }}' + imagePullPolicy: {{ .Values.opentelemetryDemoPaymentservice.paymentservice.imagePullPolicy + }} + name: paymentservice + ports: + - containerPort: 8080 + name: service + resources: {{- toYaml .Values.opentelemetryDemoPaymentservice.paymentservice.resources + | nindent 10 }} + securityContext: {{- toYaml .Values.opentelemetryDemoPaymentservice.paymentservice.containerSecurityContext + | nindent 10 }} + serviceAccountName: {{ .Values.serviceAccount.name }} diff --git a/astroshop-helm/payment/templates/service.yaml b/astroshop-helm/payment/templates/service.yaml new file mode 100644 index 0000000..021384c --- /dev/null +++ b/astroshop-helm/payment/templates/service.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.namespace }}-{{ include "payment.fullname" . }} + labels: + app.kubernetes.io/component: paymentservice + app.kubernetes.io/part-of: opentelemetry-demo + opentelemetry.io/name: {{ .Values.namespace }}-{{ include "payment.fullname" . }} + {{- include "payment.labels" . | nindent 4 }} +spec: + type: {{ .Values.opentelemetryDemoPaymentservice.type }} + selector: + opentelemetry.io/name: {{ .Values.namespace }}-{{ include "payment.fullname" . }} + {{- include "payment.selectorLabels" . | nindent 4 }} + ports: + {{- .Values.opentelemetryDemoPaymentservice.ports | toYaml | nindent 2 }} diff --git a/astroshop-helm/payment/values.yaml b/astroshop-helm/payment/values.yaml new file mode 100644 index 0000000..63add1c --- /dev/null +++ b/astroshop-helm/payment/values.yaml @@ -0,0 +1,36 @@ +namespace: opentelemetry-demo +kubernetesClusterDomain: cluster.local + +serviceAccount: + name: opentelemetry-demo + version: ">=1.32.0-0" + partOf: opentelemetry-demo + +opentelemetryDemoPaymentservice: + paymentservice: + containerSecurityContext: + runAsGroup: 1000 + runAsNonRoot: true + runAsUser: 1000 + env: + flagdHost: opentelemetry-demo-flagd + flagdPort: "8013" + otelCollectorName: opentelemetry-demo-otelcol + otelExporterOtlpEndpoint: http://$(OTEL_COLLECTOR_NAME):4317 + otelExporterOtlpMetricsTemporalityPreference: cumulative + otelResourceAttributes: service.name=$(OTEL_SERVICE_NAME),service.namespace=opentelemetry-demo,service.version=2.1.3 + paymentServicePort: "8080" + image: + repository: ghcr.io/open-telemetry/demo + tag: 2.1.3-payment + imagePullPolicy: IfNotPresent + resources: + limits: + memory: 120Mi + ports: + - name: tcp-service + port: 8080 + targetPort: 8080 + replicas: 1 + revisionHistoryLimit: 10 + type: ClusterIP |
