Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add opentelemetry-demo chart #280

Merged
merged 27 commits into from
Jul 26, 2022
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
d2faff6
add opentelemetry-demo chart
wph95 Jul 20, 2022
2180efe
fix lint
wph95 Jul 20, 2022
ce6b943
add README.and rename to opentelemetry-demo-webstore
wph95 Jul 20, 2022
fb696b1
Reduce the complexity of using otelcol's config by default (future fl…
wph95 Jul 20, 2022
03f7cbc
rename to opentelemetry-demo-webstore
wph95 Jul 20, 2022
45ad66d
clean up code
wph95 Jul 20, 2022
bae3e62
Apply suggestions from code review
wph95 Jul 20, 2022
e165617
add @dmitryax and @tigrannajaryan as opentelemetry-demo-webstore main…
wph95 Jul 20, 2022
0f665dc
double check jaeger/otelcol ports
wph95 Jul 20, 2022
c275b2f
Update charts/opentelemetry-demo-webstore/Chart.yaml
wph95 Jul 20, 2022
eeaca9b
1. rename _pod.tpl
wph95 Jul 20, 2022
97b57fc
Merge branch 'wph95/otel-demo' of github.com:wph95/opentelemetry-helm…
wph95 Jul 20, 2022
0417201
add tyler helmuth as maintainers
wph95 Jul 20, 2022
9b69ba5
fixed load generator not working
wph95 Jul 20, 2022
176aae6
fixed some service not send trace
wph95 Jul 21, 2022
4f77051
rename opentelemetry-demo-webstore to opentelemetry-demo
wph95 Jul 22, 2022
d3ecf6c
improve notes.txt
wph95 Jul 22, 2022
657b9da
Merge branch 'main' into wph95/otel-demo
wph95 Jul 22, 2022
949ff08
remove depends_on in value.yaml
wph95 Jul 22, 2022
24ca21d
style fix
wph95 Jul 22, 2022
5052d69
change value.yaml compoents name to camelCase
wph95 Jul 25, 2022
34b289f
add schema.json
wph95 Jul 25, 2022
cb3c5bc
Merge branch 'main' into wph95/otel-demo
wph95 Jul 25, 2022
6cbc2ae
Update charts/opentelemetry-demo-webstore/templates/NOTES.txt
wph95 Jul 25, 2022
efa09de
rename
wph95 Jul 25, 2022
7659844
Update charts/opentelemetry-demo/values.schema.json
wph95 Jul 25, 2022
ee2781f
move logic to _objects.tpl
wph95 Jul 25, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions charts/opentelemetry-demo/.helmignore
Original file line number Diff line number Diff line change
@@ -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/
14 changes: 14 additions & 0 deletions charts/opentelemetry-demo/Chart.yaml
Original file line number Diff line number Diff line change
@@ -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"
22 changes: 22 additions & 0 deletions charts/opentelemetry-demo/README.md
Original file line number Diff line number Diff line change
@@ -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
```
22 changes: 22 additions & 0 deletions charts/opentelemetry-demo/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -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 }}
35 changes: 35 additions & 0 deletions charts/opentelemetry-demo/templates/_deployment.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{{- 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 }}
36 changes: 36 additions & 0 deletions charts/opentelemetry-demo/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -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 }}
91 changes: 91 additions & 0 deletions charts/opentelemetry-demo/templates/_pod.tpl
Original file line number Diff line number Diff line change
@@ -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 }}
18 changes: 18 additions & 0 deletions charts/opentelemetry-demo/templates/component.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{{- end }}
{{- end }}

62 changes: 62 additions & 0 deletions charts/opentelemetry-demo/templates/jaeger.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
Loading