Skip to content

Commit

Permalink
Merge pull request #835 from solarwinds/update-collector-to-send-valu…
Browse files Browse the repository at this point in the history
…es-in-config-map

Update Collector to send Values in config map
  • Loading branch information
turytsia authored Dec 12, 2024
2 parents 279bac7 + 0b2ceff commit b97fce6
Show file tree
Hide file tree
Showing 8 changed files with 247 additions and 24 deletions.
2 changes: 1 addition & 1 deletion deploy/helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: swo-k8s-collector
version: 4.3.0-alpha.6
version: 4.3.0-alpha.7
appVersion: 0.12.0
description: SolarWinds Kubernetes Integration
keywords:
Expand Down
29 changes: 18 additions & 11 deletions deploy/helm/events-collector-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ processors:
# convert body to string
- set(body, body.string)

{{- if .Values.otel.manifests.enabled }}
transform/set_labels_and_annotations_for_entities:
error_mode: ignore
log_statements:
Expand Down Expand Up @@ -151,8 +150,12 @@ processors:

# Set labels to resource attributes
- merge_maps(resource.attributes, cache["labels"], "upsert") where ({{ $joinedConditions }}) and cache["labels"] != nil
{{- end }}
{{- if .Values.otel.manifests.enabled }}
filter/k8s_collector_config_include:
error_mode: ignore
logs:
log_record:
- resource.attributes["k8s.configmap.labels.swo.cloud.solarwinds.com/config-type"] != "values-config-map"

transform/manifest:
error_mode: ignore
log_statements:
Expand Down Expand Up @@ -183,14 +186,13 @@ processors:
- delete_key(attributes, "k8s.resource.name")
- delete_key(attributes, "event.name")
- delete_key(attributes, "event.domain")
{{- end }}
transform/scope:
log_statements:
- context: scope
statements:
- set(name, "")
- set(version, "")
{{- if .Values.otel.manifests.enabled }}

groupbyattrs/manifest:
keys:
- k8s.pod.name
Expand All @@ -208,7 +210,6 @@ processors:
- k8s.ingress.name
- sw.k8s.ingress.type
- k8s.configmap.name
{{- end }}

resource/events:
attributes:
Expand All @@ -233,7 +234,6 @@ processors:
- key: sw.k8s.log.type
value: event
action: insert
{{- if .Values.otel.manifests.enabled }}
resource/manifest:
attributes:
# Collector and Manifest version
Expand All @@ -257,18 +257,17 @@ processors:
- key: sw.k8s.log.type
value: manifest
action: insert
{{- end }}
batch:
{{ toYaml .Values.otel.events.batch | indent 4 }}
swk8sattributes:
{{ include "common.k8s-instrumentation" . | indent 4 }}

receivers:
k8s_events:
{{- if .Values.otel.manifests.enabled }}
k8sobjects:
auth_type: serviceAccount
objects:
{{- if and .Values.otel.events.enabled .Values.otel.manifests.enabled }}
{{- if or (.Capabilities.APIVersions.Has "networking.istio.io/v1alpha3") (.Capabilities.APIVersions.Has "networking.istio.io/v1beta1") (.Capabilities.APIVersions.Has "networking.istio.io/v1") -}}
{{- $arrayOfWatchedResources = append $arrayOfWatchedResources "virtualservices" }}
{{- end }}
Expand All @@ -280,7 +279,14 @@ receivers:
- name : {{ $resource }}
mode: watch
{{- end }}
{{- else }}
- name: "configmaps"
mode: pull
interval: {{ quote .Values.otel.manifests.pull_every }}
- name : "configmaps"
mode: watch
{{- end }}

service:
extensions:
{{- if .Values.otel.events.sending_queue.offload_to_disk }}
Expand Down Expand Up @@ -311,7 +317,6 @@ service:
receivers:
- k8s_events
{{- end }}
{{- if .Values.otel.manifests.enabled }}
logs/manifests:
exporters:
- otlp
Expand All @@ -324,14 +329,16 @@ service:
- resource/manifest
- swk8sattributes
- transform/cleanup_attributes_for_nonexisting_entities
{{- if not (and .Values.otel.events.enabled .Values.otel.manifests.enabled) }}
- filter/k8s_collector_config_include
{{- end }}
{{- if .Values.otel.manifests.filter }}
- filter/manifests
{{- end }}
- transform/scope
- batch
receivers:
- k8sobjects
{{- end }}
telemetry:
{{- if .Values.otel.events.telemetry.logs.enabled }}
logs:
Expand Down
1 change: 1 addition & 0 deletions deploy/helm/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ Common labels
app.kubernetes.io/part-of: swo-k8s-collector
app.kubernetes.io/instance: {{ template "common.fullname" . }}
app.kubernetes.io/managed-by: {{ .Release.Name }}
swo.cloud.solarwinds.com/cluster-uid: {{ (include "common.cluster-uid" .) }}
{{- if .Chart.AppVersion }}
helm.sh/chart: {{ include "common.chart" . }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
Expand Down
6 changes: 0 additions & 6 deletions deploy/helm/templates/common-env-config-map.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,13 @@ metadata:
namespace: {{ .Release.Namespace }}
labels:
{{ include "common.labels" . | indent 4 }}
config-type: common-env
data:
CLUSTER_NAME: {{ quote .Values.cluster.name }}
CLUSTER_UID: {{ quote (include "common.cluster-uid" .) }}
OTEL_ENVOY_ADDRESS: {{ quote .Values.otel.endpoint }}
OTEL_ENVOY_ADDRESS_TLS_INSECURE: {{ quote .Values.otel.tls_insecure }}
MANIFEST_VERSION: {{ quote .Chart.Version }}
APP_VERSION: {{ quote .Chart.AppVersion }}
METRICS_ENABLED: {{ quote .Values.otel.metrics.enabled }}
LOGS_ENABLED: {{ quote .Values.otel.logs.enabled }}
EVENTS_ENABLED: {{ quote .Values.otel.events.enabled }}
NETWORK_EBPF_ENABLED: {{ quote .Values.ebpfNetworkMonitoring.enabled }}
SWO_AGENT_ENABLED: {{ quote .Values.swoagent.enabled }}
{{ if .Values.otel.https_proxy_url }}
HTTPS_PROXY: {{ quote .Values.otel.https_proxy_url }}
{{ end }}
4 changes: 1 addition & 3 deletions deploy/helm/templates/events-collector-config-map.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{{- if .Values.otel.events.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
Expand All @@ -8,5 +7,4 @@ metadata:
{{ include "common.labels" . | indent 4 }}
data:
events.config: |
{{ tpl (.Files.Get "events-collector-config.yaml") . | fromYaml | toYaml | indent 8 }}
{{- end }}
{{ tpl (.Files.Get "events-collector-config.yaml") . | fromYaml | toYaml | indent 8 }}
4 changes: 1 addition & 3 deletions deploy/helm/templates/events-collector-deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{{- if .Values.otel.events.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down Expand Up @@ -155,5 +154,4 @@ spec:
{{- if .Values.otel.events.sending_queue.offload_to_disk }}
- name: sending-queue
emptyDir: {}
{{- end }}
{{- end}}
{{- end }}
15 changes: 15 additions & 0 deletions deploy/helm/templates/values-config-map.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "common.fullname" (tuple . "-values") }}
namespace: {{ .Release.Namespace }}
labels:
{{ include "common.labels" . | indent 4 }}
swo.cloud.solarwinds.com/config-type: values-config-map
data:
VALUES_YAML: |-
{{- $filteredValues := .Values | deepCopy }}
{{- $filteredOtel := get $filteredValues "otel" }}
{{- $_ := unset $filteredOtel "api_token" }}
{{- $_ := set $filteredValues "otel" $filteredOtel }}
{{ $filteredValues | toYaml | b64enc | indent 4 }}
Loading

0 comments on commit b97fce6

Please sign in to comment.