Skip to content

Commit

Permalink
fix(metrics): exclude metrics collector from webhooks
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikołaj Świątek committed May 17, 2023
1 parent c16d098 commit c66e812
Show file tree
Hide file tree
Showing 14 changed files with 170 additions and 159 deletions.
2 changes: 1 addition & 1 deletion deploy/helm/sumologic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ The following table lists the configurable parameters of the Sumo Logic chart an
| `opentelemetry-operator.instrumentationNamespaces` | Used to create `Instrumentation` resources in specified namespaces. | `Nil` |
| `opentelemetry-operator.instrumentationJobImage.image.repository` | Name of the image repository used to apply Instrumentation resource | `sumologic/kubernetes-tools` |
| `opentelemetry-operator.instrumentationJobImage.image.tag` | Name of the image tag used to apply Instrumentation resource | `2.14.0` |
| `opentelemetry-operator.admissionWebhooks` | Admission webhooks make sure only requests with correctly formatted rules will get into the Operator. They also enable the sidecar injection for OpenTelemetryCollector and Instrumentation CR's. | `{"failurePolicy": "Fail", "enabled": true, "certManager": {"enabled": false, "issuerRef": {}}}` |
| `opentelemetry-operator.admissionWebhooks` | Admission webhooks make sure only requests with correctly formatted rules will get into the Operator. They also enable the sidecar injection for OpenTelemetryCollector and Instrumentation CR's. | See [values.yaml] |
| `opentelemetry-operator.manager.env` | Additional environment variables for opentelemetry-operator helm chart. | `Nil` |
| `otelcolInstrumentation.enabled` | Enables Sumo OTel Distro Collector StatefulSet to collect telemetry data. | `true` |
| `otelcolInstrumentation.statefulset.replicaCount` | Set the number of otelcol-instrumentation replicasets. | `3` |
Expand Down
38 changes: 21 additions & 17 deletions deploy/helm/sumologic/conf/metrics/collector/otelcol/config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
exporters:
{{ tpl (.Files.Get "conf/metrics/otelcol/exporters.yaml") . | indent 2 }}

extensions:
health_check: {}
{{ if .Values.metadata.persistence.enabled }}
## Configuration for File Storage extension
## ref: https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/release/v0.37.x/extension/storage/filestorage
file_storage:
directory: /var/lib/storage/otc
timeout: 10s
compaction:
on_rebound: true
directory: /tmp
{{ end }}
pprof: {}

processors:
{{ tpl (.Files.Get "conf/metrics/otelcol/processors.yaml") . | indent 2 }}

receivers:
prometheus:
config:
Expand Down Expand Up @@ -88,23 +108,7 @@ receivers:
endpoint: http://{{ template "sumologic.metadata.name.metrics.targetallocator.name" . }}
interval: 30s
collector_id: ${POD_NAME}
extensions:
health_check: {}
{{ if .Values.metadata.persistence.enabled }}
## Configuration for File Storage extension
## ref: https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/release/v0.37.x/extension/storage/filestorage
file_storage:
directory: /var/lib/storage/otc
timeout: 10s
compaction:
on_rebound: true
directory: /tmp
{{ end }}
pprof: {}
exporters:
{{ tpl (.Files.Get "conf/metrics/otelcol/exporters.yaml") . | indent 2 }}
processors:
{{ tpl (.Files.Get "conf/metrics/otelcol/processors.yaml") . | indent 2 }}

service:
telemetry:
logs:
Expand Down
26 changes: 16 additions & 10 deletions deploy/helm/sumologic/templates/_helpers/_metrics.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -220,28 +220,34 @@ sumologic.com/scrape: "true"
Definitions for metrics collector
*/}}

{{- define "sumologic.labels.component.metrics" -}}
sumologic.com/component: metrics
{{- end -}}

{{- define "sumologic.labels.app.metrics.collector" -}}
{{- template "sumologic.fullname" . }}-metrics
sumologic.com/app: otelcol
{{- end -}}

{{- define "sumologic.labels.app.metrics.collector.pod" -}}
{{- template "sumologic.labels.app.metrics.collector" . }}
{{ template "sumologic.labels.app.metrics.collector" . }}
{{ template "sumologic.labels.component.metrics" . }}
{{- end -}}

{{- define "sumologic.labels.app.metrics.clusterrole" -}}
{{- template "sumologic.labels.app.metrics.collector" . }}
{{- define "sumologic.labels.metrics.clusterrole" -}}
{{- template "sumologic.labels.component.metrics" . }}
{{- end -}}

{{- define "sumologic.labels.app.metrics.clusterrolebinding" -}}
{{- template "sumologic.labels.app.metrics.collector" . }}
{{- define "sumologic.labels.metrics.clusterrolebinding" -}}
{{- template "sumologic.labels.component.metrics" . }}
{{- end -}}

{{- define "sumologic.labels.app.metrics.serviceaccount" -}}
{{- template "sumologic.labels.app.metrics.collector" . }}
{{- define "sumologic.labels.metrics.serviceaccount" -}}
{{- template "sumologic.labels.component.metrics" . }}
{{- end -}}

{{- define "sumologic.labels.app.metrics.collector.opentelemetrycollector" -}}
{{- template "sumologic.labels.app.metrics.collector" . }}
{{- define "sumologic.labels.metrics.opentelemetrycollector" -}}
{{ template "sumologic.labels.app.metrics.collector" . }}
{{ template "sumologic.labels.component.metrics" . }}
{{- end -}}

{{- define "sumologic.metadata.name.metrics.collector" -}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ kind: ClusterRole
metadata:
name: {{ template "sumologic.metadata.name.metrics.collector.clusterrole" . }}
labels:
app: {{ template "sumologic.labels.app.metrics.clusterrole" . }}
{{- include "sumologic.labels.metrics.clusterrole" . | nindent 4 }}
{{- include "sumologic.labels.common" . | nindent 4 }}
rules:
- apiGroups: [""]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ kind: ClusterRoleBinding
metadata:
name: {{ template "sumologic.metadata.name.metrics.collector.clusterrolebinding.prometheus" . }}
labels:
app: {{ template "sumologic.labels.app.metrics.clusterrolebinding" . }}
{{- include "sumologic.labels.metrics.clusterrolebinding" . | nindent 4 }}
{{- include "sumologic.labels.common" . | nindent 4 }}
subjects:
- kind: ServiceAccount
Expand All @@ -20,7 +20,7 @@ kind: ClusterRoleBinding
metadata:
name: {{ template "sumologic.metadata.name.metrics.collector.clusterrolebinding.metadata" . }}
labels:
app: {{ template "sumologic.labels.app.metrics.clusterrolebinding" . }}
{{- include "sumologic.labels.metrics.clusterrolebinding" . | nindent 4 }}
{{- include "sumologic.labels.common" . | nindent 4 }}
subjects:
- kind: ServiceAccount
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ kind: OpenTelemetryCollector
metadata:
name: {{ template "sumologic.metadata.name.metrics.collector.opentelemetrycollector" . }}
labels:
app: {{ template "sumologic.labels.app.metrics.collector" . }}
{{- include "sumologic.labels.metrics.opentelemetrycollector" . | nindent 4 }}
{{- include "sumologic.labels.common" . | nindent 4 }}
spec:
mode: statefulset
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ kind: ServiceAccount
metadata:
name: {{ template "sumologic.metadata.name.metrics.collector.serviceaccount" . }}
labels:
app: {{ template "sumologic.labels.app.metrics.serviceaccount" . }}
{{- include "sumologic.labels.metrics.serviceaccount" . | nindent 4 }}
{{- include "sumologic.labels.common" . | nindent 4 }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ kind: ClusterRole
metadata:
name: {{ template "sumologic.metadata.name.metrics.targetallocator.clusterrole" . }}
labels:
app: {{ template "sumologic.labels.app.metrics.clusterrole" . }}
{{- include "sumologic.labels.metrics.clusterrole" . | nindent 4 }}
{{- include "sumologic.labels.common" . | nindent 4 }}
rules:
- apiGroups: [""]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ kind: ClusterRoleBinding
metadata:
name: {{ template "sumologic.metadata.name.metrics.targetallocator.clusterrolebinding" . }}
labels:
app: {{ template "sumologic.labels.app.metrics.clusterrolebinding" . }}
{{- include "sumologic.labels.metrics.clusterrolebinding" . | nindent 4 }}
{{- include "sumologic.labels.common" . | nindent 4 }}
subjects:
- kind: ServiceAccount
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ kind: ServiceAccount
metadata:
name: {{ template "sumologic.metadata.name.metrics.targetallocator.serviceaccount" . }}
labels:
app: {{ template "sumologic.labels.app.metrics.serviceaccount" . }}
{{- include "sumologic.labels.metrics.serviceaccount" . | nindent 4 }}
{{- include "sumologic.labels.common" . | nindent 4 }}
{{- end }}
7 changes: 7 additions & 0 deletions deploy/helm/sumologic/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4634,6 +4634,13 @@ opentelemetry-operator:
failurePolicy: Fail
enabled: true

## skip admission webhook on our own OpenTelemetryCollector object to avoid having to wait for operator to start
objectSelector:
matchExpressions:
- key: sumologic.com/component
operator: NotIn
values: ["metrics"]

certManager:
enabled: false
issuerRef: {}
Expand Down
Loading

0 comments on commit c66e812

Please sign in to comment.