Skip to content

Commit

Permalink
feat(k8s-infra): introduce deployment.environment global var (#456)
Browse files Browse the repository at this point in the history
* feat(k8s-infra): introduce deployment.environment global var

* chore(release): 🔖 Bump up k8s-infra to 0.11.6

---------

Signed-off-by: Prashant Shahi <prashant@signoz.io>
  • Loading branch information
prashant-shahi authored Jun 25, 2024
1 parent f94fb41 commit e6e4a57
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 5 deletions.
2 changes: 1 addition & 1 deletion charts/k8s-infra/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: k8s-infra
description: Helm chart for collecting metrics and logs in K8s
type: application
version: 0.11.5
version: 0.11.6
appVersion: "0.88.0"
home: https://signoz.io
icon: https://signoz.io/img/SigNozLogo-orange.svg
Expand Down
32 changes: 32 additions & 0 deletions charts/k8s-infra/templates/_config.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ Build config file for daemonset OpenTelemetry Collector: OtelAgent
{{- if .Values.presets.resourceDetectionInternal.enabled }}
{{- $config = (include "opentelemetry-collector.applyResourceDetectionInternalConfig" (dict "Values" $data "config" $config) | fromYaml) }}
{{- end }}
{{- if .Values.global.deploymentEnvironment }}
{{- $config = (include "opentelemetry-collector.applyDeploymentEnvironmentConfig" (dict "Values" $data "config" $config) | fromYaml) }}
{{- end }}
{{- if .Values.presets.loggingExporter.enabled }}
{{- $config = (include "opentelemetry-collector.applyLoggingExporterConfig" (dict "Values" $data "config" $config) | fromYaml) }}
{{- end }}
Expand Down Expand Up @@ -68,6 +71,9 @@ Build config file for deployment OpenTelemetry Collector: OtelDeployment
{{- if .Values.presets.resourceDetectionInternal.enabled }}
{{- $config = (include "opentelemetry-collector.applyResourceDetectionInternalConfig" (dict "Values" $data "config" $config) | fromYaml) }}
{{- end }}
{{- if .Values.global.deploymentEnvironment }}
{{- $config = (include "opentelemetry-collector.applyDeploymentEnvironmentConfig" (dict "Values" $data "config" $config) | fromYaml) }}
{{- end }}
{{- if .Values.presets.clusterMetrics.enabled }}
{{- $config = (include "opentelemetry-collector.applyClusterMetricsConfig" (dict "Values" $data "config" $config) | fromYaml) }}
{{- end }}
Expand Down Expand Up @@ -358,3 +364,29 @@ processors:
timeout: {{ .Values.presets.resourceDetectionInternal.timeout }}
override: {{ .Values.presets.resourceDetectionInternal.override }}
{{- end }}

{{- define "opentelemetry-collector.applyDeploymentEnvironmentConfig" -}}
{{- $config := mustMergeOverwrite (include "opentelemetry-collector.deploymentEnvironmentConfig" .Values | fromYaml) .config }}
{{- if $config.service.pipelines.logs }}
{{- $_ := set $config.service.pipelines.logs "processors" (prepend $config.service.pipelines.logs.processors "resource/deployenv" | uniq) }}
{{- end }}
{{- if $config.service.pipelines.metrics }}
{{- $_ := set $config.service.pipelines.metrics "processors" (prepend $config.service.pipelines.metrics.processors "resource/deployenv" | uniq) }}
{{- end }}
{{- if $config.service.pipelines.traces }}
{{- $_ := set $config.service.pipelines.traces "processors" (prepend $config.service.pipelines.traces.processors "resource/deployenv" | uniq) }}
{{- end }}
{{- if index $config.service.pipelines "metrics/internal" }}
{{- $_ := set (index $config.service.pipelines "metrics/internal") "processors" (prepend (index (index $config.service.pipelines "metrics/internal") "processors") "resource/deployenv" | uniq) }}
{{- end }}
{{- $config | toYaml }}
{{- end }}

{{- define "opentelemetry-collector.deploymentEnvironmentConfig" -}}
processors:
resource/deployenv:
attributes:
- key: deployment.environment
value: ${env:DEPLOYMENT_ENVIRONMENT}
action: insert
{{- end }}
6 changes: 6 additions & 0 deletions charts/k8s-infra/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,12 @@ OTLP exporter environment variables used by OtelAgent and OtelDeployment.
value: {{ include "otel.insecureSkipVerify" . }}
- name: OTEL_SECRETS_PATH
value: {{ include "otel.secretsPath" . }}
- name: K8S_CLUSTER_NAME
value: {{ default .Values.global.clusterName .Values.clusterName }}
{{- with .Values.global.deploymentEnvironment }}
- name: DEPLOYMENT_ENVIRONMENT
value: {{ . }}
{{- end }}
{{- end }}

{{/*
Expand Down
2 changes: 0 additions & 2 deletions charts/k8s-infra/templates/otel-agent/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ spec:
env:
{{- include "snippet.otlp-env" . | nindent 12 }}
{{- include "snippet.k8s-env" . | nindent 12 }}
- name: K8S_CLUSTER_NAME
value: {{ default .Values.global.clusterName .Values.clusterName }}
- name: SIGNOZ_COMPONENT
value: {{ default "otel-agent" .Values.otelAgent.name }}
- name: OTEL_RESOURCE_ATTRIBUTES
Expand Down
2 changes: 0 additions & 2 deletions charts/k8s-infra/templates/otel-deployment/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ spec:
env:
{{- include "snippet.otlp-env" . | nindent 12 }}
{{- include "snippet.k8s-env" . | nindent 12 }}
- name: K8S_CLUSTER_NAME
value: {{ default .Values.global.clusterName .Values.clusterName }}
- name: SIGNOZ_COMPONENT
value: {{ default "otel-deployment" .Values.otelDeployment.name }}
- name: OTEL_RESOURCE_ATTRIBUTES
Expand Down
2 changes: 2 additions & 0 deletions charts/k8s-infra/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ global:
# -- Kubernetes cluster name
# It is used to attached to telemetry data via resource detection processor
clusterName: ""
# -- Deployment environment to be attached to telemetry data
deploymentEnvironment: ""
# -- Kubernetes cluster cloud provider along with distribution if any.
# example: `aws`, `azure`, `gcp`, `gcp/autogke`, `hcloud`, `other`
cloud: other
Expand Down

0 comments on commit e6e4a57

Please sign in to comment.