-
Notifications
You must be signed in to change notification settings - Fork 510
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial version of the opentelemetry-collector chart (#2)
The change was initially submitted and pre-reviewed in contrib repo: open-telemetry/opentelemetry-collector-contrib#1026
- Loading branch information
Showing
19 changed files
with
885 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
apiVersion: v2 | ||
name: opentelemetry-collector | ||
version: 0.1.0 | ||
description: OpenTelemetry Collector Helm chart for Kubernetes | ||
type: application | ||
home: https://opentelemetry.io/ | ||
sources: | ||
- https://github.com/open-telemetry/opentelemetry-collector | ||
- https://github.com/open-telemetry/opentelemetry-collector-contrib | ||
maintainers: | ||
- name: bogdandrutu | ||
- name: dmitryax | ||
- name: pjanotti | ||
- name: tigrannajaryan | ||
icon: https://opentelemetry.io/img/logos/opentelemetry-logo-nav.png | ||
appVersion: 0.11.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
# OpenTelemetry Collector Helm Chart | ||
|
||
The helm chart installs [OpenTelemetry Collector](https://github.com/open-telemetry/opentelemetry-collector) | ||
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-opentelemetry-collector, run the following command: | ||
|
||
```console | ||
helm install my-opentelemetry-collector open-telemetry/opentelemetry-collector | ||
``` | ||
|
||
## Configuration | ||
|
||
### Default configuration | ||
|
||
By default this chart will deploy an OpenTelemetry Collector as daemonset with two pipelines (traces and metrics) | ||
and logging exporter enabled by default. Besides daemonset (agent), it can be also installed as standalone deployment. | ||
Both modes can be enabled together, in that case metrics and traces will be flowing from agents to standalone collectors. | ||
|
||
*Example*: Install collector as a standalone deployment, and do not run it as an agent. | ||
```yaml | ||
agentCollector: | ||
enabled: false | ||
standaloneCollector: | ||
enabled: true | ||
``` | ||
By default collector has the following receivers enabled: | ||
- **metrics**: OTLP and prometheus. Prometheus is configured only for scraping collector's own metrics. | ||
- **traces**: OTLP, zipkin and jaeger (thrift and grpc). | ||
There are two ways to configure collector pipelines, which can be used together as well. | ||
### Basic top level configuration with `telemetry` property | ||
|
||
*Example*: Disable metrics pipeline and send traces to zipkin exporter: | ||
```yaml | ||
telemetry: | ||
metrics: | ||
enabled: false | ||
traces: | ||
exporter: | ||
type: zipkin | ||
config: | ||
endpoint: zipkin-all-in-one:14250 | ||
``` | ||
|
||
### Configuration with `agentCollector` and `standaloneCollector` properties | ||
|
||
`agentCollector` and `standaloneCollector` properties allow to override collector configurations | ||
and default parameters applied on the k8s pods. | ||
|
||
`agentCollector(standaloneCollector).configOverride` property allows to provide an extra | ||
configuration that will be merged into the default configuration. | ||
|
||
*Example*: Enable host metrics receiver on the agents: | ||
```yaml | ||
agentCollector: | ||
configOverride: | ||
receivers: | ||
hostmetrics: | ||
scrapers: | ||
cpu: | ||
load: | ||
memory: | ||
disk: | ||
service: | ||
pipelines: | ||
metrics: | ||
receivers: [prometheus, hostmetrics] | ||
extraEnvs: | ||
- name: HOST_PROC | ||
value: /hostfs/proc | ||
- name: HOST_SYS | ||
value: /hostfs/sys | ||
- name: HOST_ETC | ||
value: /hostfs/etc | ||
- name: HOST_VAR | ||
value: /hostfs/var | ||
- name: HOST_RUN | ||
value: /hostfs/run | ||
- name: HOST_DEV | ||
value: /hostfs/dev | ||
extraHostPathMounts: | ||
- name: hostfs | ||
hostPath: / | ||
mountPath: /hostfs | ||
readOnly: true | ||
mountPropagation: HostToContainer | ||
``` | ||
|
||
### Other configuration options | ||
|
||
The [values.yaml](./values.yaml) file contains information about all other configuration | ||
options for this chart. |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
{{/* | ||
Expand the name of the chart. | ||
*/}} | ||
{{- define "opentelemetry-collector.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 "opentelemetry-collector.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 "opentelemetry-collector.chart" -}} | ||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
|
||
{{/* | ||
Common labels | ||
*/}} | ||
{{- define "opentelemetry-collector.labels" -}} | ||
helm.sh/chart: {{ include "opentelemetry-collector.chart" . }} | ||
{{ include "opentelemetry-collector.selectorLabels" . }} | ||
{{- if .Chart.AppVersion }} | ||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} | ||
{{- end }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
{{- end }} | ||
|
||
{{/* | ||
Selector labels | ||
*/}} | ||
{{- define "opentelemetry-collector.selectorLabels" -}} | ||
app.kubernetes.io/name: {{ include "opentelemetry-collector.name" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create the name of the service account to use | ||
*/}} | ||
{{- define "opentelemetry-collector.serviceAccountName" -}} | ||
{{- if .Values.serviceAccount.create }} | ||
{{- default (include "opentelemetry-collector.fullname" .) .Values.serviceAccount.name }} | ||
{{- else }} | ||
{{- default "default" .Values.serviceAccount.name }} | ||
{{- end }} | ||
{{- end }} | ||
|
||
{{/* | ||
Build base config file with pipelines | ||
*/}} | ||
{{- define "opentelemetry-collector.pipelinesConfig" -}} | ||
{{- $config := include "opentelemetry-collector.baseConfig" . | fromYaml -}} | ||
{{- range $telemetryName, $telemetryParams := .Values.telemetry }} | ||
{{- if index $telemetryParams "enabled" }} | ||
{{- $config := include (printf "opentelemetry-collector.%sPipelineConfig" $telemetryName) $ | fromYaml | mustMergeOverwrite $config }} | ||
{{- end }} | ||
{{- end }} | ||
{{- $config | toYaml }} | ||
{{- end }} | ||
|
||
{{/* | ||
Build config file for agent OpenTelemetry Collector | ||
*/}} | ||
{{- define "opentelemetry-collector.agentCollectorConfig" -}} | ||
{{- $values := deepCopy .Values.agentCollector | mustMergeOverwrite (deepCopy .Values) }} | ||
{{- $data := dict "Values" $values | mustMergeOverwrite (deepCopy .) }} | ||
{{- $config := include "opentelemetry-collector.pipelinesConfig" $data | fromYaml }} | ||
{{- $config := include "opentelemetry-collector.agentConfigOverride" $data | fromYaml | mustMergeOverwrite $config }} | ||
{{- .Values.agentCollector.configOverride | mustMergeOverwrite $config | toYaml }} | ||
{{- end }} | ||
|
||
{{/* | ||
Build config file for standalone OpenTelemetry Collector | ||
*/}} | ||
{{- define "opentelemetry-collector.standaloneCollectorConfig" -}} | ||
{{- $values := deepCopy .Values.standaloneCollector | mustMergeOverwrite (deepCopy .Values) }} | ||
{{- $data := dict "Values" $values | mustMergeOverwrite (deepCopy .) }} | ||
{{- $config := include "opentelemetry-collector.pipelinesConfig" $data | fromYaml }} | ||
{{- .Values.standaloneCollector.configOverride | mustMergeOverwrite $config | toYaml }} | ||
{{- end }} | ||
|
||
{{/* | ||
Convert memory value from resources.limit to numeric value in MiB to be used by otel memory_limiter processor. | ||
*/}} | ||
{{- define "opentelemetry-collector.convertMemToMib" -}} | ||
{{- $mem := lower . -}} | ||
{{- if hasSuffix "e" $mem -}} | ||
{{- trimSuffix "e" $mem | atoi | mul 1000 | mul 1000 | mul 1000 | mul 1000 -}} | ||
{{- else if hasSuffix "ei" $mem -}} | ||
{{- trimSuffix "ei" $mem | atoi | mul 1024 | mul 1024 | mul 1024 | mul 1024 -}} | ||
{{- else if hasSuffix "p" $mem -}} | ||
{{- trimSuffix "p" $mem | atoi | mul 1000 | mul 1000 | mul 1000 -}} | ||
{{- else if hasSuffix "pi" $mem -}} | ||
{{- trimSuffix "pi" $mem | atoi | mul 1024 | mul 1024 | mul 1024 -}} | ||
{{- else if hasSuffix "t" $mem -}} | ||
{{- trimSuffix "t" $mem | atoi | mul 1000 | mul 1000 -}} | ||
{{- else if hasSuffix "ti" $mem -}} | ||
{{- trimSuffix "ti" $mem | atoi | mul 1024 | mul 1024 -}} | ||
{{- else if hasSuffix "g" $mem -}} | ||
{{- trimSuffix "g" $mem | atoi | mul 1000 -}} | ||
{{- else if hasSuffix "gi" $mem -}} | ||
{{- trimSuffix "gi" $mem | atoi | mul 1024 -}} | ||
{{- else if hasSuffix "m" $mem -}} | ||
{{- div (trimSuffix "m" $mem | atoi | mul 1000) 1024 -}} | ||
{{- else if hasSuffix "mi" $mem -}} | ||
{{- trimSuffix "mi" $mem | atoi -}} | ||
{{- else if hasSuffix "k" $mem -}} | ||
{{- div (trimSuffix "k" $mem | atoi) 1000 -}} | ||
{{- else if hasSuffix "ki" $mem -}} | ||
{{- div (trimSuffix "ki" $mem | atoi) 1024 -}} | ||
{{- else -}} | ||
{{- div (div ($mem | atoi) 1024) 1024 -}} | ||
{{- end -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Get otel memory_limiter limit_mib value based on 80% of resources.memory.limit. | ||
*/}} | ||
{{- define "opentelemetry-collector.getMemLimitMib" -}} | ||
{{- div (mul (include "opentelemetry-collector.convertMemToMib" .) 80) 100 }} | ||
{{- end -}} | ||
|
||
{{/* | ||
Get otel memory_limiter spike_limit_mib value based on 25% of resources.memory.limit. | ||
*/}} | ||
{{- define "opentelemetry-collector.getMemSpikeLimitMib" -}} | ||
{{- div (mul (include "opentelemetry-collector.convertMemToMib" .) 25) 100 }} | ||
{{- end -}} | ||
|
||
{{/* | ||
Get otel memory_limiter ballast_size_mib value based on 40% of resources.memory.limit. | ||
*/}} | ||
{{- define "opentelemetry-collector.getMemBallastSizeMib" }} | ||
{{- div (mul (include "opentelemetry-collector.convertMemToMib" .) 40) 100 }} | ||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
{{- define "opentelemetry-collector.pod" -}} | ||
{{- with .Values.imagePullSecrets }} | ||
imagePullSecrets: | ||
{{- toYaml . | nindent 2 }} | ||
{{- end }} | ||
serviceAccountName: {{ include "opentelemetry-collector.serviceAccountName" . }} | ||
securityContext: | ||
{{- toYaml .Values.podSecurityContext | nindent 2 }} | ||
containers: | ||
- name: {{ .Chart.Name }} | ||
command: | ||
- /{{ .Values.command.name }} | ||
- --config=/conf/relay.yaml | ||
- --metrics-addr=0.0.0.0:8888 | ||
- --mem-ballast-size-mib={{ template "opentelemetry-collector.getMemBallastSizeMib" .Values.resources.limits.memory }} | ||
{{- range .Values.command.extraArgs }} | ||
- {{ . }} | ||
{{- end }} | ||
securityContext: | ||
{{- toYaml .Values.securityContext | nindent 6 }} | ||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" | ||
imagePullPolicy: {{ .Values.image.pullPolicy }} | ||
ports: | ||
{{- range $key, $port := .Values.ports }} | ||
{{- if $port.enabled }} | ||
- name: {{ $key }} | ||
containerPort: {{ $port.containerPort }} | ||
protocol: {{ $port.protocol }} | ||
{{- if and $.isAgent $port.hostPort }} | ||
hostPort: {{ $port.hostPort }} | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} | ||
env: | ||
- name: MY_POD_IP | ||
valueFrom: | ||
fieldRef: | ||
apiVersion: v1 | ||
fieldPath: status.podIP | ||
{{- with .Values.extraEnvs }} | ||
{{- . | toYaml | nindent 6 }} | ||
{{- end }} | ||
livenessProbe: | ||
httpGet: | ||
path: / | ||
port: 13133 | ||
readinessProbe: | ||
httpGet: | ||
path: / | ||
port: 13133 | ||
resources: | ||
{{- toYaml .Values.resources | nindent 6 }} | ||
volumeMounts: | ||
- mountPath: /conf | ||
name: {{ .Chart.Name }}-configmap | ||
{{- range .Values.extraHostPathMounts }} | ||
- name: {{ .name }} | ||
mountPath: {{ .mountPath }} | ||
readOnly: {{ .readOnly }} | ||
{{- if .mountPropagation }} | ||
mountPropagation: {{ .mountPropagation }} | ||
{{- end }} | ||
{{- end }} | ||
volumes: | ||
- name: {{ .Chart.Name }}-configmap | ||
configMap: | ||
name: {{ include "opentelemetry-collector.fullname" . }}{{ .configmapSuffix }} | ||
items: | ||
- key: relay | ||
path: relay.yaml | ||
{{- range .Values.extraHostPathMounts }} | ||
- name: {{ .name }} | ||
hostPath: | ||
path: {{ .hostPath }} | ||
{{- end }} | ||
{{- with .Values.nodeSelector }} | ||
nodeSelector: | ||
{{- toYaml . | nindent 2 }} | ||
{{- end }} | ||
{{- with .Values.affinity }} | ||
affinity: | ||
{{- toYaml . | nindent 2 }} | ||
{{- end }} | ||
{{- with .Values.tolerations }} | ||
tolerations: | ||
{{- toYaml . | nindent 2 }} | ||
{{- end }} | ||
{{- end }} |
Oops, something went wrong.