added repo

This commit is contained in:
Your Name
2026-08-26 03:39:42 +05:30
parent 45c25a95af
commit b8575bb8b9
6889 changed files with 1217125 additions and 0 deletions
@@ -0,0 +1,49 @@
{{- if not .Values.image.repository }}
{{ fail "[ERROR] 'image.repository' must be set. See https://github.com/open-telemetry/opentelemetry-helm-charts/blob/main/charts/opentelemetry-collector/UPGRADING.md for instructions." }}
{{ end }}
{{- if and (not (eq .Values.mode "daemonset")) (not (eq .Values.mode "deployment")) (not (eq .Values.mode "statefulset")) }}
{{ fail "[ERROR] 'mode' must be set. See https://github.com/open-telemetry/opentelemetry-helm-charts/blob/main/charts/opentelemetry-collector/UPGRADING.md for instructions." }}
{{ end }}
{{- if and (eq .Values.dnsPolicy "None") (not .Values.dnsConfig) }}
{{- fail "[ERROR] dnsConfig should be provided when dnsPolicy is None" }}
{{ end }}
{{- if .Values.presets.clusterMetrics.enabled }}
{{- if eq .Values.mode "daemonset"}}
{{- fail "Cluster Metrics preset is not suitable for daemonset mode. Please use statefulset or deployment mode with replicaCount: 1"}}
{{ end }}
{{- if gt (int .Values.replicaCount) 1 }}
{{- fail "Cluster Metrics preset is not suitable for replicaCount greater than one. Please change replica count to one." }}
{{ end }}
{{ end }}
{{/* validate extensions must include health_check */}}
{{- if not (has "health_check" .Values.config.service.extensions) }}
{{ fail "[ERROR] The opentelemetry-collector chart requires that the health_check extension to be included in the extension list." }}
{{- end}}
{{- if not .Values.configMap.create }}
[WARNING] "configMap" wil not be created and "config" will not take effect.
{{ end }}
{{- if and .Values.configMap.create .Values.configMap.existingName }}
{{ fail "[ERROR] Cannot set configMap.existingName when configMap.create is true" }}
{{ end }}
{{- if and .Values.configMap.create .Values.configMap.existingPath }}
{{ fail "[ERROR] Cannot set configMap.existingPath when configMap.create is true" }}
{{ end }}
{{- if not .Values.resources }}
[WARNING] No resource limits or requests were set. Consider setter resource requests and limits for your collector(s) via the `resources` field.
{{ end }}
{{- if and (eq .Values.mode "daemonset") (eq .Values.service.internalTrafficPolicy "Cluster") }}
[WARNING] Setting internalTrafficPolicy to 'Cluster' on Daemonset is not recommended. Consider using 'Local' instead.
{{ end }}
{{- if and (.Values.useGOMEMLIMIT) (not ((((.Values.resources).limits).memory))) }}
[WARNING] "useGOMEMLIMIT" is enabled but memory limits have not been supplied so the GOMEMLIMIT env var could not be added. Solve this problem by setting resources.limits.memory or disabling useGOMEMLIMIT
{{ end }}
@@ -0,0 +1,299 @@
{{- define "opentelemetry-collector.baseConfig" -}}
{{- if .Values.alternateConfig }}
{{- .Values.alternateConfig | toYaml }}
{{- else}}
{{- .Values.config | toYaml }}
{{- end }}
{{- end }}
{{/*
Build config file for daemonset OpenTelemetry Collector
*/}}
{{- define "opentelemetry-collector.daemonsetConfig" -}}
{{- $values := deepCopy .Values }}
{{- $data := dict "Values" $values | mustMergeOverwrite (deepCopy .) }}
{{- $config := include "opentelemetry-collector.baseConfig" $data | fromYaml }}
{{- if .Values.presets.logsCollection.enabled }}
{{- $config = (include "opentelemetry-collector.applyLogsCollectionConfig" (dict "Values" $data "config" $config) | fromYaml) }}
{{- end }}
{{- if .Values.presets.hostMetrics.enabled }}
{{- $config = (include "opentelemetry-collector.applyHostMetricsConfig" (dict "Values" $data "config" $config) | fromYaml) }}
{{- end }}
{{- if .Values.presets.kubeletMetrics.enabled }}
{{- $config = (include "opentelemetry-collector.applyKubeletMetricsConfig" (dict "Values" $data "config" $config) | fromYaml) }}
{{- end }}
{{- if .Values.presets.kubernetesAttributes.enabled }}
{{- $config = (include "opentelemetry-collector.applyKubernetesAttributesConfig" (dict "Values" $data "config" $config) | fromYaml) }}
{{- end }}
{{- if .Values.presets.clusterMetrics.enabled }}
{{- $config = (include "opentelemetry-collector.applyClusterMetricsConfig" (dict "Values" $data "config" $config) | fromYaml) }}
{{- end }}
{{- tpl (toYaml $config) . }}
{{- end }}
{{/*
Build config file for deployment OpenTelemetry Collector
*/}}
{{- define "opentelemetry-collector.deploymentConfig" -}}
{{- $values := deepCopy .Values }}
{{- $data := dict "Values" $values | mustMergeOverwrite (deepCopy .) }}
{{- $config := include "opentelemetry-collector.baseConfig" $data | fromYaml }}
{{- if .Values.presets.logsCollection.enabled }}
{{- $config = (include "opentelemetry-collector.applyLogsCollectionConfig" (dict "Values" $data "config" $config) | fromYaml) }}
{{- end }}
{{- if .Values.presets.hostMetrics.enabled }}
{{- $config = (include "opentelemetry-collector.applyHostMetricsConfig" (dict "Values" $data "config" $config) | fromYaml) }}
{{- end }}
{{- if .Values.presets.kubeletMetrics.enabled }}
{{- $config = (include "opentelemetry-collector.applyKubeletMetricsConfig" (dict "Values" $data "config" $config) | fromYaml) }}
{{- end }}
{{- if .Values.presets.kubernetesAttributes.enabled }}
{{- $config = (include "opentelemetry-collector.applyKubernetesAttributesConfig" (dict "Values" $data "config" $config) | fromYaml) }}
{{- end }}
{{- if .Values.presets.kubernetesEvents.enabled }}
{{- $config = (include "opentelemetry-collector.applyKubernetesEventsConfig" (dict "Values" $data "config" $config) | fromYaml) }}
{{- end }}
{{- if .Values.presets.clusterMetrics.enabled }}
{{- $config = (include "opentelemetry-collector.applyClusterMetricsConfig" (dict "Values" $data "config" $config) | fromYaml) }}
{{- end }}
{{- tpl (toYaml $config) . }}
{{- end }}
{{- define "opentelemetry-collector.applyHostMetricsConfig" -}}
{{- $config := mustMergeOverwrite (dict "service" (dict "pipelines" (dict "metrics" (dict "receivers" list)))) (include "opentelemetry-collector.hostMetricsConfig" .Values | fromYaml) .config }}
{{- $_ := set $config.service.pipelines.metrics "receivers" (append $config.service.pipelines.metrics.receivers "hostmetrics" | uniq) }}
{{- $config | toYaml }}
{{- end }}
{{- define "opentelemetry-collector.hostMetricsConfig" -}}
receivers:
hostmetrics:
root_path: /hostfs
collection_interval: 10s
scrapers:
cpu:
load:
memory:
disk:
filesystem:
exclude_mount_points:
mount_points:
- /dev/*
- /proc/*
- /sys/*
- /run/k3s/containerd/*
- /var/lib/docker/*
- /var/lib/kubelet/*
- /snap/*
match_type: regexp
exclude_fs_types:
fs_types:
- autofs
- binfmt_misc
- bpf
- cgroup2
- configfs
- debugfs
- devpts
- devtmpfs
- fusectl
- hugetlbfs
- iso9660
- mqueue
- nsfs
- overlay
- proc
- procfs
- pstore
- rpc_pipefs
- securityfs
- selinuxfs
- squashfs
- sysfs
- tracefs
match_type: strict
network:
{{- end }}
{{- define "opentelemetry-collector.applyClusterMetricsConfig" -}}
{{- $config := mustMergeOverwrite (dict "service" (dict "pipelines" (dict "metrics" (dict "receivers" list)))) (include "opentelemetry-collector.clusterMetricsConfig" .Values | fromYaml) .config }}
{{- $_ := set $config.service.pipelines.metrics "receivers" (append $config.service.pipelines.metrics.receivers "k8s_cluster" | uniq) }}
{{- $config | toYaml }}
{{- end }}
{{- define "opentelemetry-collector.clusterMetricsConfig" -}}
receivers:
k8s_cluster:
collection_interval: 10s
{{- end }}
{{- define "opentelemetry-collector.applyKubeletMetricsConfig" -}}
{{- $config := mustMergeOverwrite (dict "service" (dict "pipelines" (dict "metrics" (dict "receivers" list)))) (include "opentelemetry-collector.kubeletMetricsConfig" .Values | fromYaml) .config }}
{{- $_ := set $config.service.pipelines.metrics "receivers" (append $config.service.pipelines.metrics.receivers "kubeletstats" | uniq) }}
{{- $config | toYaml }}
{{- end }}
{{- define "opentelemetry-collector.kubeletMetricsConfig" -}}
receivers:
kubeletstats:
collection_interval: 20s
auth_type: "serviceAccount"
endpoint: "${env:K8S_NODE_NAME}:10250"
{{- end }}
{{- define "opentelemetry-collector.applyLogsCollectionConfig" -}}
{{- $config := mustMergeOverwrite (dict "service" (dict "pipelines" (dict "logs" (dict "receivers" list)))) (include "opentelemetry-collector.logsCollectionConfig" .Values | fromYaml) .config }}
{{- $_ := set $config.service.pipelines.logs "receivers" (append $config.service.pipelines.logs.receivers "filelog" | uniq) }}
{{- if .Values.Values.presets.logsCollection.storeCheckpoints}}
{{- $configExtensions := mustMergeOverwrite (dict "service" (dict "extensions" list)) $config }}
{{- $_ := set $config.service "extensions" (append $configExtensions.service.extensions "file_storage" | uniq) }}
{{- end }}
{{- $config | toYaml }}
{{- end }}
{{- define "opentelemetry-collector.logsCollectionConfig" -}}
{{- if .Values.presets.logsCollection.storeCheckpoints }}
extensions:
file_storage:
directory: /var/lib/otelcol
{{- end }}
receivers:
filelog:
include: [ /var/log/pods/*/*/*.log ]
{{- if .Values.presets.logsCollection.includeCollectorLogs }}
exclude: []
{{- else }}
# Exclude collector container's logs. The file format is /var/log/pods/<namespace_name>_<pod_name>_<pod_uid>/<container_name>/<run_id>.log
exclude: [ /var/log/pods/{{ include "opentelemetry-collector.namespace" . }}_{{ include "opentelemetry-collector.fullname" . }}*_*/{{ include "opentelemetry-collector.lowercase_chartname" . }}/*.log ]
{{- end }}
start_at: end
retry_on_failure:
enabled: true
{{- if .Values.presets.logsCollection.storeCheckpoints}}
storage: file_storage
{{- end }}
include_file_path: true
include_file_name: false
operators:
# parse container logs
- type: container
id: container-parser
max_log_size: {{ $.Values.presets.logsCollection.maxRecombineLogSize }}
{{- end }}
{{- define "opentelemetry-collector.applyKubernetesAttributesConfig" -}}
{{- $config := mustMergeOverwrite (include "opentelemetry-collector.kubernetesAttributesConfig" .Values | fromYaml) .config }}
{{- if $config.service.pipelines.logs }}
{{- $config = mustMergeOverwrite (dict "service" (dict "pipelines" (dict "logs" (dict "processors" list)))) $config }}
{{- if not (has "k8sattributes" $config.service.pipelines.logs.processors) }}
{{- $_ := set $config.service.pipelines.logs "processors" (prepend $config.service.pipelines.logs.processors "k8sattributes" | uniq) }}
{{- end }}
{{- end }}
{{- if and $config.service.pipelines.metrics }}
{{- $config = mustMergeOverwrite (dict "service" (dict "pipelines" (dict "metrics" (dict "processors" list)))) $config }}
{{- if not (has "k8sattributes" $config.service.pipelines.metrics.processors) }}
{{- $_ := set $config.service.pipelines.metrics "processors" (prepend $config.service.pipelines.metrics.processors "k8sattributes" | uniq) }}
{{- end }}
{{- end }}
{{- if and $config.service.pipelines.traces }}
{{- $config = mustMergeOverwrite (dict "service" (dict "pipelines" (dict "traces" (dict "processors" list)))) $config }}
{{- if not (has "k8sattributes" $config.service.pipelines.traces.processors) }}
{{- $_ := set $config.service.pipelines.traces "processors" (prepend $config.service.pipelines.traces.processors "k8sattributes" | uniq) }}
{{- end }}
{{- end }}
{{- $config | toYaml }}
{{- end }}
{{- define "opentelemetry-collector.kubernetesAttributesConfig" -}}
processors:
k8sattributes:
{{- if eq .Values.mode "daemonset" }}
filter:
node_from_env_var: K8S_NODE_NAME
{{- end }}
passthrough: false
pod_association:
- sources:
- from: resource_attribute
name: k8s.pod.ip
- sources:
- from: resource_attribute
name: k8s.pod.uid
- sources:
- from: connection
extract:
metadata:
- "k8s.namespace.name"
- "k8s.deployment.name"
- "k8s.statefulset.name"
- "k8s.daemonset.name"
- "k8s.cronjob.name"
- "k8s.job.name"
- "k8s.node.name"
- "k8s.pod.name"
- "k8s.pod.uid"
- "k8s.pod.start_time"
{{- if .Values.presets.kubernetesAttributes.extractAllPodLabels }}
labels:
- tag_name: $$1
key_regex: (.*)
from: pod
{{- end }}
{{- if .Values.presets.kubernetesAttributes.extractAllPodAnnotations }}
annotations:
- tag_name: $$1
key_regex: (.*)
from: pod
{{- end }}
{{- end }}
{{/* Build the list of port for service */}}
{{- define "opentelemetry-collector.servicePortsConfig" -}}
{{- $ports := deepCopy .Values.ports }}
{{- range $key, $port := $ports }}
{{- if $port.enabled }}
- name: {{ $key }}
port: {{ $port.servicePort }}
targetPort: {{ $port.containerPort }}
protocol: {{ $port.protocol }}
{{- if $port.appProtocol }}
appProtocol: {{ $port.appProtocol }}
{{- end }}
{{- if $port.nodePort }}
nodePort: {{ $port.nodePort }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{/* Build the list of port for pod */}}
{{- define "opentelemetry-collector.podPortsConfig" -}}
{{- $ports := deepCopy .Values.ports }}
{{- range $key, $port := $ports }}
{{- if $port.enabled }}
- name: {{ $key }}
containerPort: {{ $port.containerPort }}
protocol: {{ $port.protocol }}
{{- if and $.isAgent $port.hostPort }}
hostPort: {{ $port.hostPort }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- define "opentelemetry-collector.applyKubernetesEventsConfig" -}}
{{- $config := mustMergeOverwrite (dict "service" (dict "pipelines" (dict "logs" (dict "receivers" list)))) (include "opentelemetry-collector.kubernetesEventsConfig" .Values | fromYaml) .config }}
{{- $_ := set $config.service.pipelines.logs "receivers" (append $config.service.pipelines.logs.receivers "k8sobjects" | uniq) }}
{{- $config | toYaml }}
{{- end }}
{{- define "opentelemetry-collector.kubernetesEventsConfig" -}}
receivers:
k8sobjects:
objects:
- name: events
mode: "watch"
group: "events.k8s.io"
exclude_watch_type:
- "DELETED"
{{- end }}
@@ -0,0 +1,244 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "opentelemetry-collector.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- define "opentelemetry-collector.lowercase_chartname" -}}
{{- default .Chart.Name | lower }}
{{- end }}
{{/*
Get component name
*/}}
{{- define "opentelemetry-collector.component" -}}
{{- if eq .Values.mode "deployment" -}}
component: standalone-collector
{{- end -}}
{{- if eq .Values.mode "daemonset" -}}
component: agent-collector
{{- end -}}
{{- if eq .Values.mode "statefulset" -}}
component: statefulset-collector
{{- end -}}
{{- 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 }}
{{ include "opentelemetry-collector.additionalLabels" . }}
{{- 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 }}
{{/*
Create the name of the clusterRole to use
*/}}
{{- define "opentelemetry-collector.clusterRoleName" -}}
{{- default (include "opentelemetry-collector.fullname" .) .Values.clusterRole.name }}
{{- end }}
{{/*
Create the name of the clusterRoleBinding to use
*/}}
{{- define "opentelemetry-collector.clusterRoleBindingName" -}}
{{- default (include "opentelemetry-collector.fullname" .) .Values.clusterRole.clusterRoleBinding.name }}
{{- end }}
{{- define "opentelemetry-collector.podAnnotations" -}}
{{- if .Values.podAnnotations }}
{{- tpl (.Values.podAnnotations | toYaml) . }}
{{- end }}
{{- end }}
{{- define "opentelemetry-collector.podLabels" -}}
{{- if .Values.podLabels }}
{{- tpl (.Values.podLabels | toYaml) . }}
{{- end }}
{{- end }}
{{- define "opentelemetry-collector.additionalLabels" -}}
{{- if .Values.additionalLabels }}
{{- tpl (.Values.additionalLabels | toYaml) . }}
{{- end }}
{{- end }}
{{/*
Return the appropriate apiVersion for podDisruptionBudget.
*/}}
{{- define "podDisruptionBudget.apiVersion" -}}
{{- if and (.Capabilities.APIVersions.Has "policy/v1") (semverCompare ">= 1.21-0" .Capabilities.KubeVersion.Version) -}}
{{- print "policy/v1" -}}
{{- else -}}
{{- print "policy/v1beta1" -}}
{{- end -}}
{{- end -}}
{{/*
Compute Service creation on mode
*/}}
{{- define "opentelemetry-collector.serviceEnabled" }}
{{- $serviceEnabled := true }}
{{- if not (eq (toString .Values.service.enabled) "<nil>") }}
{{- $serviceEnabled = .Values.service.enabled -}}
{{- end }}
{{- if and (eq .Values.mode "daemonset") (not .Values.service.enabled) }}
{{- $serviceEnabled = false -}}
{{- end }}
{{- print $serviceEnabled }}
{{- end -}}
{{/*
Compute InternalTrafficPolicy on Service creation
*/}}
{{- define "opentelemetry-collector.serviceInternalTrafficPolicy" }}
{{- if and (eq .Values.mode "daemonset") (eq .Values.service.enabled true) }}
{{- print (.Values.service.internalTrafficPolicy | default "Local") -}}
{{- else }}
{{- print (.Values.service.internalTrafficPolicy | default "Cluster") -}}
{{- end }}
{{- end -}}
{{/*
Allow the release namespace to be overridden
*/}}
{{- define "opentelemetry-collector.namespace" -}}
{{- if .Values.namespaceOverride -}}
{{- .Values.namespaceOverride -}}
{{- else -}}
{{- .Release.Namespace -}}
{{- end -}}
{{- end -}}
{{/*
This helper converts the input value of memory to Bytes.
Input needs to be a valid value as supported by k8s memory resource field.
*/}}
{{- define "opentelemetry-collector.convertMemToBytes" }}
{{- $mem := lower . -}}
{{- if hasSuffix "e" $mem -}}
{{- $mem = mulf (trimSuffix "e" $mem | float64) 1e18 -}}
{{- else if hasSuffix "ei" $mem -}}
{{- $mem = mulf (trimSuffix "e" $mem | float64) 0x1p60 -}}
{{- else if hasSuffix "p" $mem -}}
{{- $mem = mulf (trimSuffix "p" $mem | float64) 1e15 -}}
{{- else if hasSuffix "pi" $mem -}}
{{- $mem = mulf (trimSuffix "pi" $mem | float64) 0x1p50 -}}
{{- else if hasSuffix "t" $mem -}}
{{- $mem = mulf (trimSuffix "t" $mem | float64) 1e12 -}}
{{- else if hasSuffix "ti" $mem -}}
{{- $mem = mulf (trimSuffix "ti" $mem | float64) 0x1p40 -}}
{{- else if hasSuffix "g" $mem -}}
{{- $mem = mulf (trimSuffix "g" $mem | float64) 1e9 -}}
{{- else if hasSuffix "gi" $mem -}}
{{- $mem = mulf (trimSuffix "gi" $mem | float64) 0x1p30 -}}
{{- else if hasSuffix "m" $mem -}}
{{- $mem = mulf (trimSuffix "m" $mem | float64) 1e6 -}}
{{- else if hasSuffix "mi" $mem -}}
{{- $mem = mulf (trimSuffix "mi" $mem | float64) 0x1p20 -}}
{{- else if hasSuffix "k" $mem -}}
{{- $mem = mulf (trimSuffix "k" $mem | float64) 1e3 -}}
{{- else if hasSuffix "ki" $mem -}}
{{- $mem = mulf (trimSuffix "ki" $mem | float64) 0x1p10 -}}
{{- end }}
{{- $mem }}
{{- end }}
{{- define "opentelemetry-collector.gomemlimit" }}
{{- $memlimitBytes := include "opentelemetry-collector.convertMemToBytes" . | mulf 0.8 -}}
{{- printf "%dMiB" (divf $memlimitBytes 0x1p20 | floor | int64) -}}
{{- end }}
{{/*
Get HPA kind from mode.
The capitalization is important for StatefulSet.
*/}}
{{- define "opentelemetry-collector.hpaKind" -}}
{{- if eq .Values.mode "deployment" -}}
{{- print "Deployment" -}}
{{- end -}}
{{- if eq .Values.mode "statefulset" -}}
{{- print "StatefulSet" -}}
{{- end -}}
{{- end }}
{{/*
Get ConfigMap name if existingName is defined, otherwise use default name for generated config.
*/}}
{{- define "opentelemetry-collector.configName" -}}
{{- if .Values.configMap.existingName -}}
{{- .Values.configMap.existingName }}
{{- else }}
{{- printf "%s%s" (include "opentelemetry-collector.fullname" .) (.configmapSuffix) }}
{{- end -}}
{{- end }}
{{/*
Create ConfigMap checksum annotation if configMap.existingPath is defined, otherwise use default templates
*/}}
{{- define "opentelemetry-collector.configTemplateChecksumAnnotation" -}}
{{- if .Values.configMap.existingPath -}}
checksum/config: {{ include (print $.Template.BasePath "/" .Values.configMap.existingPath) . | sha256sum }}
{{- else -}}
{{- if eq .Values.mode "daemonset" -}}
checksum/config: {{ include (print $.Template.BasePath "/configmap-agent.yaml") . | sha256sum }}
{{- else if eq .Values.mode "deployment" -}}
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
{{- else if eq .Values.mode "statefulset" -}}
checksum/config: {{ include (print $.Template.BasePath "/configmap-statefulset.yaml") . | sha256sum }}
{{- end -}}
{{- end }}
{{- end }}
@@ -0,0 +1,221 @@
{{- define "opentelemetry-collector.pod" -}}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 2 }}
{{- end }}
serviceAccountName: {{ include "opentelemetry-collector.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 2 }}
{{- with .Values.hostAliases }}
hostAliases:
{{- toYaml . | nindent 2 }}
{{- end }}
{{- if $.Values.shareProcessNamespace }}
shareProcessNamespace: true
{{- end }}
containers:
- name: {{ include "opentelemetry-collector.lowercase_chartname" . }}
{{- if .Values.command.name }}
command:
- /{{ .Values.command.name }}
{{- end }}
args:
{{- if or .Values.configMap.create .Values.configMap.existingName }}
- --config=/conf/relay.yaml
{{- end }}
{{- range .Values.command.extraArgs }}
- {{ . }}
{{- end }}
securityContext:
{{- if and (not (.Values.securityContext)) (.Values.presets.logsCollection.storeCheckpoints) }}
runAsUser: 0
runAsGroup: 0
{{- else -}}
{{- toYaml .Values.securityContext | nindent 6 }}
{{- end }}
{{- if .Values.image.digest }}
image: "{{ ternary "" (print (.Values.global).imageRegistry "/") (empty (.Values.global).imageRegistry) }}{{ .Values.image.repository }}@{{ .Values.image.digest }}"
{{- else }}
image: "{{ ternary "" (print (.Values.global).imageRegistry "/") (empty (.Values.global).imageRegistry) }}{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
{{- end }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- $ports := include "opentelemetry-collector.podPortsConfig" . }}
{{- if $ports }}
ports:
{{- $ports | nindent 6}}
{{- end }}
env:
- name: MY_POD_IP
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: status.podIP
{{- if or .Values.presets.kubeletMetrics.enabled (and .Values.presets.kubernetesAttributes.enabled (eq .Values.mode "daemonset")) }}
- name: K8S_NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
{{- end }}
{{- if and (.Values.useGOMEMLIMIT) ((((.Values.resources).limits).memory)) }}
- name: GOMEMLIMIT
value: {{ include "opentelemetry-collector.gomemlimit" .Values.resources.limits.memory | quote }}
{{- end }}
{{- with .Values.extraEnvs }}
{{- . | toYaml | nindent 6 }}
{{- end }}
{{- with .Values.extraEnvsFrom }}
envFrom:
{{- . | toYaml | nindent 6 }}
{{- end }}
{{- if .Values.lifecycleHooks }}
lifecycle:
{{- toYaml .Values.lifecycleHooks | nindent 6 }}
{{- end }}
livenessProbe:
{{- if .Values.livenessProbe.initialDelaySeconds | empty | not }}
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
{{- end }}
{{- if .Values.livenessProbe.periodSeconds | empty | not }}
periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
{{- end }}
{{- if .Values.livenessProbe.timeoutSeconds | empty | not }}
timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
{{- end }}
{{- if .Values.livenessProbe.failureThreshold | empty | not }}
failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
{{- end }}
{{- if .Values.livenessProbe.terminationGracePeriodSeconds | empty | not }}
terminationGracePeriodSeconds: {{ .Values.livenessProbe.terminationGracePeriodSeconds }}
{{- end }}
httpGet:
path: {{ .Values.livenessProbe.httpGet.path }}
port: {{ .Values.livenessProbe.httpGet.port }}
readinessProbe:
{{- if .Values.readinessProbe.initialDelaySeconds | empty | not }}
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
{{- end }}
{{- if .Values.readinessProbe.periodSeconds | empty | not }}
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
{{- end }}
{{- if .Values.readinessProbe.timeoutSeconds | empty | not }}
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
{{- end }}
{{- if .Values.readinessProbe.successThreshold | empty | not }}
successThreshold: {{ .Values.readinessProbe.successThreshold }}
{{- end }}
{{- if .Values.readinessProbe.failureThreshold | empty | not }}
failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
{{- end }}
httpGet:
path: {{ .Values.readinessProbe.httpGet.path }}
port: {{ .Values.readinessProbe.httpGet.port }}
{{- if .Values.startupProbe }}
startupProbe:
{{- if .Values.startupProbe.initialDelaySeconds | empty | not }}
initialDelaySeconds: {{ .Values.startupProbe.initialDelaySeconds }}
{{- end }}
{{- if .Values.startupProbe.periodSeconds | empty | not }}
periodSeconds: {{ .Values.startupProbe.periodSeconds }}
{{- end }}
{{- if .Values.startupProbe.timeoutSeconds | empty | not }}
timeoutSeconds: {{ .Values.startupProbe.timeoutSeconds }}
{{- end }}
{{- if .Values.startupProbe.failureThreshold | empty | not }}
failureThreshold: {{ .Values.startupProbe.failureThreshold }}
{{- end }}
{{- if .Values.startupProbe.terminationGracePeriodSeconds | empty | not }}
terminationGracePeriodSeconds: {{ .Values.startupProbe.terminationGracePeriodSeconds }}
{{- end }}
httpGet:
path: {{ .Values.startupProbe.httpGet.path }}
port: {{ .Values.startupProbe.httpGet.port }}
{{- end }}
{{- with .Values.resources }}
resources:
{{- toYaml . | nindent 6 }}
{{- end }}
volumeMounts:
{{- if or .Values.configMap.create .Values.configMap.existingName }}
- mountPath: /conf
name: {{ include "opentelemetry-collector.lowercase_chartname" . }}-configmap
{{- end }}
{{- if .Values.presets.logsCollection.enabled }}
- name: varlogpods
mountPath: /var/log/pods
readOnly: true
- name: varlibdockercontainers
mountPath: /var/lib/docker/containers
readOnly: true
{{- if .Values.presets.logsCollection.storeCheckpoints}}
- name: varlibotelcol
mountPath: /var/lib/otelcol
{{- end }}
{{- end }}
{{- if .Values.presets.hostMetrics.enabled }}
- name: hostfs
mountPath: /hostfs
readOnly: true
mountPropagation: HostToContainer
{{- end }}
{{- if .Values.extraVolumeMounts }}
{{- tpl (toYaml .Values.extraVolumeMounts) . | nindent 6 }}
{{- end }}
{{- if .Values.extraContainers }}
{{- tpl (toYaml .Values.extraContainers) . | nindent 2 }}
{{- end }}
{{- if .Values.initContainers }}
initContainers:
{{- tpl (toYaml .Values.initContainers) . | nindent 2 }}
{{- end }}
{{- if .Values.priorityClassName }}
priorityClassName: {{ .Values.priorityClassName | quote }}
{{- end }}
volumes:
{{- if or .Values.configMap.create .Values.configMap.existingName }}
- name: {{ include "opentelemetry-collector.lowercase_chartname" . }}-configmap
configMap:
name: {{ include "opentelemetry-collector.configName" . }}
items:
- key: relay
path: relay.yaml
{{- end }}
{{- if .Values.presets.logsCollection.enabled }}
- name: varlogpods
hostPath:
path: /var/log/pods
{{- if .Values.presets.logsCollection.storeCheckpoints}}
- name: varlibotelcol
hostPath:
path: /var/lib/otelcol
type: DirectoryOrCreate
{{- end }}
- name: varlibdockercontainers
hostPath:
path: /var/lib/docker/containers
{{- end }}
{{- if .Values.presets.hostMetrics.enabled }}
- name: hostfs
hostPath:
path: /
{{- end }}
{{- if .Values.extraVolumes }}
{{- tpl (toYaml .Values.extraVolumes) . | nindent 2 }}
{{- 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 }}
{{- with .Values.topologySpreadConstraints }}
topologySpreadConstraints:
{{- toYaml . | nindent 2 }}
{{- end }}
{{- end }}
@@ -0,0 +1,56 @@
{{- if or (.Values.clusterRole.create) (.Values.presets.kubernetesAttributes.enabled) (.Values.presets.clusterMetrics.enabled) (.Values.presets.kubeletMetrics.enabled) (.Values.presets.kubernetesEvents.enabled) -}}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "opentelemetry-collector.clusterRoleName" . }}
labels:
{{- include "opentelemetry-collector.labels" . | nindent 4 }}
{{- if .Values.clusterRole.annotations }}
annotations:
{{- range $key, $value := .Values.clusterRole.annotations }}
{{- printf "%s: %s" $key (tpl $value $ | quote) | nindent 4 }}
{{- end }}
{{- end }}
rules:
{{- if .Values.clusterRole.rules -}}
{{ toYaml .Values.clusterRole.rules | nindent 2 -}}
{{- end }}
{{- if .Values.presets.kubernetesAttributes.enabled}}
- apiGroups: [""]
resources: ["pods", "namespaces"]
verbs: ["get", "watch", "list"]
- apiGroups: ["apps"]
resources: ["replicasets"]
verbs: ["get", "list", "watch"]
- apiGroups: ["extensions"]
resources: ["replicasets"]
verbs: ["get", "list", "watch"]
{{- end }}
{{- if .Values.presets.clusterMetrics.enabled}}
- apiGroups: [""]
resources: ["events", "namespaces", "namespaces/status", "nodes", "nodes/spec", "pods", "pods/status", "replicationcontrollers", "replicationcontrollers/status", "resourcequotas", "services" ]
verbs: ["get", "list", "watch"]
- apiGroups: ["apps"]
resources: ["daemonsets", "deployments", "replicasets", "statefulsets"]
verbs: ["get", "list", "watch"]
- apiGroups: ["extensions"]
resources: ["daemonsets", "deployments", "replicasets"]
verbs: ["get", "list", "watch"]
- apiGroups: ["batch"]
resources: ["jobs", "cronjobs"]
verbs: ["get", "list", "watch"]
- apiGroups: ["autoscaling"]
resources: ["horizontalpodautoscalers"]
verbs: ["get", "list", "watch"]
{{- end}}
{{- if .Values.presets.kubeletMetrics.enabled}}
- apiGroups: [""]
resources: ["nodes/stats"]
verbs: ["get", "watch", "list"]
{{- end }}
{{- if .Values.presets.kubernetesEvents.enabled }}
- apiGroups: ["events.k8s.io"]
resources: ["events"]
verbs: ["watch", "list"]
{{- end }}
{{- end }}
@@ -0,0 +1,22 @@
{{- if or (.Values.clusterRole.create) (.Values.presets.kubernetesAttributes.enabled) (.Values.presets.clusterMetrics.enabled) (.Values.presets.kubeletMetrics.enabled) (.Values.presets.kubernetesEvents.enabled) -}}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ include "opentelemetry-collector.clusterRoleBindingName" . }}
labels:
{{- include "opentelemetry-collector.labels" . | nindent 4 }}
{{- if .Values.clusterRole.clusterRoleBinding.annotations }}
annotations:
{{- range $key, $value := .Values.clusterRole.clusterRoleBinding.annotations }}
{{- printf "%s: %s" $key (tpl $value $ | quote) | nindent 4 }}
{{- end }}
{{- end }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ include "opentelemetry-collector.clusterRoleName" . }}
subjects:
- kind: ServiceAccount
name: {{ include "opentelemetry-collector.serviceAccountName" . }}
namespace: {{ include "opentelemetry-collector.namespace" . }}
{{- end }}
@@ -0,0 +1,12 @@
{{- if and (eq .Values.mode "daemonset") (.Values.configMap.create) (not .Values.configMap.existingName) -}}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "opentelemetry-collector.fullname" . }}-agent
namespace: {{ template "opentelemetry-collector.namespace" . }}
labels:
{{- include "opentelemetry-collector.labels" . | nindent 4 }}
data:
relay: |
{{- include "opentelemetry-collector.daemonsetConfig" . | nindent 4 -}}
{{- end }}
@@ -0,0 +1,12 @@
{{- if and (eq .Values.mode "statefulset") (.Values.configMap.create) (not .Values.configMap.existingName) -}}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "opentelemetry-collector.fullname" . }}-statefulset
namespace: {{ template "opentelemetry-collector.namespace" . }}
labels:
{{- include "opentelemetry-collector.labels" . | nindent 4 }}
data:
relay: |
{{- include "opentelemetry-collector.deploymentConfig" . | nindent 4 -}}
{{- end }}
@@ -0,0 +1,12 @@
{{- if and (eq .Values.mode "deployment") (.Values.configMap.create) (not .Values.configMap.existingName) -}}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "opentelemetry-collector.fullname" . }}
namespace: {{ template "opentelemetry-collector.namespace" . }}
labels:
{{- include "opentelemetry-collector.labels" . | nindent 4 }}
data:
relay: |
{{- include "opentelemetry-collector.deploymentConfig" . | nindent 4 -}}
{{- end }}
@@ -0,0 +1,49 @@
{{- if eq .Values.mode "daemonset" -}}
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: {{ include "opentelemetry-collector.fullname" . }}-agent
namespace: {{ template "opentelemetry-collector.namespace" . }}
labels:
{{- include "opentelemetry-collector.labels" . | nindent 4 }}
{{- if .Values.annotations }}
annotations:
{{- range $key, $value := .Values.annotations }}
{{- printf "%s: %s" $key (tpl $value $ | quote) | nindent 4 }}
{{- end }}
{{- end }}
spec:
selector:
matchLabels:
{{- include "opentelemetry-collector.selectorLabels" . | nindent 6 }}
{{- include "opentelemetry-collector.component" . | nindent 6 }}
updateStrategy:
{{- if eq .Values.rollout.strategy "RollingUpdate" }}
{{- with .Values.rollout.rollingUpdate }}
rollingUpdate:
{{- toYaml . | nindent 6 }}
{{- end }}
{{- end }}
type: {{ .Values.rollout.strategy }}
template:
metadata:
annotations:
{{- include "opentelemetry-collector.configTemplateChecksumAnnotation" . | nindent 8 }}
{{- include "opentelemetry-collector.podAnnotations" . | nindent 8 }}
labels:
{{- include "opentelemetry-collector.selectorLabels" . | nindent 8 }}
{{- include "opentelemetry-collector.component" . | nindent 8 }}
{{- include "opentelemetry-collector.podLabels" . | nindent 8 }}
spec:
{{- $podValues := deepCopy .Values }}
{{- $podData := dict "Values" $podValues "configmapSuffix" "-agent" "isAgent" true }}
{{- include "opentelemetry-collector.pod" ($podData | mustMergeOverwrite (deepCopy .)) | nindent 6 }}
hostNetwork: {{ .Values.hostNetwork }}
{{- with .Values.dnsPolicy }}
dnsPolicy: {{ . }}
{{- end }}
{{- with .Values.dnsConfig }}
dnsConfig:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
@@ -0,0 +1,53 @@
{{- if eq .Values.mode "deployment" -}}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "opentelemetry-collector.fullname" . }}
namespace: {{ template "opentelemetry-collector.namespace" . }}
labels:
{{- include "opentelemetry-collector.labels" . | nindent 4 }}
{{- if .Values.annotations }}
annotations:
{{- range $key, $value := .Values.annotations }}
{{- printf "%s: %s" $key (tpl $value $ | quote) | nindent 4 }}
{{- end }}
{{- end }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
revisionHistoryLimit: {{ .Values.revisionHistoryLimit }}
selector:
matchLabels:
{{- include "opentelemetry-collector.selectorLabels" . | nindent 6 }}
{{- include "opentelemetry-collector.component" . | nindent 6 }}
strategy:
{{- if eq .Values.rollout.strategy "RollingUpdate" }}
{{- with .Values.rollout.rollingUpdate }}
rollingUpdate:
{{- toYaml . | nindent 6 }}
{{- end }}
{{- end }}
type: {{ .Values.rollout.strategy }}
template:
metadata:
annotations:
{{- include "opentelemetry-collector.configTemplateChecksumAnnotation" . | nindent 8 }}
{{- include "opentelemetry-collector.podAnnotations" . | nindent 8 }}
labels:
{{- include "opentelemetry-collector.selectorLabels" . | nindent 8 }}
{{- include "opentelemetry-collector.component" . | nindent 8 }}
{{- include "opentelemetry-collector.podLabels" . | nindent 8 }}
spec:
{{- with .Values.dnsPolicy }}
dnsPolicy: {{ . }}
{{- end }}
{{- with .Values.dnsConfig }}
dnsConfig:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- $podValues := deepCopy .Values }}
{{- $podData := dict "Values" $podValues "configmapSuffix" "" "isAgent" false }}
{{- include "opentelemetry-collector.pod" ($podData | mustMergeOverwrite (deepCopy .)) | nindent 6 }}
hostNetwork: {{ .Values.hostNetwork }}
{{- end }}
@@ -0,0 +1,19 @@
{{- if .Values.externalSecret.enabled -}}
apiVersion: external-secrets.io/v1
kind: ExternalSecret
metadata:
name: {{ include "opentelemetry-collector.fullname" . }}-secret
spec:
dataFrom:
- extract:
conversionStrategy: Default
key: {{ .Values.externalSecret.key }}
refreshInterval: 15s
secretStoreRef:
kind: ClusterSecretStore
name: {{ .Values.externalSecret.secretStoreRef.name }}
target:
creationPolicy: Owner
deletionPolicy: Retain
name: {{ include "opentelemetry-collector.fullname" . }}-secret
{{- end -}}
@@ -0,0 +1,37 @@
{{- if and .Values.autoscaling.enabled (or (eq .Values.mode "deployment") (eq .Values.mode "statefulset")) }}
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "opentelemetry-collector.fullname" . }}
namespace: {{ template "opentelemetry-collector.namespace" . }}
labels:
{{- include "opentelemetry-collector.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: {{ include "opentelemetry-collector.hpaKind" . }}
name: {{ include "opentelemetry-collector.fullname" . }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
{{- if .Values.autoscaling.behavior }}
behavior:
{{- toYaml .Values.autoscaling.behavior | nindent 4 }}
{{- end }}
metrics:
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- end }}
@@ -0,0 +1,55 @@
{{- if .Values.ingress.enabled -}}
{{- $ingresses := prepend .Values.ingress.additionalIngresses .Values.ingress -}}
{{- range $ingresses }}
apiVersion: "networking.k8s.io/v1"
kind: Ingress
metadata:
{{- if .name }}
name: {{ printf "%s-%s" (include "opentelemetry-collector.fullname" $) .name }}
{{- else }}
name: {{ include "opentelemetry-collector.fullname" $ }}
{{- end }}
namespace: {{ template "opentelemetry-collector.namespace" $ }}
labels:
{{- include "opentelemetry-collector.labels" $ | nindent 4 }}
{{- include "opentelemetry-collector.component" $ | nindent 4 }}
{{- if .annotations }}
annotations:
{{- range $key, $value := .annotations }}
{{- printf "%s: %s" $key (tpl $value $ | quote) | nindent 4 }}
{{- end }}
{{- end }}
spec:
{{- if .ingressClassName }}
ingressClassName: {{ .ingressClassName }}
{{- end -}}
{{- if .tls }}
tls:
{{- range .tls }}
- hosts:
{{- range .hosts }}
- {{ tpl . $ | quote }}
{{- end }}
{{- with .secretName }}
secretName: {{ . }}
{{- end }}
{{- end }}
{{- end }}
rules:
{{- range .hosts }}
- host: {{ tpl .host $ | quote }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
pathType: {{ .pathType }}
backend:
service:
name: {{ include "opentelemetry-collector.fullname" $ }}
port:
number: {{ .port }}
{{- end }}
{{- end }}
---
{{- end }}
{{- end }}
@@ -0,0 +1,39 @@
{{- if .Values.networkPolicy.enabled }}
kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
name: {{ include "opentelemetry-collector.fullname" . }}
namespace: {{ template "opentelemetry-collector.namespace" . }}
labels:
{{- include "opentelemetry-collector.labels" . | nindent 4 }}
{{- if .Values.networkPolicy.annotations }}
annotations:
{{- range $key, $value := .Values.networkPolicy.annotations }}
{{- printf "%s: %s" $key (tpl $value $ | quote) | nindent 4 }}
{{- end }}
{{- end }}
spec:
podSelector:
matchLabels:
{{- include "opentelemetry-collector.selectorLabels" . | nindent 6 }}
{{- include "opentelemetry-collector.component" . | nindent 6 }}
ingress:
- ports:
{{- range $port := .Values.ports }}
{{- if $port.enabled }}
- port: {{ $port.containerPort }}
protocol: {{ $port.protocol }}
{{- end }}
{{- end }}
{{- if .Values.networkPolicy.allowIngressFrom }}
from:
{{- toYaml .Values.networkPolicy.allowIngressFrom | nindent 8 }}
{{- end }}
{{- if .Values.networkPolicy.extraIngressRules }}
{{- toYaml .Values.networkPolicy.extraIngressRules | nindent 4 }}
{{- end }}
{{- if .Values.networkPolicy.egressRules }}
egress:
{{- toYaml .Values.networkPolicy.egressRules | nindent 4 }}
{{- end }}
{{- end }}
@@ -0,0 +1,19 @@
{{- if and .Values.podDisruptionBudget.enabled (eq .Values.mode "deployment") }}
apiVersion: {{ include "podDisruptionBudget.apiVersion" . }}
kind: PodDisruptionBudget
metadata:
name: {{ include "opentelemetry-collector.fullname" . }}
namespace: {{ template "opentelemetry-collector.namespace" . }}
labels:
{{- include "opentelemetry-collector.labels" . | nindent 4 }}
spec:
{{- if .Values.podDisruptionBudget.minAvailable }}
minAvailable: {{ .Values.podDisruptionBudget.minAvailable }}
{{- end }}
{{- if .Values.podDisruptionBudget.maxUnavailable }}
maxUnavailable: {{ .Values.podDisruptionBudget.maxUnavailable }}
{{- end }}
selector:
matchLabels:
{{- include "opentelemetry-collector.selectorLabels" . | nindent 6 }}
{{- end }}
@@ -0,0 +1,19 @@
{{- if and .Values.podMonitor.enabled .Values.podMonitor.metricsEndpoints (eq .Values.mode "daemonset") }}
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
name: {{ include "opentelemetry-collector.fullname" . }}-agent
namespace: {{ template "opentelemetry-collector.namespace" . }}
labels:
{{- include "opentelemetry-collector.labels" . | nindent 4 }}
{{- range $key, $value := .Values.podMonitor.extraLabels }}
{{- printf "%s: %s" $key (tpl $value $ | quote) | nindent 4 }}
{{- end }}
spec:
selector:
matchLabels:
{{- include "opentelemetry-collector.selectorLabels" . | nindent 6 }}
{{- include "opentelemetry-collector.component" . | nindent 6 }}
podMetricsEndpoints:
{{- toYaml .Values.podMonitor.metricsEndpoints | nindent 2 }}
{{- end }}
@@ -0,0 +1,112 @@
{{- if and .Values.prometheusRule.enabled .Values.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: {{ include "opentelemetry-collector.fullname" . }}
namespace: {{ template "opentelemetry-collector.namespace" . }}
labels:
{{- include "opentelemetry-collector.labels" . | nindent 4 }}
{{- range $key, $value := .Values.prometheusRule.extraLabels }}
{{- printf "%s: %s" $key (tpl $value $ | quote) | nindent 4 }}
{{- end }}
spec:
groups:
{{- if .Values.prometheusRule.groups }}
{{- toYaml .Values.prometheusRule.groups | nindent 4 }}
{{- end }}
{{- if .Values.prometheusRule.defaultRules.enabled }}
- name: collectorRules
rules:
- alert: ReceiverDroppedSpans
expr: rate(otelcol_receiver_refused_spans[5m]) > 0
for: 2m
labels:
severity: critical
annotations:
description: '{{`The {{ $labels.receiver }} receiver is dropping spans at a rate of {{ humanize $value }} per second `}}'
runbook_url: 'https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/monitoring.md#receive-failures'
- alert: ReceiverDroppedMetrics
expr: rate(otelcol_receiver_refused_metric_points[5m]) > 0
for: 2m
labels:
severity: critical
annotations:
description: '{{`The {{ $labels.receiver }} receiver is dropping metrics at a rate of {{ humanize $value }} per second `}}'
runbook_url: 'https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/monitoring.md#receive-failures'
- alert: ReceiverDroppedLogs
expr: rate(otelcol_receiver_refused_log_records[5m]) > 0
for: 5m
labels:
severity: critical
annotations:
description: '{{` The {{ $labels.receiver }} is dropping logs at a rate of {{ humanize $value }} per second `}}'
runbook_url: 'https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/monitoring.md#receive-failures'
- alert: ProcessorDroppedSpans
expr: rate(otelcol_processor_dropped_spans[5m]) > 0
for: 2m
labels:
severity: critical
annotations:
description: '{{`The {{ $labels.processor }} processor is dropping spans at a rate of {{ humanize $value }} per second `}}'
runbook_url: 'https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/monitoring.md#data-loss'
- alert: ProcessorDroppedMetrics
expr: rate(otelcol_processor_dropped_metric_points[5m]) > 0
for: 2m
labels:
severity: critical
annotations:
description: '{{`The {{ $labels.processor }} processor is dropping metrics at a rate of {{ humanize $value }} per second `}}'
runbook_url: 'https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/monitoring.md#data-loss'
- alert: ProcessorDroppedLogs
expr: rate(otelcol_processor_dropped_log_records[5m]) > 0
for: 5m
labels:
severity: critical
annotations:
description: '{{` The {{ $labels.processor }} is dropping logs at a rate of {{ humanize $value }} per second `}}'
runbook_url: 'https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/monitoring.md#data-loss'
- alert: ExporterDroppedSpans
expr: rate(otelcol_exporter_send_failed_spans[5m]) > 0
for: 2m
labels:
severity: critical
annotations:
description: '{{`The {{ $labels.exporter }} exporter is dropping spans at a rate of {{ humanize $value }} per second `}}'
runbook_url: 'https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/monitoring.md#data-egress'
- alert: ExporterDroppedMetrics
expr: rate(otelcol_exporter_send_failed_metric_points[5m]) > 0
for: 2m
labels:
severity: critical
annotations:
description: '{{`The {{ $labels.exporter }} exporter is dropping metrics at a rate of {{ humanize $value }} per second `}}'
runbook_url: 'https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/monitoring.md#data-egress'
- alert: ExporterDroppedLogs
expr: rate(otelcol_exporter_send_failed_log_records[5m]) > 0
for: 5m
labels:
severity: critical
annotations:
description: '{{` The {{ $labels.exporter }} is dropping logs at a rate of {{ humanize $value }} per second `}}'
runbook_url: 'https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/monitoring.md#data-egress'
- alert: ExporterQueueSize
expr: otelcol_exporter_queue_size > 5000
for: 1m
labels:
severity: warning
annotations:
description: '{{`The {{ $labels.exporter }} queue has reached a size of {{ $value }} `}}'
runbook_url: 'https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/monitoring.md#queue-length'
{{- $signals := list "spans" "metric_points" "log_records" }}
{{- range $signal := $signals }}
- alert: SendQueueFailed{{ $signal }}
expr: rate(otelcol_exporter_enqueue_failed_{{ $signal }}[5m]) > 0
for: 1m
labels:
severity: warning
annotations:
description: '{{`The {{ $labels.exporter }} sending queue failed to accept {{ $value }} `}} {{ $signal }}'
runbook_url: 'https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/monitoring.md#queue-length'
{{- end }}
{{- end }}
{{- end }}
@@ -0,0 +1,17 @@
apiVersion: v1
kind: ResourceQuota
metadata:
labels:
addonmanager.kubernetes.io/mode: Reconcile
name: opentelemetry-critical-pods
namespace: opentelemetry
spec:
hard:
pods: "15000"
scopeSelector:
matchExpressions:
- operator: In
scopeName: PriorityClass
values:
- system-node-critical
- system-cluster-critical
@@ -0,0 +1,42 @@
{{- if or (eq (include "opentelemetry-collector.serviceEnabled" .) "true") (.Values.ingress.enabled) -}}
apiVersion: v1
kind: Service
metadata:
name: {{ include "opentelemetry-collector.fullname" . }}
namespace: {{ template "opentelemetry-collector.namespace" . }}
labels:
{{- include "opentelemetry-collector.labels" . | nindent 4 }}
{{- include "opentelemetry-collector.component" . | nindent 4 }}
{{- if .Values.service.annotations }}
annotations:
{{- range $key, $value := .Values.service.annotations }}
{{- printf "%s: %s" $key (tpl $value $ | quote) | nindent 4 }}
{{- end }}
{{- end }}
spec:
type: {{ .Values.service.type }}
{{- if .Values.service.clusterIP }}
clusterIP: {{ .Values.service.clusterIP }}
{{- end }}
{{- if and .Values.service.loadBalancerIP (eq .Values.service.type "LoadBalancer") }}
loadBalancerIP: {{ .Values.service.loadBalancerIP }}
{{- end }}
{{- if and .Values.service.loadBalancerSourceRanges (eq .Values.service.type "LoadBalancer") }}
loadBalancerSourceRanges:
{{- range .Values.service.loadBalancerSourceRanges }}
- {{ . }}
{{- end }}
{{- end }}
{{- $ports := include "opentelemetry-collector.servicePortsConfig" . }}
{{- if $ports }}
ports:
{{- $ports | nindent 4}}
{{- end }}
selector:
{{- include "opentelemetry-collector.selectorLabels" . | nindent 4 }}
{{- include "opentelemetry-collector.component" . | nindent 4 }}
internalTrafficPolicy: {{ include "opentelemetry-collector.serviceInternalTrafficPolicy" . }}
{{- if and (eq .Values.service.type "LoadBalancer") (.Values.service.externalTrafficPolicy) }}
externalTrafficPolicy: {{ .Values.service.externalTrafficPolicy }}
{{- end }}
{{- end }}
@@ -0,0 +1,15 @@
{{- if or (.Values.serviceAccount.create) (.Values.presets.kubeletMetrics.enabled) -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "opentelemetry-collector.serviceAccountName" . }}
namespace: {{ template "opentelemetry-collector.namespace" . }}
labels:
{{- include "opentelemetry-collector.labels" . | nindent 4 }}
{{- if .Values.serviceAccount.annotations }}
annotations:
{{- range $key, $value := .Values.serviceAccount.annotations }}
{{- printf "%s: %s" $key (tpl $value $ | quote) | nindent 4 }}
{{- end }}
{{- end }}
{{ end }}
@@ -0,0 +1,27 @@
{{- if and (eq (include "opentelemetry-collector.serviceEnabled" .) "true") .Values.serviceMonitor.enabled .Values.serviceMonitor.metricsEndpoints }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "opentelemetry-collector.fullname" . }}
namespace: {{ template "opentelemetry-collector.namespace" . }}
labels:
{{- include "opentelemetry-collector.labels" . | nindent 4 }}
{{- range $key, $value := .Values.serviceMonitor.extraLabels }}
{{- printf "%s: %s" $key (tpl $value $ | quote) | nindent 4 }}
{{- end }}
spec:
selector:
matchLabels:
{{- include "opentelemetry-collector.selectorLabels" . | nindent 6 }}
{{- include "opentelemetry-collector.component" . | nindent 6 }}
endpoints:
{{- toYaml .Values.serviceMonitor.metricsEndpoints | nindent 4 }}
{{- with .Values.serviceMonitor.relabelings }}
relabelings:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.serviceMonitor.metricRelabelings }}
metricRelabelings:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
@@ -0,0 +1,57 @@
{{- if eq .Values.mode "statefulset" -}}
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ include "opentelemetry-collector.fullname" . }}
namespace: {{ template "opentelemetry-collector.namespace" . }}
labels:
{{- include "opentelemetry-collector.labels" . | nindent 4 }}
{{- if .Values.annotations }}
annotations:
{{- range $key, $value := .Values.annotations }}
{{- printf "%s: %s" $key (tpl $value $ | quote) | nindent 4 }}
{{- end }}
{{- end }}
spec:
serviceName: {{ include "opentelemetry-collector.fullname" . }}
podManagementPolicy: {{ .Values.statefulset.podManagementPolicy }}
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
{{- if .Values.statefulset.persistentVolumeClaimRetentionPolicy.enabled }}
persistentVolumeClaimRetentionPolicy:
whenDeleted: {{ .Values.statefulset.persistentVolumeClaimRetentionPolicy.whenDeleted }}
whenScaled: {{ .Values.statefulset.persistentVolumeClaimRetentionPolicy.whenScaled }}
{{- end }}
selector:
matchLabels:
{{- include "opentelemetry-collector.selectorLabels" . | nindent 6 }}
{{- include "opentelemetry-collector.component" . | nindent 6 }}
updateStrategy:
type: {{ .Values.rollout.strategy }}
template:
metadata:
annotations:
{{- include "opentelemetry-collector.configTemplateChecksumAnnotation" . | nindent 8 }}
{{- include "opentelemetry-collector.podAnnotations" . | nindent 8 }}
labels:
{{- include "opentelemetry-collector.selectorLabels" . | nindent 8 }}
{{- include "opentelemetry-collector.component" . | nindent 8 }}
{{- include "opentelemetry-collector.podLabels" . | nindent 8 }}
spec:
{{- with .Values.dnsPolicy }}
dnsPolicy: {{ . }}
{{- end }}
{{- with .Values.dnsConfig }}
dnsConfig:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- $podValues := deepCopy .Values }}
{{- $podData := dict "Values" $podValues "configmapSuffix" "-statefulset" "isAgent" false }}
{{- include "opentelemetry-collector.pod" ($podData | mustMergeOverwrite (deepCopy .)) | nindent 6 }}
hostNetwork: {{ .Values.hostNetwork }}
{{- with .Values.statefulset.volumeClaimTemplates }}
volumeClaimTemplates:
{{- toYaml . | nindent 2 }}
{{- end }}
{{- end }}