Skip to content

Commit b5f9889

Browse files
committed
Add initial version of the opentelemetry-collector chart
The change was initially submitted and pre-reviewed in contrib repo: open-telemetry/opentelemetry-collector-contrib#1026
1 parent 7d6a471 commit b5f9889

19 files changed

+875
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: v2
2+
name: opentelemetry-collector
3+
version: 0.1.0
4+
description: OpenTelemetry Collector Helm chart for Kubernetes
5+
type: application
6+
home: https://opentelemetry.io/
7+
sources:
8+
- https://github.com/open-telemetry/opentelemetry-collector
9+
- https://github.com/open-telemetry/opentelemetry-collector-contrib
10+
maintainers:
11+
- name: OpenTelemetry Collector Maintainers
12+
url: https://github.com/open-telemetry/opentelemetry-collector#contributing
13+
- name: Dmitrii Anoshin
14+
url: https://github.com/dmitryax
15+
icon: https://opentelemetry.io/img/logos/opentelemetry-logo-nav.png
16+
appVersion: 0.11.0
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# OpenTelemetry Collector Helm Chart
2+
3+
The helm chart installs [OpenTelemetry Collector](https://github.com/open-telemetry/opentelemetry-collector)
4+
in kubernetes cluster.
5+
6+
## Prerequisites
7+
8+
- Helm 3.0+
9+
10+
## Installing the Chart
11+
12+
TBD
13+
14+
## Configuration
15+
16+
### Default configuration
17+
18+
By default this chart will deploy an OpenTelemetry Collector as daemonset with two pipelines (traces and metrics)
19+
and logging exporter enabled by default. Besides daemonset (agent), it can be also installed as standalone deployment.
20+
Both modes can be enabled together, in that case metrics and traces will be flowing from agents to standalone collectors.
21+
22+
*Example*: Install collector as a standalone deployment, and do not run it as an agent.
23+
```yaml
24+
agentCollector:
25+
enabled: false
26+
standaloneCollector:
27+
enabled: true
28+
```
29+
30+
By default collector has the following receivers enabled:
31+
- **metrics**: OTLP and prometheus. Prometheus is configured only for scraping collector's own metrics.
32+
- **traces**: zipkin and jaeger (thrift and grpc).
33+
34+
There are two ways to configure collector pipelines, which can be used together as well.
35+
36+
### Basic top level configuration with `telemetry` property
37+
38+
*Example*: Disable metrics pipeline and send traces to zipkin exporter:
39+
```yaml
40+
telemetry:
41+
metrics:
42+
enabled: false
43+
traces:
44+
exporter:
45+
type: zipkin
46+
config:
47+
endpoint: zipkin-all-in-one:14250
48+
```
49+
50+
### Configuration with `agentCollector` and `standaloneCollector` properties
51+
52+
`agentCollector` and `standaloneCollector` properties allow to override collector configurations
53+
and default parameters applied on the k8s pods.
54+
55+
`agentCollector(standaloneCollector).configOverride` property allows to provide an extra
56+
configuration that will be merged into the default configuration.
57+
58+
*Example*: Enable host metrics receiver on the agents:
59+
```yaml
60+
agentCollector:
61+
configOverride:
62+
receivers:
63+
hostmetrics:
64+
scrapers:
65+
cpu:
66+
load:
67+
memory:
68+
disk:
69+
service:
70+
pipelines:
71+
metrics:
72+
receivers: [prometheus, hostmetrics]
73+
extraEnvs:
74+
- name: HOST_PROC
75+
value: /hostfs/proc
76+
- name: HOST_SYS
77+
value: /hostfs/sys
78+
- name: HOST_ETC
79+
value: /hostfs/etc
80+
- name: HOST_VAR
81+
value: /hostfs/var
82+
- name: HOST_RUN
83+
value: /hostfs/run
84+
- name: HOST_DEV
85+
value: /hostfs/dev
86+
extraHostPathMounts:
87+
- name: hostfs
88+
hostPath: /
89+
mountPath: /hostfs
90+
readOnly: true
91+
mountPropagation: HostToContainer
92+
```
93+
94+
### Other configuration options
95+
96+
The [values.yaml](./values.yaml) file contains information about all other configuration
97+
options for this chart.

charts/opentelemetry-collector/templates/NOTES.txt

Whitespace-only changes.
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "opentelemetry-collector.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "opentelemetry-collector.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "opentelemetry-collector.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "opentelemetry-collector.labels" -}}
37+
helm.sh/chart: {{ include "opentelemetry-collector.chart" . }}
38+
{{ include "opentelemetry-collector.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "opentelemetry-collector.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "opentelemetry-collector.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
52+
53+
{{/*
54+
Create the name of the service account to use
55+
*/}}
56+
{{- define "opentelemetry-collector.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "opentelemetry-collector.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}
63+
64+
{{/*
65+
Build base config file with pipelines
66+
*/}}
67+
{{- define "opentelemetry-collector.pipelinesConfig" -}}
68+
{{- $config := include "opentelemetry-collector.baseConfig" . | fromYaml -}}
69+
{{- range $telemetryName, $telemetryParams := .Values.telemetry }}
70+
{{- if index $telemetryParams "enabled" }}
71+
{{- $config := include (printf "opentelemetry-collector.%sPipelineConfig" $telemetryName) $ | fromYaml | mustMergeOverwrite $config }}
72+
{{- end }}
73+
{{- end }}
74+
{{- $config | toYaml }}
75+
{{- end }}
76+
77+
{{/*
78+
Build config file for agent OpenTelemetry Collector
79+
*/}}
80+
{{- define "opentelemetry-collector.agentCollectorConfig" -}}
81+
{{- $values := deepCopy .Values.agentCollector | mustMergeOverwrite (deepCopy .Values) }}
82+
{{- $data := dict "Values" $values | mustMergeOverwrite (deepCopy .) }}
83+
{{- $config := include "opentelemetry-collector.pipelinesConfig" $data | fromYaml }}
84+
{{- $config := include "opentelemetry-collector.agentConfigOverride" $data | fromYaml | mustMergeOverwrite $config }}
85+
{{- .Values.agentCollector.configOverride | mustMergeOverwrite $config | toYaml }}
86+
{{- end }}
87+
88+
{{/*
89+
Build config file for standalone OpenTelemetry Collector
90+
*/}}
91+
{{- define "opentelemetry-collector.standaloneCollectorConfig" -}}
92+
{{- $values := deepCopy .Values.standaloneCollector | mustMergeOverwrite (deepCopy .Values) }}
93+
{{- $data := dict "Values" $values | mustMergeOverwrite (deepCopy .) }}
94+
{{- $config := include "opentelemetry-collector.pipelinesConfig" $data | fromYaml }}
95+
{{- .Values.standaloneCollector.configOverride | mustMergeOverwrite $config | toYaml }}
96+
{{- end }}
97+
98+
{{/*
99+
Convert memory value from resources.limit to numeric value in MiB to be used by otel memory_limiter processor.
100+
*/}}
101+
{{- define "opentelemetry-collector.convertMemToMib" -}}
102+
{{- $mem := lower . -}}
103+
{{- if hasSuffix "e" $mem -}}
104+
{{- trimSuffix "e" $mem | atoi | mul 1000 | mul 1000 | mul 1000 | mul 1000 -}}
105+
{{- else if hasSuffix "ei" $mem -}}
106+
{{- trimSuffix "ei" $mem | atoi | mul 1024 | mul 1024 | mul 1024 | mul 1024 -}}
107+
{{- else if hasSuffix "p" $mem -}}
108+
{{- trimSuffix "p" $mem | atoi | mul 1000 | mul 1000 | mul 1000 -}}
109+
{{- else if hasSuffix "pi" $mem -}}
110+
{{- trimSuffix "pi" $mem | atoi | mul 1024 | mul 1024 | mul 1024 -}}
111+
{{- else if hasSuffix "t" $mem -}}
112+
{{- trimSuffix "t" $mem | atoi | mul 1000 | mul 1000 -}}
113+
{{- else if hasSuffix "ti" $mem -}}
114+
{{- trimSuffix "ti" $mem | atoi | mul 1024 | mul 1024 -}}
115+
{{- else if hasSuffix "g" $mem -}}
116+
{{- trimSuffix "g" $mem | atoi | mul 1000 -}}
117+
{{- else if hasSuffix "gi" $mem -}}
118+
{{- trimSuffix "gi" $mem | atoi | mul 1024 -}}
119+
{{- else if hasSuffix "m" $mem -}}
120+
{{- div (trimSuffix "m" $mem | atoi | mul 1000) 1024 -}}
121+
{{- else if hasSuffix "mi" $mem -}}
122+
{{- trimSuffix "mi" $mem | atoi -}}
123+
{{- else if hasSuffix "k" $mem -}}
124+
{{- div (trimSuffix "k" $mem | atoi) 1000 -}}
125+
{{- else if hasSuffix "ki" $mem -}}
126+
{{- div (trimSuffix "ki" $mem | atoi) 1024 -}}
127+
{{- else -}}
128+
{{- div (div ($mem | atoi) 1024) 1024 -}}
129+
{{- end -}}
130+
{{- end -}}
131+
132+
{{/*
133+
Get otel memory_limiter limit_mib value based on 80% of resources.memory.limit.
134+
*/}}
135+
{{- define "opentelemetry-collector.getMemLimitMib" -}}
136+
{{- div (mul (include "opentelemetry-collector.convertMemToMib" .) 80) 100 }}
137+
{{- end -}}
138+
139+
{{/*
140+
Get otel memory_limiter spike_limit_mib value based on 25% of resources.memory.limit.
141+
*/}}
142+
{{- define "opentelemetry-collector.getMemSpikeLimitMib" -}}
143+
{{- div (mul (include "opentelemetry-collector.convertMemToMib" .) 25) 100 }}
144+
{{- end -}}
145+
146+
{{/*
147+
Get otel memory_limiter ballast_size_mib value based on 40% of resources.memory.limit.
148+
*/}}
149+
{{- define "opentelemetry-collector.getMemBallastSizeMib" }}
150+
{{- div (mul (include "opentelemetry-collector.convertMemToMib" .) 40) 100 }}
151+
{{- end -}}
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
{{- define "opentelemetry-collector.pod" -}}
2+
{{- with .Values.imagePullSecrets }}
3+
imagePullSecrets:
4+
{{- toYaml . | nindent 2 }}
5+
{{- end }}
6+
serviceAccountName: {{ include "opentelemetry-collector.serviceAccountName" . }}
7+
securityContext:
8+
{{- toYaml .Values.podSecurityContext | nindent 2 }}
9+
containers:
10+
- name: {{ .Chart.Name }}
11+
command:
12+
- /{{ .Values.command.name }}
13+
- --config=/conf/relay.yaml
14+
- --metrics-addr=0.0.0.0:8888
15+
- --mem-ballast-size-mib={{ template "opentelemetry-collector.getMemBallastSizeMib" .Values.resources.limits.memory }}
16+
{{- range .Values.command.extraArgs }}
17+
- {{ . }}
18+
{{- end }}
19+
securityContext:
20+
{{- toYaml .Values.securityContext | nindent 6 }}
21+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
22+
imagePullPolicy: {{ .Values.image.pullPolicy }}
23+
ports:
24+
{{- range $key, $port := .Values.ports }}
25+
{{- if $port.enabled }}
26+
- name: {{ $key }}
27+
containerPort: {{ $port.containerPort }}
28+
protocol: {{ $port.protocol }}
29+
{{- if and $.isAgent $port.hostPort }}
30+
hostPort: {{ $port.hostPort }}
31+
{{- end }}
32+
{{- end }}
33+
{{- end }}
34+
env:
35+
- name: MY_POD_IP
36+
valueFrom:
37+
fieldRef:
38+
apiVersion: v1
39+
fieldPath: status.podIP
40+
{{- with .Values.extraEnvs }}
41+
{{- . | toYaml | nindent 6 }}
42+
{{- end }}
43+
livenessProbe:
44+
httpGet:
45+
path: /
46+
port: 13133
47+
readinessProbe:
48+
httpGet:
49+
path: /
50+
port: 13133
51+
resources:
52+
{{- toYaml .Values.resources | nindent 6 }}
53+
volumeMounts:
54+
- mountPath: /conf
55+
name: {{ .Chart.Name }}-configmap
56+
{{- range .Values.extraHostPathMounts }}
57+
- name: {{ .name }}
58+
mountPath: {{ .mountPath }}
59+
readOnly: {{ .readOnly }}
60+
{{- if .mountPropagation }}
61+
mountPropagation: {{ .mountPropagation }}
62+
{{- end }}
63+
{{- end }}
64+
volumes:
65+
- name: {{ .Chart.Name }}-configmap
66+
configMap:
67+
name: {{ include "opentelemetry-collector.fullname" . }}{{ .configmapSuffix }}
68+
items:
69+
- key: relay
70+
path: relay.yaml
71+
{{- range .Values.extraHostPathMounts }}
72+
- name: {{ .name }}
73+
hostPath:
74+
path: {{ .hostPath }}
75+
{{- end }}
76+
{{- with .Values.nodeSelector }}
77+
nodeSelector:
78+
{{- toYaml . | nindent 2 }}
79+
{{- end }}
80+
{{- with .Values.affinity }}
81+
affinity:
82+
{{- toYaml . | nindent 2 }}
83+
{{- end }}
84+
{{- with .Values.tolerations }}
85+
tolerations:
86+
{{- toYaml . | nindent 2 }}
87+
{{- end }}
88+
{{- end }}

0 commit comments

Comments
 (0)