diff --git a/charts/opentelemetry-demo/.helmignore b/charts/opentelemetry-demo/.helmignore new file mode 100644 index 000000000..0e8a0eb36 --- /dev/null +++ b/charts/opentelemetry-demo/.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/charts/opentelemetry-demo/Chart.yaml b/charts/opentelemetry-demo/Chart.yaml new file mode 100644 index 000000000..c826ef85f --- /dev/null +++ b/charts/opentelemetry-demo/Chart.yaml @@ -0,0 +1,14 @@ +apiVersion: v2 +type: application +name: opentelemetry-demo +version: 0.1.0 +description: opentelemetry demo helm chart +home: https://opentelemetry.io/ +sources: + - https://github.com/open-telemetry/opentelemetry-demo +maintainers: + - name: dmitryax + - name: tylerhelmuth + - name: wph95 +icon: https://opentelemetry.io/img/logos/opentelemetry-logo-nav.png +appVersion: "0.2.0-alpha" diff --git a/charts/opentelemetry-demo/README.md b/charts/opentelemetry-demo/README.md new file mode 100644 index 000000000..50acdb8ba --- /dev/null +++ b/charts/opentelemetry-demo/README.md @@ -0,0 +1,22 @@ +# OpenTelemetry Demo Helm Chart + +The helm chart installs [OpenTelemetry Demo](https://github.com/open-telemetry/opentelemetry-demo) +in kubernetes cluster. + +## Prerequisites + +- Helm 3.0+ + +## Installing the Chart + +Add OpenTelemetry Helm repository: + +```console +helm repo add open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts +``` + +To install the chart with the release name my-otel-demo, run the following command: + +```console +helm install my-otel-demo open-telemetry/opentelemetry-demo +``` diff --git a/charts/opentelemetry-demo/templates/NOTES.txt b/charts/opentelemetry-demo/templates/NOTES.txt new file mode 100644 index 000000000..48fafe185 --- /dev/null +++ b/charts/opentelemetry-demo/templates/NOTES.txt @@ -0,0 +1,22 @@ +======================================================================================= + + + ██████╗ ████████╗███████╗██╗ ██████╗ ███████╗███╗ ███╗ ██████╗ +██╔═══██╗╚══██╔══╝██╔════╝██║ ██╔══██╗██╔════╝████╗ ████║██╔═══██╗ +██║ ██║ ██║ █████╗ ██║ ██║ ██║█████╗ ██╔████╔██║██║ ██║ +██║ ██║ ██║ ██╔══╝ ██║ ██║ ██║██╔══╝ ██║╚██╔╝██║██║ ██║ +╚██████╔╝ ██║ ███████╗███████╗ ██████╔╝███████╗██║ ╚═╝ ██║╚██████╔╝ + ╚═════╝ ╚═╝ ╚══════╝╚══════╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝ ╚═════╝ + + +- Frontend UI: http://localhost:8080 + by running these commands: + kubectl port-forward svc/{{ include "otel-demo.name" . }}-frontend 8080:8080 + + +{{- if $.Values.observability.jaeger.enabled }} + +- Jaeger UI: http://localhost:16686 + by running these commands: + kubectl port-forward svc/{{ include "otel-demo.name" . }}-jaeger 16686:16686 +{{- end }} diff --git a/charts/opentelemetry-demo/templates/_helpers.tpl b/charts/opentelemetry-demo/templates/_helpers.tpl new file mode 100644 index 000000000..43f9750ef --- /dev/null +++ b/charts/opentelemetry-demo/templates/_helpers.tpl @@ -0,0 +1,36 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "otel-demo.name" -}} +{{- default .Release.Name | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "otel-demo.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "otel-demo.labels" -}} +helm.sh/chart: {{ include "otel-demo.chart" . }} +{{ include "otel-demo.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "otel-demo.selectorLabels" -}} +app.kubernetes.io/name: {{ include "otel-demo.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- if .name }} +app.kubernetes.io/component: {{ .name}} +{{- end}} +{{- end }} diff --git a/charts/opentelemetry-demo/templates/_objects.tpl b/charts/opentelemetry-demo/templates/_objects.tpl new file mode 100644 index 000000000..13789e99e --- /dev/null +++ b/charts/opentelemetry-demo/templates/_objects.tpl @@ -0,0 +1,96 @@ +{{- define "otel.demo.deployment" }} +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "otel-demo.name" . }}-{{ .name }} + labels: + {{- include "otel-demo.labels" . | nindent 4 }} +spec: + selector: + matchLabels: + {{- include "otel-demo.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + {{- include "otel-demo.selectorLabels" . | nindent 8 }} + spec: + {{- if .imageConfig.pullSecrets }} + imagePullSecrets: + {{- toYaml .imageConfig.pullSecrets | nindent 8}} + {{- end }} + {{- with .serviceAccountName }} + serviceAccountName: {{ .serviceAccountName}} + {{- end }} + containers: + - name: {{ .name }} + image: {{ .image | default (printf "%s:v%s-%s" .imageConfig.repository .Chart.AppVersion (.name | replace "-" "" | lower)) }} + {{- if or .ports .servicePort}} + ports: + {{- include "otel-demo.pod.ports" . | nindent 10 }} + {{- end }} + env: + {{- include "otel-demo.pod.env" . | nindent 10 }} + +{{- end }} + +{{- define "otel.demo.service" }} +{{- if or .ports .servicePort}} +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ include "otel-demo.name" . }}-{{ .name }} + labels: + {{- include "otel-demo.labels" . | nindent 4 }} +spec: + ports: + {{- if .ports }} + {{- range $port := .ports }} + - port: {{ $port.value }} + name: {{ $port.name}} + targetPort: {{ $port.value }} + {{- end }} + {{- end }} + + {{- if .servicePort }} + - port: {{.servicePort}} + name: service + targetPort: {{ .servicePort }} + {{- end }} + selector: + {{- include "otel-demo.selectorLabels" . | nindent 4 }} +{{- end}} +{{- end}} + +{{- define "otel-demo.otelcol.config" -}} +receivers: + otlp: + protocols: + grpc: + http: +exporters: + {{- if .Values.observability.jaeger.enabled }} + jaeger: + endpoint: "${JAEGER_ADDR}" + tls: + insecure: true + {{- end}} + logging: + +processors: + batch: + +service: + pipelines: + traces: + receivers: + - otlp + processors: + - batch + exporters: + - logging + {{- if .Values.observability.jaeger.enabled }} + - jaeger + {{- end}} +{{- end }} diff --git a/charts/opentelemetry-demo/templates/_pod.tpl b/charts/opentelemetry-demo/templates/_pod.tpl new file mode 100644 index 000000000..3af25d9d3 --- /dev/null +++ b/charts/opentelemetry-demo/templates/_pod.tpl @@ -0,0 +1,91 @@ +{{/* +Component Depends Config +*/}} +{{- define "otel-demo.pod.dependsConfig" -}} +cart-service: + - redis +checkout-service: + - cart-service + - currency-service + - email-service + - payment-service + - product-catalog-service + - shipping-service +frontend: + - ad-service + - cart-service + - checkout-service + - currency-service + - product-catalog-service + - recommendation-service + - shipping-service +loadgenerator: + - frontend +recommendation-service: + - product-catalog-service +{{- end}} + + +{{/* +Get Services Port Mapping +*/}} +{{- define "otel-demo.pod.serviceMapping" -}} +{{ $servicePortMap := default dict }} +{{- range $name, $config := .Values.components }} + {{- if $config.servicePort }} + {{ $name | kebabcase }}: {{ $config.servicePort }} + {{- else if $config.ports }} + {{ $name | kebabcase}}: {{ (get (index $config.ports 0 ) "value") }} + {{- end }} +{{- end }} +{{- end }} + +{{/* +Get Pod Env +*/}} +{{- define "otel-demo.pod.env" -}} +{{- $prefix := include "otel-demo.name" $ }} + +{{- if .env }} +{{- toYaml .env }} +{{- end }} + +{{- if .observability.otelcol.enabled }} +- name: OTEL_EXPORTER_OTLP_ENDPOINT + value: http://{{ include "otel-demo.name" . }}-otelcol:4317 +- name: OTEL_RESOURCE_ATTRIBUTES + value: service.name={{ .name | kebabcase }} +{{- end }} + +{{- if .servicePort}} +- name: {{ printf "%s_PORT" .name | snakecase | upper }} + value: {{.servicePort | quote}} +{{- end }} + +# {{ $.depends }} +# {{ .name }} +{{- if hasKey $.depends .name }} +{{- range $depend := get $.depends .name }} +- name: {{ printf "%s_ADDR" $depend | snakecase | upper }} + value: {{ printf "%s-%s:%0.f" $prefix ($depend | kebabcase) (get $.serviceMapping $depend )}} +{{- end }} +{{- end }} + +{{- end }} + +{{/* +Get Pod ports +*/}} +{{- define "otel-demo.pod.ports" -}} +{{- if .ports }} +{{- range $port := .ports }} +- containerPort: {{ $port.value }} + name: {{ $port.name}} +{{- end }} +{{- end }} + +{{- if .servicePort }} +- containerPort: {{.servicePort}} + name: service +{{- end }} +{{- end }} diff --git a/charts/opentelemetry-demo/templates/component.yaml b/charts/opentelemetry-demo/templates/component.yaml new file mode 100644 index 000000000..517c326b6 --- /dev/null +++ b/charts/opentelemetry-demo/templates/component.yaml @@ -0,0 +1,18 @@ +{{ $serviceMapping := include "otel-demo.pod.serviceMapping" . | fromYaml}} +{{ $depends := include "otel-demo.pod.dependsConfig" . | fromYaml }} +{{- range $name, $config := .Values.components }} + {{- $config := set . "name" ($name | kebabcase) }} + {{- $config := set . "Release" $.Release }} + {{- $config := set . "Chart" $.Chart }} + {{- $config := set . "imageConfig" $.Values.image }} + {{- $config := set . "serviceAccount" $.Values.serviceAccount }} + {{- $config := set . "observability" $.Values.observability }} + {{- $config := set . "serviceMapping" $serviceMapping }} + {{- $config := set . "depends" $depends }} + + {{- if $config.enabled -}} + {{- include "otel.demo.deployment" $config -}} + {{- include "otel.demo.service" $config -}} + {{ end }} + +{{- end }} \ No newline at end of file diff --git a/charts/opentelemetry-demo/templates/jaeger.yaml b/charts/opentelemetry-demo/templates/jaeger.yaml new file mode 100644 index 000000000..f518dc208 --- /dev/null +++ b/charts/opentelemetry-demo/templates/jaeger.yaml @@ -0,0 +1,62 @@ +{{- $config := set . "name" "jaeger" }} +{{- if $.Values.observability.jaeger.enabled -}} +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "otel-demo.name" . }}-{{ .name }} + labels: + {{- include "otel-demo.labels" . | nindent 4 }} +spec: + replicas: 1 + selector: + matchLabels: + {{- include "otel-demo.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + {{- include "otel-demo.selectorLabels" . | nindent 8 }} + spec: + containers: + - env: + - name: COLLECTOR_ZIPKIN_HTTP_PORT + value: "9411" + image: jaegertracing/all-in-one + name: jaeger + ports: + - containerPort: 5775 + protocol: UDP + - containerPort: 6831 + protocol: UDP + - containerPort: 6832 + protocol: UDP + - containerPort: 5778 + protocol: TCP + - containerPort: 16686 + protocol: TCP + - containerPort: 14268 + protocol: TCP + - containerPort: 9411 + protocol: TCP + - containerPort: 14250 + protocol: TCP +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ include "otel-demo.name" . }}-{{ .name }} + labels: + {{- include "otel-demo.labels" . | nindent 4 }} +spec: + ports: + - name: frontend + port: 16686 + protocol: TCP + targetPort: 16686 + - name: collector + port: 14250 + protocol: TCP + targetPort: 14250 + selector: + {{- include "otel-demo.selectorLabels" . | nindent 4 }} +{{- end }} diff --git a/charts/opentelemetry-demo/templates/otelcol.yaml b/charts/opentelemetry-demo/templates/otelcol.yaml new file mode 100644 index 000000000..4d4f62eb0 --- /dev/null +++ b/charts/opentelemetry-demo/templates/otelcol.yaml @@ -0,0 +1,81 @@ +{{- $ := set . "name" "otelcol" }} +{{- $otelconfig := include "otel-demo.otelcol.config" .}} + +{{- if .Values.observability.otelcol.enabled -}} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "otel-demo.name" . }}-{{ .name }}-config + labels: + {{- include "otel-demo.labels" . | nindent 4 }} +data: + otelcol-config.yml: | + + {{- $otelconfig | nindent 4 }} +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "otel-demo.name" . }}-{{ .name }} + labels: + {{- include "otel-demo.labels" . | nindent 4 }} +spec: + replicas: 1 + selector: + matchLabels: + {{- include "otel-demo.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + checksum/otel_config: {{ sha256sum $otelconfig | trunc 63 }} + {{- include "otel-demo.selectorLabels" . | nindent 8 }} + spec: + containers: + - image: otel/opentelemetry-collector:0.55.0 + name: otel-col + args: ["--config=/etc/otelcol-config.yml"] + {{- if .Values.observability.jaeger.enabled }} + env: + - name: JAEGER_ADDR + value: {{ include "otel-demo.name" . }}-jaeger:14250 + {{- end }} + ports: + - containerPort: 4317 + protocol: TCP + - containerPort: 4318 + protocol: TCP + - containerPort: 8888 + protocol: TCP + volumeMounts: + - mountPath: /etc/otelcol-config.yml + name: otel-config + subPath: otelcol-config.yml + volumes: + - configMap: + name: {{ include "otel-demo.name" . }}-{{.name}}-config + name: otel-config +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ include "otel-demo.name" . }}-{{ .name }} + labels: + {{- include "otel-demo.labels" . | nindent 4 }} +spec: + ports: + - name: otlp + port: 4317 + protocol: TCP + targetPort: 4317 + - name: otlphttp + port: 4318 + protocol: TCP + targetPort: 4318 + - name: metric + port: 8888 + protocol: TCP + targetPort: 8888 + selector: + {{- include "otel-demo.selectorLabels" . | nindent 4 }} +{{- end }} diff --git a/charts/opentelemetry-demo/values.schema.json b/charts/opentelemetry-demo/values.schema.json new file mode 100644 index 000000000..4ab447e8f --- /dev/null +++ b/charts/opentelemetry-demo/values.schema.json @@ -0,0 +1,188 @@ +{ + "$schema": "http://json-schema.org/schema#", + "type": "object", + "title": "Values", + "additionalProperties": false, + "properties": { + "observability": { + "$ref": "#/definitions/Observability" + }, + "image": { + "$ref": "#/definitions/Image" + }, + "serviceAccount": { + "type": "string" + }, + "components": { + "$ref": "#/definitions/Components" + } + }, + "required": [ + "components", + "image", + "observability", + "serviceAccount" + ], + "definitions": { + "Components": { + "type": "object", + "additionalProperties": false, + "properties": { + "redis": { + "$ref": "#/definitions/Service" + }, + "adService": { + "$ref": "#/definitions/Service" + }, + "cartService": { + "$ref": "#/definitions/Service" + }, + "checkoutService": { + "$ref": "#/definitions/Service" + }, + "currencyService": { + "$ref": "#/definitions/Service" + }, + "emailService": { + "$ref": "#/definitions/Service" + }, + "featureflagService": { + "$ref": "#/definitions/Service" + }, + "ffsPostgres": { + "$ref": "#/definitions/Service" + }, + "frontend": { + "$ref": "#/definitions/Service" + }, + "loadgenerator": { + "$ref": "#/definitions/Service" + }, + "paymentService": { + "$ref": "#/definitions/Service" + }, + "productCatalogService": { + "$ref": "#/definitions/Service" + }, + "recommendationService": { + "$ref": "#/definitions/Service" + }, + "shippingService": { + "$ref": "#/definitions/Service" + } + }, + "title": "Components" + }, + "Service": { + "type": "object", + "additionalProperties": false, + "properties": { + "enabled": { + "type": "boolean" + }, + "servicePort": { + "type": "integer" + }, + "env": { + "type": "array", + "items": { + "$ref": "#/definitions/Env" + } + }, + "ports": { + "type": "array", + "items": { + "$ref": "#/definitions/Port" + } + }, + "image": { + "type": "string" + } + }, + "required": [ + "enabled" + ], + "title": "Service" + }, + "Env": { + "type": "object", + "additionalProperties": false, + "properties": { + "name": { + "type": "string" + }, + "value": { + "type": "string" + } + }, + "required": [ + "name" + ], + "title": "Env" + }, + "Port": { + "type": "object", + "additionalProperties": false, + "properties": { + "name": { + "type": "string" + }, + "value": { + "type": "integer" + } + }, + "required": [ + "name", + "value" + ], + "title": "Port" + }, + "Image": { + "type": "object", + "additionalProperties": false, + "properties": { + "repository": { + "type": "string" + }, + "pullSecrets": { + "type": "array", + "items": {} + } + }, + "required": [ + "repository" + ], + "title": "Image" + }, + "Observability": { + "type": "object", + "additionalProperties": false, + "properties": { + "otelcol": { + "$ref": "#/definitions/ObservabilityProp" + }, + "jaeger": { + "$ref": "#/definitions/ObservabilityProp" + } + }, + "required": [ + "jaeger", + "otelcol" + ], + "title": "Observability" + }, + "ObservabilityProp": { + "type": "object", + "additionalProperties": false, + "properties": { + "enabled": { + "type": "boolean" + } + }, + "required": [ + "enabled" + ], + "title": "ObservabilityProp" + } + } +} diff --git a/charts/opentelemetry-demo/values.yaml b/charts/opentelemetry-demo/values.yaml new file mode 100644 index 000000000..bf13306af --- /dev/null +++ b/charts/opentelemetry-demo/values.yaml @@ -0,0 +1,116 @@ +observability: + otelcol: + enabled: true + jaeger: + enabled: true + +image: + repository: otel/demo + pullSecrets: [] + +serviceAccount: "" + +components: + redis: + enabled: true + image: redis:alpine + ports: + - name: redis + value: 6379 + + adService: + enabled: true + servicePort: 8080 + + cartService: + enabled: true + servicePort: 8080 + env: + - name: ASPNETCORE_URLS + value: http://*:8080 + + checkoutService: + enabled: true + servicePort: 8080 + + currencyService: + enabled: true + servicePort: 8080 + env: + - name: PORT + value: '8080' + + emailService: + enabled: true + servicePort: 8080 + env: + - name: APP_ENV + value: production + - name: PORT + value: '8080' + + featureflagService: + enabled: true + env: + - name: DATABASE_URL + value: ecto://ffs:ffs@ffs-postgres:5432/ffs + - name: GRPC_PORT + value: '50053' + - name: PORT + value: '50052' + ports: + - name: grpc + value: 50052 + - name: http + value: 50053 + + ffsPostgres: + enabled: true + env: + - name: POSTGRES_DB + value: ffs + - name: POSTGRES_PASSWORD + value: ffs + - name: POSTGRES_USER + value: ffs + image: cimg/postgres:14.2 + ports: + - name: postgres + value: 5432 + + frontend: + enabled: true + servicePort: 8080 + env: + - name: FRONTEND_ADDR + value: :8080 + + loadgenerator: + enabled: true + env: + - name: USERS + value: '10' + - name: PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION + value: python + + paymentService: + enabled: true + servicePort: 8080 + + productCatalogService: + enabled: true + servicePort: 8080 + + recommendationService: + enabled: true + servicePort: 8080 + env: + - name: OTEL_PYTHON_LOG_CORRELATION + value: 'true' + + shippingService: + enabled: true + servicePort: 8080 + env: + - name: PORT + value: '8080'