From 319ad715518bdc051f8eb1bb3b22cac7829da0ff Mon Sep 17 00:00:00 2001 From: 8naama Date: Wed, 6 Nov 2024 15:14:53 +0200 Subject: [PATCH 01/15] logzio-apm-collector v1.0.0 init --- charts/logzio-apm-collector/.helmignore | 23 + charts/logzio-apm-collector/CHANGELOG.md | 7 + charts/logzio-apm-collector/Chart.yaml | 16 + charts/logzio-apm-collector/README.md | 153 +++++ charts/logzio-apm-collector/VALUES.md | 88 +++ .../logzio-apm-collector/templates/NOTES.txt | 25 + .../templates/_config.tpl | 58 ++ .../templates/_helpers-spm.tpl | 39 ++ .../templates/_helpers.tpl | 141 ++++ .../templates/_pod-spm.tpl | 161 +++++ .../logzio-apm-collector/templates/_pod.tpl | 180 ++++++ .../templates/_validations.tpl | 20 + .../templates/clusterrole.yaml | 33 + .../templates/clusterrolebinding.yaml | 24 + .../templates/configmap-spm.yaml | 12 + .../templates/configmap.yaml | 12 + .../templates/deployment-spm.yaml | 40 ++ .../templates/deployment.yaml | 42 ++ .../logzio-apm-collector/templates/hpa.yaml | 38 ++ .../templates/instrumentation.yaml | 46 ++ .../templates/secret.yaml | 25 + .../templates/service-spm.yaml | 42 ++ .../templates/service.yaml | 44 ++ .../templates/serviceaccount.yaml | 17 + .../templates/vpa-spm.yaml | 36 ++ charts/logzio-apm-collector/values.yaml | 606 ++++++++++++++++++ 26 files changed, 1928 insertions(+) create mode 100644 charts/logzio-apm-collector/.helmignore create mode 100644 charts/logzio-apm-collector/CHANGELOG.md create mode 100644 charts/logzio-apm-collector/Chart.yaml create mode 100644 charts/logzio-apm-collector/README.md create mode 100644 charts/logzio-apm-collector/VALUES.md create mode 100644 charts/logzio-apm-collector/templates/NOTES.txt create mode 100644 charts/logzio-apm-collector/templates/_config.tpl create mode 100644 charts/logzio-apm-collector/templates/_helpers-spm.tpl create mode 100644 charts/logzio-apm-collector/templates/_helpers.tpl create mode 100644 charts/logzio-apm-collector/templates/_pod-spm.tpl create mode 100644 charts/logzio-apm-collector/templates/_pod.tpl create mode 100644 charts/logzio-apm-collector/templates/_validations.tpl create mode 100644 charts/logzio-apm-collector/templates/clusterrole.yaml create mode 100644 charts/logzio-apm-collector/templates/clusterrolebinding.yaml create mode 100644 charts/logzio-apm-collector/templates/configmap-spm.yaml create mode 100644 charts/logzio-apm-collector/templates/configmap.yaml create mode 100644 charts/logzio-apm-collector/templates/deployment-spm.yaml create mode 100644 charts/logzio-apm-collector/templates/deployment.yaml create mode 100644 charts/logzio-apm-collector/templates/hpa.yaml create mode 100644 charts/logzio-apm-collector/templates/instrumentation.yaml create mode 100644 charts/logzio-apm-collector/templates/secret.yaml create mode 100644 charts/logzio-apm-collector/templates/service-spm.yaml create mode 100644 charts/logzio-apm-collector/templates/service.yaml create mode 100644 charts/logzio-apm-collector/templates/serviceaccount.yaml create mode 100644 charts/logzio-apm-collector/templates/vpa-spm.yaml create mode 100644 charts/logzio-apm-collector/values.yaml diff --git a/charts/logzio-apm-collector/.helmignore b/charts/logzio-apm-collector/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/charts/logzio-apm-collector/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/charts/logzio-apm-collector/CHANGELOG.md b/charts/logzio-apm-collector/CHANGELOG.md new file mode 100644 index 00000000..c3ae05e0 --- /dev/null +++ b/charts/logzio-apm-collector/CHANGELOG.md @@ -0,0 +1,7 @@ +# Changes by Version + + + +## 1.0.0 (date?) +- Initial release +- Kubernetes APM Agent for Logz.io, based on OpenTelemetry Collector diff --git a/charts/logzio-apm-collector/Chart.yaml b/charts/logzio-apm-collector/Chart.yaml new file mode 100644 index 00000000..4e719703 --- /dev/null +++ b/charts/logzio-apm-collector/Chart.yaml @@ -0,0 +1,16 @@ +apiVersion: v2 +name: logzio-apm-collector +version: 0.0.1 +description: Kubernetes APM agent for Logz.io based on OpenTelemetry Collector +type: application +home: https://logz.io/ +dependencies: + - name: opentelemetry-operator + alias: otel-operator + version: ~0.71.2 + repository: https://github.com/open-telemetry/opentelemetry-helm-charts + condition: otel-operator.enabled +maintainers: + - name: Naama Bendalak + email: naama.bendalak@logz.io +appVersion: 0.110.0 diff --git a/charts/logzio-apm-collector/README.md b/charts/logzio-apm-collector/README.md new file mode 100644 index 00000000..3c9aa281 --- /dev/null +++ b/charts/logzio-apm-collector/README.md @@ -0,0 +1,153 @@ +# Logz.io APM Collector Helm Chart +> [!IMPORTANT] +> Kubernetes APM Collection Agent is still In development + +This Helm chart deploys an agent, which leverages the OpenTelemetry Collector, that collects traces and span metrics from Kubernetes clusters and sends them to Logz.io + +## Prerequisites +- Kubernetes 1.24+ +- Helm 3.9+ + +## Installation +### Add Logz.io Helm Repository +Before installing the chart, add the Logz.io Helm repository: +```shell +helm repo add logzio-helm https://logzio.github.io/logzio-helm +helm repo update +``` + +### Install the Chart + +The chart provides options for enabling the following: +1. Traces +2. SPM (Service Performance Monitoring) +3. Service Graph +4. OpenTelemetry Operator (Auto-instrumentation) + + +```shell +helm install logzio-apm-collector -n monitoring \ +--set enabled=true \ +--set spm.enabled=true \ +--set serviceGraph.enabled=true \ +--set otel-operator.enabled=true \ +--set secrets.logzioTracesToken="<>" \ +--set secrets.logzioSpmToken="<>" \ +--set secrets.logzioRegion="<>" \ +--set secrets.env_id="<>" \ +logzio-apm-collector logzio-helm/logzio-apm-collector +``` + +> [!NOTE] +> To disable either one of SPM, Service Graph or OpenTelemetry Operator, remove the relevant `--set XXX.enabled` line from the above command. + +> [!IMPORTANT] +> Values of `<>`, `<>` and `<>` can be found in your Logz.io account. +> For `<>` define any environment identifier attribute (for example, the cluster name). + + +## Configuration + +- [All configuration options](./VALUES.md) +- [Auto-instrumentation options](#auto-instrumentation-options) + - [Enable Auto-instrumentation](#enable-auto-instrumentation) + - [Multi-container pods](#multi-container-pods) + - [Customize Auto-instrumentation](#customize-auto-instrumentation) + - [Customize Propagator](#customize-propagator) + - [Add a custom Sampler](#add-a-custom-sampler) + - [Distribute namespaces](#distribute-namespaces) +- [Custom Trace Sampling rules](#custom-trace-sampling-rules) + +### Auto-instrumentation options +Below, you can find guidance on enabling and customizing OpenTelemetry Operator Auto-instrumentation. + +#### Enable Auto-instrumentation +- **Step 1:** Make sure to enable the OpenTelemetry operator in the chart: +```shell +--set otel-operator.enabled=true \ +``` + +- **Step 2**: Add annotations to your relevant Kubernetes object (Deployment, StatefulSet, Namespace, Daemonset, or Pod) +```yaml +instrumentation.opentelemetry.io/inject-": "monitoring/logzio-apm-collector" +``` + +> [!TIP] +> `` can be one of `apache-httpd`, `dotnet`, `go`, `java`, `nginx`, `nodejs` or `python`. + + +##### Multi-container pods +By default, in multi-container pods, instrumentation is performed on the first container available in the pod spec. +To fine tune which containers to instrument, add the below annotations to your pod: +```yaml +instrumentation.opentelemetry.io/inject-": "monitoring/logzio-apm-collector" +instrumentation.opentelemetry.io/-container-names: "myapp,myapp2" +instrumentation.opentelemetry.io/inject-": "monitoring/logzio-apm-collector" +instrumentation.opentelemetry.io/-container-names: "myapp3" +``` + +> [!TIP] +> ``, `` can be one of `apache-httpd`, `dotnet`, `go`, `java`, `nginx`, `nodejs` or `python`. + + +#### Customize Auto-instrumentation +Below you can find multiple ways in which you can customize the OpenTelemetry Operator Auto-instrumentation. + +##### Customize Propagator +The propagator specifies how context is injected into and extracted from carriers for distributed tracing. +By default, the propagators `tracecontext` (W3C Trace Context) and `baggage` (W3C Correlation Context) are enabled. +You can customize this to include other formats ([full list here](https://opentelemetry.io/docs/languages/sdk-configuration/general/#otel_propagators)) or set it to "none" to disable automatic propagation. +```shell +--set instrumentation.propagator={tracecontext, baggage, b3} +``` + +##### Add a custom Sampler +You can specify a sampler to be used by the instrumentor. You'll need to specify the below: +- Sampler used to sample the traces ([available options](https://opentelemetry.io/docs/languages/sdk-configuration/general/#otel_traces_sampler)) +- Sampler arguments ([Sampler type expected input](https://opentelemetry.io/docs/languages/sdk-configuration/general/#otel_traces_sampler_arg)) + +Example: +```shell +--set instrumentation.sampler.type="parentbased_always_on" \ +--set instrumentation.sampler.argument="0.25" +``` + +##### Distribute namespaces +For intensive applications, to reduce the performance impact of the operator, you can define multiple namespaces to deploy the instrumentor resource at, which can help distribute the load in larger clusters. +To do so, specify which namespaces to deploy the instrumentor at: +```shell +--set includeNamespaces="ns1,ns2,ns3" +``` + +For resources in the namespaces where you configured the instrumentation, you need to add annotation in this format: +```yaml +instrumentation.opentelemetry.io/inject-": "true" +``` + +> [!TIP] +> `` can be one of `apache-httpd`, `dotnet`, `go`, `java`, `nginx`, `nodejs` or `python`. + +### Custom trace sampling rules +To customize the Traces Sampling rules in the OpenTelemetry Collector, you can follow the below steps: + +- **Step 1**: Create [customized Tail sampling rules configuration](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/tailsamplingprocessor). + +- **Step 2**: Update the `values.yaml` file: + +Get the current Chart's `values.yaml` file: +```shell +helm get values logzio-apm-collector -n monitoring > new-values.yaml +``` + +Edit the section under `traceConfig` >> `processors` >> `tail_sampling` in `new-values.yaml` to contain the custom config which you created in step 1. + +- **Step 3**: Apply the config: +```shell +helm upgrade logzio-apm-collector logzio-helm/logzio-apm-collector -n monitoring -f new-values.yaml +``` + +## Uninstalling +To uninstall the `logzio-apm-collector` chart, you can use: +```shell +helm uninstall -n monitoring logzio-apm-collector +``` diff --git a/charts/logzio-apm-collector/VALUES.md b/charts/logzio-apm-collector/VALUES.md new file mode 100644 index 00000000..762d06ec --- /dev/null +++ b/charts/logzio-apm-collector/VALUES.md @@ -0,0 +1,88 @@ +# Logz.io APM Collector All Configuration options +Below you can find a complete list of settings in `values.yaml`. + +| Key | Description | Default Value | +|-----------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------| +| enabled | Toggle for enabling the Helm chart deployment | `false` | +| spm.enabled | Toggle for enabling SPM Collection | `false` | +| serviceGraph.enabled | Toggle for enabling Service Graph metrics Collection | `false` | +| otel-operator.enabled | Toggle for enabling Auto instrumentation with [OpenTelemetry Operator](https://github.com/open-telemetry/opentelemetry-operator) | `false` | +| fullnameOverride | Override the default name for the deployment. | `""` | +| namespaceOverride | Override the namespace into which the resources will be deployed. | `""` | +| secrets.enabled | Toggle for creating and managing the Logz.io secret by this chart. | `"true"` | +| secrets.name | The name of the secret for Logz.io APM collector. | `"logzio-apm-collector-secret"` | +| secrets.env_id | Environment identifier attribute added to all logs. | `"my_env"` | +| secrets.logzioTracesToken | Secret with your Logz.io tracing shipping token. | `""` | +| secrets.logzioSpmToken | Secret with your Logz.io SPM shipping token. | `""` | +| secrets.logzioRegion | Secret with your Logz.io region. | `"us"` | +| secrets.customTracesEndpoint | Secret with a custom endpoint to send traces to, overrides Logz.io region listener address. | `""` | +| secrets.customSpmEndpoint | Secret with your custom endpoint to send SPM to, overrides Logz.io region listener address. | `""` | +| otelLogLevel | Change the OpenTelemetry Collector log level | `"info"` | +| SamplingProbability | Traces Sampling Probability | `10` | +| SamplingProbability | Traces Sampling Latency | `500` | +| traceConfig | Traces collector configuration, supports templating. | see `values.yaml` | +| spmForwarderConfig | Collector configuration to pass traces to the SPM Collector, supports templating. | see `values.yaml` | +| spmConfig | Collector configuration to generate SPM, supports templating. | see `values.yaml` | +| serviceGraphConfig | Collector configuration to generate Service Graph metrics. | see `values.yaml` | +| image.repository | Opentelemetry collector image repository. | `otel/opentelemetry-collector-contrib` | +| image.pullPolicy | Image pull policy. | `IfNotPresent` | +| image.tag | Overrides the image tag whose default is the chart appVersion. | `""` | +| image.digest | Pull images by digest. | `""` | +| imagePullSecrets | Specifies image pull secrets. | `[]` | +| command.name | OpenTelemetry Collector executable. | `"otelcol-contrib"` | +| command.extraArgs | Additional arguments for the command. | `[]` | +| instrumentation.includeNamespaces | Specifies namespaces to deploy the instrumentor resource at. By default, it's created only at the chart's other resources namespace. | `""` | +| instrumentation.propagators | Choose propagator to specify the method of injecting and extracting context from carriers. | `[tracecontext, baggage]` | +| instrumentation.sampler | Specifies the Sampler used to sample traces by the SDK. | `{}` | +| configMap.create | Specifies whether a configMap should be created. | `true` | +| serviceAccount.create | Specifies whether a service account should be created. | `true` | +| serviceAccount.annotations | Specifies annotations for the service account. | `{}` | +| serviceAccount.name | The name of the service account. | `""` | +| clusterRole.create | Specifies whether a clusterRole should be created. | `true` | +| clusterRole.annotations | Specifies annotations for the cluster role. | `{}` | +| clusterRole.name | The name of the clusterRole. | `""` | +| clusterRole.rules | Specifies additional rules for the clusterRole. | `[]` | +| clusterRole.clusterRoleBinding.annotations | Specifies annotations for the clusterRoleBinding. | `{}` | +| clusterRole.clusterRoleBinding.name | The name of the clusterRoleBinding. | `""` | +| service.enabled | Enable the creation of a Service. | `true` | +| service.type | Specifies the type of service. | `ClusterIP` | +| service.annotations | Specifies annotations for the service. | `{}` | +| spmService.type | Specifies the type of service for SPM. | `ClusterIP` | +| spmService.annotations | Specifies annotations for the service for SPM. | `{}` | +| autoscaling.enabled | Specifies if HPA should be created for the Traces Collector. | `false` | +| autoscaling.annotations | Specifies annotations for the HPA. | `{}` | +| autoscaling.minReplicas | Control autoscaling scale. | `1` | +| autoscaling.maxReplicas | Control autoscaling scale. | `10` | +| autoscaling.targetCPUUtilizationPercentage | Control autoscaling scale. | `80` | +| autoscaling.targetMemoryUtilizationPercentage | Control autoscaling scale. | `80` | +| spmAutoscaling.enabled | Specifies if VPA should be created for the SPM Collector. | `false` | +| autoscaling.annotations | Specifies annotations for the VPA. | `{}` | +| autoscaling.minAllowed.cpu | Control autoscaling scale. | `"50m"` | +| autoscaling.minAllowed.memory | Control autoscaling scale. | `"70Mi"` | +| autoscaling.maxAllowed.cpu | Control autoscaling scale. | `"150m"` | +| autoscaling.maxAllowed.memory | Control autoscaling scale. | `"250Mi"` | +| ports | Defines ports configurations | see `values.yaml` | +| additionalLabels | labels to add to all otel-collector resources | `{}` | +| podSecurityContext | Security context policies for the pod. | `{}` | +| securityContext | Security context policies for the container. | `{}` | +| nodeSelector | Node labels for pod assignment | `{}` | +| tolerations | Tolerations for pod assignment | `[]` | +| affinity | Affinity rules for pod assignment. | see `values.yaml` | +| priorityClassName | Scheduler priority class name. | `""` | +| extraEnvs | Extra environment variables to set in the pods | `[]` | +| extraEnvsFrom | Extra environment variables from secret or configMap to set in the pods | `[]` | +| extraVolumes | Extra volumes to add in the pods | `[]` | +| extraVolumeMounts | Extra volume mounts to add in the pods | `[]` | +| useGOMEMLIMIT | Set `GOMEMLIMIT` env var to a percentage of `resources.limits.memory` | `false` | +| resources | CPU/memory resource requests/limits | see `values.yaml` | +| podAnnotations | Annotations to add to the pod. | `{}` | +| podLabels | Labels to add to the pod. | `{}` | +| hostAliases | Adding entries to Pod /etc/hosts with HostAliases. | `[]` | +| dnsPolicy | Pod DNS policy. | `""` | +| dnsConfig | Custom DNS config. Required when `dnsPolicy: None`. | `{}` | +| annotations | Annotations to add to the ???. | `{}` | +| extraContainers | List of extra sidecars to add. | `[]` | +| initContainers | List of init container specs. | `[]` | +| lifecycleHooks | Pod lifecycle policies. | `{}` | +| livenessProbe | Liveness probe configuration. | see `values.yaml` | +| readinessProbe | Readiness probe configuration. | see `values.yaml` | diff --git a/charts/logzio-apm-collector/templates/NOTES.txt b/charts/logzio-apm-collector/templates/NOTES.txt new file mode 100644 index 00000000..0a655d63 --- /dev/null +++ b/charts/logzio-apm-collector/templates/NOTES.txt @@ -0,0 +1,25 @@ +{{- if and (eq .Values.dnsPolicy "None") (not .Values.dnsConfig) }} +{{- fail "[ERROR] dnsConfig should be provided when dnsPolicy is None" }} +{{ end }} + +{{- if not .Values.configMap.create }} +[WARNING] "configMap" will not be created and `traceConfig`, `spmConfig` and `serviceGraphConfig` will not take effect. +{{ end }} + +{{- if not .Values.resources }} +[WARNING] No resource limits or requests were set. Consider setter resource requests and limits for your logzio-apm-collector via the `resources` field. +{{ end }} + +{{- $logLevel := lower .Values.otelLogLevel }} +{{- if not (or (eq $logLevel "info") (eq $logLevel "warn") (eq $logLevel "error") (eq $logLevel "debug")) }} +{{ fail "[ERROR] The logzio-apm-collector Chart's `otelLogLevel` must be one of 'info', 'warn', 'error' or 'debug'." }} +{{- end }} + +{{- $region := lower .Values.secrets.logzioRegion }} +{{- if not (or (eq $region "us") (eq $region "eu") (eq $region "uk") (eq $region "ca") (eq $region "au")) }} +{{ print "[WARN] The `logzioRegion` expected value should be one of 'us', 'eu', 'uk', 'ca', 'au'." }} +{{- end }} + +{{- if and (.Values.useGOMEMLIMIT) (not ((((.Values.resources).limits).memory))) }} +[WARNING] "useGOMEMLIMIT" is enabled but memory limits have not been supplied, which means no GOMEMLIMIT env var was configured but the Memory Ballast Extension was removed. It is highly recommended to only use "useGOMEMLIMIT" when memory limits have been set. +{{ end }} diff --git a/charts/logzio-apm-collector/templates/_config.tpl b/charts/logzio-apm-collector/templates/_config.tpl new file mode 100644 index 00000000..e486737d --- /dev/null +++ b/charts/logzio-apm-collector/templates/_config.tpl @@ -0,0 +1,58 @@ +{{/* Build the list of port for service */}} +{{- define "apm-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 "apm-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 }} + +{{/* Build config file for APM Collector */}} +{{- define "apm-collector.config" -}} +{{- if .Values.spm.enabled }} +{{- $tracesConfig := deepCopy .Values.traceConfig }} +{{- $spmForwarderConfig := deepCopy .Values.spmForwarderConfig }} +{{- ($tracesConfig | merge $spmForwarderConfig | mustMergeOverwrite) | toYaml }} +{{- else }} +{{- .Values.traceConfig | toYaml }} +{{- end}} +{{- end }} + +{{/* Build config file for SPM Collector */}} +{{- define "spm-collector.config" -}} +{{- if .Values.serviceGraph.enabled }} +{{- $spmConfig := deepCopy .Values.spmConfig }} +{{- $serviceGraphConfig := deepCopy .Values.serviceGraphConfig }} +{{- $spmConfig.connectors = merge $spmConfig.connectors $serviceGraphConfig.connectors }} +{{- $spmConfig.service.pipelines.traces.exporters = concat $spmConfig.service.pipelines.traces.exporters $serviceGraphConfig.service.pipelines.traces.exporters }} +{{- $spmConfig.service.pipelines.metrics.spm-logzio.receivers = concat $spmConfig.service.pipelines.metrics.spm-logzio.receivers $serviceGraphConfig.service.pipelines.metrics.spm-logzio.receivers }} +{{- $spmConfig | toYaml }} +{{- else }} +{{- .Values.spmConfig | toYaml }} +{{- end }} +{{- end }} diff --git a/charts/logzio-apm-collector/templates/_helpers-spm.tpl b/charts/logzio-apm-collector/templates/_helpers-spm.tpl new file mode 100644 index 00000000..4353fe6f --- /dev/null +++ b/charts/logzio-apm-collector/templates/_helpers-spm.tpl @@ -0,0 +1,39 @@ + +{{/* +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). +*/}} +{{- define "spm-collector.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- printf "%s-%s" .Values.fullnameOverride "spm" | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Chart.Name "spm" | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} + +{{/* +Get component name +*/}} +{{- define "spm-collector.component" -}} +component: spm-collector +{{- end }} + +{{/* +Create Logz.io listener address based on region +*/}} +{{- define "spm-collector.listenerAddress" -}} +{{- $region := .Values.secrets.logzioRegion }} +{{- if or (eq $region "us") (not $region) }} +https://listener.logz.io:8053 +{{- else }} +{{ printf "https://listener-%s.logz.io:8053" $region }} +{{- end }} +{{- end }} + +{{/* +The SPM service address +*/}} +{{- define "spm-collector.serviceAddr" -}} +{{- $serviceName := include "spm-collector.fullname" .}} +{{ printf "http://%s.%s.svc.cluster.local:4317" $serviceName .Release.Namespace }} +{{- end }} diff --git a/charts/logzio-apm-collector/templates/_helpers.tpl b/charts/logzio-apm-collector/templates/_helpers.tpl new file mode 100644 index 00000000..9cb45cf5 --- /dev/null +++ b/charts/logzio-apm-collector/templates/_helpers.tpl @@ -0,0 +1,141 @@ +{{/* +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). +*/}} +{{- define "apm-collector.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- .Chart.Name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} + +{{/* Allow the release namespace to be overridden */}} +{{- define "apm-collector.namespace" -}} + {{- if .Values.namespaceOverride -}} + {{- .Values.namespaceOverride -}} + {{- else -}} + {{- .Release.Namespace -}} + {{- end -}} +{{- end -}} + +{{/* Get component name */}} +{{- define "apm-collector.component" -}} +component: apm-collector +{{- end }} + +{{/* Create chart name and version as used by the chart label. */}} +{{- define "apm-collector.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{- define "apm-collector.lowercase_chartname" -}} +{{- default .Chart.Name | lower }} +{{- end }} + +{{/* Selector labels */}} +{{- define "apm-collector.selectorLabels" -}} +app.kubernetes.io/name: {{ include "apm-collector.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* Custom additional labels */}} +{{- define "apm-collector.additionalLabels" -}} +{{- if .Values.additionalLabels }} +{{- tpl (.Values.additionalLabels | toYaml) . }} +{{- end }} +{{- end }} + +{{/* Common labels */}} +{{- define "apm-collector.labels" -}} +helm.sh/chart: {{ include "apm-collector.chart" . }} +{{ include "apm-collector.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{ include "apm-collector.additionalLabels" . }} +{{- end }} + +{{/* Create the name of the service account to use */}} +{{- define "apm-collector.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "apm-collector.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} + +{{/* Create the name of the clusterRole to use */}} +{{- define "apm-collector.clusterRoleName" -}} +{{- default (include "apm-collector.fullname" .) .Values.clusterRole.name }} +{{- end }} + +{{/* Create the name of the clusterRoleBinding to use */}} +{{- define "apm-collector.clusterRoleBindingName" -}} +{{- default (include "apm-collector.fullname" .) .Values.clusterRole.clusterRoleBinding.name }} +{{- end }} + +{{/* Custom pod annotations */}} +{{- define "apm-collector.podAnnotations" -}} +{{- if .Values.podAnnotations }} +{{- tpl (.Values.podAnnotations | toYaml) . }} +{{- end }} +{{- end }} + +{{/*Custom pod labels */}} +{{- define "apm-collector.podLabels" -}} +{{- if .Values.podLabels }} +{{- tpl (.Values.podLabels | toYaml) . }} +{{- 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 "apm-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 }} + +{{/* +Create GOMEMLIMIT value +*/}} +{{- define "apm-collector.gomemlimit" }} +{{- $memlimitBytes := include "apm-collector.convertMemToBytes" . | mulf 0.8 -}} +{{- printf "%dMiB" (divf $memlimitBytes 0x1p20 | floor | int64) -}} +{{- end }} + +{{/* +The APM service address +*/}} +{{- define "apm-collector.serviceAddr" -}} +{{- $serviceName := include "apm-collector.fullname" .}} +{{ printf "http://%s.%s.svc.cluster.local" $serviceName .Release.Namespace }} +{{- end }} diff --git a/charts/logzio-apm-collector/templates/_pod-spm.tpl b/charts/logzio-apm-collector/templates/_pod-spm.tpl new file mode 100644 index 00000000..be666fcd --- /dev/null +++ b/charts/logzio-apm-collector/templates/_pod-spm.tpl @@ -0,0 +1,161 @@ +{{- define "spm-collector.pod" -}} +{{- with .Values.imagePullSecrets }} +imagePullSecrets: + {{- toYaml . | nindent 2 }} +{{- end }} +serviceAccountName: {{ include "apm-collector.serviceAccountName" . }} +securityContext: + {{- toYaml .Values.podSecurityContext | nindent 2 }} +{{- with .Values.hostAliases }} +hostAliases: + {{- toYaml . | nindent 2 }} +{{- end }} +containers: + - name: {{ include "apm-collector.lowercase_chartname" . }}-spm + command: + - /{{ .Values.command.name }} + {{- if .Values.configMap.create }} + - --config=/conf/relay.yaml + {{- end }} + {{- range .Values.command.extraArgs }} + - {{ . }} + {{- end }} + securityContext: + {{- toYaml .Values.containerSecurityContext | nindent 6 }} + {{- if .Values.image.digest }} + {{- if .Values.image.digest }} + image: "{{ .Values.image.repository }}@{{ .Values.image.digest }}" + {{- else }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + {{- end }} + imagePullPolicy: {{ .Values.image.pullPolicy }} + {{- $ports := include "apm-collector.podPortsConfig" . }} + {{- if $ports }} + ports: + {{- $ports | nindent 6}} + {{- end }} + env: + - name: MY_POD_IP + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: status.podIP + - name: K8S_NODE_NAME + valueFrom: + fieldRef: + fieldPath: spec.nodeName + {{- if .Values.secrets.enabled }} + - name: ENV_ID + valueFrom: + secretKeyRef: + name: {{ .Values.secrets.name }} + key: env-id + - name: SPM_ENDPOINT + {{- if .Values.secrets.customSpmEndpoint }} + valueFrom: + secretKeyRef: + name: {{ .Values.secrets.name }} + key: custom-spm-endpoint + {{- else }} + value: {{ include "spm-collector.listenerAddress" . }} + {{- end }} + - name: LOGZIO_SPM_TOKEN + valueFrom: + secretKeyRef: + name: {{ .Values.secrets.name }} + key: logzio-spm-token + {{- end }} + - name: LOG_LEVEL + value: {{ .Values.otelLogLevel | default "info" | quote }} + {{- with .Values.extraEnvs }} + {{- . | toYaml | nindent 6 }} + {{- end }} + {{- with .Values.extraEnvsFrom }} + envFrom: + {{- . | toYaml | nindent 6 }} + {{- end }} + 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 }} + {{- with .Values.resources }} + resources: + {{- toYaml . | nindent 6 }} + {{- end }} + volumeMounts: + {{- if .Values.configMap.create }} + - mountPath: /conf + name: {{ include "apm-collector.lowercase_chartname" . }}-configmap-spm + {{- end }} + {{- if .Values.extraVolumeMounts }} + {{- toYaml .Values.extraVolumeMounts | nindent 6 }} + {{- end }} +{{- if .Values.priorityClassName }} +priorityClassName: {{ .Values.priorityClassName | quote }} +{{- end }} +volumes: + {{- if .Values.configMap.create }} + - name: {{ include "apm-collector.lowercase_chartname" . }}-configmap-spm + configMap: + name: {{ include "spm-collector.fullname" . }} + items: + - key: relay + path: relay.yaml + {{- end }} + {{- if .Values.extraVolumes }} + {{- 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}} diff --git a/charts/logzio-apm-collector/templates/_pod.tpl b/charts/logzio-apm-collector/templates/_pod.tpl new file mode 100644 index 00000000..3e0f4ed9 --- /dev/null +++ b/charts/logzio-apm-collector/templates/_pod.tpl @@ -0,0 +1,180 @@ +{{- define "apm-collector.pod" -}} +{{- with .Values.imagePullSecrets }} +imagePullSecrets: + {{- toYaml . | nindent 2 }} +{{- end }} +serviceAccountName: {{ include "apm-collector.serviceAccountName" . }} +securityContext: + {{- toYaml .Values.podSecurityContext | nindent 2 }} +{{- with .Values.hostAliases }} +hostAliases: + {{- toYaml . | nindent 2 }} +{{- end }} +containers: + - name: {{ include "apm-collector.lowercase_chartname" . }} + command: + - /{{ .Values.command.name }} + {{- if .Values.configMap.create }} + - --config=/conf/relay.yaml + {{- end }} + {{- range .Values.command.extraArgs }} + - {{ . }} + {{- end }} + securityContext: + {{- toYaml .Values.containerSecurityContext | nindent 6 }} + {{- if .Values.image.digest }} + image: "{{ .Values.image.repository }}@{{ .Values.image.digest }}" + {{- else }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + {{- end }} + imagePullPolicy: {{ .Values.image.pullPolicy }} + {{- $ports := include "apm-collector.podPortsConfig" . }} + {{- if $ports }} + ports: + {{- $ports | nindent 6}} + {{- end }} + env: + - name: MY_POD_IP + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: status.podIP + - name: K8S_NODE_NAME + valueFrom: + fieldRef: + fieldPath: spec.nodeName + - name: SPM_SERVICE_ENDPOINT + value: {{ include "spm-collector.serviceAddr" . }} + {{- if .Values.secrets.enabled }} + - name: ENV_ID + valueFrom: + secretKeyRef: + name: {{ .Values.secrets.name }} + key: env-id + - name: LOGZIO_REGION + valueFrom: + secretKeyRef: + name: {{ .Values.secrets.name }} + key: logzio-listener-region + - name: LOGZIO_TRACES_TOKEN + valueFrom: + secretKeyRef: + name: {{ .Values.secrets.name }} + key: logzio-traces-token + {{- if .Values.secrets.customEndpoint }} + - name: CUSTOM_ENDPOINT + valueFrom: + secretKeyRef: + name: {{ .Values.secrets.name }} + key: custom-traces-endpoint + {{- end }} + {{- end }} + - name: LOG_LEVEL + value: {{ .Values.otelLogLevel | default "info" | quote }} + - name: SAMPLING_LATENCY + value: {{ .Values.SamplingLatency | default 10 }} + - name: SAMPLING_PROBABILITY + value: {{ .Values.SamplingProbability | default 500 }} + {{- if and (.Values.useGOMEMLIMIT) (((.Values.resources).limits).memory) }} + - name: GOMEMLIMIT + value: {{ include "apm-collector.gomemlimit" .Values.resources.limits.memory | quote }} + {{- end }} + {{- with .Values.extraEnvs }} + {{- . | toYaml | nindent 6 }} + {{- end }} + {{- with .Values.extraEnvsFrom }} + envFrom: + {{- . | toYaml | nindent 6 }} + {{- end }} + 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 }} + {{- with .Values.resources }} + resources: + {{- toYaml . | nindent 6 }} + {{- end }} + volumeMounts: + {{- if .Values.configMap.create }} + - mountPath: /conf + name: {{ include "apm-collector.lowercase_chartname" . }}-configmap + {{- end }} + {{- if .Values.extraVolumeMounts }} + {{- toYaml .Values.extraVolumeMounts | nindent 6 }} + {{- end }} +{{- with .Values.extraContainers }} +{{- toYaml . | nindent 2 }} +{{- end }} +{{- if .Values.initContainers }} +initContainers: + {{- tpl (toYaml .Values.initContainers) . | nindent 2 }} +{{- end }} +{{- if .Values.priorityClassName }} +priorityClassName: {{ .Values.priorityClassName | quote }} +{{- end }} +volumes: + {{- if .Values.configMap.create }} + - name: {{ include "apm-collector.lowercase_chartname" . }}-configmap + configMap: + name: {{ include "apm-collector.fullname" . }} + items: + - key: relay + path: relay.yaml + {{- end }} + {{- if .Values.extraVolumes }} + {{- 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 }} diff --git a/charts/logzio-apm-collector/templates/_validations.tpl b/charts/logzio-apm-collector/templates/_validations.tpl new file mode 100644 index 00000000..d49c6546 --- /dev/null +++ b/charts/logzio-apm-collector/templates/_validations.tpl @@ -0,0 +1,20 @@ +{{/* +This file will contain validations on the input of the chart. +For example, verify the log level is with a valid value +*/}} + +{{- define "check-tracing-token" -}} + {{- if .Values.enabled }} + {{- if and (not .Values.global.logzioTracesToken) (not .Values.secrets.logzioTracesToken) }} + {{- fail "Missing Tracing Token" }} + {{- end }} + {{- end }} +{{- end -}} + +{{- define "check-spm-token" -}} + {{- if and (.Values.enabled) (.Values.spm.enabled) }} + {{- if and (not .Values.global.logzioSpmToken) (not .Values.secrets.logzioSpmToken) }} + {{- fail "Missing SPM Token" }} + {{- end }} + {{- end }} +{{- end -}} diff --git a/charts/logzio-apm-collector/templates/clusterrole.yaml b/charts/logzio-apm-collector/templates/clusterrole.yaml new file mode 100644 index 00000000..e54f16f9 --- /dev/null +++ b/charts/logzio-apm-collector/templates/clusterrole.yaml @@ -0,0 +1,33 @@ +{{ if .Values.enabled }} +{{- if (.Values.clusterRole.create) -}} +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: {{ include "apm-collector.clusterRoleName" . }} + labels: + {{- include "apm-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 }} + # TODO: make sure if we need all of these permissions... + - apiGroups: [""] + resources: ["events", "namespaces", "namespaces/status", "pods", "pods/status", "replicationcontrollers", "replicationcontrollers/status", "resourcequotas", "services", "endpoints"] + verbs: ["get", "watch", "list"] + - apiGroups: ["apps"] + resources: ["deployments", "replicasets"] + verbs: ["get", "watch", "list"] + - apiGroups: ["extensions"] + resources: ["deployments", "replicasets"] + verbs: ["get", "watch", "list"] + - apiGroups: ["autoscaling"] + resources: ["horizontalpodautoscalers"] + verbs: ["get", "watch", "list"] +{{- end }} +{{ end }} diff --git a/charts/logzio-apm-collector/templates/clusterrolebinding.yaml b/charts/logzio-apm-collector/templates/clusterrolebinding.yaml new file mode 100644 index 00000000..7d6524ec --- /dev/null +++ b/charts/logzio-apm-collector/templates/clusterrolebinding.yaml @@ -0,0 +1,24 @@ +{{ if .Values.enabled}} +{{- if .Values.clusterRole.create }} +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: {{ include "apm-collector.clusterRoleBindingName" . }} + labels: + {{- include "apm-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 "apm-collector.clusterRoleName" . }} +subjects: +- kind: ServiceAccount + name: {{ include "apm-collector.serviceAccountName" . }} + namespace: {{ include "apm-collector.namespace" . }} +{{- end }} +{{ end }} diff --git a/charts/logzio-apm-collector/templates/configmap-spm.yaml b/charts/logzio-apm-collector/templates/configmap-spm.yaml new file mode 100644 index 00000000..d9b79864 --- /dev/null +++ b/charts/logzio-apm-collector/templates/configmap-spm.yaml @@ -0,0 +1,12 @@ +{{ if .Values.enabled }} +{{- if .Values.configMap.create }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "spm-collector.fullname" . }} + namespace: {{ template "apm-collector.namespace" . }} + labels: {{- include "apm-collector.labels" . | nindent 4 }} +data: + relay: {{ include "spm-collector.config" . | nindent 4 }} +{{- end }} +{{ end }} diff --git a/charts/logzio-apm-collector/templates/configmap.yaml b/charts/logzio-apm-collector/templates/configmap.yaml new file mode 100644 index 00000000..99c7fcd9 --- /dev/null +++ b/charts/logzio-apm-collector/templates/configmap.yaml @@ -0,0 +1,12 @@ +{{ if .Values.enabled }} +{{- if .Values.configMap.create }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "apm-collector.fullname" . }} + namespace: {{ template "apm-collector.namespace" . }} + labels: {{- include "apm-collector.labels" . | nindent 4 }} +data: + relay: {{ include "apm-collector.config" . | nindent 4 }} +{{- end }} +{{ end }} diff --git a/charts/logzio-apm-collector/templates/deployment-spm.yaml b/charts/logzio-apm-collector/templates/deployment-spm.yaml new file mode 100644 index 00000000..5ff9d823 --- /dev/null +++ b/charts/logzio-apm-collector/templates/deployment-spm.yaml @@ -0,0 +1,40 @@ +{{ if and .Values.enabled .Values.spm.enabled }} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "spm-collector.fullname" . }} + namespace: {{ template "apm-collector.namespace" . }} + labels: + {{- include "apm-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: + replicas: {{ .Values.standaloneCollector.replicaCount }} + selector: + matchLabels: + {{- include "apm-collector.selectorLabels" . | nindent 6 }} + {{- include "spm-collector.component" . | nindent 6 }} + template: + metadata: + annotations: + checksum/config: {{ include (print $.Template.BasePath "/configmap-spm.yaml") . | sha256sum }} + {{- include "apm-collector.podAnnotations" . | nindent 8 }} + labels: + {{- include "apm-collector.selectorLabels" . | nindent 8 }} + {{- include "apm-collector.podLabels" . | nindent 8 }} + {{- include "spm-collector.component" . | nindent 8 }} + spec: + {{- include "spm-collector.pod" . | nindent 6 }} + hostNetwork: {{ .Values.hostNetwork }} + {{- with .Values.dnsPolicy }} + dnsPolicy: {{ . }} + {{- end }} + {{- with .Values.dnsConfig }} + dnsConfig: + {{- toYaml . | nindent 8 }} + {{- end }} +{{ end }} diff --git a/charts/logzio-apm-collector/templates/deployment.yaml b/charts/logzio-apm-collector/templates/deployment.yaml new file mode 100644 index 00000000..13e3a93f --- /dev/null +++ b/charts/logzio-apm-collector/templates/deployment.yaml @@ -0,0 +1,42 @@ +{{ if .Values.enabled }} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "apm-collector.fullname" . }} + namespace: {{ template "apm-collector.namespace" . }} + labels: + {{- include "apm-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.standaloneCollector.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "apm-collector.selectorLabels" . | nindent 6 }} + {{- include "apm-collector.component" . | nindent 6 }} + template: + metadata: + annotations: + checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }} + {{- include "apm-collector.podAnnotations" . | nindent 8 }} + labels: + {{- include "apm-collector.selectorLabels" . | nindent 8 }} + {{- include "apm-collector.podLabels" . | nindent 8 }} + {{- include "apm-collector.component" . | nindent 8 }} + spec: + {{- include "apm-collector.pod" . | nindent 6}} + hostNetwork: {{ .Values.hostNetwork }} + {{- with .Values.dnsPolicy }} + dnsPolicy: {{ . }} + {{- end }} + {{- with .Values.dnsConfig }} + dnsConfig: + {{- toYaml . | nindent 8 }} + {{- end }} +{{ end }} diff --git a/charts/logzio-apm-collector/templates/hpa.yaml b/charts/logzio-apm-collector/templates/hpa.yaml new file mode 100644 index 00000000..a20f8ef9 --- /dev/null +++ b/charts/logzio-apm-collector/templates/hpa.yaml @@ -0,0 +1,38 @@ +{{- if and .Values.enabled .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "apm-collector.fullname" . }} + namespace: {{ template "apm-collector.namespace" . }} + labels: + {{- include "apm-collector.labels" . | nindent 4 }} + {{- if .Values.autoscaling.annotations }} + annotations: + {{- range $key, $value := .Values.autoscaling.annotations }} + {{- printf "%s: %s" $key (tpl $value $ | quote) | nindent 4 }} + {{- end }} + {{- end }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "apm-collector.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} diff --git a/charts/logzio-apm-collector/templates/instrumentation.yaml b/charts/logzio-apm-collector/templates/instrumentation.yaml new file mode 100644 index 00000000..b6a66b95 --- /dev/null +++ b/charts/logzio-apm-collector/templates/instrumentation.yaml @@ -0,0 +1,46 @@ +{{ if and (.Values.enabled) (.otel-operator.enabled) }} +apiVersion: opentelemetry.io/v1alpha1 +kind: Instrumentation +metadata: + name: {{ include "apm-collector.fullname" . }} + namespace: {{ .Values.instrumentation.includeNamespaces | default template "apm-collector.namespace" . }} + labels: + {{- include "apm-collector.labels" . | nindent 4 }} + {{- include "apm-collector.component" . | nindent 4 }} + {{- if .Values.annotations }} + annotations: + {{- range $key, $value := .Values.annotations }} + {{- printf "%s: %s" $key (tpl $value $ | quote) | nindent 4 }} + {{- end }} + {{- end }} +spec: + exporter: + endpoint: {{ include "apm-collector.serviceAddr" . }}:4317 + propagators: + {{- $defaultPropagators := list "tracecontext" "baggage" }} + {{- range .Values.instrumentation.propagators | default $defaultPropagators }} + - {{ . }} + {{- end }} + {{- with .Values.instrumentation.sampler }} + sampler: + {{- . | toYaml | nindent 4 }} + {{- end }} + # Python, .NET, Go and Java autoinstrumentation uses http/proto by default + # so data must be sent to 4318 instead of 4317. + python: + env: + - name: OTEL_EXPORTER_OTLP_ENDPOINT + value: {{ include "apm-collector.serviceAddr" . }}:4318 + dotnet: + env: + - name: OTEL_EXPORTER_OTLP_ENDPOINT + value: {{ include "apm-collector.serviceAddr" . }}:4318 + go: + env: + - name: OTEL_EXPORTER_OTLP_ENDPOINT + value: {{ include "apm-collector.serviceAddr" . }}:4318 + java: + env: + - name: OTEL_EXPORTER_OTLP_ENDPOINT + value: {{ include "apm-collector.serviceAddr" . }}:4318 +{{ end }} diff --git a/charts/logzio-apm-collector/templates/secret.yaml b/charts/logzio-apm-collector/templates/secret.yaml new file mode 100644 index 00000000..6ca2fb8d --- /dev/null +++ b/charts/logzio-apm-collector/templates/secret.yaml @@ -0,0 +1,25 @@ +{{ if .Values.enabled}} +{{- if .Values.secrets.enabled }} +apiVersion: v1 +kind: Secret +metadata: + name: {{ .Values.secrets.name }} + namespace: {{ .Release.Namespace }} +type: Opaque +stringData: + env-id: {{ .Values.global.env_id | default .Values.secrets.env_id | quote }} + logzio-listener-region: {{ .Values.global.logzioRegion | default .Values.secrets.logzioRegion }} + {{- template "check-tracing-token" . }} + logzio-traces-token: {{ .Values.global.logzioTracesToken | default .Values.secrets.logzioTracesToken }} + {{- end }} + {{- template "check-spm-token" . }} + logzio-spm-token: {{ .Values.global.logzioSpmToken | default .Values.secrets.logzioSpmToken }} + {{- end }} + {{- if .Values.secrets.customEndpoint}} + custom-traces-endpoint: {{ .Values.secrets.customTracesEndpoint }} + {{- end }} + {{- if .Values.secrets.customEndpoint}} + custom-spm-endpoint: {{ .Values.secrets.customSpmEndpoint }} + {{- end }} +{{- end }} +{{ end }} diff --git a/charts/logzio-apm-collector/templates/service-spm.yaml b/charts/logzio-apm-collector/templates/service-spm.yaml new file mode 100644 index 00000000..61371d3f --- /dev/null +++ b/charts/logzio-apm-collector/templates/service-spm.yaml @@ -0,0 +1,42 @@ +{{ if and .Values.enabled .Values.spm.enabled }} +apiVersion: v1 +kind: Service +metadata: + name: {{ include "spm-collector.fullname" . }} + namespace: {{ template "apm-collector.namespace" . }} + labels: + {{- include "apm-collector.labels" . | nindent 4 }} + {{- include "spm-collector.component" . | nindent 4 }} + {{- if .Values.spmService.annotations }} + annotations: + {{- range $key, $value := .Values.spmService.annotations }} + {{- printf "%s: %s" $key (tpl $value $ | quote) | nindent 4 }} + {{- end }} + {{- end }} +spec: + type: {{ .Values.spmService.type }} + {{- if .Values.spmService.clusterIP }} + clusterIP: {{ .Values.spmService.clusterIP }} + {{- end }} + {{- if and .Values.spmService.loadBalancerIP (eq .Values.spmService.type "LoadBalancer") }} + loadBalancerIP: {{ .Values.spmService.loadBalancerIP }} + {{- end }} + {{- if and .Values.spmService.loadBalancerSourceRanges (eq .Values.spmService.type "LoadBalancer") }} + loadBalancerSourceRanges: + {{- range .Values.spmService.loadBalancerSourceRanges }} + - {{ . }} + {{- end }} + {{- end }} + {{- $ports := include "apm-collector.servicePortsConfig" . }} + {{- if $ports }} + ports: + {{- $ports | nindent 4}} + {{- end }} + selector: + {{- include "apm-collector.selectorLabels" . | nindent 4 }} + {{- include "spm-collector.component" . | nindent 4 }} + internalTrafficPolicy: {{ .Values.spmService.internalTrafficPolicy | default "Cluster" }} + {{- if and (eq .Values.spmService.type "LoadBalancer") (.Values.spmService.externalTrafficPolicy) }} + externalTrafficPolicy: {{ .Values.spmService.externalTrafficPolicy | default "Cluster" }} + {{- end }} +{{ end }} diff --git a/charts/logzio-apm-collector/templates/service.yaml b/charts/logzio-apm-collector/templates/service.yaml new file mode 100644 index 00000000..fa70cae9 --- /dev/null +++ b/charts/logzio-apm-collector/templates/service.yaml @@ -0,0 +1,44 @@ +# A basic manifest for creating a service endpoint for your deployment +{{ if .Values.enabled }} +{{- if .service.enabled }} +apiVersion: v1 +kind: Service +metadata: + name: {{ include "apm-collector.fullname" . }} + namespace: {{ template "apm-collector.namespace" . }} + labels: + {{- include "apm-collector.labels" . | nindent 4 }} + {{- include "apm-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 "apm-collector.servicePortsConfig" . }} + {{- if $ports }} + ports: + {{- $ports | nindent 4}} + {{- end }} + selector: + {{- include "apm-collector.selectorLabels" . | nindent 4 }} + internalTrafficPolicy: {{ .service.internalTrafficPolicy | default "Cluster" }} + {{- if and (eq .Values.service.type "LoadBalancer") (.Values.service.externalTrafficPolicy) }} + externalTrafficPolicy: {{ .Values.service.externalTrafficPolicy | default "Cluster" }} + {{- end }} +{{- end }} +{{ end }} diff --git a/charts/logzio-apm-collector/templates/serviceaccount.yaml b/charts/logzio-apm-collector/templates/serviceaccount.yaml new file mode 100644 index 00000000..7ed2fd43 --- /dev/null +++ b/charts/logzio-apm-collector/templates/serviceaccount.yaml @@ -0,0 +1,17 @@ +{{ if .Values.enabled}} +{{- if (.Values.serviceAccount.create) -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "apm-collector.serviceAccountName" . }} + namespace: {{ template "apm-collector.namespace" . }} + labels: + {{- include "apm-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 }} +{{ end }} diff --git a/charts/logzio-apm-collector/templates/vpa-spm.yaml b/charts/logzio-apm-collector/templates/vpa-spm.yaml new file mode 100644 index 00000000..ffb0c367 --- /dev/null +++ b/charts/logzio-apm-collector/templates/vpa-spm.yaml @@ -0,0 +1,36 @@ +{{- if and .Values.spm.enabled .Values.spmAutoscaling.enabled }} +apiVersion: autoscaling.k8s.io/v1 +kind: VerticalPodAutoscaler +metadata: + name: {{ include "spm-collector.fullname" . }} + namespace: {{ template "apm-collector.namespace" . }} + labels: + {{- include "apm-collector.labels" . | nindent 4 }} + {{- if .Values.spmAutoscaling.annotations }} + annotations: + {{- range $key, $value := .Values.spmAutoscaling.annotations }} + {{- printf "%s: %s" $key (tpl $value $ | quote) | nindent 4 }} + {{- end }} + {{- end }} +spec: + targetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "spm-collector.fullname" . }} + updatePolicy: + updateMode: "Auto" + resourcePolicy: + containerPolicies: + - containerName: {{ include "apm-collector.lowercase_chartname" . }}-spm + {{- with .Values.spmAutoscaling.minAllowed }} + minAllowed: + cpu: {{ .cpu }} + memory: {{ .memory }} + {{- end }} + {{- with .Values.spmAutoscaling.maxAllowed }} + maxAllowed: + cpu: {{ .cpu }} + memory: {{ .memory }} + {{- end }} + controlledResources: ["cpu", "memory"] +{{- end }} diff --git a/charts/logzio-apm-collector/values.yaml b/charts/logzio-apm-collector/values.yaml new file mode 100644 index 00000000..d265907a --- /dev/null +++ b/charts/logzio-apm-collector/values.yaml @@ -0,0 +1,606 @@ +# Default values for logzio-apm-collector. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +# Control the deployment of this chart by a parent chart +enabled: false + +# Enable Span metrics +spm: + enabled: false + +# Enable Service Graph metrics +serviceGraph: + enabled: false + +# Enable Auto Instrumentation +# ref: https://github.com/open-telemetry/opentelemetry-helm-charts/tree/main/charts/opentelemetry-operator +otel-operator: + enabled: false + +# Specifies a custom name for the chart's resources +fullnameOverride: "" +namespaceOverride: "" + +####################################################################################################################### +# Base Configuration Parameters +####################################################################################################################### +secrets: + # When secrets.enabled is true, the logzio secret will be created and managed by this Chart. + # If you're managing the logzio secrets by yourself, set to false. + # Note that in order for the default configuration to work properly, you need to create the following env variables: + # ENV_ID, LOGZIO_TRACES_TOKEN, LOGZIO_SPM_TOKEN, LOGZIO_REGION, LOGZIO_LISTENER + enabled: true + name: logzio-apm-collector-secret + # environment identifier attribute that will be added to all telemetry + env_id: "my_env" + # Logz.io Tracing Shipping Token + logzioTracesToken: "" + # Logz.io SPM Shipping Token + logzioSpmToken: "" + # Logz.io region code + logzioRegion: "us" + # Overrides secrets.LogzioRegion listener address with a custom endpoint. For example: http://endpoint:8080 + customTracesEndpoint: "" + customSpmEndpoint: "" + +# Allows changing the OpenTelemetry Collector log level +otelLogLevel: "info" + +# Number of collector replicas +standaloneCollector: + replicaCount: 1 + +####################################################################################################################### +# OpenTelemetry Collector Configuration +####################################################################################################################### + +# Trace sampling default rules configuration. +# These settings do not affect the traces used for calculating SPM (span metrics). +# SamplingProbability: 10 # Traces Sampling Probability +# SamplingLatency: 500 # Traces Sampling Latency + +# Tracing Collector configuration +traceConfig: + exporters: + logzio: + endpoint: ${CUSTOM_ENDPOINT} + region: ${LOGZIO_REGION} + account_token: ${LOGZIO_TRACES_TOKEN} + headers: + user-agent: "{{ .Chart.Name }}-{{ .Chart.Version }}-helm" + extensions: + pprof: + endpoint: :1777 + zpages: + endpoint: :55679 + receivers: + jaeger: + protocols: + thrift_compact: + endpoint: "0.0.0.0:6831" + thrift_binary: + endpoint: "0.0.0.0:6832" + grpc: + endpoint: "0.0.0.0:14250" + thrift_http: + endpoint: "0.0.0.0:14268" + otlp: + protocols: + grpc: + endpoint: "0.0.0.0:4317" + http: + endpoint: "0.0.0.0:4318" + zipkin: + endpoint: "0.0.0.0:9411" + processors: + resourcedetection/all: + detectors: [ec2, azure, gcp] + tail_sampling: + policies: + [ + { + name: error-in-policy, + type: status_code, + status_code: {status_codes: [ERROR]} + }, + { + name: slow-traces-policy, + type: latency, + latency: {threshold_ms: "${SAMPLING_LATENCY}" } + }, + { + name: probability-policy, + type: probabilistic, + probabilistic: {sampling_percentage: "${SAMPLING_PROBABILITY}" } + } + ] + service: + extensions: [health_check, pprof, zpages] + pipelines: + traces: + receivers: [jaeger, zipkin, otlp] + processors: [resourcedetection/all,attributes/env_id, k8sattributes, resource/k8s, tail_sampling, batch] + exporters: [logzio] + telemetry: + logs: + level: ${LOG_LEVEL} + +# Exporter from Traces Collector to SPM Collector +spmForwarderConfig: + exporters: + otlp: + endpoint: "${SPM_SERVICE_ENDPOINT}" + tls: + insecure: true + service: + pipelines: + traces/spm: + receivers: [jaeger, zipkin, otlp] + processors: [resourcedetection/all, attributes/env_id, k8sattributes] + exporters: [otlp] + +# SPM Collector configuration +spmConfig: + exporters: + prometheusremotewrite/spm-logzio: + endpoint: ${SPM_ENDPOINT} + headers: + Authorization: Bearer ${LOGZIO_SPM_TOKEN} + user-agent: "{{ .Chart.Name }}-{{ .Chart.Version }}-helm" + timeout: 30s # Time to wait per attempt to send data + add_metric_suffixes: false + receivers: + otlp: + protocols: + grpc: + endpoint: "0.0.0.0:4317" + processors: + metricstransform/metrics-rename: + transforms: + # rename metric duration.XXX >> latency.XXX + - include: ^duration(.*)$$ + action: update + match_type: regexp + new_name: latency.$${1} + # rename metric calls >> calls_total + - action: update + include: calls + new_name: calls_total + metricstransform/labels-rename: + transforms: + # for metrics matching `latencyXXX` or `callsXXX` + # rename label span.name >> operation + - action: update + include: ^(latency|calls) + match_type: regexp + operations: + - action: update_label + label: span.name + new_label: operation + connectors: + spanmetrics: + aggregation_temporality: AGGREGATION_TEMPORALITY_CUMULATIVE + dimensions: + - name: rpc.grpc.status_code + - name: http.method + - name: http.status_code + - name: k8s.pod.name + - name: k8s.deployment.name + - name: k8s.namespace.name + - name: k8s.node.name + - name: k8s.statefulset.name + - name: k8s.replicaset.name + - name: k8s.daemonset.name + - name: k8s.cronjob.name + - name: k8s.job.name + - name: cloud.provider + - name: cloud.region + - name: db.system + - name: messaging.system + - default: ${ENV_ID} + name: env_id + dimensions_cache_size: 100000 + histogram: + explicit: + buckets: + - 2ms + - 8ms + - 50ms + - 100ms + - 200ms + - 500ms + - 1s + - 5s + - 10s + metrics_expiration: 5m + resource_metrics_key_attributes: + - service.name + - telemetry.sdk.language + - telemetry.sdk.name + service: + pipelines: + traces: + receivers: [otlp] + exporters: [spanmetrics] + metrics/spm-logzio: + receivers: [spanmetrics] + processors: [metricstransform/metrics-rename, metricstransform/labels-rename] + exporters: [prometheusremotewrite/spm-logzio] + +# Service Graph configuration +serviceGraphConfig: + connectors: + servicegraph: + latency_histogram_buckets: [2ms, 8ms, 50ms, 100ms, 200ms, 500ms, 1s, 5s, 10s] + dimensions: + - env_id + store: + ttl: 5s + max_items: 100000 + service: + pipelines: + traces: + exporters: [servicegraph] + metrics/spm-logzio: + receivers: [servicegraph] + +####################################################################################################################### +# OpenTelemetry Collector Image Settings +####################################################################################################################### +image: + # If you want to use the core image `otel/opentelemetry-collector`, you also need to change `command.name` value to `otelcol`. + repository: otel/opentelemetry-collector-contrib + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + # When digest is set to a non-empty value, images will be pulled by digest (regardless of tag value). + digest: "" + +imagePullSecrets: [] + +# OpenTelemetry Collector executable +command: + name: otelcol-contrib + extraArgs: [] + +####################################################################################################################### +# Otel Operator Auto Instrumentation configuration +####################################################################################################################### +instrumentation: + # For intensive applications, to reduce the performance impact of the operator, you can define multiple + # namespaces to deploy the instrumentor resource at. This can help distribute the load in larger clusters. + # By default, a single instrumentation resource is deployed either in the default "monitoring" namespace, or in the + # "namespaceOverride" namespace (if defined). + includeNamespaces: "" + + # Choose propagator to specify the method of injecting and extracting context from carriers. + # By default, "tracecontext" (W3C Trace Context) and "baggage" (W3C Correlation Context) are enabled. + # You can enable or disable propagators as needed, or use "none" for no automatically configured propagator + # ref: https://opentelemetry.io/docs/languages/sdk-configuration/general/#otel_propagators + propagators: + - tracecontext + - baggage + # - b3 + # - b3multi + # - jaeger + # - xray + # - ottrace + + # Specifies the Sampler used to sample traces by the SDK. (Optional) + sampler: + # By default, "parentbased_always_on" is enabled, meaning new traces will always be recorded and if the parent span is sampled, then the child span will be sampled. + # ref: https://opentelemetry.io/docs/languages/sdk-configuration/general/#otel_traces_sampler + # type: "parentbased_always_on" + + # Each Sampler type defines its own expected args input gor configuring the sampler + # ref: https://opentelemetry.io/docs/languages/sdk-configuration/general/#otel_traces_sampler_arg + # argument: "0.25" + +####################################################################################################################### +# Kubernetes Resources Configuration +####################################################################################################################### +configMap: + # Specifies whether a configMap should be created + create: true + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +clusterRole: + # Specifies whether a clusterRole should be created + # Some presets also trigger the creation of a cluster role and cluster role binding. + # If using one of those presets, this field is no-op. + create: true + # Annotations to add to the clusterRole + # Can be used in combination with presets that create a cluster role. + annotations: {} + # The name of the clusterRole to use. + # If not set a name is generated using the fullname template + # Can be used in combination with presets that create a cluster role. + name: "" + # A set of rules as documented here : https://kubernetes.io/docs/reference/access-authn-authz/rbac/ + # Can be used in combination with presets that create a cluster role to add additional rules. + rules: [] + # - apiGroups: + # - '' + # resources: + # - 'pods' + # - 'nodes' + # verbs: + # - 'get' + # - 'list' + # - 'watch' + clusterRoleBinding: + # Annotations to add to the clusterRoleBinding + # Can be used in combination with presets that create a cluster role binding. + annotations: {} + # The name of the clusterRoleBinding to use. + # If not set a name is generated using the fullname template + # Can be used in combination with presets that create a cluster role binding. + name: "" + +service: + # Enable the creation of a Traces Collector Service. + enabled: true + + type: ClusterIP + # type: LoadBalancer + # loadBalancerIP: 1.2.3.4 + # loadBalancerSourceRanges: [] + + # Annotations to add to the Service. + annotations: {} + + # By default, Service will be created setting 'internalTrafficPolicy: Cluster' + # unless other value is explicitly set. + # Setting 'internalTrafficPolicy: Cluster' on a daemonset is not recommended (in such case, use 'internalTrafficPolicy: Local') + # internalTrafficPolicy: Cluster + + # By default, Service of type 'LoadBalancer' will be created setting 'externalTrafficPolicy: Cluster' + # unless other value is explicitly set. + # Possible values are Cluster or Local (https://kubernetes.io/docs/tasks/access-application-cluster/create-external-load-balancer/#preserving-the-client-source-ip) + # externalTrafficPolicy: Cluster + +spmService: + # Only generated if spm.enabled is set to true. + type: ClusterIP + + # Annotations to add to the Service. + annotations: {} + + # By default, Service will be created setting 'internalTrafficPolicy: Cluster' + # unless other value is explicitly set. + # Setting 'internalTrafficPolicy: Cluster' on a daemonset is not recommended (in such case, use 'internalTrafficPolicy: Local') + # internalTrafficPolicy: Cluster + + # By default, Service of type 'LoadBalancer' will be created setting 'externalTrafficPolicy: Cluster' + # unless other value is explicitly set. + # Possible values are Cluster or Local (https://kubernetes.io/docs/tasks/access-application-cluster/create-external-load-balancer/#preserving-the-client-source-ip) + # externalTrafficPolicy: Cluster + +# Configure HPA for Traces Collector. +# Make sure that the `service.type` is `ClusterIP` to utilize K8S ability to automatically distribute traffic across all pod replicas +autoscaling: + # Enable the creation of HPA for autoscaling. + enabled: false + # Annotations to add to the HPA. + annotations: {} + # Control autoscaling scale + minReplicas: 1 + maxReplicas: 10 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +# Configure VPA for SPM Collector. +# The reason we use vertical scaling and not horizontal is to make sure the SPM aggregations are correct. +spmAutoscaling: + # Enable the vertical scaling + enabled: false + # Annotations to add to the HPA. + annotations: {} + # Control scaling limits + minAllowed: + cpu: 50m + memory: 70Mi + maxAllowed: + cpu: 150m + memory: 250Mi + +# Configuration for ports +ports: + otlp: + enabled: true + containerPort: 4317 + servicePort: 4317 + hostPort: 4317 + protocol: TCP + otlp-http: + enabled: true + containerPort: 4318 + servicePort: 4318 + hostPort: 4318 + protocol: TCP + jaeger-compact: + enabled: true + containerPort: 6831 + servicePort: 6831 + hostPort: 6831 + protocol: UDP + jaeger-thrift: + enabled: true + containerPort: 14268 + servicePort: 14268 + hostPort: 14268 + protocol: TCP + jaeger-grpc: + enabled: true + containerPort: 14250 + servicePort: 14250 + hostPort: 14250 + protocol: TCP + zipkin: + enabled: true + containerPort: 9411 + servicePort: 9411 + hostPort: 9411 + protocol: TCP + +# Common labels to add to all otel-collector resources. Evaluated as a template. +additionalLabels: {} +# app.kubernetes.io/part-of: my-app + +####################################################################################################################### +# Pod Configuration +####################################################################################################################### +podSecurityContext: {} +securityContext: {} + +nodeSelector: {} +tolerations: [] +# Set affinity rules for the scheduler to determine where all DaemonSet pods can be placed. +# The following configuration prevent logzio apm collector DaemonSet deploymment on fargate nodes +# DaemonSet mode is not used in the current APM chart, this configuration is retained for potential future support. +affinity: + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: eks.amazonaws.com/compute-type + operator: DoesNotExist +topologySpreadConstraints: [] + +# Allows for pod scheduler prioritisation +priorityClassName: "" + +extraEnvs: [] +extraEnvsFrom: [] +extraVolumes: [] +extraVolumeMounts: [] + +# When enabled, the chart will set the GOMEMLIMIT env var to 80% of the configured +# resources.limits.memory +# If no resources.limits.memory are defined enabling does nothing. +# In a future release this setting will be enabled by default. +# See https://github.com/open-telemetry/opentelemetry-helm-charts/issues/891 +# for more details. +useGOMEMLIMIT: false + +# Resource allocation. +resources: + # guaranteed resource allocation + requests: + cpu: 50m + memory: 70Mi + # upper bound the container can consume + # must be configured if you enable useGOMEMLIMIT + limits: + cpu: 250m + memory: 512Mi + +podAnnotations: {} +podLabels: {} + +# Adding entries to Pod /etc/hosts with HostAliases +# https://kubernetes.io/docs/tasks/network/customize-hosts-file-for-pods/ +hostAliases: [] + # - ip: "1.2.3.4" + # hostnames: + # - "my.host.com" + +# Pod DNS policy ClusterFirst, ClusterFirstWithHostNet, None, Default +dnsPolicy: "" + +# Custom DNS config. Required when DNS policy is None. +dnsConfig: {} + +annotations: {} + +# List of extra sidecars to add +extraContainers: [] +# extraContainers: +# - name: test +# command: +# - cp +# args: +# - /bin/sleep +# - /test/sleep +# image: busybox:latest +# volumeMounts: +# - name: test +# mountPath: /test + +# List of init container specs, e.g. for copying a binary to be executed as a lifecycle hook. +# Another usage of init containers is e.g. initializing filesystem permissions to the OTLP Collector user `10001` in case you are using persistence and the volume is producing a permission denied error for the OTLP Collector container. +initContainers: [] +# initContainers: +# - name: test +# image: busybox:latest +# command: +# - cp +# args: +# - /bin/sleep +# - /test/sleep +# volumeMounts: +# - name: test +# mountPath: /test +# - name: init-fs +# image: busybox:latest +# command: +# - sh +# - '-c' +# - 'chown -R 10001: /var/lib/storage/otc' # use the path given as per `extensions.file_storage.directory` & `extraVolumeMounts[x].mountPath` +# volumeMounts: +# - name: opentelemetry-collector-data # use the name of the volume used for persistence +# mountPath: /var/lib/storage/otc # use the path given as per `extensions.file_storage.directory` & `extraVolumeMounts[x].mountPath` + +# Pod lifecycle policies. +lifecycleHooks: {} +# lifecycleHooks: +# preStop: +# exec: +# command: +# - /test/sleep +# - "5" + +# liveness probe configuration +# Ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/ +## +livenessProbe: + # Number of seconds after the container has started before startup, liveness or readiness probes are initiated. + # initialDelaySeconds: 1 + # How often in seconds to perform the probe. + # periodSeconds: 10 + # Number of seconds after which the probe times out. + # timeoutSeconds: 1 + # Minimum consecutive failures for the probe to be considered failed after having succeeded. + # failureThreshold: 1 + # Duration in seconds the pod needs to terminate gracefully upon probe failure. + # terminationGracePeriodSeconds: 10 + httpGet: + port: 13133 + path: / + +# readiness probe configuration +# Ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/ +## +readinessProbe: + # Number of seconds after the container has started before startup, liveness or readiness probes are initiated. + # initialDelaySeconds: 1 + # How often (in seconds) to perform the probe. + # periodSeconds: 10 + # Number of seconds after which the probe times out. + # timeoutSeconds: 1 + # Minimum consecutive successes for the probe to be considered successful after having failed. + # successThreshold: 1 + # Minimum consecutive failures for the probe to be considered failed after having succeeded. + # failureThreshold: 1 + httpGet: + port: 13133 + path: / From 89274b6adb163defef1da501a7fba7c773d1bf88 Mon Sep 17 00:00:00 2001 From: 8naama Date: Wed, 6 Nov 2024 15:26:53 +0200 Subject: [PATCH 02/15] update readme headers nesting --- charts/logzio-apm-collector/README.md | 30 ++++++++++++--------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/charts/logzio-apm-collector/README.md b/charts/logzio-apm-collector/README.md index 3c9aa281..8d7922cb 100644 --- a/charts/logzio-apm-collector/README.md +++ b/charts/logzio-apm-collector/README.md @@ -49,19 +49,15 @@ logzio-apm-collector logzio-helm/logzio-apm-collector ## Configuration - [All configuration options](./VALUES.md) -- [Auto-instrumentation options](#auto-instrumentation-options) - - [Enable Auto-instrumentation](#enable-auto-instrumentation) - - [Multi-container pods](#multi-container-pods) - - [Customize Auto-instrumentation](#customize-auto-instrumentation) - - [Customize Propagator](#customize-propagator) - - [Add a custom Sampler](#add-a-custom-sampler) - - [Distribute namespaces](#distribute-namespaces) +- [Enable Auto-instrumentation](#enable-auto-instrumentation) + - [Multi-container pods](#multi-container-pods) +- [Customize Auto-instrumentation](#customize-auto-instrumentation) + - [Customize Propagator](#customize-propagator) + - [Add a custom Sampler](#add-a-custom-sampler) + - [Distribute namespaces](#distribute-namespaces) - [Custom Trace Sampling rules](#custom-trace-sampling-rules) -### Auto-instrumentation options -Below, you can find guidance on enabling and customizing OpenTelemetry Operator Auto-instrumentation. - -#### Enable Auto-instrumentation +## Enable Auto-instrumentation - **Step 1:** Make sure to enable the OpenTelemetry operator in the chart: ```shell --set otel-operator.enabled=true \ @@ -76,7 +72,7 @@ instrumentation.opentelemetry.io/inject-": "monitoring/logzio-apm- > `` can be one of `apache-httpd`, `dotnet`, `go`, `java`, `nginx`, `nodejs` or `python`. -##### Multi-container pods +### Multi-container pods By default, in multi-container pods, instrumentation is performed on the first container available in the pod spec. To fine tune which containers to instrument, add the below annotations to your pod: ```yaml @@ -90,10 +86,10 @@ instrumentation.opentelemetry.io/-container-names: "myapp3" > ``, `` can be one of `apache-httpd`, `dotnet`, `go`, `java`, `nginx`, `nodejs` or `python`. -#### Customize Auto-instrumentation +## Customize Auto-instrumentation Below you can find multiple ways in which you can customize the OpenTelemetry Operator Auto-instrumentation. -##### Customize Propagator +### Customize Propagator The propagator specifies how context is injected into and extracted from carriers for distributed tracing. By default, the propagators `tracecontext` (W3C Trace Context) and `baggage` (W3C Correlation Context) are enabled. You can customize this to include other formats ([full list here](https://opentelemetry.io/docs/languages/sdk-configuration/general/#otel_propagators)) or set it to "none" to disable automatic propagation. @@ -101,7 +97,7 @@ You can customize this to include other formats ([full list here](https://opente --set instrumentation.propagator={tracecontext, baggage, b3} ``` -##### Add a custom Sampler +### Add a custom Sampler You can specify a sampler to be used by the instrumentor. You'll need to specify the below: - Sampler used to sample the traces ([available options](https://opentelemetry.io/docs/languages/sdk-configuration/general/#otel_traces_sampler)) - Sampler arguments ([Sampler type expected input](https://opentelemetry.io/docs/languages/sdk-configuration/general/#otel_traces_sampler_arg)) @@ -112,7 +108,7 @@ Example: --set instrumentation.sampler.argument="0.25" ``` -##### Distribute namespaces +### Distribute namespaces For intensive applications, to reduce the performance impact of the operator, you can define multiple namespaces to deploy the instrumentor resource at, which can help distribute the load in larger clusters. To do so, specify which namespaces to deploy the instrumentor at: ```shell @@ -127,7 +123,7 @@ instrumentation.opentelemetry.io/inject-": "true" > [!TIP] > `` can be one of `apache-httpd`, `dotnet`, `go`, `java`, `nginx`, `nodejs` or `python`. -### Custom trace sampling rules +## Custom trace sampling rules To customize the Traces Sampling rules in the OpenTelemetry Collector, you can follow the below steps: - **Step 1**: Create [customized Tail sampling rules configuration](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/tailsamplingprocessor). From 71094c71d34f4a9b10edf17872d5f21025f33e5e Mon Sep 17 00:00:00 2001 From: 8naama Date: Wed, 6 Nov 2024 15:46:37 +0200 Subject: [PATCH 03/15] add manual instrumentation section --- charts/logzio-apm-collector/README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/charts/logzio-apm-collector/README.md b/charts/logzio-apm-collector/README.md index 8d7922cb..f3e843fc 100644 --- a/charts/logzio-apm-collector/README.md +++ b/charts/logzio-apm-collector/README.md @@ -55,6 +55,7 @@ logzio-apm-collector logzio-helm/logzio-apm-collector - [Customize Propagator](#customize-propagator) - [Add a custom Sampler](#add-a-custom-sampler) - [Distribute namespaces](#distribute-namespaces) +- [Manual Instrumentation](#manual-instrumentation) - [Custom Trace Sampling rules](#custom-trace-sampling-rules) ## Enable Auto-instrumentation @@ -123,6 +124,19 @@ instrumentation.opentelemetry.io/inject-": "true" > [!TIP] > `` can be one of `apache-httpd`, `dotnet`, `go`, `java`, `nginx`, `nodejs` or `python`. +## Manual Instrumentation +If you're using manual instrumentation or a custom instrumentation agent, configure it to export data to the Logz.io APM collector by setting the export/output address as follows: + +``` +logzio-monitoring-otel-collector.monitoring.svc.cluster.local:<> +``` + +> [!IMPORTANT] +> Replace `<>` based on the protocol your agent uses: +> - 4317 for GRCP +> - 4318 for HTTP +> For a complete list, see `values.yaml` >> `traceConfig` >> `receivers`. + ## Custom trace sampling rules To customize the Traces Sampling rules in the OpenTelemetry Collector, you can follow the below steps: From f35ffb18140e9f9d1ae5ca8b0f89357f0040116a Mon Sep 17 00:00:00 2001 From: 8naama Date: Wed, 6 Nov 2024 16:36:04 +0200 Subject: [PATCH 04/15] update chart.yaml --- charts/logzio-apm-collector/Chart.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/charts/logzio-apm-collector/Chart.yaml b/charts/logzio-apm-collector/Chart.yaml index 4e719703..e76f258b 100644 --- a/charts/logzio-apm-collector/Chart.yaml +++ b/charts/logzio-apm-collector/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v2 name: logzio-apm-collector -version: 0.0.1 +version: 1.0.0 description: Kubernetes APM agent for Logz.io based on OpenTelemetry Collector type: application home: https://logz.io/ @@ -8,7 +8,7 @@ dependencies: - name: opentelemetry-operator alias: otel-operator version: ~0.71.2 - repository: https://github.com/open-telemetry/opentelemetry-helm-charts + repository: https://open-telemetry.github.io/opentelemetry-helm-charts condition: otel-operator.enabled maintainers: - name: Naama Bendalak From 63aeca62ca4319d76c37a50495d24633e055e23a Mon Sep 17 00:00:00 2001 From: 8naama Date: Sun, 10 Nov 2024 09:49:35 +0200 Subject: [PATCH 05/15] fixes following tests --- charts/logzio-apm-collector/README.md | 2 +- charts/logzio-apm-collector/VALUES.md | 1 + charts/logzio-apm-collector/templates/_config.tpl | 6 +++--- charts/logzio-apm-collector/templates/_helpers.tpl | 7 +++++++ charts/logzio-apm-collector/templates/_pod.tpl | 1 + .../templates/_validations.tpl | 7 ++++--- charts/logzio-apm-collector/templates/hpa.yaml | 1 + .../templates/instrumentation.yaml | 5 +++-- charts/logzio-apm-collector/templates/secret.yaml | 14 ++++++-------- charts/logzio-apm-collector/templates/service.yaml | 4 ++-- charts/logzio-apm-collector/values.yaml | 7 +++++++ 11 files changed, 36 insertions(+), 19 deletions(-) diff --git a/charts/logzio-apm-collector/README.md b/charts/logzio-apm-collector/README.md index f3e843fc..63487a94 100644 --- a/charts/logzio-apm-collector/README.md +++ b/charts/logzio-apm-collector/README.md @@ -26,7 +26,7 @@ The chart provides options for enabling the following: ```shell -helm install logzio-apm-collector -n monitoring \ +helm install -n monitoring --create-namespace \ --set enabled=true \ --set spm.enabled=true \ --set serviceGraph.enabled=true \ diff --git a/charts/logzio-apm-collector/VALUES.md b/charts/logzio-apm-collector/VALUES.md index 762d06ec..8c40e287 100644 --- a/charts/logzio-apm-collector/VALUES.md +++ b/charts/logzio-apm-collector/VALUES.md @@ -7,6 +7,7 @@ Below you can find a complete list of settings in `values.yaml`. | spm.enabled | Toggle for enabling SPM Collection | `false` | | serviceGraph.enabled | Toggle for enabling Service Graph metrics Collection | `false` | | otel-operator.enabled | Toggle for enabling Auto instrumentation with [OpenTelemetry Operator](https://github.com/open-telemetry/opentelemetry-operator) | `false` | +| nameOverride | Override the default name for the deployment. | `""` | | fullnameOverride | Override the default name for the deployment. | `""` | | namespaceOverride | Override the namespace into which the resources will be deployed. | `""` | | secrets.enabled | Toggle for creating and managing the Logz.io secret by this chart. | `"true"` | diff --git a/charts/logzio-apm-collector/templates/_config.tpl b/charts/logzio-apm-collector/templates/_config.tpl index e486737d..44654a1f 100644 --- a/charts/logzio-apm-collector/templates/_config.tpl +++ b/charts/logzio-apm-collector/templates/_config.tpl @@ -48,9 +48,9 @@ {{- if .Values.serviceGraph.enabled }} {{- $spmConfig := deepCopy .Values.spmConfig }} {{- $serviceGraphConfig := deepCopy .Values.serviceGraphConfig }} -{{- $spmConfig.connectors = merge $spmConfig.connectors $serviceGraphConfig.connectors }} -{{- $spmConfig.service.pipelines.traces.exporters = concat $spmConfig.service.pipelines.traces.exporters $serviceGraphConfig.service.pipelines.traces.exporters }} -{{- $spmConfig.service.pipelines.metrics.spm-logzio.receivers = concat $spmConfig.service.pipelines.metrics.spm-logzio.receivers $serviceGraphConfig.service.pipelines.metrics.spm-logzio.receivers }} +// TODO: fix this +{{- $mergedConfig := merge $spmConfig $serviceGraphConfig }} +{{- $mergedConfig | toYaml }} {{- $spmConfig | toYaml }} {{- else }} {{- .Values.spmConfig | toYaml }} diff --git a/charts/logzio-apm-collector/templates/_helpers.tpl b/charts/logzio-apm-collector/templates/_helpers.tpl index 9cb45cf5..998681f4 100644 --- a/charts/logzio-apm-collector/templates/_helpers.tpl +++ b/charts/logzio-apm-collector/templates/_helpers.tpl @@ -1,3 +1,10 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "apm-collector.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + {{/* Create a default fully qualified app name. We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). diff --git a/charts/logzio-apm-collector/templates/_pod.tpl b/charts/logzio-apm-collector/templates/_pod.tpl index 3e0f4ed9..08485a17 100644 --- a/charts/logzio-apm-collector/templates/_pod.tpl +++ b/charts/logzio-apm-collector/templates/_pod.tpl @@ -86,6 +86,7 @@ containers: envFrom: {{- . | toYaml | nindent 6 }} {{- end }} + {{- if .Values.lifecycleHooks }} lifecycle: {{- toYaml .Values.lifecycleHooks | nindent 6 }} {{- end }} diff --git a/charts/logzio-apm-collector/templates/_validations.tpl b/charts/logzio-apm-collector/templates/_validations.tpl index d49c6546..ae04d30b 100644 --- a/charts/logzio-apm-collector/templates/_validations.tpl +++ b/charts/logzio-apm-collector/templates/_validations.tpl @@ -1,8 +1,6 @@ {{/* -This file will contain validations on the input of the chart. -For example, verify the log level is with a valid value +Verify tracing token was provided if the chart is enabled */}} - {{- define "check-tracing-token" -}} {{- if .Values.enabled }} {{- if and (not .Values.global.logzioTracesToken) (not .Values.secrets.logzioTracesToken) }} @@ -11,6 +9,9 @@ For example, verify the log level is with a valid value {{- end }} {{- end -}} +{{/* +Verify SPM token was provided if SPM is enabled +*/}} {{- define "check-spm-token" -}} {{- if and (.Values.enabled) (.Values.spm.enabled) }} {{- if and (not .Values.global.logzioSpmToken) (not .Values.secrets.logzioSpmToken) }} diff --git a/charts/logzio-apm-collector/templates/hpa.yaml b/charts/logzio-apm-collector/templates/hpa.yaml index a20f8ef9..11ad637a 100644 --- a/charts/logzio-apm-collector/templates/hpa.yaml +++ b/charts/logzio-apm-collector/templates/hpa.yaml @@ -36,3 +36,4 @@ spec: type: Utilization averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} {{- end }} +{{- end }} \ No newline at end of file diff --git a/charts/logzio-apm-collector/templates/instrumentation.yaml b/charts/logzio-apm-collector/templates/instrumentation.yaml index b6a66b95..e468cdf2 100644 --- a/charts/logzio-apm-collector/templates/instrumentation.yaml +++ b/charts/logzio-apm-collector/templates/instrumentation.yaml @@ -1,9 +1,10 @@ -{{ if and (.Values.enabled) (.otel-operator.enabled) }} +{{ $operatorEnabled := index .Values "otel-operator" "enabled" }} +{{ if and .Values.enabled $operatorEnabled }} apiVersion: opentelemetry.io/v1alpha1 kind: Instrumentation metadata: name: {{ include "apm-collector.fullname" . }} - namespace: {{ .Values.instrumentation.includeNamespaces | default template "apm-collector.namespace" . }} + namespace: {{ .Values.instrumentation.includeNamespaces | default (include "apm-collector.namespace" .) }} labels: {{- include "apm-collector.labels" . | nindent 4 }} {{- include "apm-collector.component" . | nindent 4 }} diff --git a/charts/logzio-apm-collector/templates/secret.yaml b/charts/logzio-apm-collector/templates/secret.yaml index 6ca2fb8d..41beb156 100644 --- a/charts/logzio-apm-collector/templates/secret.yaml +++ b/charts/logzio-apm-collector/templates/secret.yaml @@ -7,18 +7,16 @@ metadata: namespace: {{ .Release.Namespace }} type: Opaque stringData: - env-id: {{ .Values.global.env_id | default .Values.secrets.env_id | quote }} - logzio-listener-region: {{ .Values.global.logzioRegion | default .Values.secrets.logzioRegion }} + env-id: {{ template "getValueOrDefault" "env_id" | quote }} + logzio-listener-region: {{ template "getValueOrDefault" "logzioRegion" }} {{- template "check-tracing-token" . }} - logzio-traces-token: {{ .Values.global.logzioTracesToken | default .Values.secrets.logzioTracesToken }} - {{- end }} + logzio-traces-token: {{ template "getValueOrDefault" "logzioTracesToken" }} {{- template "check-spm-token" . }} - logzio-spm-token: {{ .Values.global.logzioSpmToken | default .Values.secrets.logzioSpmToken }} - {{- end }} - {{- if .Values.secrets.customEndpoint}} + logzio-spm-token: {{ template "getValueOrDefault" "logzioSpmToken" }} + {{- if .Values.secrets.customTracesEndpoint}} custom-traces-endpoint: {{ .Values.secrets.customTracesEndpoint }} {{- end }} - {{- if .Values.secrets.customEndpoint}} + {{- if .Values.secrets.customSpmEndpoint}} custom-spm-endpoint: {{ .Values.secrets.customSpmEndpoint }} {{- end }} {{- end }} diff --git a/charts/logzio-apm-collector/templates/service.yaml b/charts/logzio-apm-collector/templates/service.yaml index fa70cae9..de75bb9b 100644 --- a/charts/logzio-apm-collector/templates/service.yaml +++ b/charts/logzio-apm-collector/templates/service.yaml @@ -1,6 +1,6 @@ # A basic manifest for creating a service endpoint for your deployment {{ if .Values.enabled }} -{{- if .service.enabled }} +{{- if .Values.service.enabled }} apiVersion: v1 kind: Service metadata: @@ -36,7 +36,7 @@ spec: {{- end }} selector: {{- include "apm-collector.selectorLabels" . | nindent 4 }} - internalTrafficPolicy: {{ .service.internalTrafficPolicy | default "Cluster" }} + internalTrafficPolicy: {{ .Values.service.internalTrafficPolicy | default "Cluster" }} {{- if and (eq .Values.service.type "LoadBalancer") (.Values.service.externalTrafficPolicy) }} externalTrafficPolicy: {{ .Values.service.externalTrafficPolicy | default "Cluster" }} {{- end }} diff --git a/charts/logzio-apm-collector/values.yaml b/charts/logzio-apm-collector/values.yaml index d265907a..f459a926 100644 --- a/charts/logzio-apm-collector/values.yaml +++ b/charts/logzio-apm-collector/values.yaml @@ -18,7 +18,14 @@ serviceGraph: otel-operator: enabled: false + # Deploying the collector using the operator is not supported currently. + # The collector image is specified to meet operator subchart requirments. + manager: + collectorImage: + repository: "otel/opentelemetry-collector-contrib" + # Specifies a custom name for the chart's resources +nameOverride: "" fullnameOverride: "" namespaceOverride: "" From eb81be779d3fa6cec1095f0676124906b25bc10c Mon Sep 17 00:00:00 2001 From: 8naama Date: Tue, 19 Nov 2024 13:29:36 +0200 Subject: [PATCH 06/15] chnages following testing --- charts/logzio-apm-collector/Chart.yaml | 5 ++++ .../templates/_config.tpl | 12 +++++----- .../templates/_helpers-spm.tpl | 2 +- .../templates/_helpers.tpl | 23 +++++++++++++++---- .../templates/_pod-spm.tpl | 2 -- .../logzio-apm-collector/templates/_pod.tpl | 6 ++--- .../templates/_validations.tpl | 16 ++++++++----- .../templates/configmap-spm.yaml | 2 +- .../templates/secret.yaml | 10 ++++---- charts/logzio-apm-collector/values.yaml | 9 +++++--- 10 files changed, 55 insertions(+), 32 deletions(-) diff --git a/charts/logzio-apm-collector/Chart.yaml b/charts/logzio-apm-collector/Chart.yaml index e76f258b..6213f108 100644 --- a/charts/logzio-apm-collector/Chart.yaml +++ b/charts/logzio-apm-collector/Chart.yaml @@ -5,6 +5,11 @@ description: Kubernetes APM agent for Logz.io based on OpenTelemetry Collector type: application home: https://logz.io/ dependencies: + - name: cert-manager + version: ~v1.16.1 + alias: certmanager + repository: https://charts.jetstack.io + condition: certmanager.enabled - name: opentelemetry-operator alias: otel-operator version: ~0.71.2 diff --git a/charts/logzio-apm-collector/templates/_config.tpl b/charts/logzio-apm-collector/templates/_config.tpl index 44654a1f..83fb686c 100644 --- a/charts/logzio-apm-collector/templates/_config.tpl +++ b/charts/logzio-apm-collector/templates/_config.tpl @@ -28,9 +28,9 @@ {{- if and $.isAgent $port.hostPort }} hostPort: {{ $port.hostPort }} {{- end }} -{{- end }} -{{- end }} -{{- end }} +{{- end -}} +{{- end -}} +{{- end -}} {{/* Build config file for APM Collector */}} {{- define "apm-collector.config" -}} @@ -48,10 +48,10 @@ {{- if .Values.serviceGraph.enabled }} {{- $spmConfig := deepCopy .Values.spmConfig }} {{- $serviceGraphConfig := deepCopy .Values.serviceGraphConfig }} -// TODO: fix this -{{- $mergedConfig := merge $spmConfig $serviceGraphConfig }} +{{- $mergedConfig := merge $spmConfig $serviceGraphConfig }} +{{- $_ := set (index $mergedConfig "service" "pipelines" "metrics/spm-logzio") "receivers" (concat (index $mergedConfig "service" "pipelines" "metrics/spm-logzio" "receivers") (index $serviceGraphConfig "service" "pipelines" "metrics/spm-logzio" "receivers" )) -}} +{{- $_ := set (index $mergedConfig "service" "pipelines" "traces") "exporters" (concat (index $mergedConfig "service" "pipelines" "traces" "exporters") (index $serviceGraphConfig "service" "pipelines" "traces" "exporters" )) -}} {{- $mergedConfig | toYaml }} -{{- $spmConfig | toYaml }} {{- else }} {{- .Values.spmConfig | toYaml }} {{- end }} diff --git a/charts/logzio-apm-collector/templates/_helpers-spm.tpl b/charts/logzio-apm-collector/templates/_helpers-spm.tpl index 4353fe6f..59bab8df 100644 --- a/charts/logzio-apm-collector/templates/_helpers-spm.tpl +++ b/charts/logzio-apm-collector/templates/_helpers-spm.tpl @@ -35,5 +35,5 @@ The SPM service address */}} {{- define "spm-collector.serviceAddr" -}} {{- $serviceName := include "spm-collector.fullname" .}} -{{ printf "http://%s.%s.svc.cluster.local:4317" $serviceName .Release.Namespace }} +{{- printf "http://%s.%s.svc.cluster.local:4317" $serviceName .Release.Namespace }} {{- end }} diff --git a/charts/logzio-apm-collector/templates/_helpers.tpl b/charts/logzio-apm-collector/templates/_helpers.tpl index 998681f4..3c148613 100644 --- a/charts/logzio-apm-collector/templates/_helpers.tpl +++ b/charts/logzio-apm-collector/templates/_helpers.tpl @@ -85,10 +85,10 @@ app.kubernetes.io/managed-by: {{ .Release.Service }} {{/* Custom pod annotations */}} {{- define "apm-collector.podAnnotations" -}} -{{- if .Values.podAnnotations }} +{{- if .Values.podAnnotations -}} {{- tpl (.Values.podAnnotations | toYaml) . }} -{{- end }} -{{- end }} +{{- end -}} +{{- end -}} {{/*Custom pod labels */}} {{- define "apm-collector.podLabels" -}} @@ -144,5 +144,20 @@ The APM service address */}} {{- define "apm-collector.serviceAddr" -}} {{- $serviceName := include "apm-collector.fullname" .}} -{{ printf "http://%s.%s.svc.cluster.local" $serviceName .Release.Namespace }} +{{- printf "http://%s.%s.svc.cluster.local" $serviceName .Release.Namespace }} {{- end }} + + +{{/* +Get secret value either from the global section (parent chart is running) or the default sub chart section +*/}} +{{- define "getGlobalOrDefaultValue" -}} +{{- $ctx := index . 0 -}} +{{- $key := index . 1 -}} +{{- $fallback := index . 2 -}} +{{- if hasKey $ctx.Values "global" -}} + {{- $ctx.Values.global | default dict | get $key | default $fallback -}} +{{- else -}} + {{- $fallback -}} +{{- end -}} +{{- end -}} diff --git a/charts/logzio-apm-collector/templates/_pod-spm.tpl b/charts/logzio-apm-collector/templates/_pod-spm.tpl index be666fcd..abc4b80b 100644 --- a/charts/logzio-apm-collector/templates/_pod-spm.tpl +++ b/charts/logzio-apm-collector/templates/_pod-spm.tpl @@ -44,7 +44,6 @@ containers: valueFrom: fieldRef: fieldPath: spec.nodeName - {{- if .Values.secrets.enabled }} - name: ENV_ID valueFrom: secretKeyRef: @@ -64,7 +63,6 @@ containers: secretKeyRef: name: {{ .Values.secrets.name }} key: logzio-spm-token - {{- end }} - name: LOG_LEVEL value: {{ .Values.otelLogLevel | default "info" | quote }} {{- with .Values.extraEnvs }} diff --git a/charts/logzio-apm-collector/templates/_pod.tpl b/charts/logzio-apm-collector/templates/_pod.tpl index 08485a17..571249a3 100644 --- a/charts/logzio-apm-collector/templates/_pod.tpl +++ b/charts/logzio-apm-collector/templates/_pod.tpl @@ -31,7 +31,7 @@ containers: {{- $ports := include "apm-collector.podPortsConfig" . }} {{- if $ports }} ports: - {{- $ports | nindent 6}} + {{- $ports | nindent 6 }} {{- end }} env: - name: MY_POD_IP @@ -44,8 +44,7 @@ containers: fieldRef: fieldPath: spec.nodeName - name: SPM_SERVICE_ENDPOINT - value: {{ include "spm-collector.serviceAddr" . }} - {{- if .Values.secrets.enabled }} + value: {{ include "spm-collector.serviceAddr" . | quote }} - name: ENV_ID valueFrom: secretKeyRef: @@ -68,7 +67,6 @@ containers: name: {{ .Values.secrets.name }} key: custom-traces-endpoint {{- end }} - {{- end }} - name: LOG_LEVEL value: {{ .Values.otelLogLevel | default "info" | quote }} - name: SAMPLING_LATENCY diff --git a/charts/logzio-apm-collector/templates/_validations.tpl b/charts/logzio-apm-collector/templates/_validations.tpl index ae04d30b..f02bdad1 100644 --- a/charts/logzio-apm-collector/templates/_validations.tpl +++ b/charts/logzio-apm-collector/templates/_validations.tpl @@ -3,19 +3,23 @@ Verify tracing token was provided if the chart is enabled */}} {{- define "check-tracing-token" -}} {{- if .Values.enabled }} - {{- if and (not .Values.global.logzioTracesToken) (not .Values.secrets.logzioTracesToken) }} - {{- fail "Missing Tracing Token" }} + {{- $hasGlobalToken := and (hasKey .Values "global") .Values.global.logzioTracesToken -}} + {{- $hasSecretsToken := .Values.secrets.logzioTracesToken -}} + {{- if not (or $hasGlobalToken $hasSecretsToken) }} + {{- fail "Missing Tracing Token" }} {{- end }} {{- end }} -{{- end -}} +{{- end }} {{/* Verify SPM token was provided if SPM is enabled */}} {{- define "check-spm-token" -}} {{- if and (.Values.enabled) (.Values.spm.enabled) }} - {{- if and (not .Values.global.logzioSpmToken) (not .Values.secrets.logzioSpmToken) }} - {{- fail "Missing SPM Token" }} + {{- $hasGlobalToken := and (hasKey .Values "global") .Values.global.logzioSpmToken -}} + {{- $hasSecretsToken := .Values.secrets.logzioSpmToken -}} + {{- if not (or $hasGlobalToken $hasSecretsToken) }} + {{- fail "Missing SPM Token" }} {{- end }} {{- end }} -{{- end -}} +{{- end }} diff --git a/charts/logzio-apm-collector/templates/configmap-spm.yaml b/charts/logzio-apm-collector/templates/configmap-spm.yaml index d9b79864..364e29b5 100644 --- a/charts/logzio-apm-collector/templates/configmap-spm.yaml +++ b/charts/logzio-apm-collector/templates/configmap-spm.yaml @@ -1,4 +1,4 @@ -{{ if .Values.enabled }} +{{ if and (.Values.enabled) (.Values.spm.enabled) }} {{- if .Values.configMap.create }} apiVersion: v1 kind: ConfigMap diff --git a/charts/logzio-apm-collector/templates/secret.yaml b/charts/logzio-apm-collector/templates/secret.yaml index 41beb156..19fc02f3 100644 --- a/charts/logzio-apm-collector/templates/secret.yaml +++ b/charts/logzio-apm-collector/templates/secret.yaml @@ -7,13 +7,13 @@ metadata: namespace: {{ .Release.Namespace }} type: Opaque stringData: - env-id: {{ template "getValueOrDefault" "env_id" | quote }} - logzio-listener-region: {{ template "getValueOrDefault" "logzioRegion" }} + env-id: {{ include "getGlobalOrDefaultValue" (list . "env_id" .Values.secrets.env_id) | quote }} + logzio-listener-region: {{ include "getGlobalOrDefaultValue" (list . "logzioRegion" .Values.secrets.logzioRegion) }} {{- template "check-tracing-token" . }} - logzio-traces-token: {{ template "getValueOrDefault" "logzioTracesToken" }} + logzio-traces-token: {{ include "getGlobalOrDefaultValue" (list . "logzioTracesToken" .Values.secrets.logzioTracesToken) }} {{- template "check-spm-token" . }} - logzio-spm-token: {{ template "getValueOrDefault" "logzioSpmToken" }} - {{- if .Values.secrets.customTracesEndpoint}} + logzio-spm-token: {{ include "getGlobalOrDefaultValue" (list . "logzioSpmToken" .Values.secrets.logzioSpmToken) }} + {{- if .Values.secrets.customTracesEndpoint }} custom-traces-endpoint: {{ .Values.secrets.customTracesEndpoint }} {{- end }} {{- if .Values.secrets.customSpmEndpoint}} diff --git a/charts/logzio-apm-collector/values.yaml b/charts/logzio-apm-collector/values.yaml index f459a926..f3b88603 100644 --- a/charts/logzio-apm-collector/values.yaml +++ b/charts/logzio-apm-collector/values.yaml @@ -35,8 +35,11 @@ namespaceOverride: "" secrets: # When secrets.enabled is true, the logzio secret will be created and managed by this Chart. # If you're managing the logzio secrets by yourself, set to false. - # Note that in order for the default configuration to work properly, you need to create the following env variables: - # ENV_ID, LOGZIO_TRACES_TOKEN, LOGZIO_SPM_TOKEN, LOGZIO_REGION, LOGZIO_LISTENER + # Note that in order for the default configuration to work properly, you need to: + # 1. Update secrets.name to your custom secret name + # 2. Include these keys in your secret: env-id, logzio-listener-region, logzio-traces-token, logzio-spm-token + # To use a custom endpoint, include custom-traces-endpoint, custom-spm-endpoint or both parameters in your secret, + # depending on your needs and set secrets.customTracesEndpoint and/or secrets.customSpmEndpoint to `true`. enabled: true name: logzio-apm-collector-secret # environment identifier attribute that will be added to all telemetry @@ -47,7 +50,7 @@ secrets: logzioSpmToken: "" # Logz.io region code logzioRegion: "us" - # Overrides secrets.LogzioRegion listener address with a custom endpoint. For example: http://endpoint:8080 + # Optional - Overrides secrets.LogzioRegion listener address with a custom endpoint. For example: http://endpoint:8080 customTracesEndpoint: "" customSpmEndpoint: "" From f3c6981849a3a9e6f4c1331c37a98062a6c5e68c Mon Sep 17 00:00:00 2001 From: 8naama Date: Wed, 20 Nov 2024 16:40:36 +0200 Subject: [PATCH 07/15] fixes following tests --- charts/logzio-apm-collector/Chart.yaml | 5 -- .../templates/_helpers-spm.tpl | 6 +- .../templates/_helpers.tpl | 7 ++ .../templates/_pod-spm.tpl | 4 +- .../logzio-apm-collector/templates/_pod.tpl | 8 +- .../templates/configmap-spm.yaml | 3 +- .../templates/configmap.yaml | 3 +- .../templates/instrumentation.yaml | 3 +- charts/logzio-apm-collector/values.yaml | 87 ++++++++++++++++++- 9 files changed, 108 insertions(+), 18 deletions(-) diff --git a/charts/logzio-apm-collector/Chart.yaml b/charts/logzio-apm-collector/Chart.yaml index 6213f108..e76f258b 100644 --- a/charts/logzio-apm-collector/Chart.yaml +++ b/charts/logzio-apm-collector/Chart.yaml @@ -5,11 +5,6 @@ description: Kubernetes APM agent for Logz.io based on OpenTelemetry Collector type: application home: https://logz.io/ dependencies: - - name: cert-manager - version: ~v1.16.1 - alias: certmanager - repository: https://charts.jetstack.io - condition: certmanager.enabled - name: opentelemetry-operator alias: otel-operator version: ~0.71.2 diff --git a/charts/logzio-apm-collector/templates/_helpers-spm.tpl b/charts/logzio-apm-collector/templates/_helpers-spm.tpl index 59bab8df..4206bb90 100644 --- a/charts/logzio-apm-collector/templates/_helpers-spm.tpl +++ b/charts/logzio-apm-collector/templates/_helpers-spm.tpl @@ -22,11 +22,11 @@ component: spm-collector Create Logz.io listener address based on region */}} {{- define "spm-collector.listenerAddress" -}} -{{- $region := .Values.secrets.logzioRegion }} -{{- if or (eq $region "us") (not $region) }} +{{- $region := .Values.secrets.logzioRegion -}} +{{- if or (eq $region "us") (not $region) -}} https://listener.logz.io:8053 {{- else }} -{{ printf "https://listener-%s.logz.io:8053" $region }} +{{- printf "https://listener-%s.logz.io:8053" $region }} {{- end }} {{- end }} diff --git a/charts/logzio-apm-collector/templates/_helpers.tpl b/charts/logzio-apm-collector/templates/_helpers.tpl index 3c148613..7758cdee 100644 --- a/charts/logzio-apm-collector/templates/_helpers.tpl +++ b/charts/logzio-apm-collector/templates/_helpers.tpl @@ -161,3 +161,10 @@ Get secret value either from the global section (parent chart is running) or the {{- $fallback -}} {{- end -}} {{- end -}} + + +{{/* Helm hooks annotations for otel operator */}} +{{- define "apm-collector.otelOpAnnotations" -}} +helm.sh/hook: "post-install, post-upgrade" +helm.sh/hook-delete-policy: "before-hook-creation, hook-succeeded" +{{- end -}} diff --git a/charts/logzio-apm-collector/templates/_pod-spm.tpl b/charts/logzio-apm-collector/templates/_pod-spm.tpl index abc4b80b..f5aaa777 100644 --- a/charts/logzio-apm-collector/templates/_pod-spm.tpl +++ b/charts/logzio-apm-collector/templates/_pod-spm.tpl @@ -23,7 +23,6 @@ containers: securityContext: {{- toYaml .Values.containerSecurityContext | nindent 6 }} {{- if .Values.image.digest }} - {{- if .Values.image.digest }} image: "{{ .Values.image.repository }}@{{ .Values.image.digest }}" {{- else }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" @@ -56,7 +55,7 @@ containers: name: {{ .Values.secrets.name }} key: custom-spm-endpoint {{- else }} - value: {{ include "spm-collector.listenerAddress" . }} + value: {{ include "spm-collector.listenerAddress" . | quote }} {{- end }} - name: LOGZIO_SPM_TOKEN valueFrom: @@ -72,6 +71,7 @@ containers: envFrom: {{- . | toYaml | nindent 6 }} {{- end }} + {{- if .Values.lifecycleHooks }} lifecycle: {{- toYaml .Values.lifecycleHooks | nindent 6 }} {{- end }} diff --git a/charts/logzio-apm-collector/templates/_pod.tpl b/charts/logzio-apm-collector/templates/_pod.tpl index 571249a3..e89375fe 100644 --- a/charts/logzio-apm-collector/templates/_pod.tpl +++ b/charts/logzio-apm-collector/templates/_pod.tpl @@ -60,8 +60,8 @@ containers: secretKeyRef: name: {{ .Values.secrets.name }} key: logzio-traces-token - {{- if .Values.secrets.customEndpoint }} - - name: CUSTOM_ENDPOINT + {{- if .Values.secrets.customTracesEndpoint }} + - name: CUSTOM_TRACES_ENDPOINT valueFrom: secretKeyRef: name: {{ .Values.secrets.name }} @@ -70,9 +70,9 @@ containers: - name: LOG_LEVEL value: {{ .Values.otelLogLevel | default "info" | quote }} - name: SAMPLING_LATENCY - value: {{ .Values.SamplingLatency | default 10 }} + value: {{ .Values.SamplingLatency | default 10 | quote}} - name: SAMPLING_PROBABILITY - value: {{ .Values.SamplingProbability | default 500 }} + value: {{ .Values.SamplingProbability | default 500 | quote }} {{- if and (.Values.useGOMEMLIMIT) (((.Values.resources).limits).memory) }} - name: GOMEMLIMIT value: {{ include "apm-collector.gomemlimit" .Values.resources.limits.memory | quote }} diff --git a/charts/logzio-apm-collector/templates/configmap-spm.yaml b/charts/logzio-apm-collector/templates/configmap-spm.yaml index 364e29b5..294593cb 100644 --- a/charts/logzio-apm-collector/templates/configmap-spm.yaml +++ b/charts/logzio-apm-collector/templates/configmap-spm.yaml @@ -7,6 +7,7 @@ metadata: namespace: {{ template "apm-collector.namespace" . }} labels: {{- include "apm-collector.labels" . | nindent 4 }} data: - relay: {{ include "spm-collector.config" . | nindent 4 }} + relay: | + {{- include "spm-collector.config" . | nindent 4 }} {{- end }} {{ end }} diff --git a/charts/logzio-apm-collector/templates/configmap.yaml b/charts/logzio-apm-collector/templates/configmap.yaml index 99c7fcd9..2458f4df 100644 --- a/charts/logzio-apm-collector/templates/configmap.yaml +++ b/charts/logzio-apm-collector/templates/configmap.yaml @@ -7,6 +7,7 @@ metadata: namespace: {{ template "apm-collector.namespace" . }} labels: {{- include "apm-collector.labels" . | nindent 4 }} data: - relay: {{ include "apm-collector.config" . | nindent 4 }} + relay: | + {{- include "apm-collector.config" . | nindent 4 }} {{- end }} {{ end }} diff --git a/charts/logzio-apm-collector/templates/instrumentation.yaml b/charts/logzio-apm-collector/templates/instrumentation.yaml index e468cdf2..c128385d 100644 --- a/charts/logzio-apm-collector/templates/instrumentation.yaml +++ b/charts/logzio-apm-collector/templates/instrumentation.yaml @@ -8,8 +8,9 @@ metadata: labels: {{- include "apm-collector.labels" . | nindent 4 }} {{- include "apm-collector.component" . | nindent 4 }} - {{- if .Values.annotations }} annotations: + {{- include "apm-collector.otelOpAnnotations" . | nindent 4 }} + {{- if .Values.annotations }} {{- range $key, $value := .Values.annotations }} {{- printf "%s: %s" $key (tpl $value $ | quote) | nindent 4 }} {{- end }} diff --git a/charts/logzio-apm-collector/values.yaml b/charts/logzio-apm-collector/values.yaml index f3b88603..25203772 100644 --- a/charts/logzio-apm-collector/values.yaml +++ b/charts/logzio-apm-collector/values.yaml @@ -18,6 +18,16 @@ serviceGraph: otel-operator: enabled: false + # Ensure certificate and issuer are created after the CRDs are installed + admissionWebhooks: + certManager: + certificateAnnotations: + helm.sh/hook: "post-install, post-upgrade" + helm.sh/hook-delete-policy: "before-hook-creation, hook-succeeded" + issuerAnnotations: + helm.sh/hook: "post-install, post-upgrade" + helm.sh/hook-delete-policy: "before-hook-creation, hook-succeeded" + # Deploying the collector using the operator is not supported currently. # The collector image is specified to meet operator subchart requirments. manager: @@ -74,7 +84,7 @@ standaloneCollector: traceConfig: exporters: logzio: - endpoint: ${CUSTOM_ENDPOINT} + endpoint: ${CUSTOM_TRACES_ENDPOINT} region: ${LOGZIO_REGION} account_token: ${LOGZIO_TRACES_TOKEN} headers: @@ -84,6 +94,8 @@ traceConfig: endpoint: :1777 zpages: endpoint: :55679 + health_check: + endpoint: :13133 receivers: jaeger: protocols: @@ -125,6 +137,79 @@ traceConfig: probabilistic: {sampling_percentage: "${SAMPLING_PROBABILITY}" } } ] + k8sattributes: + extract: + metadata: + - k8s.pod.name + - k8s.deployment.name + - k8s.namespace.name + - k8s.node.name + - k8s.statefulset.name + - k8s.replicaset.name + - k8s.daemonset.name + - k8s.cronjob.name + - k8s.job.name + resource/k8s: + attributes: + # Rename fields + - key: pod + action: insert + from_attribute: k8s.pod.name + - key: kubernetes_node + action: insert + from_attribute: k8s.node.name + - key: kubernetes_namespace + action: insert + from_attribute: k8s.namespace.name + - key: kubernetes_deployment + action: insert + from_attribute: k8s.deployment.name + - key: kubernetes_pod_ip + action: insert + from_attribute: k8s.pod.ip + - key: kubernetes_statefulset + action: insert + from_attribute: k8s.statefulset.name + - key: kubernetes_replicaset + action: insert + from_attribute: k8s.replicaset.name + - key: kubernetes_cronjob + action: insert + from_attribute: k8s.cronjob.name + - key: kubernetes_daemonset + action: insert + from_attribute: k8s.daemonset.name + - key: kubernetes_job + action: insert + from_attribute: k8s.job.name + # Delete old + - key: k8s.deployment.name + action: delete + - key: k8s.pod.name + action: delete + - key: k8s.namespace.name + action: delete + - key: k8s.node.name + action: delete + - key: k8s.pod.ip + action: delete + - key: k8s.statefulset.name + action: delete + - key: k8s.replicaset.name + action: delete + - key: k8s.daemonset.name + action: delete + - key: k8s.job.name + action: delete + - key: k8s.cronjob.name + action: delete + attributes/env_id: + # Add env_id to all spans + actions: + - key: env_id + value: ${ENV_ID} + action: insert + batch: {} service: extensions: [health_check, pprof, zpages] pipelines: From 860269f1686098809430638846cd1ad6178fdf94 Mon Sep 17 00:00:00 2001 From: 8naama Date: Thu, 21 Nov 2024 14:48:31 +0200 Subject: [PATCH 08/15] add tls explanation --- charts/logzio-apm-collector/Chart.yaml | 2 +- charts/logzio-apm-collector/values.yaml | 47 ++++++++++++++++++++++++- 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/charts/logzio-apm-collector/Chart.yaml b/charts/logzio-apm-collector/Chart.yaml index e76f258b..c753dfc7 100644 --- a/charts/logzio-apm-collector/Chart.yaml +++ b/charts/logzio-apm-collector/Chart.yaml @@ -7,7 +7,7 @@ home: https://logz.io/ dependencies: - name: opentelemetry-operator alias: otel-operator - version: ~0.71.2 + version: ~0.74.2 repository: https://open-telemetry.github.io/opentelemetry-helm-charts condition: otel-operator.enabled maintainers: diff --git a/charts/logzio-apm-collector/values.yaml b/charts/logzio-apm-collector/values.yaml index 25203772..4377b439 100644 --- a/charts/logzio-apm-collector/values.yaml +++ b/charts/logzio-apm-collector/values.yaml @@ -18,15 +18,60 @@ serviceGraph: otel-operator: enabled: false - # Ensure certificate and issuer are created after the CRDs are installed + # Openteleemtry operator requires a TLS certificate. + # ref: https://github.com/open-telemetry/opentelemetry-helm-charts/tree/main/charts/opentelemetry-operator#tls-certificate-requirement admissionWebhooks: + # TLS certificate Option 1 + # If you have cert-manager installed on your cluster, you can set `certManager.enabled` to true + # and the cert-manager will generate a self-signed certificate for the otel-operator automatically. certManager: + enabled: false + + # Ensure certificate and issuer are created after the CRDs are installed certificateAnnotations: helm.sh/hook: "post-install, post-upgrade" helm.sh/hook-delete-policy: "before-hook-creation, hook-succeeded" issuerAnnotations: helm.sh/hook: "post-install, post-upgrade" helm.sh/hook-delete-policy: "before-hook-creation, hook-succeeded" + + ## Provide the issuer kind and name to do the cert auth job. + ## By default, OpenTelemetry Operator will use self-signer issuer. + # issuerRef: {} + # kind: + # name: + + ## Annotations for the cert and issuer if cert-manager is enabled. + # certificateAnnotations: {} + # issuerAnnotations: {} + + # duration must be specified by a Go time.Duration (ending in s, m or h) + # duration: "" + + # renewBefore must be specified by a Go time.Duration (ending in s, m or h) + # Take care when setting the renewBefore field to be very close to the duration + # as this can lead to a renewal loop, where the Certificate is always in the renewal period. + # renewBefore: "" + + # TLS certificate Option 2 + # The default option enabled by this chart. Helm will automatically create a self-signed cert and secret for you. + autoGenerateCert: + enabled: true + # If set to true, new webhook key/certificate is generated on helm upgrade. + # recreate: true + + # Cert period time in days. The default is 365 days. + # certPeriodDays: 365 + + ## TLS certificate Option 3 + # Use your own self-signed certificate + # To enable this option, set `autoGenerateCert.enabled` to false and provide the necessary values: + ## Path to your own PEM-encoded certificate. + # certFile: "" + ## Path to your own PEM-encoded private key. + # keyFile: "" + ## Path to the CA cert. + # caFile: "" # Deploying the collector using the operator is not supported currently. # The collector image is specified to meet operator subchart requirments. From be6216a270bb6ff212392aeb75e3bd179f09f28f Mon Sep 17 00:00:00 2001 From: 8naama Date: Tue, 26 Nov 2024 17:38:49 +0200 Subject: [PATCH 09/15] changes following tests --- charts/logzio-apm-collector/Chart.yaml | 2 +- charts/logzio-apm-collector/templates/_config.tpl | 8 ++++---- charts/logzio-apm-collector/templates/_helpers.tpl | 2 -- charts/logzio-apm-collector/values.yaml | 8 ++++++++ 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/charts/logzio-apm-collector/Chart.yaml b/charts/logzio-apm-collector/Chart.yaml index c753dfc7..85e2dce9 100644 --- a/charts/logzio-apm-collector/Chart.yaml +++ b/charts/logzio-apm-collector/Chart.yaml @@ -13,4 +13,4 @@ dependencies: maintainers: - name: Naama Bendalak email: naama.bendalak@logz.io -appVersion: 0.110.0 +appVersion: 0.113.0 diff --git a/charts/logzio-apm-collector/templates/_config.tpl b/charts/logzio-apm-collector/templates/_config.tpl index 83fb686c..3175483c 100644 --- a/charts/logzio-apm-collector/templates/_config.tpl +++ b/charts/logzio-apm-collector/templates/_config.tpl @@ -37,9 +37,9 @@ {{- if .Values.spm.enabled }} {{- $tracesConfig := deepCopy .Values.traceConfig }} {{- $spmForwarderConfig := deepCopy .Values.spmForwarderConfig }} -{{- ($tracesConfig | merge $spmForwarderConfig | mustMergeOverwrite) | toYaml }} +{{- tpl (($tracesConfig | merge $spmForwarderConfig | mustMergeOverwrite) | toYaml) . }} {{- else }} -{{- .Values.traceConfig | toYaml }} +{{- tpl (.Values.traceConfig | toYaml) . }} {{- end}} {{- end }} @@ -51,8 +51,8 @@ {{- $mergedConfig := merge $spmConfig $serviceGraphConfig }} {{- $_ := set (index $mergedConfig "service" "pipelines" "metrics/spm-logzio") "receivers" (concat (index $mergedConfig "service" "pipelines" "metrics/spm-logzio" "receivers") (index $serviceGraphConfig "service" "pipelines" "metrics/spm-logzio" "receivers" )) -}} {{- $_ := set (index $mergedConfig "service" "pipelines" "traces") "exporters" (concat (index $mergedConfig "service" "pipelines" "traces" "exporters") (index $serviceGraphConfig "service" "pipelines" "traces" "exporters" )) -}} -{{- $mergedConfig | toYaml }} +{{- tpl ($mergedConfig | toYaml) . }} {{- else }} -{{- .Values.spmConfig | toYaml }} +{{- tpl (.Values.spmConfig | toYaml) . }} {{- end }} {{- end }} diff --git a/charts/logzio-apm-collector/templates/_helpers.tpl b/charts/logzio-apm-collector/templates/_helpers.tpl index 7758cdee..606597c3 100644 --- a/charts/logzio-apm-collector/templates/_helpers.tpl +++ b/charts/logzio-apm-collector/templates/_helpers.tpl @@ -147,7 +147,6 @@ The APM service address {{- printf "http://%s.%s.svc.cluster.local" $serviceName .Release.Namespace }} {{- end }} - {{/* Get secret value either from the global section (parent chart is running) or the default sub chart section */}} @@ -162,7 +161,6 @@ Get secret value either from the global section (parent chart is running) or the {{- end -}} {{- end -}} - {{/* Helm hooks annotations for otel operator */}} {{- define "apm-collector.otelOpAnnotations" -}} helm.sh/hook: "post-install, post-upgrade" diff --git a/charts/logzio-apm-collector/values.yaml b/charts/logzio-apm-collector/values.yaml index 4377b439..98916b97 100644 --- a/charts/logzio-apm-collector/values.yaml +++ b/charts/logzio-apm-collector/values.yaml @@ -73,6 +73,10 @@ otel-operator: ## Path to the CA cert. # caFile: "" + # The OpenTelemetry Operator webhook service may not always be ready in time, causing an error. + # to retry, we set `failurePolicy` to `ignore`. To block the operation if it fails, set to `Fail`. + failurePolicy: Ignore + # Deploying the collector using the operator is not supported currently. # The collector image is specified to meet operator subchart requirments. manager: @@ -290,6 +294,9 @@ spmConfig: user-agent: "{{ .Chart.Name }}-{{ .Chart.Version }}-helm" timeout: 30s # Time to wait per attempt to send data add_metric_suffixes: false + extensions: + health_check: + endpoint: :13133 receivers: otlp: protocols: @@ -359,6 +366,7 @@ spmConfig: - telemetry.sdk.language - telemetry.sdk.name service: + extensions: [health_check] pipelines: traces: receivers: [otlp] From 0ccf633305f39512dda95e8e18e168adbd7dfbb9 Mon Sep 17 00:00:00 2001 From: 8naama Date: Wed, 27 Nov 2024 13:23:51 +0200 Subject: [PATCH 10/15] add tls certificate to readme --- charts/logzio-apm-collector/README.md | 27 +++- charts/logzio-apm-collector/VALUES.md | 186 ++++++++++++++------------ 2 files changed, 126 insertions(+), 87 deletions(-) diff --git a/charts/logzio-apm-collector/README.md b/charts/logzio-apm-collector/README.md index 63487a94..fec69acc 100644 --- a/charts/logzio-apm-collector/README.md +++ b/charts/logzio-apm-collector/README.md @@ -2,7 +2,8 @@ > [!IMPORTANT] > Kubernetes APM Collection Agent is still In development -This Helm chart deploys an agent, which leverages the OpenTelemetry Collector, that collects traces and span metrics from Kubernetes clusters and sends them to Logz.io +This Helm chart deploys an agent, which leverages the OpenTelemetry Collector, that collects traces and span metrics from Kubernetes clusters and sends them to Logz.io. +It also allows enabling Service graph metrics and supports adding Auto instrumentation to the cluster applications via Opentelemetry Operator. ## Prerequisites - Kubernetes 1.24+ @@ -55,6 +56,7 @@ logzio-apm-collector logzio-helm/logzio-apm-collector - [Customize Propagator](#customize-propagator) - [Add a custom Sampler](#add-a-custom-sampler) - [Distribute namespaces](#distribute-namespaces) + - [TLS certificate Requirements](#tls-certificate-requirements) - [Manual Instrumentation](#manual-instrumentation) - [Custom Trace Sampling rules](#custom-trace-sampling-rules) @@ -124,6 +126,28 @@ instrumentation.opentelemetry.io/inject-": "true" > [!TIP] > `` can be one of `apache-httpd`, `dotnet`, `go`, `java`, `nginx`, `nodejs` or `python`. +### TLS certificate Requirements +Openteleemtry operator requires a TLS certificate. For more details, refer to [OpenTelemetry documentation](https://github.com/open-telemetry/opentelemetry-helm-charts/tree/main/charts/opentelemetry-operator#tls-certificate-requirement). + +There are 3 TLS certificate options, by default this chart is using option 2. + +1. If you have `cert-manager` installed on your cluster, you can set `otel-operator.admissionWebhooks.certManager.enabled` to true and the cert-manager will generate a self-signed certificate for the otel-operator automatically. + +```shell +--set otel-operator.admissionWebhooks.certManager.enabled=true \ +``` + +2. Helm will automatically create a self-signed cert and secret for you. (Enabled by default by this chart) + +3. Use your own self-signed certificate, To enable this option, set `otel-operator.admissionWebhooks.autoGenerateCert.enabled` to `false` and provide the necessary `certFile`, `keyFile` and `caFile`. + +```shell +--set otel-operator.admissionWebhooks.autoGenerateCert.enabled=false \ +--set otel-operator.admissionWebhooks.certFile="<>" \ +--set otel-operator.admissionWebhooks.keyFile="<>" \ +--set otel-operator.admissionWebhooks.caFile="<>" \ +``` + ## Manual Instrumentation If you're using manual instrumentation or a custom instrumentation agent, configure it to export data to the Logz.io APM collector by setting the export/output address as follows: @@ -135,6 +159,7 @@ logzio-monitoring-otel-collector.monitoring.svc.cluster.local:<> > Replace `<>` based on the protocol your agent uses: > - 4317 for GRCP > - 4318 for HTTP +> > For a complete list, see `values.yaml` >> `traceConfig` >> `receivers`. ## Custom trace sampling rules diff --git a/charts/logzio-apm-collector/VALUES.md b/charts/logzio-apm-collector/VALUES.md index 8c40e287..f47f814b 100644 --- a/charts/logzio-apm-collector/VALUES.md +++ b/charts/logzio-apm-collector/VALUES.md @@ -1,89 +1,103 @@ # Logz.io APM Collector All Configuration options Below you can find a complete list of settings in `values.yaml`. -| Key | Description | Default Value | -|-----------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------| -| enabled | Toggle for enabling the Helm chart deployment | `false` | -| spm.enabled | Toggle for enabling SPM Collection | `false` | -| serviceGraph.enabled | Toggle for enabling Service Graph metrics Collection | `false` | -| otel-operator.enabled | Toggle for enabling Auto instrumentation with [OpenTelemetry Operator](https://github.com/open-telemetry/opentelemetry-operator) | `false` | -| nameOverride | Override the default name for the deployment. | `""` | -| fullnameOverride | Override the default name for the deployment. | `""` | -| namespaceOverride | Override the namespace into which the resources will be deployed. | `""` | -| secrets.enabled | Toggle for creating and managing the Logz.io secret by this chart. | `"true"` | -| secrets.name | The name of the secret for Logz.io APM collector. | `"logzio-apm-collector-secret"` | -| secrets.env_id | Environment identifier attribute added to all logs. | `"my_env"` | -| secrets.logzioTracesToken | Secret with your Logz.io tracing shipping token. | `""` | -| secrets.logzioSpmToken | Secret with your Logz.io SPM shipping token. | `""` | -| secrets.logzioRegion | Secret with your Logz.io region. | `"us"` | -| secrets.customTracesEndpoint | Secret with a custom endpoint to send traces to, overrides Logz.io region listener address. | `""` | -| secrets.customSpmEndpoint | Secret with your custom endpoint to send SPM to, overrides Logz.io region listener address. | `""` | -| otelLogLevel | Change the OpenTelemetry Collector log level | `"info"` | -| SamplingProbability | Traces Sampling Probability | `10` | -| SamplingProbability | Traces Sampling Latency | `500` | -| traceConfig | Traces collector configuration, supports templating. | see `values.yaml` | -| spmForwarderConfig | Collector configuration to pass traces to the SPM Collector, supports templating. | see `values.yaml` | -| spmConfig | Collector configuration to generate SPM, supports templating. | see `values.yaml` | -| serviceGraphConfig | Collector configuration to generate Service Graph metrics. | see `values.yaml` | -| image.repository | Opentelemetry collector image repository. | `otel/opentelemetry-collector-contrib` | -| image.pullPolicy | Image pull policy. | `IfNotPresent` | -| image.tag | Overrides the image tag whose default is the chart appVersion. | `""` | -| image.digest | Pull images by digest. | `""` | -| imagePullSecrets | Specifies image pull secrets. | `[]` | -| command.name | OpenTelemetry Collector executable. | `"otelcol-contrib"` | -| command.extraArgs | Additional arguments for the command. | `[]` | -| instrumentation.includeNamespaces | Specifies namespaces to deploy the instrumentor resource at. By default, it's created only at the chart's other resources namespace. | `""` | -| instrumentation.propagators | Choose propagator to specify the method of injecting and extracting context from carriers. | `[tracecontext, baggage]` | -| instrumentation.sampler | Specifies the Sampler used to sample traces by the SDK. | `{}` | -| configMap.create | Specifies whether a configMap should be created. | `true` | -| serviceAccount.create | Specifies whether a service account should be created. | `true` | -| serviceAccount.annotations | Specifies annotations for the service account. | `{}` | -| serviceAccount.name | The name of the service account. | `""` | -| clusterRole.create | Specifies whether a clusterRole should be created. | `true` | -| clusterRole.annotations | Specifies annotations for the cluster role. | `{}` | -| clusterRole.name | The name of the clusterRole. | `""` | -| clusterRole.rules | Specifies additional rules for the clusterRole. | `[]` | -| clusterRole.clusterRoleBinding.annotations | Specifies annotations for the clusterRoleBinding. | `{}` | -| clusterRole.clusterRoleBinding.name | The name of the clusterRoleBinding. | `""` | -| service.enabled | Enable the creation of a Service. | `true` | -| service.type | Specifies the type of service. | `ClusterIP` | -| service.annotations | Specifies annotations for the service. | `{}` | -| spmService.type | Specifies the type of service for SPM. | `ClusterIP` | -| spmService.annotations | Specifies annotations for the service for SPM. | `{}` | -| autoscaling.enabled | Specifies if HPA should be created for the Traces Collector. | `false` | -| autoscaling.annotations | Specifies annotations for the HPA. | `{}` | -| autoscaling.minReplicas | Control autoscaling scale. | `1` | -| autoscaling.maxReplicas | Control autoscaling scale. | `10` | -| autoscaling.targetCPUUtilizationPercentage | Control autoscaling scale. | `80` | -| autoscaling.targetMemoryUtilizationPercentage | Control autoscaling scale. | `80` | -| spmAutoscaling.enabled | Specifies if VPA should be created for the SPM Collector. | `false` | -| autoscaling.annotations | Specifies annotations for the VPA. | `{}` | -| autoscaling.minAllowed.cpu | Control autoscaling scale. | `"50m"` | -| autoscaling.minAllowed.memory | Control autoscaling scale. | `"70Mi"` | -| autoscaling.maxAllowed.cpu | Control autoscaling scale. | `"150m"` | -| autoscaling.maxAllowed.memory | Control autoscaling scale. | `"250Mi"` | -| ports | Defines ports configurations | see `values.yaml` | -| additionalLabels | labels to add to all otel-collector resources | `{}` | -| podSecurityContext | Security context policies for the pod. | `{}` | -| securityContext | Security context policies for the container. | `{}` | -| nodeSelector | Node labels for pod assignment | `{}` | -| tolerations | Tolerations for pod assignment | `[]` | -| affinity | Affinity rules for pod assignment. | see `values.yaml` | -| priorityClassName | Scheduler priority class name. | `""` | -| extraEnvs | Extra environment variables to set in the pods | `[]` | -| extraEnvsFrom | Extra environment variables from secret or configMap to set in the pods | `[]` | -| extraVolumes | Extra volumes to add in the pods | `[]` | -| extraVolumeMounts | Extra volume mounts to add in the pods | `[]` | -| useGOMEMLIMIT | Set `GOMEMLIMIT` env var to a percentage of `resources.limits.memory` | `false` | -| resources | CPU/memory resource requests/limits | see `values.yaml` | -| podAnnotations | Annotations to add to the pod. | `{}` | -| podLabels | Labels to add to the pod. | `{}` | -| hostAliases | Adding entries to Pod /etc/hosts with HostAliases. | `[]` | -| dnsPolicy | Pod DNS policy. | `""` | -| dnsConfig | Custom DNS config. Required when `dnsPolicy: None`. | `{}` | -| annotations | Annotations to add to the ???. | `{}` | -| extraContainers | List of extra sidecars to add. | `[]` | -| initContainers | List of init container specs. | `[]` | -| lifecycleHooks | Pod lifecycle policies. | `{}` | -| livenessProbe | Liveness probe configuration. | see `values.yaml` | -| readinessProbe | Readiness probe configuration. | see `values.yaml` | +| Key | Description | Default Value | +|--------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------| +| enabled | Toggle for enabling the Helm chart deployment | `false` | +| spm.enabled | Toggle for enabling SPM Collection | `false` | +| serviceGraph.enabled | Toggle for enabling Service Graph metrics Collection | `false` | +| otel-operator.enabled | Toggle for enabling Auto instrumentation with [OpenTelemetry Operator](https://github.com/open-telemetry/opentelemetry-operator) | `false` | +| otel-operator.admissionWebhooks.certManager.enabled | If you have cert-manager installed on your cluster, set to true and the cert-manager will generate a self-signed certificate for the otel-operator | `false` | +| otel-operator.admissionWebhooks.certManager.issuerRef | Provide the issuer kind and name to do the cert auth job. By default, OpenTelemetry Operator will use self-signer issuer. | `{}` | +| otel-operator.admissionWebhooks.certManager.kind | Provide the issuer kind and name to do the cert auth job. By default, OpenTelemetry Operator will use self-signer issuer. | `""` | +| otel-operator.admissionWebhooks.certManager.name | Provide the issuer kind and name to do the cert auth job. By default, OpenTelemetry Operator will use self-signer issuer. | `""` | +| otel-operator.admissionWebhooks.certManager.certificateAnnotations | Annotations for the certificate if cert-manager is enabled. | `{}` | +| otel-operator.admissionWebhooks.certManager.issuerAnnotations | Annotations for the issuer if cert-manager is enabled. | `{}` | +| otel-operator.admissionWebhooks.certManager.duration | `duration` must be specified by a Go time.Duration. | `""` | +| otel-operator.admissionWebhooks.certManager.renewBefore | `renewBefore` must be specified by a Go time.Duration. | `""` | +| otel-operator.admissionWebhooks.autoGenerateCert.enabled | If you have Helm will automatically create a self-signed certificate and secret for you. | `true` | +| otel-operator.admissionWebhooks.autoGenerateCert.recreate | If set to true, new webhook key/certificate is generated on helm upgrade. | `true` | +| otel-operator.admissionWebhooks.autoGenerateCert.certPeriodDays | Automatically generated certificate period time in days. | `365` | +| otel-operator.admissionWebhooks.certFile | To use your own self-signed certificate, add path to your own PEM-encoded certificate. | `""` | +| otel-operator.admissionWebhooks.keyFile | To use your own self-signed certificate, add path to your own PEM-encoded private key. | `""` | +| otel-operator.admissionWebhooks.caFile | To use your own self-signed certificate, add path to your own CA certificate. | `""` | +| nameOverride | Override the default name for the deployment. | `""` | +| fullnameOverride | Override the default name for the deployment. | `""` | +| namespaceOverride | Override the namespace into which the resources will be deployed. | `""` | +| secrets.enabled | Toggle for creating and managing the Logz.io secret by this chart. | `"true"` | +| secrets.name | The name of the secret for Logz.io APM collector. | `"logzio-apm-collector-secret"` | +| secrets.env_id | Environment identifier attribute added to all logs. | `"my_env"` | +| secrets.logzioTracesToken | Secret with your Logz.io tracing shipping token. | `""` | +| secrets.logzioSpmToken | Secret with your Logz.io SPM shipping token. | `""` | +| secrets.logzioRegion | Secret with your Logz.io region. | `"us"` | +| secrets.customTracesEndpoint | Secret with a custom endpoint to send traces to, overrides Logz.io region listener address. | `""` | +| secrets.customSpmEndpoint | Secret with your custom endpoint to send SPM to, overrides Logz.io region listener address. | `""` | +| otelLogLevel | Change the OpenTelemetry Collector log level | `"info"` | +| SamplingProbability | Traces Sampling Probability | `10` | +| SamplingProbability | Traces Sampling Latency | `500` | +| traceConfig | Traces collector configuration, supports templating. | see `values.yaml` | +| spmForwarderConfig | Collector configuration to pass traces to the SPM Collector, supports templating. | see `values.yaml` | +| spmConfig | Collector configuration to generate SPM, supports templating. | see `values.yaml` | +| serviceGraphConfig | Collector configuration to generate Service Graph metrics. | see `values.yaml` | +| image.repository | Opentelemetry collector image repository. | `otel/opentelemetry-collector-contrib` | +| image.pullPolicy | Image pull policy. | `IfNotPresent` | +| image.tag | Overrides the image tag whose default is the chart appVersion. | `""` | +| image.digest | Pull images by digest. | `""` | +| imagePullSecrets | Specifies image pull secrets. | `[]` | +| command.name | OpenTelemetry Collector executable. | `"otelcol-contrib"` | +| command.extraArgs | Additional arguments for the command. | `[]` | +| instrumentation.includeNamespaces | Specifies namespaces to deploy the instrumentor resource at. By default, it's created only at the chart's other resources namespace. | `""` | +| instrumentation.propagators | Choose propagator to specify the method of injecting and extracting context from carriers. | `[tracecontext, baggage]` | +| instrumentation.sampler | Specifies the Sampler used to sample traces by the SDK. | `{}` | +| configMap.create | Specifies whether a configMap should be created. | `true` | +| serviceAccount.create | Specifies whether a service account should be created. | `true` | +| serviceAccount.annotations | Specifies annotations for the service account. | `{}` | +| serviceAccount.name | The name of the service account. | `""` | +| clusterRole.create | Specifies whether a clusterRole should be created. | `true` | +| clusterRole.annotations | Specifies annotations for the cluster role. | `{}` | +| clusterRole.name | The name of the clusterRole. | `""` | +| clusterRole.rules | Specifies additional rules for the clusterRole. | `[]` | +| clusterRole.clusterRoleBinding.annotations | Specifies annotations for the clusterRoleBinding. | `{}` | +| clusterRole.clusterRoleBinding.name | The name of the clusterRoleBinding. | `""` | +| service.enabled | Enable the creation of a Service. | `true` | +| service.type | Specifies the type of service. | `ClusterIP` | +| service.annotations | Specifies annotations for the service. | `{}` | +| spmService.type | Specifies the type of service for SPM. | `ClusterIP` | +| spmService.annotations | Specifies annotations for the service for SPM. | `{}` | +| autoscaling.enabled | Specifies if HPA should be created for the Traces Collector. | `false` | +| autoscaling.annotations | Specifies annotations for the HPA. | `{}` | +| autoscaling.minReplicas | Control autoscaling scale. | `1` | +| autoscaling.maxReplicas | Control autoscaling scale. | `10` | +| autoscaling.targetCPUUtilizationPercentage | Control autoscaling scale. | `80` | +| autoscaling.targetMemoryUtilizationPercentage | Control autoscaling scale. | `80` | +| spmAutoscaling.enabled | Specifies if VPA should be created for the SPM Collector. | `false` | +| autoscaling.annotations | Specifies annotations for the VPA. | `{}` | +| autoscaling.minAllowed.cpu | Control autoscaling scale. | `"50m"` | +| autoscaling.minAllowed.memory | Control autoscaling scale. | `"70Mi"` | +| autoscaling.maxAllowed.cpu | Control autoscaling scale. | `"150m"` | +| autoscaling.maxAllowed.memory | Control autoscaling scale. | `"250Mi"` | +| ports | Defines ports configurations | see `values.yaml` | +| additionalLabels | labels to add to all otel-collector resources | `{}` | +| podSecurityContext | Security context policies for the pod. | `{}` | +| securityContext | Security context policies for the container. | `{}` | +| nodeSelector | Node labels for pod assignment | `{}` | +| tolerations | Tolerations for pod assignment | `[]` | +| affinity | Affinity rules for pod assignment. | see `values.yaml` | +| priorityClassName | Scheduler priority class name. | `""` | +| extraEnvs | Extra environment variables to set in the pods | `[]` | +| extraEnvsFrom | Extra environment variables from secret or configMap to set in the pods | `[]` | +| extraVolumes | Extra volumes to add in the pods | `[]` | +| extraVolumeMounts | Extra volume mounts to add in the pods | `[]` | +| useGOMEMLIMIT | Set `GOMEMLIMIT` env var to a percentage of `resources.limits.memory` | `false` | +| resources | CPU/memory resource requests/limits | see `values.yaml` | +| podAnnotations | Annotations to add to the pod. | `{}` | +| podLabels | Labels to add to the pod. | `{}` | +| hostAliases | Adding entries to Pod /etc/hosts with HostAliases. | `[]` | +| dnsPolicy | Pod DNS policy. | `""` | +| dnsConfig | Custom DNS config. Required when `dnsPolicy: None`. | `{}` | +| annotations | Annotations to add to the ???. | `{}` | +| extraContainers | List of extra sidecars to add. | `[]` | +| initContainers | List of init container specs. | `[]` | +| lifecycleHooks | Pod lifecycle policies. | `{}` | +| livenessProbe | Liveness probe configuration. | see `values.yaml` | +| readinessProbe | Readiness probe configuration. | see `values.yaml` | From b792e28c00695d5c5c7ba81ea231806046c5dbba Mon Sep 17 00:00:00 2001 From: 8naama Date: Tue, 3 Dec 2024 16:01:39 +0200 Subject: [PATCH 11/15] split otel operator from the chart --- charts/logzio-apm-collector/Chart.yaml | 6 - charts/logzio-apm-collector/README.md | 113 ++---------------- charts/logzio-apm-collector/VALUES.md | 18 --- .../templates/_helpers.tpl | 6 - .../templates/instrumentation.yaml | 48 -------- charts/logzio-apm-collector/values.yaml | 105 +--------------- 6 files changed, 12 insertions(+), 284 deletions(-) delete mode 100644 charts/logzio-apm-collector/templates/instrumentation.yaml diff --git a/charts/logzio-apm-collector/Chart.yaml b/charts/logzio-apm-collector/Chart.yaml index 85e2dce9..d42dffae 100644 --- a/charts/logzio-apm-collector/Chart.yaml +++ b/charts/logzio-apm-collector/Chart.yaml @@ -4,12 +4,6 @@ version: 1.0.0 description: Kubernetes APM agent for Logz.io based on OpenTelemetry Collector type: application home: https://logz.io/ -dependencies: - - name: opentelemetry-operator - alias: otel-operator - version: ~0.74.2 - repository: https://open-telemetry.github.io/opentelemetry-helm-charts - condition: otel-operator.enabled maintainers: - name: Naama Bendalak email: naama.bendalak@logz.io diff --git a/charts/logzio-apm-collector/README.md b/charts/logzio-apm-collector/README.md index fec69acc..4eb1e9ab 100644 --- a/charts/logzio-apm-collector/README.md +++ b/charts/logzio-apm-collector/README.md @@ -3,7 +3,7 @@ > Kubernetes APM Collection Agent is still In development This Helm chart deploys an agent, which leverages the OpenTelemetry Collector, that collects traces and span metrics from Kubernetes clusters and sends them to Logz.io. -It also allows enabling Service graph metrics and supports adding Auto instrumentation to the cluster applications via Opentelemetry Operator. + ## Prerequisites - Kubernetes 1.24+ @@ -23,7 +23,6 @@ The chart provides options for enabling the following: 1. Traces 2. SPM (Service Performance Monitoring) 3. Service Graph -4. OpenTelemetry Operator (Auto-instrumentation) ```shell @@ -31,7 +30,6 @@ helm install -n monitoring --create-namespace \ --set enabled=true \ --set spm.enabled=true \ --set serviceGraph.enabled=true \ ---set otel-operator.enabled=true \ --set secrets.logzioTracesToken="<>" \ --set secrets.logzioSpmToken="<>" \ --set secrets.logzioRegion="<>" \ @@ -40,7 +38,7 @@ logzio-apm-collector logzio-helm/logzio-apm-collector ``` > [!NOTE] -> To disable either one of SPM, Service Graph or OpenTelemetry Operator, remove the relevant `--set XXX.enabled` line from the above command. +> To disable either one of SPM or Service Graph remove the relevant `--set XXX.enabled` line from the above command. > [!IMPORTANT] > Values of `<>`, `<>` and `<>` can be found in your Logz.io account. @@ -50,109 +48,15 @@ logzio-apm-collector logzio-helm/logzio-apm-collector ## Configuration - [All configuration options](./VALUES.md) -- [Enable Auto-instrumentation](#enable-auto-instrumentation) - - [Multi-container pods](#multi-container-pods) -- [Customize Auto-instrumentation](#customize-auto-instrumentation) - - [Customize Propagator](#customize-propagator) - - [Add a custom Sampler](#add-a-custom-sampler) - - [Distribute namespaces](#distribute-namespaces) - - [TLS certificate Requirements](#tls-certificate-requirements) -- [Manual Instrumentation](#manual-instrumentation) +- [Instrumentation](#instrumentation) - [Custom Trace Sampling rules](#custom-trace-sampling-rules) -## Enable Auto-instrumentation -- **Step 1:** Make sure to enable the OpenTelemetry operator in the chart: -```shell ---set otel-operator.enabled=true \ -``` - -- **Step 2**: Add annotations to your relevant Kubernetes object (Deployment, StatefulSet, Namespace, Daemonset, or Pod) -```yaml -instrumentation.opentelemetry.io/inject-": "monitoring/logzio-apm-collector" -``` - -> [!TIP] -> `` can be one of `apache-httpd`, `dotnet`, `go`, `java`, `nginx`, `nodejs` or `python`. - - -### Multi-container pods -By default, in multi-container pods, instrumentation is performed on the first container available in the pod spec. -To fine tune which containers to instrument, add the below annotations to your pod: -```yaml -instrumentation.opentelemetry.io/inject-": "monitoring/logzio-apm-collector" -instrumentation.opentelemetry.io/-container-names: "myapp,myapp2" -instrumentation.opentelemetry.io/inject-": "monitoring/logzio-apm-collector" -instrumentation.opentelemetry.io/-container-names: "myapp3" -``` - -> [!TIP] -> ``, `` can be one of `apache-httpd`, `dotnet`, `go`, `java`, `nginx`, `nodejs` or `python`. - - -## Customize Auto-instrumentation -Below you can find multiple ways in which you can customize the OpenTelemetry Operator Auto-instrumentation. - -### Customize Propagator -The propagator specifies how context is injected into and extracted from carriers for distributed tracing. -By default, the propagators `tracecontext` (W3C Trace Context) and `baggage` (W3C Correlation Context) are enabled. -You can customize this to include other formats ([full list here](https://opentelemetry.io/docs/languages/sdk-configuration/general/#otel_propagators)) or set it to "none" to disable automatic propagation. -```shell ---set instrumentation.propagator={tracecontext, baggage, b3} -``` - -### Add a custom Sampler -You can specify a sampler to be used by the instrumentor. You'll need to specify the below: -- Sampler used to sample the traces ([available options](https://opentelemetry.io/docs/languages/sdk-configuration/general/#otel_traces_sampler)) -- Sampler arguments ([Sampler type expected input](https://opentelemetry.io/docs/languages/sdk-configuration/general/#otel_traces_sampler_arg)) - -Example: -```shell ---set instrumentation.sampler.type="parentbased_always_on" \ ---set instrumentation.sampler.argument="0.25" -``` - -### Distribute namespaces -For intensive applications, to reduce the performance impact of the operator, you can define multiple namespaces to deploy the instrumentor resource at, which can help distribute the load in larger clusters. -To do so, specify which namespaces to deploy the instrumentor at: -```shell ---set includeNamespaces="ns1,ns2,ns3" -``` - -For resources in the namespaces where you configured the instrumentation, you need to add annotation in this format: -```yaml -instrumentation.opentelemetry.io/inject-": "true" -``` - -> [!TIP] -> `` can be one of `apache-httpd`, `dotnet`, `go`, `java`, `nginx`, `nodejs` or `python`. - -### TLS certificate Requirements -Openteleemtry operator requires a TLS certificate. For more details, refer to [OpenTelemetry documentation](https://github.com/open-telemetry/opentelemetry-helm-charts/tree/main/charts/opentelemetry-operator#tls-certificate-requirement). - -There are 3 TLS certificate options, by default this chart is using option 2. -1. If you have `cert-manager` installed on your cluster, you can set `otel-operator.admissionWebhooks.certManager.enabled` to true and the cert-manager will generate a self-signed certificate for the otel-operator automatically. +## Instrumentation +If you're using manual instrumentation or an instrumentation agent, configure it to export data to the Logz.io APM collector by setting the export/output address as follows: -```shell ---set otel-operator.admissionWebhooks.certManager.enabled=true \ ``` - -2. Helm will automatically create a self-signed cert and secret for you. (Enabled by default by this chart) - -3. Use your own self-signed certificate, To enable this option, set `otel-operator.admissionWebhooks.autoGenerateCert.enabled` to `false` and provide the necessary `certFile`, `keyFile` and `caFile`. - -```shell ---set otel-operator.admissionWebhooks.autoGenerateCert.enabled=false \ ---set otel-operator.admissionWebhooks.certFile="<>" \ ---set otel-operator.admissionWebhooks.keyFile="<>" \ ---set otel-operator.admissionWebhooks.caFile="<>" \ -``` - -## Manual Instrumentation -If you're using manual instrumentation or a custom instrumentation agent, configure it to export data to the Logz.io APM collector by setting the export/output address as follows: - -``` -logzio-monitoring-otel-collector.monitoring.svc.cluster.local:<> +logzio-apm-collector.monitoring.svc.cluster.local:<> ``` > [!IMPORTANT] @@ -162,6 +66,11 @@ logzio-monitoring-otel-collector.monitoring.svc.cluster.local:<> > > For a complete list, see `values.yaml` >> `traceConfig` >> `receivers`. +> [!WARNING] +> If you're deploying the chart as a sub chart of the `logzio-monitoring` chart, replace: +> `logzio-apm-collector` >> `logzio-monitoring-otel-collector` + + ## Custom trace sampling rules To customize the Traces Sampling rules in the OpenTelemetry Collector, you can follow the below steps: diff --git a/charts/logzio-apm-collector/VALUES.md b/charts/logzio-apm-collector/VALUES.md index f47f814b..1add0932 100644 --- a/charts/logzio-apm-collector/VALUES.md +++ b/charts/logzio-apm-collector/VALUES.md @@ -6,21 +6,6 @@ Below you can find a complete list of settings in `values.yaml`. | enabled | Toggle for enabling the Helm chart deployment | `false` | | spm.enabled | Toggle for enabling SPM Collection | `false` | | serviceGraph.enabled | Toggle for enabling Service Graph metrics Collection | `false` | -| otel-operator.enabled | Toggle for enabling Auto instrumentation with [OpenTelemetry Operator](https://github.com/open-telemetry/opentelemetry-operator) | `false` | -| otel-operator.admissionWebhooks.certManager.enabled | If you have cert-manager installed on your cluster, set to true and the cert-manager will generate a self-signed certificate for the otel-operator | `false` | -| otel-operator.admissionWebhooks.certManager.issuerRef | Provide the issuer kind and name to do the cert auth job. By default, OpenTelemetry Operator will use self-signer issuer. | `{}` | -| otel-operator.admissionWebhooks.certManager.kind | Provide the issuer kind and name to do the cert auth job. By default, OpenTelemetry Operator will use self-signer issuer. | `""` | -| otel-operator.admissionWebhooks.certManager.name | Provide the issuer kind and name to do the cert auth job. By default, OpenTelemetry Operator will use self-signer issuer. | `""` | -| otel-operator.admissionWebhooks.certManager.certificateAnnotations | Annotations for the certificate if cert-manager is enabled. | `{}` | -| otel-operator.admissionWebhooks.certManager.issuerAnnotations | Annotations for the issuer if cert-manager is enabled. | `{}` | -| otel-operator.admissionWebhooks.certManager.duration | `duration` must be specified by a Go time.Duration. | `""` | -| otel-operator.admissionWebhooks.certManager.renewBefore | `renewBefore` must be specified by a Go time.Duration. | `""` | -| otel-operator.admissionWebhooks.autoGenerateCert.enabled | If you have Helm will automatically create a self-signed certificate and secret for you. | `true` | -| otel-operator.admissionWebhooks.autoGenerateCert.recreate | If set to true, new webhook key/certificate is generated on helm upgrade. | `true` | -| otel-operator.admissionWebhooks.autoGenerateCert.certPeriodDays | Automatically generated certificate period time in days. | `365` | -| otel-operator.admissionWebhooks.certFile | To use your own self-signed certificate, add path to your own PEM-encoded certificate. | `""` | -| otel-operator.admissionWebhooks.keyFile | To use your own self-signed certificate, add path to your own PEM-encoded private key. | `""` | -| otel-operator.admissionWebhooks.caFile | To use your own self-signed certificate, add path to your own CA certificate. | `""` | | nameOverride | Override the default name for the deployment. | `""` | | fullnameOverride | Override the default name for the deployment. | `""` | | namespaceOverride | Override the namespace into which the resources will be deployed. | `""` | @@ -46,9 +31,6 @@ Below you can find a complete list of settings in `values.yaml`. | imagePullSecrets | Specifies image pull secrets. | `[]` | | command.name | OpenTelemetry Collector executable. | `"otelcol-contrib"` | | command.extraArgs | Additional arguments for the command. | `[]` | -| instrumentation.includeNamespaces | Specifies namespaces to deploy the instrumentor resource at. By default, it's created only at the chart's other resources namespace. | `""` | -| instrumentation.propagators | Choose propagator to specify the method of injecting and extracting context from carriers. | `[tracecontext, baggage]` | -| instrumentation.sampler | Specifies the Sampler used to sample traces by the SDK. | `{}` | | configMap.create | Specifies whether a configMap should be created. | `true` | | serviceAccount.create | Specifies whether a service account should be created. | `true` | | serviceAccount.annotations | Specifies annotations for the service account. | `{}` | diff --git a/charts/logzio-apm-collector/templates/_helpers.tpl b/charts/logzio-apm-collector/templates/_helpers.tpl index 606597c3..d46def68 100644 --- a/charts/logzio-apm-collector/templates/_helpers.tpl +++ b/charts/logzio-apm-collector/templates/_helpers.tpl @@ -160,9 +160,3 @@ Get secret value either from the global section (parent chart is running) or the {{- $fallback -}} {{- end -}} {{- end -}} - -{{/* Helm hooks annotations for otel operator */}} -{{- define "apm-collector.otelOpAnnotations" -}} -helm.sh/hook: "post-install, post-upgrade" -helm.sh/hook-delete-policy: "before-hook-creation, hook-succeeded" -{{- end -}} diff --git a/charts/logzio-apm-collector/templates/instrumentation.yaml b/charts/logzio-apm-collector/templates/instrumentation.yaml deleted file mode 100644 index c128385d..00000000 --- a/charts/logzio-apm-collector/templates/instrumentation.yaml +++ /dev/null @@ -1,48 +0,0 @@ -{{ $operatorEnabled := index .Values "otel-operator" "enabled" }} -{{ if and .Values.enabled $operatorEnabled }} -apiVersion: opentelemetry.io/v1alpha1 -kind: Instrumentation -metadata: - name: {{ include "apm-collector.fullname" . }} - namespace: {{ .Values.instrumentation.includeNamespaces | default (include "apm-collector.namespace" .) }} - labels: - {{- include "apm-collector.labels" . | nindent 4 }} - {{- include "apm-collector.component" . | nindent 4 }} - annotations: - {{- include "apm-collector.otelOpAnnotations" . | nindent 4 }} - {{- if .Values.annotations }} - {{- range $key, $value := .Values.annotations }} - {{- printf "%s: %s" $key (tpl $value $ | quote) | nindent 4 }} - {{- end }} - {{- end }} -spec: - exporter: - endpoint: {{ include "apm-collector.serviceAddr" . }}:4317 - propagators: - {{- $defaultPropagators := list "tracecontext" "baggage" }} - {{- range .Values.instrumentation.propagators | default $defaultPropagators }} - - {{ . }} - {{- end }} - {{- with .Values.instrumentation.sampler }} - sampler: - {{- . | toYaml | nindent 4 }} - {{- end }} - # Python, .NET, Go and Java autoinstrumentation uses http/proto by default - # so data must be sent to 4318 instead of 4317. - python: - env: - - name: OTEL_EXPORTER_OTLP_ENDPOINT - value: {{ include "apm-collector.serviceAddr" . }}:4318 - dotnet: - env: - - name: OTEL_EXPORTER_OTLP_ENDPOINT - value: {{ include "apm-collector.serviceAddr" . }}:4318 - go: - env: - - name: OTEL_EXPORTER_OTLP_ENDPOINT - value: {{ include "apm-collector.serviceAddr" . }}:4318 - java: - env: - - name: OTEL_EXPORTER_OTLP_ENDPOINT - value: {{ include "apm-collector.serviceAddr" . }}:4318 -{{ end }} diff --git a/charts/logzio-apm-collector/values.yaml b/charts/logzio-apm-collector/values.yaml index 98916b97..6908711b 100644 --- a/charts/logzio-apm-collector/values.yaml +++ b/charts/logzio-apm-collector/values.yaml @@ -13,76 +13,6 @@ spm: serviceGraph: enabled: false -# Enable Auto Instrumentation -# ref: https://github.com/open-telemetry/opentelemetry-helm-charts/tree/main/charts/opentelemetry-operator -otel-operator: - enabled: false - - # Openteleemtry operator requires a TLS certificate. - # ref: https://github.com/open-telemetry/opentelemetry-helm-charts/tree/main/charts/opentelemetry-operator#tls-certificate-requirement - admissionWebhooks: - # TLS certificate Option 1 - # If you have cert-manager installed on your cluster, you can set `certManager.enabled` to true - # and the cert-manager will generate a self-signed certificate for the otel-operator automatically. - certManager: - enabled: false - - # Ensure certificate and issuer are created after the CRDs are installed - certificateAnnotations: - helm.sh/hook: "post-install, post-upgrade" - helm.sh/hook-delete-policy: "before-hook-creation, hook-succeeded" - issuerAnnotations: - helm.sh/hook: "post-install, post-upgrade" - helm.sh/hook-delete-policy: "before-hook-creation, hook-succeeded" - - ## Provide the issuer kind and name to do the cert auth job. - ## By default, OpenTelemetry Operator will use self-signer issuer. - # issuerRef: {} - # kind: - # name: - - ## Annotations for the cert and issuer if cert-manager is enabled. - # certificateAnnotations: {} - # issuerAnnotations: {} - - # duration must be specified by a Go time.Duration (ending in s, m or h) - # duration: "" - - # renewBefore must be specified by a Go time.Duration (ending in s, m or h) - # Take care when setting the renewBefore field to be very close to the duration - # as this can lead to a renewal loop, where the Certificate is always in the renewal period. - # renewBefore: "" - - # TLS certificate Option 2 - # The default option enabled by this chart. Helm will automatically create a self-signed cert and secret for you. - autoGenerateCert: - enabled: true - # If set to true, new webhook key/certificate is generated on helm upgrade. - # recreate: true - - # Cert period time in days. The default is 365 days. - # certPeriodDays: 365 - - ## TLS certificate Option 3 - # Use your own self-signed certificate - # To enable this option, set `autoGenerateCert.enabled` to false and provide the necessary values: - ## Path to your own PEM-encoded certificate. - # certFile: "" - ## Path to your own PEM-encoded private key. - # keyFile: "" - ## Path to the CA cert. - # caFile: "" - - # The OpenTelemetry Operator webhook service may not always be ready in time, causing an error. - # to retry, we set `failurePolicy` to `ignore`. To block the operation if it fails, set to `Fail`. - failurePolicy: Ignore - - # Deploying the collector using the operator is not supported currently. - # The collector image is specified to meet operator subchart requirments. - manager: - collectorImage: - repository: "otel/opentelemetry-collector-contrib" - # Specifies a custom name for the chart's resources nameOverride: "" fullnameOverride: "" @@ -410,40 +340,7 @@ imagePullSecrets: [] # OpenTelemetry Collector executable command: name: otelcol-contrib - extraArgs: [] - -####################################################################################################################### -# Otel Operator Auto Instrumentation configuration -####################################################################################################################### -instrumentation: - # For intensive applications, to reduce the performance impact of the operator, you can define multiple - # namespaces to deploy the instrumentor resource at. This can help distribute the load in larger clusters. - # By default, a single instrumentation resource is deployed either in the default "monitoring" namespace, or in the - # "namespaceOverride" namespace (if defined). - includeNamespaces: "" - - # Choose propagator to specify the method of injecting and extracting context from carriers. - # By default, "tracecontext" (W3C Trace Context) and "baggage" (W3C Correlation Context) are enabled. - # You can enable or disable propagators as needed, or use "none" for no automatically configured propagator - # ref: https://opentelemetry.io/docs/languages/sdk-configuration/general/#otel_propagators - propagators: - - tracecontext - - baggage - # - b3 - # - b3multi - # - jaeger - # - xray - # - ottrace - - # Specifies the Sampler used to sample traces by the SDK. (Optional) - sampler: - # By default, "parentbased_always_on" is enabled, meaning new traces will always be recorded and if the parent span is sampled, then the child span will be sampled. - # ref: https://opentelemetry.io/docs/languages/sdk-configuration/general/#otel_traces_sampler - # type: "parentbased_always_on" - - # Each Sampler type defines its own expected args input gor configuring the sampler - # ref: https://opentelemetry.io/docs/languages/sdk-configuration/general/#otel_traces_sampler_arg - # argument: "0.25" + extraArgs: [] ####################################################################################################################### # Kubernetes Resources Configuration From 589dd8d38cee7cbb52dc1f6c8ef062610eeeecdb Mon Sep 17 00:00:00 2001 From: 8naama Date: Tue, 3 Dec 2024 18:07:23 +0200 Subject: [PATCH 12/15] add apm chart tests --- .../workflows/logzio-apm-collector-test.yaml | 94 +++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 .github/workflows/logzio-apm-collector-test.yaml diff --git a/.github/workflows/logzio-apm-collector-test.yaml b/.github/workflows/logzio-apm-collector-test.yaml new file mode 100644 index 00000000..d0c87de9 --- /dev/null +++ b/.github/workflows/logzio-apm-collector-test.yaml @@ -0,0 +1,94 @@ +name: Test `logzio-apm-collector` chart + +on: + pull_request: + branches: + - master + paths: + - 'charts/logzio-apm-collector/Chart.yaml' + - 'charts/logzio-apm-collector/templates/**' + - 'charts/logzio-apm-collector/values.yaml' +jobs: + test-helm-chart: + name: Test Helm Chart on Kind + runs-on: ubuntu-latest + steps: + - name: Generate random id + id: random_id + run: echo "::set-output name=rand::$(echo $RANDOM)" + + - name: Set ENV_ID + run: echo "ENV_ID=apm-test-run-${{ steps.random_id.outputs.rand }}" >> $GITHUB_ENV + + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.20' + + - name: Set up Helm + uses: azure/setup-helm@v4.2.0 + + - name: Set up kubectl + uses: azure/setup-kubectl@v4 + + - name: Install Kind + run: | + curl -Lo ./kind "https://kind.sigs.k8s.io/dl/v0.11.1/kind-Linux-amd64" + chmod +x ./kind + mv ./kind /usr/local/bin/kind + + - name: Create Kind cluster + run: | + kind create cluster --name kind-${{ github.run_id }}-${{ matrix.mode }} + kubectl cluster-info + + - name: Deploy Helm Chart + run: | + cd charts/logzio-telemetry + helm upgrade --install \ + --set enabled=true \ \ + --set spm.enabled=true \ + --set serviceGraph.enabled=true \ + --set secrets.logzioTracesToken=${{ secrets.LOGZIO_TRACES_TOKEN }} \ + --set secrets.logzioSpmToken=${{ secrets.LOGZIO_METRICS_TOKEN }} \ + --set secrets.logzioRegion="us" \ + --set secrets.env_id=${{ env.ENV_ID }} \ + logzio-apm-collector . + kubectl rollout status deployment/logzio-apm-collector --timeout=300s + kubectl rollout status deployment/logzio-apm-collector-spm --timeout=300s + + - name: Run trace generator + run: | + kubectl apply -f tests/resources/tracegen.yaml + kubectl rollout status deployment/trace-gen --timeout=300s + + - name: Run otel demo for service graph + run: | + helm repo add open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts + helm repo update + helm install otel-demo -f tests/resources/otel-demo.yaml open-telemetry/opentelemetry-demo --version 0.32.5 + kubectl rollout status deployment/otel-demo-loadgenerator --timeout=300s + + - name: sleep for 3 minutes + run: sleep 180 + + - name: Run Go Tests + env: + LOGZIO_METRICS_API_KEY: ${{ secrets.LOGZIO_METRICS_API_KEY }} + LOGZIO_TRACES_API_KEY: ${{ secrets.LOGZIO_TRACES_API_KEY }} + run: | + go get go.uber.org/zap + go test -v ./tests/traces_e2e_test.go ./tests/common.go + go test -v ./tests/metrics_e2e_test.go ./tests/common.go + + - name: Cleanup Environment + run: | + helm uninstall logzio-apm-collector + + - name: Delete Kind cluster + if: always() + run: kind delete cluster --name kind-${{ github.run_id }}-${{ matrix.mode }} + From 679600998bcf201505002adf512a0c55ef37c65e Mon Sep 17 00:00:00 2001 From: 8naama Date: Tue, 10 Dec 2024 11:59:39 +0200 Subject: [PATCH 13/15] changes following tests --- .../workflows/logzio-apm-collector-test.yaml | 18 +-- charts/logzio-apm-collector/Chart.yaml | 1 + charts/logzio-apm-collector/README.md | 12 +- .../logzio-apm-collector/templates/NOTES.txt | 2 +- .../templates/_helpers-spm.tpl | 2 +- .../templates/_helpers.tpl | 14 -- .../templates/_pod-spm.tpl | 8 +- .../logzio-apm-collector/templates/_pod.tpl | 10 +- .../templates/_validations.tpl | 8 +- .../templates/secret.yaml | 20 +-- charts/logzio-apm-collector/values.yaml | 86 +++++----- tests/apm_metrics_e2e_test.go | 153 ++++++++++++++++++ tests/resources/otel-demo-apm.yaml | 16 ++ tests/resources/tracegen-apm.yaml | 24 +++ 14 files changed, 276 insertions(+), 98 deletions(-) create mode 100644 tests/apm_metrics_e2e_test.go create mode 100644 tests/resources/otel-demo-apm.yaml create mode 100644 tests/resources/tracegen-apm.yaml diff --git a/.github/workflows/logzio-apm-collector-test.yaml b/.github/workflows/logzio-apm-collector-test.yaml index d0c87de9..cdf3a101 100644 --- a/.github/workflows/logzio-apm-collector-test.yaml +++ b/.github/workflows/logzio-apm-collector-test.yaml @@ -47,29 +47,29 @@ jobs: - name: Deploy Helm Chart run: | - cd charts/logzio-telemetry + cd charts/logzio-apm-collector helm upgrade --install \ - --set enabled=true \ \ + --set enabled=true \ --set spm.enabled=true \ --set serviceGraph.enabled=true \ - --set secrets.logzioTracesToken=${{ secrets.LOGZIO_TRACES_TOKEN }} \ - --set secrets.logzioSpmToken=${{ secrets.LOGZIO_METRICS_TOKEN }} \ - --set secrets.logzioRegion="us" \ - --set secrets.env_id=${{ env.ENV_ID }} \ + --set global.logzioTracesToken=${{ secrets.LOGZIO_TRACES_TOKEN }} \ + --set global.logzioSpmToken=${{ secrets.LOGZIO_METRICS_TOKEN }} \ + --set global.logzioRegion="us" \ + --set global.env_id=${{ env.ENV_ID }} \ logzio-apm-collector . kubectl rollout status deployment/logzio-apm-collector --timeout=300s kubectl rollout status deployment/logzio-apm-collector-spm --timeout=300s - name: Run trace generator run: | - kubectl apply -f tests/resources/tracegen.yaml + kubectl apply -f tests/resources/tracegen-apm.yaml kubectl rollout status deployment/trace-gen --timeout=300s - name: Run otel demo for service graph run: | helm repo add open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts helm repo update - helm install otel-demo -f tests/resources/otel-demo.yaml open-telemetry/opentelemetry-demo --version 0.32.5 + helm install otel-demo -f tests/resources/otel-demo-apm.yaml open-telemetry/opentelemetry-demo --version 0.32.5 kubectl rollout status deployment/otel-demo-loadgenerator --timeout=300s - name: sleep for 3 minutes @@ -82,7 +82,7 @@ jobs: run: | go get go.uber.org/zap go test -v ./tests/traces_e2e_test.go ./tests/common.go - go test -v ./tests/metrics_e2e_test.go ./tests/common.go + go test -v ./tests/apm_metrics_e2e_test.go ./tests/common.go - name: Cleanup Environment run: | diff --git a/charts/logzio-apm-collector/Chart.yaml b/charts/logzio-apm-collector/Chart.yaml index d42dffae..ca3fd627 100644 --- a/charts/logzio-apm-collector/Chart.yaml +++ b/charts/logzio-apm-collector/Chart.yaml @@ -4,6 +4,7 @@ version: 1.0.0 description: Kubernetes APM agent for Logz.io based on OpenTelemetry Collector type: application home: https://logz.io/ +icon: https://logzbucket.s3.eu-west-1.amazonaws.com/logz-io-img/logo400x400.png maintainers: - name: Naama Bendalak email: naama.bendalak@logz.io diff --git a/charts/logzio-apm-collector/README.md b/charts/logzio-apm-collector/README.md index 4eb1e9ab..53545b1e 100644 --- a/charts/logzio-apm-collector/README.md +++ b/charts/logzio-apm-collector/README.md @@ -30,10 +30,10 @@ helm install -n monitoring --create-namespace \ --set enabled=true \ --set spm.enabled=true \ --set serviceGraph.enabled=true \ ---set secrets.logzioTracesToken="<>" \ ---set secrets.logzioSpmToken="<>" \ ---set secrets.logzioRegion="<>" \ ---set secrets.env_id="<>" \ +--set global.logzioTracesToken="<>" \ +--set global.logzioSpmToken="<>" \ +--set global.logzioRegion="<>" \ +--set global.env_id="<>" \ logzio-apm-collector logzio-helm/logzio-apm-collector ``` @@ -66,10 +66,6 @@ logzio-apm-collector.monitoring.svc.cluster.local:<> > > For a complete list, see `values.yaml` >> `traceConfig` >> `receivers`. -> [!WARNING] -> If you're deploying the chart as a sub chart of the `logzio-monitoring` chart, replace: -> `logzio-apm-collector` >> `logzio-monitoring-otel-collector` - ## Custom trace sampling rules To customize the Traces Sampling rules in the OpenTelemetry Collector, you can follow the below steps: diff --git a/charts/logzio-apm-collector/templates/NOTES.txt b/charts/logzio-apm-collector/templates/NOTES.txt index 0a655d63..fbf4bb17 100644 --- a/charts/logzio-apm-collector/templates/NOTES.txt +++ b/charts/logzio-apm-collector/templates/NOTES.txt @@ -15,7 +15,7 @@ {{ fail "[ERROR] The logzio-apm-collector Chart's `otelLogLevel` must be one of 'info', 'warn', 'error' or 'debug'." }} {{- end }} -{{- $region := lower .Values.secrets.logzioRegion }} +{{- $region := lower .Values.global.logzioRegion }} {{- if not (or (eq $region "us") (eq $region "eu") (eq $region "uk") (eq $region "ca") (eq $region "au")) }} {{ print "[WARN] The `logzioRegion` expected value should be one of 'us', 'eu', 'uk', 'ca', 'au'." }} {{- end }} diff --git a/charts/logzio-apm-collector/templates/_helpers-spm.tpl b/charts/logzio-apm-collector/templates/_helpers-spm.tpl index 4206bb90..c583a649 100644 --- a/charts/logzio-apm-collector/templates/_helpers-spm.tpl +++ b/charts/logzio-apm-collector/templates/_helpers-spm.tpl @@ -22,7 +22,7 @@ component: spm-collector Create Logz.io listener address based on region */}} {{- define "spm-collector.listenerAddress" -}} -{{- $region := .Values.secrets.logzioRegion -}} +{{- $region := .Values.global.logzioRegion -}} {{- if or (eq $region "us") (not $region) -}} https://listener.logz.io:8053 {{- else }} diff --git a/charts/logzio-apm-collector/templates/_helpers.tpl b/charts/logzio-apm-collector/templates/_helpers.tpl index d46def68..90212554 100644 --- a/charts/logzio-apm-collector/templates/_helpers.tpl +++ b/charts/logzio-apm-collector/templates/_helpers.tpl @@ -146,17 +146,3 @@ The APM service address {{- $serviceName := include "apm-collector.fullname" .}} {{- printf "http://%s.%s.svc.cluster.local" $serviceName .Release.Namespace }} {{- end }} - -{{/* -Get secret value either from the global section (parent chart is running) or the default sub chart section -*/}} -{{- define "getGlobalOrDefaultValue" -}} -{{- $ctx := index . 0 -}} -{{- $key := index . 1 -}} -{{- $fallback := index . 2 -}} -{{- if hasKey $ctx.Values "global" -}} - {{- $ctx.Values.global | default dict | get $key | default $fallback -}} -{{- else -}} - {{- $fallback -}} -{{- end -}} -{{- end -}} diff --git a/charts/logzio-apm-collector/templates/_pod-spm.tpl b/charts/logzio-apm-collector/templates/_pod-spm.tpl index f5aaa777..cc9e22ec 100644 --- a/charts/logzio-apm-collector/templates/_pod-spm.tpl +++ b/charts/logzio-apm-collector/templates/_pod-spm.tpl @@ -46,13 +46,13 @@ containers: - name: ENV_ID valueFrom: secretKeyRef: - name: {{ .Values.secrets.name }} + name: {{ .Values.secret.name }} key: env-id - name: SPM_ENDPOINT - {{- if .Values.secrets.customSpmEndpoint }} + {{- if .Values.global.customSpmEndpoint }} valueFrom: secretKeyRef: - name: {{ .Values.secrets.name }} + name: {{ .Values.secret.name }} key: custom-spm-endpoint {{- else }} value: {{ include "spm-collector.listenerAddress" . | quote }} @@ -60,7 +60,7 @@ containers: - name: LOGZIO_SPM_TOKEN valueFrom: secretKeyRef: - name: {{ .Values.secrets.name }} + name: {{ .Values.secret.name }} key: logzio-spm-token - name: LOG_LEVEL value: {{ .Values.otelLogLevel | default "info" | quote }} diff --git a/charts/logzio-apm-collector/templates/_pod.tpl b/charts/logzio-apm-collector/templates/_pod.tpl index e89375fe..642fca6b 100644 --- a/charts/logzio-apm-collector/templates/_pod.tpl +++ b/charts/logzio-apm-collector/templates/_pod.tpl @@ -48,23 +48,23 @@ containers: - name: ENV_ID valueFrom: secretKeyRef: - name: {{ .Values.secrets.name }} + name: {{ .Values.secret.name }} key: env-id - name: LOGZIO_REGION valueFrom: secretKeyRef: - name: {{ .Values.secrets.name }} + name: {{ .Values.secret.name }} key: logzio-listener-region - name: LOGZIO_TRACES_TOKEN valueFrom: secretKeyRef: - name: {{ .Values.secrets.name }} + name: {{ .Values.secret.name }} key: logzio-traces-token - {{- if .Values.secrets.customTracesEndpoint }} + {{- if .Values.global.customTracesEndpoint }} - name: CUSTOM_TRACES_ENDPOINT valueFrom: secretKeyRef: - name: {{ .Values.secrets.name }} + name: {{ .Values.secret.name }} key: custom-traces-endpoint {{- end }} - name: LOG_LEVEL diff --git a/charts/logzio-apm-collector/templates/_validations.tpl b/charts/logzio-apm-collector/templates/_validations.tpl index f02bdad1..2ed6e9b3 100644 --- a/charts/logzio-apm-collector/templates/_validations.tpl +++ b/charts/logzio-apm-collector/templates/_validations.tpl @@ -3,9 +3,7 @@ Verify tracing token was provided if the chart is enabled */}} {{- define "check-tracing-token" -}} {{- if .Values.enabled }} - {{- $hasGlobalToken := and (hasKey .Values "global") .Values.global.logzioTracesToken -}} - {{- $hasSecretsToken := .Values.secrets.logzioTracesToken -}} - {{- if not (or $hasGlobalToken $hasSecretsToken) }} + {{- if not .Values.global.logzioTracesToken }} {{- fail "Missing Tracing Token" }} {{- end }} {{- end }} @@ -16,9 +14,7 @@ Verify SPM token was provided if SPM is enabled */}} {{- define "check-spm-token" -}} {{- if and (.Values.enabled) (.Values.spm.enabled) }} - {{- $hasGlobalToken := and (hasKey .Values "global") .Values.global.logzioSpmToken -}} - {{- $hasSecretsToken := .Values.secrets.logzioSpmToken -}} - {{- if not (or $hasGlobalToken $hasSecretsToken) }} + {{- if not .Values.global.logzioSpmToken }} {{- fail "Missing SPM Token" }} {{- end }} {{- end }} diff --git a/charts/logzio-apm-collector/templates/secret.yaml b/charts/logzio-apm-collector/templates/secret.yaml index 19fc02f3..f990ccfa 100644 --- a/charts/logzio-apm-collector/templates/secret.yaml +++ b/charts/logzio-apm-collector/templates/secret.yaml @@ -1,23 +1,23 @@ {{ if .Values.enabled}} -{{- if .Values.secrets.enabled }} +{{- if .Values.secret.enabled }} apiVersion: v1 kind: Secret metadata: - name: {{ .Values.secrets.name }} + name: {{ .Values.secret.name }} namespace: {{ .Release.Namespace }} type: Opaque stringData: - env-id: {{ include "getGlobalOrDefaultValue" (list . "env_id" .Values.secrets.env_id) | quote }} - logzio-listener-region: {{ include "getGlobalOrDefaultValue" (list . "logzioRegion" .Values.secrets.logzioRegion) }} + env-id: {{ .Values.global.env_id | quote}} + logzio-listener-region: {{ .Values.global.logzioRegion | quote}} {{- template "check-tracing-token" . }} - logzio-traces-token: {{ include "getGlobalOrDefaultValue" (list . "logzioTracesToken" .Values.secrets.logzioTracesToken) }} + logzio-traces-token: {{ .Values.global.logzioTracesToken }} {{- template "check-spm-token" . }} - logzio-spm-token: {{ include "getGlobalOrDefaultValue" (list . "logzioSpmToken" .Values.secrets.logzioSpmToken) }} - {{- if .Values.secrets.customTracesEndpoint }} - custom-traces-endpoint: {{ .Values.secrets.customTracesEndpoint }} + logzio-spm-token: {{ .Values.global.logzioSpmToken }} + {{- if .Values.global.customTracesEndpoint }} + custom-traces-endpoint: {{ .Values.global.customTracesEndpoint }} {{- end }} - {{- if .Values.secrets.customSpmEndpoint}} - custom-spm-endpoint: {{ .Values.secrets.customSpmEndpoint }} + {{- if .Values.global.customSpmEndpoint}} + custom-spm-endpoint: {{ .Values.global.customSpmEndpoint }} {{- end }} {{- end }} {{ end }} diff --git a/charts/logzio-apm-collector/values.yaml b/charts/logzio-apm-collector/values.yaml index 6908711b..7ad351c8 100644 --- a/charts/logzio-apm-collector/values.yaml +++ b/charts/logzio-apm-collector/values.yaml @@ -21,16 +21,7 @@ namespaceOverride: "" ####################################################################################################################### # Base Configuration Parameters ####################################################################################################################### -secrets: - # When secrets.enabled is true, the logzio secret will be created and managed by this Chart. - # If you're managing the logzio secrets by yourself, set to false. - # Note that in order for the default configuration to work properly, you need to: - # 1. Update secrets.name to your custom secret name - # 2. Include these keys in your secret: env-id, logzio-listener-region, logzio-traces-token, logzio-spm-token - # To use a custom endpoint, include custom-traces-endpoint, custom-spm-endpoint or both parameters in your secret, - # depending on your needs and set secrets.customTracesEndpoint and/or secrets.customSpmEndpoint to `true`. - enabled: true - name: logzio-apm-collector-secret +global: # environment identifier attribute that will be added to all telemetry env_id: "my_env" # Logz.io Tracing Shipping Token @@ -39,7 +30,7 @@ secrets: logzioSpmToken: "" # Logz.io region code logzioRegion: "us" - # Optional - Overrides secrets.LogzioRegion listener address with a custom endpoint. For example: http://endpoint:8080 + # Optional - Overrides global.LogzioRegion listener address with a custom endpoint. For example: http://endpoint:8080 customTracesEndpoint: "" customSpmEndpoint: "" @@ -211,7 +202,7 @@ spmForwarderConfig: pipelines: traces/spm: receivers: [jaeger, zipkin, otlp] - processors: [resourcedetection/all, attributes/env_id, k8sattributes] + processors: [resourcedetection/all, attributes/env_id, k8sattributes, batch] exporters: [otlp] # SPM Collector configuration @@ -233,6 +224,7 @@ spmConfig: grpc: endpoint: "0.0.0.0:4317" processors: + batch: {} metricstransform/metrics-rename: transforms: # rename metric duration.XXX >> latency.XXX @@ -244,6 +236,11 @@ spmConfig: - action: update include: calls new_name: calls_total + # manually add 'seconds' unit to the relevant Service Graph metric names + - include: ^(traces_service_graph_request_(server|client).*)$$ + action: update + match_type: regexp + new_name: $${1}_seconds metricstransform/labels-rename: transforms: # for metrics matching `latencyXXX` or `callsXXX` @@ -303,7 +300,7 @@ spmConfig: exporters: [spanmetrics] metrics/spm-logzio: receivers: [spanmetrics] - processors: [metricstransform/metrics-rename, metricstransform/labels-rename] + processors: [metricstransform/metrics-rename, metricstransform/labels-rename, batch] exporters: [prometheusremotewrite/spm-logzio] # Service Graph configuration @@ -340,11 +337,23 @@ imagePullSecrets: [] # OpenTelemetry Collector executable command: name: otelcol-contrib - extraArgs: [] + extraArgs: + - --feature-gates=connector.spanmetrics.legacyMetricNames # rename traces_span_metrics_xxx >> xxx ####################################################################################################################### # Kubernetes Resources Configuration ####################################################################################################################### +secret: + # When secret.enabled is true, the logzio secret will be created and managed by this Chart. + # If you're managing the logzio secrets by yourself, set to false. + # Note that in order for the default configuration to work properly, you need to: + # 1. Update secrets.name to your custom secret name. + # 2. Include these keys in your secret: env-id, logzio-listener-region, logzio-traces-token, logzio-spm-token. + # To use a custom endpoint, include custom-traces-endpoint, custom-spm-endpoint or both parameters in your secret, + # depending on your needs and set global.customTracesEndpoint and/or global.customSpmEndpoint to `true`. + enabled: true + name: logzio-apm-collector-secret + configMap: # Specifies whether a configMap should be created create: true @@ -403,14 +412,14 @@ service: # Annotations to add to the Service. annotations: {} - # By default, Service will be created setting 'internalTrafficPolicy: Cluster' - # unless other value is explicitly set. - # Setting 'internalTrafficPolicy: Cluster' on a daemonset is not recommended (in such case, use 'internalTrafficPolicy: Local') + ## By default, Service will be created setting 'internalTrafficPolicy: Cluster' + ## unless other value is explicitly set. + ## Setting 'internalTrafficPolicy: Cluster' on a daemonset is not recommended (in such case, use 'internalTrafficPolicy: Local') # internalTrafficPolicy: Cluster - # By default, Service of type 'LoadBalancer' will be created setting 'externalTrafficPolicy: Cluster' - # unless other value is explicitly set. - # Possible values are Cluster or Local (https://kubernetes.io/docs/tasks/access-application-cluster/create-external-load-balancer/#preserving-the-client-source-ip) + ## By default, Service of type 'LoadBalancer' will be created setting 'externalTrafficPolicy: Cluster' + ## unless other value is explicitly set. + ## Possible values are Cluster or Local (https://kubernetes.io/docs/tasks/access-application-cluster/create-external-load-balancer/#preserving-the-client-source-ip) # externalTrafficPolicy: Cluster spmService: @@ -420,14 +429,14 @@ spmService: # Annotations to add to the Service. annotations: {} - # By default, Service will be created setting 'internalTrafficPolicy: Cluster' - # unless other value is explicitly set. - # Setting 'internalTrafficPolicy: Cluster' on a daemonset is not recommended (in such case, use 'internalTrafficPolicy: Local') + ## By default, Service will be created setting 'internalTrafficPolicy: Cluster' + ## unless other value is explicitly set. + ## Setting 'internalTrafficPolicy: Cluster' on a daemonset is not recommended (in such case, use 'internalTrafficPolicy: Local') # internalTrafficPolicy: Cluster - # By default, Service of type 'LoadBalancer' will be created setting 'externalTrafficPolicy: Cluster' - # unless other value is explicitly set. - # Possible values are Cluster or Local (https://kubernetes.io/docs/tasks/access-application-cluster/create-external-load-balancer/#preserving-the-client-source-ip) + ## By default, Service of type 'LoadBalancer' will be created setting 'externalTrafficPolicy: Cluster' + ## unless other value is explicitly set. + ## Possible values are Cluster or Local (https://kubernetes.io/docs/tasks/access-application-cluster/create-external-load-balancer/#preserving-the-client-source-ip) # externalTrafficPolicy: Cluster # Configure HPA for Traces Collector. @@ -533,8 +542,7 @@ extraVolumeMounts: [] # resources.limits.memory # If no resources.limits.memory are defined enabling does nothing. # In a future release this setting will be enabled by default. -# See https://github.com/open-telemetry/opentelemetry-helm-charts/issues/891 -# for more details. +# For more details see https://github.com/open-telemetry/opentelemetry-helm-charts/issues/891 useGOMEMLIMIT: false # Resource allocation. @@ -616,17 +624,16 @@ lifecycleHooks: {} # liveness probe configuration # Ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/ -## livenessProbe: - # Number of seconds after the container has started before startup, liveness or readiness probes are initiated. + ## Number of seconds after the container has started before startup, liveness or readiness probes are initiated. # initialDelaySeconds: 1 - # How often in seconds to perform the probe. + ## How often in seconds to perform the probe. # periodSeconds: 10 - # Number of seconds after which the probe times out. + ## Number of seconds after which the probe times out. # timeoutSeconds: 1 - # Minimum consecutive failures for the probe to be considered failed after having succeeded. + ## Minimum consecutive failures for the probe to be considered failed after having succeeded. # failureThreshold: 1 - # Duration in seconds the pod needs to terminate gracefully upon probe failure. + ## Duration in seconds the pod needs to terminate gracefully upon probe failure. # terminationGracePeriodSeconds: 10 httpGet: port: 13133 @@ -634,17 +641,16 @@ livenessProbe: # readiness probe configuration # Ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/ -## readinessProbe: - # Number of seconds after the container has started before startup, liveness or readiness probes are initiated. + ## Number of seconds after the container has started before startup, liveness or readiness probes are initiated. # initialDelaySeconds: 1 - # How often (in seconds) to perform the probe. + ## How often (in seconds) to perform the probe. # periodSeconds: 10 - # Number of seconds after which the probe times out. + ## Number of seconds after which the probe times out. # timeoutSeconds: 1 - # Minimum consecutive successes for the probe to be considered successful after having failed. + ## Minimum consecutive successes for the probe to be considered successful after having failed. # successThreshold: 1 - # Minimum consecutive failures for the probe to be considered failed after having succeeded. + ## Minimum consecutive failures for the probe to be considered failed after having succeeded. # failureThreshold: 1 httpGet: port: 13133 diff --git a/tests/apm_metrics_e2e_test.go b/tests/apm_metrics_e2e_test.go new file mode 100644 index 00000000..8ba1b8d9 --- /dev/null +++ b/tests/apm_metrics_e2e_test.go @@ -0,0 +1,153 @@ +package tests + +import ( + "encoding/json" + "fmt" + "go.uber.org/zap" + "io" + "net/http" + "os" + "strings" + "testing" +) + +// MetricResponse represents the structure of the API response +type MetricResponse struct { + Status string `json:"status"` + Data struct { + ResultType string `json:"resultType"` + Result []struct { + Metric map[string]string `json:"metric"` + Value []interface{} `json:"value"` + } `json:"result"` + } `json:"data"` +} + +func TestSpmMetricsApm(t *testing.T) { + requiredMetrics := map[string][]string{ + "calls_total": {"k8s_node_name", "k8s_namespace_name", "k8s_pod_name", "span_kind", "operation"}, + "latency_sum": {"k8s_node_name", "k8s_namespace_name", "k8s_pod_name", "span_kind", "operation"}, + "latency_count": {"k8s_node_name", "k8s_namespace_name", "k8s_pod_name", "span_kind", "operation"}, + "latency_bucket": {"k8s_node_name", "k8s_namespace_name", "k8s_pod_name", "span_kind", "operation"}, + } + envId := os.Getenv("ENV_ID") + query := fmt.Sprintf(`{env_id='%s'}`, envId) + testMetrics(t, requiredMetrics, query) +} + +func TestServiceGraphMetricsApm(t *testing.T) { + requiredMetrics := map[string][]string{ + "traces_service_graph_request_total": {"client", "server"}, + "traces_service_graph_request_failed_total": {"client", "server"}, + "traces_service_graph_request_server_seconds_bucket": {"client", "server"}, + "traces_service_graph_request_server_seconds_count": {"client", "server"}, + "traces_service_graph_request_server_seconds_sum": {"client", "server"}, + "traces_service_graph_request_client_seconds_bucket": {"client", "server"}, + "traces_service_graph_request_client_seconds_count": {"client", "server"}, + "traces_service_graph_request_client_seconds_sum": {"client", "server"}, + } + envId := os.Getenv("ENV_ID") + query := fmt.Sprintf(`{client_env_id='%s'}`, envId) + testMetrics(t, requiredMetrics, query) +} + +func testMetrics(t *testing.T, requiredMetrics map[string][]string, query string) { + metricsApiKey := os.Getenv("LOGZIO_METRICS_API_KEY") + if metricsApiKey == "" { + t.Fatalf("LOGZIO_METRICS_API_KEY environment variable not set") + } + + metricResponse, err := fetchMetrics(metricsApiKey, query) + if err != nil { + t.Fatalf("Failed to fetch metrics: %v", err) + } + + if metricResponse.Status != "success" { + t.Errorf("No metrics found") + } + logger.Info("Found metrics", zap.Int("metrics_count", len(metricResponse.Data.Result))) + // Verify required metrics + missingMetrics := verifyMetrics(metricResponse, requiredMetrics) + if len(missingMetrics) > 0 { + var sb strings.Builder + for _, metric := range missingMetrics { + sb.WriteString(metric + "\n") + } + t.Errorf("Missing metrics or labels:\n%s", sb.String()) + } +} + +// fetchMetrics fetches the metrics from the logz.io API +func fetchMetrics(metricsApiKey string, query string) (*MetricResponse, error) { + url := fmt.Sprintf("%s/metrics/prometheus/api/v1/query?query=%s", BaseLogzioApiUrl, query) + client := &http.Client{} + logger.Info("sending api request", zap.String("url", url)) + req, err := http.NewRequest("GET", url, nil) + if err != nil { + return nil, err + } + req.Header.Set("Accept", "application/json") + req.Header.Set("X-API-TOKEN", metricsApiKey) + + resp, err := client.Do(req) + if err != nil { + return nil, err + } + defer resp.Body.Close() + + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("unexpected status code: %d", resp.StatusCode) + } + + body, err := io.ReadAll(resp.Body) + if err != nil { + return nil, err + } + + var metricResponse MetricResponse + err = json.Unmarshal(body, &metricResponse) + if err != nil { + return nil, err + } + + return &metricResponse, nil +} + +// verifyMetrics checks if the required metrics and their labels are present in the response +func verifyMetrics(metricResponse *MetricResponse, requiredMetrics map[string][]string) []string { + missingMetrics := []string{} + + for metricName, requiredLabels := range requiredMetrics { + found := false + for _, result := range metricResponse.Data.Result { + if result.Metric["__name__"] == metricName { + found = true + for _, label := range requiredLabels { + if _, exists := result.Metric[label]; !exists { + missingMetrics = append(missingMetrics, fmt.Sprintf("%s (missing label: %s)", metricName, label)) + } + } + } + } + if !found { + missingMetrics = append(missingMetrics, metricName+" (not found)") + } + } + return deduplicate(missingMetrics) +} + +// deduplicate removes duplicate strings from the input array. +func deduplicate(data []string) []string { + uniqueMap := make(map[string]bool) + var uniqueList []string + + for _, item := range data { + trimmedItem := strings.TrimSpace(item) + if _, exists := uniqueMap[trimmedItem]; !exists { + uniqueMap[trimmedItem] = true + uniqueList = append(uniqueList, trimmedItem) + } + } + + return uniqueList +} diff --git a/tests/resources/otel-demo-apm.yaml b/tests/resources/otel-demo-apm.yaml new file mode 100644 index 00000000..2a1e55da --- /dev/null +++ b/tests/resources/otel-demo-apm.yaml @@ -0,0 +1,16 @@ +default: + envOverrides: + - name: OTEL_COLLECTOR_NAME + value: logzio-apm-collector.default.svc.cluster.local + +opentelemetry-collector: + enabled: false + +jaeger: + enabled: false + +prometheus: + enabled: false + +grafana: + enabled: false diff --git a/tests/resources/tracegen-apm.yaml b/tests/resources/tracegen-apm.yaml new file mode 100644 index 00000000..fdf12d55 --- /dev/null +++ b/tests/resources/tracegen-apm.yaml @@ -0,0 +1,24 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: trace-gen +spec: + selector: + matchLabels: + app: trace-gen + template: + metadata: + labels: + app: trace-gen + spec: + containers: + - name: trace-gen + image: ghcr.io/frzifus/jaeger-otel-test:latest + args: + [ + '-otel.agent.host=logzio-apm-collector', + '-otel.agent.port=4317', + ] + env: + - name: OTEL_SERVICE_NAME + value: 'local-test-service' \ No newline at end of file From 11783fc0d4bd44db7269ef4debedbcf09e9705e9 Mon Sep 17 00:00:00 2001 From: 8naama Date: Thu, 12 Dec 2024 16:57:12 +0200 Subject: [PATCH 14/15] fine tuning following tests --- charts/logzio-apm-collector/Chart.yaml | 2 +- charts/logzio-apm-collector/VALUES.md | 165 +++++++++--------- .../templates/service.yaml | 1 + charts/logzio-apm-collector/values.yaml | 21 ++- 4 files changed, 98 insertions(+), 91 deletions(-) diff --git a/charts/logzio-apm-collector/Chart.yaml b/charts/logzio-apm-collector/Chart.yaml index ca3fd627..c217c430 100644 --- a/charts/logzio-apm-collector/Chart.yaml +++ b/charts/logzio-apm-collector/Chart.yaml @@ -8,4 +8,4 @@ icon: https://logzbucket.s3.eu-west-1.amazonaws.com/logz-io-img/logo400x400.png maintainers: - name: Naama Bendalak email: naama.bendalak@logz.io -appVersion: 0.113.0 +appVersion: 0.115.1 \ No newline at end of file diff --git a/charts/logzio-apm-collector/VALUES.md b/charts/logzio-apm-collector/VALUES.md index 1add0932..a6b0ee3a 100644 --- a/charts/logzio-apm-collector/VALUES.md +++ b/charts/logzio-apm-collector/VALUES.md @@ -1,85 +1,86 @@ # Logz.io APM Collector All Configuration options Below you can find a complete list of settings in `values.yaml`. -| Key | Description | Default Value | -|--------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------| -| enabled | Toggle for enabling the Helm chart deployment | `false` | -| spm.enabled | Toggle for enabling SPM Collection | `false` | -| serviceGraph.enabled | Toggle for enabling Service Graph metrics Collection | `false` | -| nameOverride | Override the default name for the deployment. | `""` | -| fullnameOverride | Override the default name for the deployment. | `""` | -| namespaceOverride | Override the namespace into which the resources will be deployed. | `""` | -| secrets.enabled | Toggle for creating and managing the Logz.io secret by this chart. | `"true"` | -| secrets.name | The name of the secret for Logz.io APM collector. | `"logzio-apm-collector-secret"` | -| secrets.env_id | Environment identifier attribute added to all logs. | `"my_env"` | -| secrets.logzioTracesToken | Secret with your Logz.io tracing shipping token. | `""` | -| secrets.logzioSpmToken | Secret with your Logz.io SPM shipping token. | `""` | -| secrets.logzioRegion | Secret with your Logz.io region. | `"us"` | -| secrets.customTracesEndpoint | Secret with a custom endpoint to send traces to, overrides Logz.io region listener address. | `""` | -| secrets.customSpmEndpoint | Secret with your custom endpoint to send SPM to, overrides Logz.io region listener address. | `""` | -| otelLogLevel | Change the OpenTelemetry Collector log level | `"info"` | -| SamplingProbability | Traces Sampling Probability | `10` | -| SamplingProbability | Traces Sampling Latency | `500` | -| traceConfig | Traces collector configuration, supports templating. | see `values.yaml` | -| spmForwarderConfig | Collector configuration to pass traces to the SPM Collector, supports templating. | see `values.yaml` | -| spmConfig | Collector configuration to generate SPM, supports templating. | see `values.yaml` | -| serviceGraphConfig | Collector configuration to generate Service Graph metrics. | see `values.yaml` | -| image.repository | Opentelemetry collector image repository. | `otel/opentelemetry-collector-contrib` | -| image.pullPolicy | Image pull policy. | `IfNotPresent` | -| image.tag | Overrides the image tag whose default is the chart appVersion. | `""` | -| image.digest | Pull images by digest. | `""` | -| imagePullSecrets | Specifies image pull secrets. | `[]` | -| command.name | OpenTelemetry Collector executable. | `"otelcol-contrib"` | -| command.extraArgs | Additional arguments for the command. | `[]` | -| configMap.create | Specifies whether a configMap should be created. | `true` | -| serviceAccount.create | Specifies whether a service account should be created. | `true` | -| serviceAccount.annotations | Specifies annotations for the service account. | `{}` | -| serviceAccount.name | The name of the service account. | `""` | -| clusterRole.create | Specifies whether a clusterRole should be created. | `true` | -| clusterRole.annotations | Specifies annotations for the cluster role. | `{}` | -| clusterRole.name | The name of the clusterRole. | `""` | -| clusterRole.rules | Specifies additional rules for the clusterRole. | `[]` | -| clusterRole.clusterRoleBinding.annotations | Specifies annotations for the clusterRoleBinding. | `{}` | -| clusterRole.clusterRoleBinding.name | The name of the clusterRoleBinding. | `""` | -| service.enabled | Enable the creation of a Service. | `true` | -| service.type | Specifies the type of service. | `ClusterIP` | -| service.annotations | Specifies annotations for the service. | `{}` | -| spmService.type | Specifies the type of service for SPM. | `ClusterIP` | -| spmService.annotations | Specifies annotations for the service for SPM. | `{}` | -| autoscaling.enabled | Specifies if HPA should be created for the Traces Collector. | `false` | -| autoscaling.annotations | Specifies annotations for the HPA. | `{}` | -| autoscaling.minReplicas | Control autoscaling scale. | `1` | -| autoscaling.maxReplicas | Control autoscaling scale. | `10` | -| autoscaling.targetCPUUtilizationPercentage | Control autoscaling scale. | `80` | -| autoscaling.targetMemoryUtilizationPercentage | Control autoscaling scale. | `80` | -| spmAutoscaling.enabled | Specifies if VPA should be created for the SPM Collector. | `false` | -| autoscaling.annotations | Specifies annotations for the VPA. | `{}` | -| autoscaling.minAllowed.cpu | Control autoscaling scale. | `"50m"` | -| autoscaling.minAllowed.memory | Control autoscaling scale. | `"70Mi"` | -| autoscaling.maxAllowed.cpu | Control autoscaling scale. | `"150m"` | -| autoscaling.maxAllowed.memory | Control autoscaling scale. | `"250Mi"` | -| ports | Defines ports configurations | see `values.yaml` | -| additionalLabels | labels to add to all otel-collector resources | `{}` | -| podSecurityContext | Security context policies for the pod. | `{}` | -| securityContext | Security context policies for the container. | `{}` | -| nodeSelector | Node labels for pod assignment | `{}` | -| tolerations | Tolerations for pod assignment | `[]` | -| affinity | Affinity rules for pod assignment. | see `values.yaml` | -| priorityClassName | Scheduler priority class name. | `""` | -| extraEnvs | Extra environment variables to set in the pods | `[]` | -| extraEnvsFrom | Extra environment variables from secret or configMap to set in the pods | `[]` | -| extraVolumes | Extra volumes to add in the pods | `[]` | -| extraVolumeMounts | Extra volume mounts to add in the pods | `[]` | -| useGOMEMLIMIT | Set `GOMEMLIMIT` env var to a percentage of `resources.limits.memory` | `false` | -| resources | CPU/memory resource requests/limits | see `values.yaml` | -| podAnnotations | Annotations to add to the pod. | `{}` | -| podLabels | Labels to add to the pod. | `{}` | -| hostAliases | Adding entries to Pod /etc/hosts with HostAliases. | `[]` | -| dnsPolicy | Pod DNS policy. | `""` | -| dnsConfig | Custom DNS config. Required when `dnsPolicy: None`. | `{}` | -| annotations | Annotations to add to the ???. | `{}` | -| extraContainers | List of extra sidecars to add. | `[]` | -| initContainers | List of init container specs. | `[]` | -| lifecycleHooks | Pod lifecycle policies. | `{}` | -| livenessProbe | Liveness probe configuration. | see `values.yaml` | -| readinessProbe | Readiness probe configuration. | see `values.yaml` | +| Key | Description | Default Value | +|-----------------------------------------------|---------------------------------------------------------------------------------------------|---------------------------------------------------------------| +| enabled | Toggle for enabling the Helm chart deployment | `false` | +| spm.enabled | Toggle for enabling SPM Collection | `false` | +| serviceGraph.enabled | Toggle for enabling Service Graph metrics Collection | `false` | +| nameOverride | Override the default name for the deployment. | `""` | +| fullnameOverride | Override the default name for the deployment. | `""` | +| namespaceOverride | Override the namespace into which the resources will be deployed. | `""` | +| global.env_id | Environment identifier attribute added to all logs. | `"my_env"` | +| global.logzioTracesToken | Secret with your Logz.io tracing shipping token. | `""` | +| global.logzioSpmToken | Secret with your Logz.io SPM shipping token. | `""` | +| global.logzioRegion | Secret with your Logz.io region. | `"us"` | +| global.customTracesEndpoint | Secret with a custom endpoint to send traces to, overrides Logz.io region listener address. | `""` | +| global.customSpmEndpoint | Secret with your custom endpoint to send SPM to, overrides Logz.io region listener address. | `""` | +| otelLogLevel | Change the OpenTelemetry Collector log level | `"info"` | +| standaloneCollector.replicaCount | Number of replicas for the standalone collector. | `1` | +| SamplingProbability | Traces Sampling Probability | `10` | +| SamplingLatency | Traces Sampling Latency | `500` | +| traceConfig | Traces collector configuration, supports templating. | see `values.yaml` | +| spmForwarderConfig | Collector configuration to pass traces to the SPM Collector, supports templating. | see `values.yaml` | +| spmConfig | Collector configuration to generate SPM, supports templating. | see `values.yaml` | +| serviceGraphConfig | Collector configuration to generate Service Graph metrics. | see `values.yaml` | +| image.repository | Opentelemetry collector image repository. | `otel/opentelemetry-collector-contrib` | +| image.pullPolicy | Image pull policy. | `IfNotPresent` | +| image.tag | Overrides the image tag whose default is the chart appVersion. | `""` | +| image.digest | Pull images by digest. | `""` | +| imagePullSecrets | Specifies image pull secrets. | `[]` | +| command.name | OpenTelemetry Collector executable. | `"otelcol-contrib"` | +| command.extraArgs | Additional arguments for the command. | `["--feature-gates=connector.spanmetrics.legacyMetricNames"]` | +| secret.enabled | Toggle for creating and managing the Logz.io secret by this chart. | `"true"` | +| secret.name | The name of the secret for Logz.io APM collector. | `"logzio-apm-collector-secret"` | +| configMap.create | Specifies whether a configMap should be created. | `true` | +| serviceAccount.create | Specifies whether a service account should be created. | `true` | +| serviceAccount.annotations | Specifies annotations for the service account. | `{}` | +| serviceAccount.name | The name of the service account. | `""` | +| clusterRole.create | Specifies whether a clusterRole should be created. | `true` | +| clusterRole.annotations | Specifies annotations for the cluster role. | `{}` | +| clusterRole.name | The name of the clusterRole. | `""` | +| clusterRole.rules | Specifies additional rules for the clusterRole. | `[]` | +| clusterRole.clusterRoleBinding.annotations | Specifies annotations for the clusterRoleBinding. | `{}` | +| clusterRole.clusterRoleBinding.name | The name of the clusterRoleBinding. | `""` | +| service.enabled | Enable the creation of a Service. | `true` | +| service.type | Specifies the type of service. | `ClusterIP` | +| service.annotations | Specifies annotations for the service. | `{}` | +| spmService.type | Specifies the type of service for SPM. | `ClusterIP` | +| spmService.annotations | Specifies annotations for the service for SPM. | `{}` | +| autoscaling.enabled | Specifies if HPA should be created for the Traces Collector. | `false` | +| autoscaling.annotations | Specifies annotations for the HPA. | `{}` | +| autoscaling.minReplicas | Control HPA autoscaling scale. | `1` | +| autoscaling.maxReplicas | Control HPA autoscaling scale. | `10` | +| autoscaling.targetCPUUtilizationPercentage | Control HPA autoscaling scale. | `80` | +| autoscaling.targetMemoryUtilizationPercentage | Control HPA autoscaling scale. | `80` | +| spmAutoscaling.enabled | Specifies if VPA should be created for the SPM Collector. | `false` | +| spmAutoscaling.annotations | Specifies annotations for the VPA. | `{}` | +| spmAutoscaling.minAllowed.cpu | Control VPA autoscaling scale. | `"50m"` | +| spmAutoscaling.minAllowed.memory | Control VPA autoscaling scale. | `"70Mi"` | +| spmAutoscaling.maxAllowed.cpu | Control VPA autoscaling scale. | `"150m"` | +| spmAutoscaling.maxAllowed.memory | Control VPA autoscaling scale. | `"250Mi"` | +| ports | Defines ports configurations | see `values.yaml` | +| additionalLabels | labels to add to all otel-collector resources | `{}` | +| podSecurityContext | Security context policies for the pod. | `{}` | +| securityContext | Security context policies for the container. | `{}` | +| nodeSelector | Node labels for pod assignment | `{}` | +| tolerations | Tolerations for pod assignment | `[]` | +| affinity | Affinity rules for pod assignment. | see `values.yaml` | +| priorityClassName | Scheduler priority class name. | `""` | +| extraEnvs | Extra environment variables to set in the pods | `[]` | +| extraEnvsFrom | Extra environment variables from secret or configMap to set in the pods | `[]` | +| extraVolumes | Extra volumes to add in the pods | `[]` | +| extraVolumeMounts | Extra volume mounts to add in the pods | `[]` | +| useGOMEMLIMIT | Set `GOMEMLIMIT` env var to a percentage of `resources.limits.memory` | `false` | +| resources | CPU/memory resource requests/limits | see `values.yaml` | +| podAnnotations | Annotations to add to the pod. | `{}` | +| podLabels | Labels to add to the pod. | `{}` | +| hostAliases | Adding entries to Pod /etc/hosts with HostAliases. | `[]` | +| dnsPolicy | Pod DNS policy. | `""` | +| dnsConfig | Custom DNS config. Required when `dnsPolicy: None`. | `{}` | +| annotations | Annotations to add to the ???. | `{}` | +| extraContainers | List of extra sidecars to add. | `[]` | +| initContainers | List of init container specs. | `[]` | +| lifecycleHooks | Pod lifecycle policies. | `{}` | +| livenessProbe | Liveness probe configuration. | see `values.yaml` | +| readinessProbe | Readiness probe configuration. | see `values.yaml` | diff --git a/charts/logzio-apm-collector/templates/service.yaml b/charts/logzio-apm-collector/templates/service.yaml index de75bb9b..e23087f9 100644 --- a/charts/logzio-apm-collector/templates/service.yaml +++ b/charts/logzio-apm-collector/templates/service.yaml @@ -36,6 +36,7 @@ spec: {{- end }} selector: {{- include "apm-collector.selectorLabels" . | nindent 4 }} + {{- include "apm-collector.component" . | nindent 4 }} internalTrafficPolicy: {{ .Values.service.internalTrafficPolicy | default "Cluster" }} {{- if and (eq .Values.service.type "LoadBalancer") (.Values.service.externalTrafficPolicy) }} externalTrafficPolicy: {{ .Values.service.externalTrafficPolicy | default "Cluster" }} diff --git a/charts/logzio-apm-collector/values.yaml b/charts/logzio-apm-collector/values.yaml index 7ad351c8..a4ad987e 100644 --- a/charts/logzio-apm-collector/values.yaml +++ b/charts/logzio-apm-collector/values.yaml @@ -45,8 +45,8 @@ standaloneCollector: # OpenTelemetry Collector Configuration ####################################################################################################################### -# Trace sampling default rules configuration. -# These settings do not affect the traces used for calculating SPM (span metrics). +## Trace sampling default rules configuration. +## These settings do not affect the traces used for calculating SPM (span metrics). # SamplingProbability: 10 # Traces Sampling Probability # SamplingLatency: 500 # Traces Sampling Latency @@ -105,7 +105,7 @@ traceConfig: name: probability-policy, type: probabilistic, probabilistic: {sampling_percentage: "${SAMPLING_PROBABILITY}" } - } + } ] k8sattributes: extract: @@ -302,6 +302,9 @@ spmConfig: receivers: [spanmetrics] processors: [metricstransform/metrics-rename, metricstransform/labels-rename, batch] exporters: [prometheusremotewrite/spm-logzio] + telemetry: + logs: + level: ${LOG_LEVEL} # Service Graph configuration serviceGraphConfig: @@ -313,6 +316,7 @@ serviceGraphConfig: store: ttl: 5s max_items: 100000 + metrics_flush_interval: 60s service: pipelines: traces: @@ -453,7 +457,9 @@ autoscaling: # targetMemoryUtilizationPercentage: 80 # Configure VPA for SPM Collector. -# The reason we use vertical scaling and not horizontal is to make sure the SPM aggregations are correct. +# Vertical scaling is used instead of horizontal scaling to ensure the accuracy of SPM aggregations. +# Note: This feature requires the VPA Custom Resource Definitions (CRDs) to be installed. +# Installation guide: https://github.com/kubernetes/autoscaler/blob/master/vertical-pod-autoscaler/docs/installation.md spmAutoscaling: # Enable the vertical scaling enabled: false @@ -519,7 +525,7 @@ securityContext: {} nodeSelector: {} tolerations: [] # Set affinity rules for the scheduler to determine where all DaemonSet pods can be placed. -# The following configuration prevent logzio apm collector DaemonSet deploymment on fargate nodes +# The following configuration prevent logzio APM collector DaemonSet deployment on fargate nodes # DaemonSet mode is not used in the current APM chart, this configuration is retained for potential future support. affinity: nodeAffinity: @@ -538,9 +544,8 @@ extraEnvsFrom: [] extraVolumes: [] extraVolumeMounts: [] -# When enabled, the chart will set the GOMEMLIMIT env var to 80% of the configured -# resources.limits.memory -# If no resources.limits.memory are defined enabling does nothing. +# When enabled, the chart will set the GOMEMLIMIT env var to 80% of the configured 'resources.limits.memory' +# If no 'resources.limits.memory' are defined, enabling does nothing. # In a future release this setting will be enabled by default. # For more details see https://github.com/open-telemetry/opentelemetry-helm-charts/issues/891 useGOMEMLIMIT: false From 087ef6881abbce6d33ca3dc4122dfd025516ddd3 Mon Sep 17 00:00:00 2001 From: 8naama Date: Thu, 12 Dec 2024 17:12:40 +0200 Subject: [PATCH 15/15] remove redunt comment --- charts/logzio-apm-collector/templates/clusterrole.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/charts/logzio-apm-collector/templates/clusterrole.yaml b/charts/logzio-apm-collector/templates/clusterrole.yaml index e54f16f9..bc69fffb 100644 --- a/charts/logzio-apm-collector/templates/clusterrole.yaml +++ b/charts/logzio-apm-collector/templates/clusterrole.yaml @@ -16,7 +16,6 @@ rules: {{- if .Values.clusterRole.rules -}} {{ toYaml .Values.clusterRole.rules | nindent 2 -}} {{- end }} - # TODO: make sure if we need all of these permissions... - apiGroups: [""] resources: ["events", "namespaces", "namespaces/status", "pods", "pods/status", "replicationcontrollers", "replicationcontrollers/status", "resourcequotas", "services", "endpoints"] verbs: ["get", "watch", "list"]