Add VictoriaMetrics observability stack + sync catalog for monitoring test

- VM stack 10 charts: victoria-metrics-cluster/auth, victoria-logs-cluster,
  victoria-metrics-agent/alert, opentelemetry-collector, kube-state-metrics,
  prometheus-node-exporter, alertmanager, perses (JWT/OIDC, Infisical-ready)
- ArgoCD ApplicationSet (syncWave) + per-chart dip-values overlays
- doc/victoria-metrics-architecture.md, define-chart-resources updates
- includes pending working-tree changes (mlflow, kubeflow, apisix, CLAUDE.md)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
wbsong111
2026-06-25 11:10:51 +09:00
parent a55427730e
commit 6290322f1b
514 changed files with 68103 additions and 40 deletions
@@ -0,0 +1,82 @@
{{- 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 .Values.presets.profiling.enabled }}
{{- $repo := .Values.image.repository -}}
{{- $unsupported := include "opentelemetry-collector.profilingUnsupportedImages" . | fromYamlArray -}}
{{- range $distro := $unsupported }}
{{- if or (eq $repo $distro) (hasSuffix (printf "/%s" $distro) $repo) }}
{{ fail "[ERROR] presets.profiling is enabled but image.repository is a community distribution that does not include the profiling receiver. Use the opentelemetry-collector-ebpf-profiler distribution or a custom distribution that includes the receiver." }}
{{- end }}
{{- end }}
{{- if eq (toString .Values.podSecurityContext.runAsNonRoot) "true" }}
{{ fail "[ERROR] presets.profiling is enabled but podSecurityContext.runAsNonRoot is true. The eBPF profiler requires runAsUser: 0 to run. Set podSecurityContext.runAsNonRoot to false or remove it." }}
{{ end }}
{{- if .Values.securityContext }}
[WARNING] presets.profiling is enabled with a custom securityContext. The preset will NOT inject runAsUser: 0 and privileged: true automatically; required by the eBPF profiler to function. Ensure your securityContext sets runAsUser: 0 plus either privileged: true, or right capabilities otherwise.
{{ end }}
{{ 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 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 and (not (has "health_check" .Values.config.service.extensions)) (not (has "healthcheckv2" .Values.config.service.extensions)) }}
{{ fail "[ERROR] The opentelemetry-collector chart requires that the health_check extension or the healthcheckv2 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 setting 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 }}
{{- if or (and (.Values.internalTelemetryViaOTLP.traces.enabled) (not (or .Values.internalTelemetryViaOTLP.endpoint .Values.internalTelemetryViaOTLP.traces.endpoint))) }}
{{ fail "[ERROR] internalTelemetryViaOTLP.endpoint or .Values.internalTelemetryViaOTLP.traces.endpoint must be set when internalTelemetryViaOTLP.traces.enabled is true" }}
{{ end }}
{{- if or (and (.Values.internalTelemetryViaOTLP.metrics.enabled) (not (or .Values.internalTelemetryViaOTLP.endpoint .Values.internalTelemetryViaOTLP.metrics.endpoint))) }}
{{ fail "[ERROR] internalTelemetryViaOTLP.endpoint or .Values.internalTelemetryViaOTLP.metrics.endpoint must be set when internalTelemetryViaOTLP.metrics.enabled is true" }}
{{ end }}
{{- if or (and (.Values.internalTelemetryViaOTLP.logs.enabled) (not (or .Values.internalTelemetryViaOTLP.endpoint .Values.internalTelemetryViaOTLP.logs.endpoint))) }}
{{ fail "[ERROR] internalTelemetryViaOTLP.endpoint or .Values.internalTelemetryViaOTLP.logs.endpoint must be set when internalTelemetryViaOTLP.logs.enabled is true" }}
{{ end }}
{{- if .Values.config.service.telemetry.metrics.address }}
[WARNING] config.service.telemetry.metrics.address should not be used and will be removed in the future. Use internalTelemetryViaOTLP or config.service.telemetry.metrics.readers instead"
{{ end }}
{{- if and .Values.presets.logsCollection.enabled .Values.presets.annotationDiscovery.logs.enabled }}
{{- fail "[ERROR] logsCollection and annotationDiscovery.logs are mutually exclusive" }}
{{- end }}
@@ -0,0 +1,745 @@
{{- define "opentelemetry-collector.otelsdkotlp.traces" -}}
traces:
processors:
- batch:
exporter:
otlp:
protocol: http/protobuf
endpoint: {{ default .Values.internalTelemetryViaOTLP.endpoint .Values.internalTelemetryViaOTLP.traces.endpoint }}
{{- if or .Values.internalTelemetryViaOTLP.headers .Values.internalTelemetryViaOTLP.traces.headers }}
headers:
{{- toYaml (default .Values.internalTelemetryViaOTLP.headers .Values.internalTelemetryViaOTLP.traces.headers) | nindent 14 }}
{{- end }}
{{- end }}
{{- define "opentelemetry-collector.otelsdkotlp.metrics" -}}
metrics:
readers:
- periodic:
exporter:
otlp:
protocol: http/protobuf
endpoint: {{ default .Values.internalTelemetryViaOTLP.endpoint .Values.internalTelemetryViaOTLP.metrics.endpoint }}
{{- if or .Values.internalTelemetryViaOTLP.headers .Values.internalTelemetryViaOTLP.metrics.headers }}
headers:
{{- toYaml (default .Values.internalTelemetryViaOTLP.headers .Values.internalTelemetryViaOTLP.metrics.headers) | nindent 14 }}
{{- end }}
{{- end }}
{{- define "opentelemetry-collector.metrics.prometheus" -}}
metrics:
readers:
- pull:
exporter:
prometheus:
host: {{ .address._0 | replace "{env!" "{env:" }}
port: {{ .address._1 }}
{{- if .Values.config.service.telemetry.resource }}
with_resource_constant_labels:
included:
{{- range (keys .Values.config.service.telemetry.resource | sortAlpha) }}
- {{ println . }}
{{- end }}
{{- end }}
{{- end }}
{{- define "opentelemetry-collector.otelsdkotlp.logs" -}}
logs:
processors:
- batch:
exporter:
otlp:
protocol: http/protobuf
endpoint: {{ default .Values.internalTelemetryViaOTLP.endpoint .Values.internalTelemetryViaOTLP.logs.endpoint }}
{{- if or .Values.internalTelemetryViaOTLP.headers .Values.internalTelemetryViaOTLP.logs.headers }}
headers:
{{- toYaml (default .Values.internalTelemetryViaOTLP.headers .Values.internalTelemetryViaOTLP.logs.headers) | nindent 14 }}
{{- end }}
{{- end }}
{{- define "opentelemetry-collector.baseConfig" -}}
{{- if .Values.alternateConfig }}
{{- .Values.alternateConfig | toYaml }}
{{- else}}
{{- $config := deepCopy .Values.config }}
{{- if .Values.internalTelemetryViaOTLP.traces.enabled }}
{{- $_ := set $config.service "telemetry" (mustMerge $config.service.telemetry (include "opentelemetry-collector.otelsdkotlp.traces" . | fromYaml)) }}
{{- end }}
{{- if .Values.internalTelemetryViaOTLP.metrics.enabled }}
{{- $_ := unset $config.receivers "prometheus" }}
{{- if $config.service.pipelines.metrics }}
{{- $_ := set $config.service.pipelines.metrics "receivers" (mustWithout $config.service.pipelines.metrics.receivers "prometheus") }}
{{- end }}
{{- $_ := unset $config.service.telemetry.metrics "readers" }}
{{- $_ := set $config.service "telemetry" (mustMerge $config.service.telemetry (include "opentelemetry-collector.otelsdkotlp.metrics" . | fromYaml)) }}
{{- else if .Values.config.service.telemetry.metrics.address }}
{{/* First replace env: with env! so we can split the host with the port and replace it back later */}}
{{- $address:= .Values.config.service.telemetry.metrics.address | replace "{env:" "{env!" | split ":" }}
{{- $_ := unset $config.service.telemetry.metrics "address" }}
{{- $_ := set $config.service "telemetry" (mustMerge (include "opentelemetry-collector.metrics.prometheus" (mustMerge (dict "address" $address) .) | fromYaml) $config.service.telemetry ) }}
{{- end }}
{{- if .Values.internalTelemetryViaOTLP.logs.enabled }}
{{- $_ := set $config.service "telemetry" (mustMerge $config.service.telemetry (include "opentelemetry-collector.otelsdkotlp.logs" . | fromYaml)) }}
{{- end }}
{{- $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 or .Values.presets.annotationDiscovery.logs.enabled .Values.presets.annotationDiscovery.metrics.enabled }}
{{- $config = (include "opentelemetry-collector.applyAnnotationDiscoveryConfig" (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.profiling.enabled }}
{{- $config = (include "opentelemetry-collector.applyProfilingConfig" (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.kubernetesObjects.enabled }}
{{- $config = (include "opentelemetry-collector.applyKubernetesObjectsConfig" (dict "Values" $data "config" $config) | fromYaml) }}
{{- end }}
{{- if .Values.presets.clusterMetrics.enabled }}
{{- $config = (include "opentelemetry-collector.applyClusterMetricsConfig" (dict "Values" $data "config" $config) | fromYaml) }}
{{- end }}
{{- if and .Values.presets.resourceDetection.enabled (or .Values.presets.resourceDetection.env.enabled .Values.presets.resourceDetection.k8snode.enabled .Values.presets.resourceDetection.eks.enabled .Values.presets.resourceDetection.aks.enabled .Values.presets.resourceDetection.gcp.enabled) }}
{{- $config = (include "opentelemetry-collector.applyResourceDetectionConfig" (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 or .Values.presets.annotationDiscovery.logs.enabled .Values.presets.annotationDiscovery.metrics.enabled }}
{{- $config = (include "opentelemetry-collector.applyAnnotationDiscoveryConfig" (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.profiling.enabled }}
{{- $config = (include "opentelemetry-collector.applyProfilingConfig" (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.kubernetesObjects.enabled }}
{{- $config = (include "opentelemetry-collector.applyKubernetesObjectsConfig" (dict "Values" $data "config" $config) | fromYaml) }}
{{- end }}
{{- if .Values.presets.clusterMetrics.enabled }}
{{- $config = (include "opentelemetry-collector.applyClusterMetricsConfig" (dict "Values" $data "config" $config) | fromYaml) }}
{{- end }}
{{- if and .Values.presets.resourceDetection.enabled (or .Values.presets.resourceDetection.env.enabled .Values.presets.resourceDetection.k8snode.enabled .Values.presets.resourceDetection.eks.enabled .Values.presets.resourceDetection.aks.enabled .Values.presets.resourceDetection.gcp.enabled) }}
{{- $config = (include "opentelemetry-collector.applyResourceDetectionConfig" (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" -}}
{{- $vals := .Values.Values -}}
{{- $disableLeaderElection := false -}}
{{- if and (hasKey $vals "presets") (hasKey $vals.presets "clusterMetrics") -}}
{{- $disableLeaderElection = $vals.presets.clusterMetrics.disableLeaderElection -}}
{{- end -}}
{{- $useLeaderElection := and (eq $vals.mode "daemonset") (not $disableLeaderElection) -}}
{{- $electorName := "k8s_cluster" }}
{{- $ctx := mustMerge (dict "namespace" (include "opentelemetry-collector.namespace" .Values) "useLeaderElection" $useLeaderElection "electorName" $electorName) .Values }}
{{- $config := mustMergeOverwrite (dict "service" (dict "pipelines" (dict "metrics" (dict "receivers" list)))) (include "opentelemetry-collector.clusterMetricsConfig" $ctx | fromYaml) .config }}
{{- if $useLeaderElection}}
{{- $configExtensions := mustMergeOverwrite (dict "service" (dict "extensions" list)) $config }}
{{- $_ := set $config.service "extensions" (append $configExtensions.service.extensions (printf "k8s_leader_elector/%s" $electorName) | uniq) }}
{{- end }}
{{- $_ := set $config.service.pipelines.metrics "receivers" (append $config.service.pipelines.metrics.receivers "k8s_cluster" | uniq) }}
{{- $config | toYaml }}
{{- end }}
{{- define "opentelemetry-collector.clusterMetricsConfig" -}}
{{- if .useLeaderElection}}
{{- include "opentelemetry-collector.leaderElectionConfig" (dict "name" .electorName "leaseName" "k8s.cluster.receiver.opentelemetry.io" "leaseNamespace" .namespace)}}
{{- end}}
receivers:
k8s_cluster:
{{- if .useLeaderElection}}
k8s_leader_elector: k8s_leader_elector/{{ .electorName }}
{{- end}}
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_IP}: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.applyAnnotationDiscoveryConfig" -}}
{{- $config := mustMergeOverwrite (include "opentelemetry-collector.annotationDiscoveryConfig" .Values | fromYaml) .config }}
{{- $_ := set $config.service "extensions" (append $config.service.extensions "k8s_observer" | uniq) }}
{{- if .Values.Values.presets.annotationDiscovery.logs.enabled }}
{{- $_ := set $config.service.pipelines.logs "receivers" (append $config.service.pipelines.logs.receivers "receiver_creator/logs" | uniq) }}
{{- end }}
{{- if .Values.Values.presets.annotationDiscovery.metrics.enabled }}
{{- $_ := set $config.service.pipelines.metrics "receivers" (append $config.service.pipelines.metrics.receivers "receiver_creator/metrics" | uniq) }}
{{- end }}
{{- $config | toYaml }}
{{- end }}
{{- define "opentelemetry-collector.annotationDiscoveryConfig" -}}
extensions:
k8s_observer:
auth_type: serviceAccount
{{- if eq .Values.mode "daemonset" }}
node: ${env:K8S_NODE_NAME}
{{- end }}
receivers:
{{- if .Values.presets.annotationDiscovery.logs.enabled }}
receiver_creator/logs:
watch_observers:
- k8s_observer
discovery:
enabled: true
default_annotations:
io.opentelemetry.discovery.logs/enabled: "true"
{{- end }}
{{- if .Values.presets.annotationDiscovery.metrics.enabled }}
receiver_creator/metrics:
watch_observers:
- k8s_observer
discovery:
enabled: true
{{- end }}
{{- end }}
{{- define "opentelemetry-collector.applyProfilingConfig" -}}
{{- $config := mustMergeOverwrite (dict "service" (dict "pipelines" (dict "profiles" (dict "receivers" list "exporters" list)))) (include "opentelemetry-collector.profilingConfig" .Values | fromYaml) .config }}
{{- $_ := set $config.service.pipelines.profiles "receivers" (append $config.service.pipelines.profiles.receivers "profiling" | uniq) }}
{{- if not $config.service.pipelines.profiles.exporters }}
{{- $_ := set $config.service.pipelines.profiles "exporters" (list "debug") }}
{{- end }}
{{- $config | toYaml }}
{{- end }}
{{- define "opentelemetry-collector.profilingConfig" -}}
receivers:
profiling: {}
exporters:
debug: {}
{{- 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 }}
{{- if $config.service.pipelines.profiles }}
{{- $config = mustMergeOverwrite (dict "service" (dict "pipelines" (dict "profiles" (dict "processors" list)))) $config }}
{{- if not (has "k8sattributes" $config.service.pipelines.profiles.processors) }}
{{- $_ := set $config.service.pipelines.profiles "processors" (prepend $config.service.pipelines.profiles.processors "k8sattributes" | uniq) }}
{{- end }}
{{- $podAssoc := $config.processors.k8sattributes.pod_association }}
{{- $containerIdSource := dict "sources" (list (dict "from" "resource_attribute" "name" "container.id")) }}
{{- $hasContainerId := false }}
{{- range $podAssoc }}
{{- range .sources }}
{{- if and (eq .from "resource_attribute") (eq .name "container.id") }}
{{- $hasContainerId = true }}
{{- end }}
{{- end }}
{{- end }}
{{- if not $hasContainerId }}
{{- $_ := set $config.processors.k8sattributes "pod_association" (prepend $podAssoc $containerIdSource) }}
{{- 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:
otel_annotations: true
metadata:
- k8s.namespace.name
- k8s.pod.name
- k8s.pod.uid
- k8s.node.name
- k8s.pod.start_time
- k8s.deployment.name
- k8s.replicaset.name
- k8s.replicaset.uid
- k8s.daemonset.name
- k8s.daemonset.uid
- k8s.job.name
- k8s.job.uid
- k8s.container.name
- k8s.cronjob.name
- k8s.statefulset.name
- k8s.statefulset.uid
- container.image.tag
- container.image.name
- k8s.cluster.uid
- service.namespace
- service.name
- service.version
- service.instance.id
{{- 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 }}
{{- define "opentelemetry-collector.applyKubernetesObjectsConfig" -}}
{{- $vals := .Values.Values -}}
{{- $disableLeaderElection := false -}}
{{- if and (hasKey $vals "presets") (hasKey $vals.presets "kubernetesObjects") -}}
{{- $disableLeaderElection = $vals.presets.kubernetesObjects.disableLeaderElection -}}
{{- end -}}
{{- $useLeaderElection := and (eq $vals.mode "daemonset") (not $disableLeaderElection) -}}
{{- $electorName := "k8s_objects" }}
{{- $ctx := mustMerge (dict "namespace" (include "opentelemetry-collector.namespace" .Values) "useLeaderElection" $useLeaderElection "electorName" $electorName) .Values }}
{{- $objectsYaml := include "opentelemetry-collector.kubernetesObjectsConfig" $ctx | fromYaml }}
{{- $newObjects := (index $objectsYaml.receivers "k8sobjects").objects }}
{{- $existingObjects := list }}
{{- if .config.receivers }}
{{- if index .config.receivers "k8sobjects" }}
{{- if (index .config.receivers "k8sobjects").objects }}
{{- $existingObjects = (index .config.receivers "k8sobjects").objects }}
{{- end }}
{{- end }}
{{- end }}
{{- $allObjects := concat $newObjects $existingObjects }}
{{- $config := mustMergeOverwrite (dict "service" (dict "pipelines" (dict "logs" (dict "receivers" list)))) $objectsYaml .config }}
{{- $_ := set (index $config.receivers "k8sobjects") "objects" $allObjects }}
{{- if $useLeaderElection }}
{{- $configExtensions := mustMergeOverwrite (dict "service" (dict "extensions" list)) $config }}
{{- $_ := set $config.service "extensions" (append $configExtensions.service.extensions (printf "k8s_leader_elector/%s" $electorName) | uniq) }}
{{- end }}
{{- $_ := set $config.service.pipelines.logs "receivers" (append $config.service.pipelines.logs.receivers "k8sobjects" | uniq) }}
{{- $config | toYaml }}
{{- end }}
{{- define "opentelemetry-collector.kubernetesObjectsConfig" -}}
{{- $preset := .Values.presets.kubernetesObjects -}}
{{- if .useLeaderElection }}
{{- include "opentelemetry-collector.leaderElectionConfig" (dict "name" .electorName "leaseName" "k8s.objects.receiver.opentelemetry.io" "leaseNamespace" .namespace) }}
{{- end }}
receivers:
k8sobjects:
{{- if .useLeaderElection }}
k8s_leader_elector: k8s_leader_elector/{{ .electorName }}
{{- end }}
objects:
{{- if $preset.core.enabled }}
{{- range list "namespaces" "pods" "nodes" "services" "serviceaccounts" }}
- name: {{ . }}
mode: pull
{{- if $preset.watch }}
- name: {{ . }}
mode: watch
{{- end }}
{{- end }}
{{- range list "deployments" "replicasets" "daemonsets" "statefulsets" }}
- name: {{ . }}
mode: pull
group: apps
{{- if $preset.watch }}
- name: {{ . }}
mode: watch
group: apps
{{- end }}
{{- end }}
{{- range list "jobs" "cronjobs" }}
- name: {{ . }}
mode: pull
group: batch
{{- if $preset.watch }}
- name: {{ . }}
mode: watch
group: batch
{{- end }}
{{- end }}
{{- end }}
{{- if $preset.rbac.enabled }}
{{- range list "roles" "rolebindings" "clusterroles" "clusterrolebindings" }}
- name: {{ . }}
mode: pull
group: rbac.authorization.k8s.io
{{- if $preset.watch }}
- name: {{ . }}
mode: watch
group: rbac.authorization.k8s.io
{{- end }}
{{- end }}
{{- end }}
{{- if $preset.storage.enabled }}
{{- range list "storageclasses" }}
- name: {{ . }}
mode: pull
group: storage.k8s.io
{{- if $preset.watch }}
- name: {{ . }}
mode: watch
group: storage.k8s.io
{{- end }}
{{- end }}
{{- range list "persistentvolumes" "persistentvolumeclaims" }}
- name: {{ . }}
mode: pull
{{- if $preset.watch }}
- name: {{ . }}
mode: watch
{{- end }}
{{- end }}
{{- end }}
{{- if $preset.networking.enabled }}
{{- range list "ingresses" "networkpolicies" }}
- name: {{ . }}
mode: pull
group: networking.k8s.io
{{- if $preset.watch }}
- name: {{ . }}
mode: watch
group: networking.k8s.io
{{- end }}
{{- end }}
{{- end }}
{{- if $preset.autoscaling.enabled }}
- name: horizontalpodautoscalers
mode: pull
group: autoscaling
{{- if $preset.watch }}
- name: horizontalpodautoscalers
mode: watch
group: autoscaling
{{- end }}
{{- if $preset.autoscaling.vpa.enabled }}
- name: verticalpodautoscalers
mode: pull
group: autoscaling.k8s.io
{{- if $preset.watch }}
- name: verticalpodautoscalers
mode: watch
group: autoscaling.k8s.io
{{- end }}
{{- end }}
{{- end }}
{{- if $preset.policy.enabled }}
- name: poddisruptionbudgets
mode: pull
group: policy
{{- if $preset.watch }}
- name: poddisruptionbudgets
mode: watch
group: policy
{{- end }}
{{- end }}
{{- if $preset.apiExtensions.enabled }}
- name: customresourcedefinitions
mode: pull
group: apiextensions.k8s.io
{{- if $preset.watch }}
- name: customresourcedefinitions
mode: watch
group: apiextensions.k8s.io
{{- end }}
{{- end }}
{{- end }}
{{- define "opentelemetry-collector.leaderElectionConfig" -}}
extensions:
k8s_leader_elector/{{ .name }}:
auth_type: serviceAccount
lease_name: {{ .leaseName }}
lease_namespace: {{ .leaseNamespace }}
{{- end }}
{{- define "opentelemetry-collector.applyResourceDetectionConfig" -}}
{{- $config := .config }}
{{- $processors := get $config "processors" | default dict }}
{{- $resourceDetectionProcessor := get $processors "resourcedetection/env" | default dict }}
{{- $detectors := get $resourceDetectionProcessor "detectors" | default list }}
{{- if .Values.Values.presets.resourceDetection.env.enabled }}
{{- $detectors = append $detectors "env" | uniq }}
{{- end }}
{{- if .Values.Values.presets.resourceDetection.k8snode.enabled }}
{{- $detectors = append $detectors "k8snode" | uniq }}
{{- end }}
{{- if .Values.Values.presets.resourceDetection.aks.enabled }}
{{- $aksConfig := include "opentelemetry-collector.resourceDetectionAksDetectorConfig" . | fromYaml }}
{{- $resourceDetectionProcessor = mustMergeOverwrite $resourceDetectionProcessor $aksConfig }}
{{- $detectors = append $detectors "aks" | uniq }}
{{- end }}
{{- if .Values.Values.presets.resourceDetection.eks.enabled }}
{{- $eksConfig := include "opentelemetry-collector.resourceDetectionEksDetectorConfig" . | fromYaml }}
{{- $resourceDetectionProcessor = mustMergeOverwrite $resourceDetectionProcessor $eksConfig }}
{{- $detectors = append $detectors "eks" | uniq }}
{{- end }}
{{- if .Values.Values.presets.resourceDetection.gcp.enabled }}
{{- $gcpConfig := include "opentelemetry-collector.resourceDetectionGcpDetectorConfig" . | fromYaml }}
{{- $resourceDetectionProcessor = mustMergeOverwrite $resourceDetectionProcessor $gcpConfig }}
{{- $detectors = append $detectors "gcp" | uniq }}
{{- end }}
{{- $_ := set $resourceDetectionProcessor "detectors" $detectors }}
{{- $_ := set $processors "resourcedetection/env" $resourceDetectionProcessor }}
{{- $_ := set $config "processors" $processors }}
{{- if $config.service.pipelines.logs }}
{{- $config = mustMergeOverwrite (dict "service" (dict "pipelines" (dict "logs" (dict "processors" list)))) $config }}
{{- if not (has "resourcedetection/env" $config.service.pipelines.logs.processors) }}
{{- $_ := set $config.service.pipelines.logs "processors" (prepend $config.service.pipelines.logs.processors "resourcedetection/env" | uniq) }}
{{- end }}
{{- end }}
{{- if $config.service.pipelines.metrics }}
{{- $config = mustMergeOverwrite (dict "service" (dict "pipelines" (dict "metrics" (dict "processors" list)))) $config }}
{{- if not (has "resourcedetection/env" $config.service.pipelines.metrics.processors) }}
{{- $_ := set $config.service.pipelines.metrics "processors" (prepend $config.service.pipelines.metrics.processors "resourcedetection/env" | uniq) }}
{{- end }}
{{- end }}
{{- if $config.service.pipelines.traces }}
{{- $config = mustMergeOverwrite (dict "service" (dict "pipelines" (dict "traces" (dict "processors" list)))) $config }}
{{- if not (has "resourcedetection/env" $config.service.pipelines.traces.processors) }}
{{- $_ := set $config.service.pipelines.traces "processors" (prepend $config.service.pipelines.traces.processors "resourcedetection/env" | uniq) }}
{{- end }}
{{- end }}
{{- $config | toYaml }}
{{- end }}
{{- define "opentelemetry-collector.resourceDetectionEksDetectorConfig" -}}
timeout: 15s
eks:
resource_attributes:
k8s.cluster.name:
enabled: true
{{- end -}}
{{- define "opentelemetry-collector.resourceDetectionAksDetectorConfig" -}}
aks:
resource_attributes:
k8s.cluster.name:
enabled: true
{{- end -}}
{{- define "opentelemetry-collector.resourceDetectionGcpDetectorConfig" -}}
gcp:
resource_attributes:
k8s.cluster.name:
enabled: true
{{- end -}}
@@ -0,0 +1,265 @@
{{/*
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 }}
app.kubernetes.io/part-of: opentelemetry-collector
{{- if eq .Values.mode "deployment" }}
app.kubernetes.io/component: standalone-collector
{{- end -}}
{{- if eq .Values.mode "daemonset" }}
app.kubernetes.io/component: agent-collector
{{- end -}}
{{- if eq .Values.mode "statefulset" }}
app.kubernetes.io/component: statefulset-collector
{{- end -}}
{{- if .Values.additionalLabels }}
{{ tpl (.Values.additionalLabels | toYaml) . }}
{{- end }}
{{- 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 }}
{{/*
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 -}}
{{- tpl (.Values.configMap.existingName | toYaml) . }}
{{- 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 }}
{{/*
List of upstream community OpenTelemetry Collector distributions that do NOT include
the profiling receiver. Among community images only `opentelemetry-collector-ebpf-profiler`
ships the receiver; custom/vendor distributions pass through.
Consumed by NOTES.txt to fail-fast when the profiling preset
is enabled with an incompatible community image.
See https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions
*/}}
{{- define "opentelemetry-collector.profilingUnsupportedImages" -}}
- opentelemetry-collector
- opentelemetry-collector-contrib
- opentelemetry-collector-k8s
- opentelemetry-collector-otlp
{{- end }}
@@ -0,0 +1,277 @@
{{- define "opentelemetry-collector.pod" -}}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 2 }}
{{- end }}
serviceAccountName: {{ include "opentelemetry-collector.serviceAccountName" . }}
automountServiceAccountToken: {{ .Values.serviceAccount.automountServiceAccountToken }}
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.profiling.enabled) }}
runAsUser: 0
runAsGroup: 0
privileged: true
{{- else 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
- name: OTEL_K8S_NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: OTEL_K8S_NODE_IP
valueFrom:
fieldRef:
fieldPath: status.hostIP
- name: OTEL_K8S_NAMESPACE
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
- name: OTEL_K8S_POD_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.name
- name: OTEL_K8S_POD_IP
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: status.podIP
{{- if or
.Values.presets.kubeletMetrics.enabled
(and .Values.presets.kubernetesAttributes.enabled (eq .Values.mode "daemonset"))
(and (or .Values.presets.annotationDiscovery.logs.enabled .Values.presets.annotationDiscovery.metrics.enabled) (eq .Values.mode "daemonset"))
}}
- name: K8S_NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: K8S_NODE_IP
valueFrom:
fieldRef:
fieldPath: status.hostIP
{{- 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.resizePolicy }}
resizePolicy:
{{- toYaml . | nindent 6 }}
{{- 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 or .Values.presets.logsCollection.enabled .Values.presets.annotationDiscovery.logs.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.presets.profiling.enabled }}
- name: tracefs
mountPath: /sys/kernel/tracing
readOnly: true
{{- 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 }}
{{- if .Values.runtimeClassName }}
runtimeClassName: {{ .Values.runtimeClassName | quote }}
{{- end }}
{{- if .Values.terminationGracePeriodSeconds }}
terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }}
{{- 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 or .Values.presets.logsCollection.enabled .Values.presets.annotationDiscovery.logs.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.presets.profiling.enabled }}
- name: tracefs
hostPath:
path: /sys/kernel/tracing
{{- 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,123 @@
{{- if or (.Values.clusterRole.create) (.Values.presets.kubernetesAttributes.enabled) (.Values.presets.clusterMetrics.enabled) (.Values.presets.kubeletMetrics.enabled) (.Values.presets.kubernetesEvents.enabled) (.Values.presets.kubernetesObjects.enabled) (.Values.presets.annotationDiscovery.logs.enabled) (.Values.presets.annotationDiscovery.metrics.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:
{{- $clusterMetricsEnabled := .Values.presets.clusterMetrics.enabled }}
{{- $disableLeaderElectionForClusterMetrics := .Values.presets.clusterMetrics.disableLeaderElection}}
{{- $useLeaderElectionForClusterMetrics := and (eq .Values.mode "daemonset") ( $clusterMetricsEnabled ) (not $disableLeaderElectionForClusterMetrics) }}
{{- $kubernetesObjectsEnabled := .Values.presets.kubernetesObjects.enabled }}
{{- $disableLeaderElectionForKubernetesObjects := .Values.presets.kubernetesObjects.disableLeaderElection }}
{{- $useLeaderElectionForKubernetesObjects := and (eq .Values.mode "daemonset") ( $kubernetesObjectsEnabled ) (not $disableLeaderElectionForKubernetesObjects) }}
{{- if or $useLeaderElectionForClusterMetrics $useLeaderElectionForKubernetesObjects }}
- apiGroups: ["coordination.k8s.io"]
resources: ["leases"]
verbs: ["get","list","watch","create","update","patch","delete"]
{{- end }}
{{- 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 }}
{{- if .Values.presets.kubernetesObjects.enabled }}
{{- if .Values.presets.kubernetesObjects.core.enabled }}
- apiGroups: [""]
resources: ["namespaces", "pods", "nodes", "services", "serviceaccounts"]
verbs: ["get", "list", "watch"]
- apiGroups: ["apps"]
resources: ["deployments", "replicasets", "daemonsets", "statefulsets"]
verbs: ["get", "list", "watch"]
- apiGroups: ["batch"]
resources: ["jobs", "cronjobs"]
verbs: ["get", "list", "watch"]
{{- end }}
{{- if .Values.presets.kubernetesObjects.rbac.enabled }}
- apiGroups: ["rbac.authorization.k8s.io"]
resources: ["roles", "rolebindings", "clusterroles", "clusterrolebindings"]
verbs: ["get", "list", "watch"]
{{- end }}
{{- if .Values.presets.kubernetesObjects.storage.enabled }}
- apiGroups: [""]
resources: ["persistentvolumes", "persistentvolumeclaims"]
verbs: ["get", "list", "watch"]
- apiGroups: ["storage.k8s.io"]
resources: ["storageclasses"]
verbs: ["get", "list", "watch"]
{{- end }}
{{- if .Values.presets.kubernetesObjects.networking.enabled }}
- apiGroups: ["networking.k8s.io"]
resources: ["ingresses", "networkpolicies"]
verbs: ["get", "list", "watch"]
{{- end }}
{{- if .Values.presets.kubernetesObjects.autoscaling.enabled }}
- apiGroups: ["autoscaling"]
resources: ["horizontalpodautoscalers"]
verbs: ["get", "list", "watch"]
{{- if .Values.presets.kubernetesObjects.autoscaling.vpa.enabled }}
- apiGroups: ["autoscaling.k8s.io"]
resources: ["verticalpodautoscalers"]
verbs: ["get", "list", "watch"]
{{- end }}
{{- end }}
{{- if .Values.presets.kubernetesObjects.policy.enabled }}
- apiGroups: ["policy"]
resources: ["poddisruptionbudgets"]
verbs: ["get", "list", "watch"]
{{- end }}
{{- if .Values.presets.kubernetesObjects.apiExtensions.enabled }}
- apiGroups: ["apiextensions.k8s.io"]
resources: ["customresourcedefinitions"]
verbs: ["get", "list", "watch"]
{{- end }}
{{- end }}
{{- if or .Values.presets.annotationDiscovery.logs.enabled .Values.presets.annotationDiscovery.metrics.enabled }}
- apiGroups: [""]
resources: ["pods"]
verbs: ["get", "list", "watch"]
{{- 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) (.Values.presets.kubernetesObjects.enabled) (.Values.presets.annotationDiscovery.logs.enabled) (.Values.presets.annotationDiscovery.metrics.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,53 @@
{{- if eq .Values.mode "daemonset" -}}
apiVersion: {{ .Values.apiVersion }}
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:
revisionHistoryLimit: {{ .Values.revisionHistoryLimit }}
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:
{{- if .Values.enableConfigChecksumAnnotation }}
{{- include "opentelemetry-collector.configTemplateChecksumAnnotation" . | nindent 8 }}
{{- end }}
{{- 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 }}
hostPID: {{ or .Values.hostPID .Values.presets.profiling.enabled }}
{{- with .Values.dnsPolicy }}
dnsPolicy: {{ . }}
{{- end }}
{{- with .Values.dnsConfig }}
dnsConfig:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
@@ -0,0 +1,59 @@
{{- if eq .Values.mode "deployment" -}}
apiVersion: {{ .Values.apiVersion }}
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 and (not .Values.autoscaling.enabled) (.Values.replicaCount) }}
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:
{{- if .Values.enableConfigChecksumAnnotation }}
{{- include "opentelemetry-collector.configTemplateChecksumAnnotation" . | nindent 8 }}
{{- end }}
{{- 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 }}
{{- with .Values.schedulerName }}
schedulerName: {{ . }}
{{- end }}
{{- $podValues := deepCopy .Values }}
{{- $podData := dict "Values" $podValues "configmapSuffix" "" "isAgent" false }}
{{- include "opentelemetry-collector.pod" ($podData | mustMergeOverwrite (deepCopy .)) | nindent 6 }}
hostNetwork: {{ .Values.hostNetwork }}
hostPID: {{ or .Values.hostPID .Values.presets.profiling.enabled }}
{{- end }}
@@ -0,0 +1,4 @@
{{ range .Values.extraManifests }}
---
{{ tpl (toYaml .) $ }}
{{ end }}
@@ -0,0 +1,40 @@
{{- 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 }}
{{- with .Values.autoscaling.additionalMetrics }}
{{- toYaml . | nindent 4 }}
{{- 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 (or (eq .Values.mode "deployment") (eq .Values.mode "statefulset")) }}
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 }}
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,136 @@
{{- if .Values.prometheusRule.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 2 }}
{{- end }}
{{- if .Values.prometheusRule.defaultRules.enabled }}
- name: collectorRules
rules:
- alert: ReceiverDroppedSpans
expr: rate(otelcol_receiver_refused_spans_total[5m]) > 0
for: 2m
labels:
severity: critical
{{- with .Values.prometheusRule.defaultRules.additionalRuleLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
annotations:
description: '{{`The {{ $labels.receiver }} receiver is dropping spans at a rate of {{ humanize $value }} per second `}}'
runbook_url: 'https://opentelemetry.io/docs/collector/internal-telemetry/#receive-failures'
{{- with .Values.prometheusRule.defaultRules.additionalRuleAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
- alert: ReceiverDroppedMetrics
expr: rate(otelcol_receiver_refused_metric_points_total[5m]) > 0
for: 2m
labels:
severity: critical
{{- with .Values.prometheusRule.defaultRules.additionalRuleLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
annotations:
description: '{{`The {{ $labels.receiver }} receiver is dropping metrics at a rate of {{ humanize $value }} per second `}}'
runbook_url: 'https://opentelemetry.io/docs/collector/internal-telemetry/#receive-failures'
{{- with .Values.prometheusRule.defaultRules.additionalRuleAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
- alert: ReceiverDroppedLogs
expr: rate(otelcol_receiver_refused_log_records_total[5m]) > 0
for: 5m
labels:
severity: critical
{{- with .Values.prometheusRule.defaultRules.additionalRuleLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
annotations:
description: '{{` The {{ $labels.receiver }} is dropping logs at a rate of {{ humanize $value }} per second `}}'
runbook_url: 'https://opentelemetry.io/docs/collector/internal-telemetry/#receive-failures'
{{- with .Values.prometheusRule.defaultRules.additionalRuleAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
- alert: ExporterDroppedSpans
expr: rate(otelcol_exporter_send_failed_spans_total[5m]) > 0
for: 2m
labels:
severity: critical
{{- with .Values.prometheusRule.defaultRules.additionalRuleLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
annotations:
description: '{{`The {{ $labels.exporter }} exporter is dropping spans at a rate of {{ humanize $value }} per second `}}'
runbook_url: 'https://opentelemetry.io/docs/collector/internal-telemetry/#receive-failures'
{{- with .Values.prometheusRule.defaultRules.additionalRuleAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
- alert: ExporterDroppedMetrics
expr: rate(otelcol_exporter_send_failed_metric_points_total[5m]) > 0
for: 2m
labels:
severity: critical
{{- with .Values.prometheusRule.defaultRules.additionalRuleLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
annotations:
description: '{{`The {{ $labels.exporter }} exporter is dropping metrics at a rate of {{ humanize $value }} per second `}}'
runbook_url: 'https://opentelemetry.io/docs/collector/internal-telemetry/#receive-failures'
{{- with .Values.prometheusRule.defaultRules.additionalRuleAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
- alert: ExporterDroppedLogs
expr: rate(otelcol_exporter_send_failed_log_records_total[5m]) > 0
for: 5m
labels:
severity: critical
{{- with .Values.prometheusRule.defaultRules.additionalRuleLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
annotations:
description: '{{` The {{ $labels.exporter }} is dropping logs at a rate of {{ humanize $value }} per second `}}'
runbook_url: 'https://opentelemetry.io/docs/collector/internal-telemetry/#receive-failures'
{{- with .Values.prometheusRule.defaultRules.additionalRuleAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
- alert: ExporterQueueSize
expr: otelcol_exporter_queue_size > otelcol_exporter_queue_capacity * 0.8
for: 1m
labels:
severity: warning
{{- with .Values.prometheusRule.defaultRules.additionalRuleLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
annotations:
description: '{{`The {{ $labels.exporter }} queue has reached a size of {{ $value }} `}}'
runbook_url: 'https://opentelemetry.io/docs/collector/internal-telemetry/#queue-length'
{{- with .Values.prometheusRule.defaultRules.additionalRuleAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- $signals := list "spans" "metric_points" "log_records" }}
{{- range $signal := $signals }}
- alert: SendQueueFailed{{ $signal }}
expr: rate(otelcol_exporter_enqueue_failed_{{ $signal }}_total[5m]) > 0
for: 1m
labels:
severity: warning
{{- with $.Values.prometheusRule.defaultRules.additionalRuleLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
annotations:
description: '{{`The {{ $labels.exporter }} sending queue failed to accept {{ $value }} `}} {{ $signal }}'
runbook_url: 'https://opentelemetry.io/docs/collector/internal-telemetry/#queue-length'
{{- with $.Values.prometheusRule.defaultRules.additionalRuleAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
@@ -0,0 +1,45 @@
{{- 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.trafficDistribution }}
trafficDistribution: {{ .Values.service.trafficDistribution }}
{{- end }}
{{- 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) (.Values.presets.kubernetesObjects.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,30 @@
{{- 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:
{{- with .Values.serviceMonitor.sampleLimit }}
sampleLimit: {{ . }}
{{- end }}
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,67 @@
{{- if eq .Values.mode "statefulset" -}}
apiVersion: {{ .Values.apiVersion }}
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 }}
revisionHistoryLimit: {{ .Values.revisionHistoryLimit }}
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:
{{- if .Values.enableConfigChecksumAnnotation }}
{{- include "opentelemetry-collector.configTemplateChecksumAnnotation" . | nindent 8 }}
{{- end }}
{{- 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 }}
hostPID: {{ or .Values.hostPID .Values.presets.profiling.enabled }}
{{- with .Values.statefulset.volumeClaimTemplates }}
volumeClaimTemplates:
{{- toYaml . | nindent 2 }}
{{- end }}
{{- end }}