Skip to content

Commit

Permalink
feat: allow setting otelcol image globally
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikołaj Świątek committed May 15, 2023
1 parent 82d6096 commit 8a6ab3c
Show file tree
Hide file tree
Showing 46 changed files with 1,282 additions and 310 deletions.
1 change: 1 addition & 0 deletions .changelog/3051.added.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
feat: allow setting otelcol image globally
26 changes: 14 additions & 12 deletions deploy/helm/sumologic/README.md

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions deploy/helm/sumologic/templates/_helpers/_common.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,13 @@ pvc-cleaner
{{- template "sumologic.fullname" . }}-pvc-cleaner
{{- end -}}

{{/*
Return the otelcol metadata enrichment image
*/}}
{{- define "sumologic.metadata.image" -}}
{{ template "utils.getOtelImage" (dict "overrideImage" .Values.metadata.image "defaultImage" .Values.sumologic.otelcolImage) }}
{{- end -}}

{{/*
Create common labels used throughout the chart.
If dryRun=true, we do not create any chart labels.
Expand Down Expand Up @@ -309,6 +316,26 @@ Returns clusterName with spaces replaced with dashes
{{ .Values.sumologic.clusterName | replace " " "-"}}
{{- end -}}

{{/*
Returns the otelcol image given two image dicts of the form {"repository": "...", "tag"}
The first block is for defaults, and the second for overrides.
For both the image repository and tag, the override will be used if present, otherwise the default will be used.
This is a helper method for ensuring the global default image is used where appropriate.

Example usage:

{{ template "utils.getOtelImage" (dict "overrideImage" .Values.tracesSampler.deployment.image "defaultImage" .Values.sumologic.otelcolImage) }}
*/}}
{{- define "utils.getOtelImage" -}}
{{- $defaultRepository := .defaultImage.repository -}}
{{- $defaultTag := .defaultImage.tag -}}
{{- $repositoryOverride := .overrideImage.repository -}}
{{- $tagOverride:= .overrideImage.tag -}}
{{- $repository := $repositoryOverride | default $defaultRepository }}
{{- $tag := $tagOverride | default $defaultTag }}
{{- printf "%s:%s" $repository $tag | quote }}
{{- end -}}

{{/*
Get configuration value, otherwise returns default
Expand Down
7 changes: 7 additions & 0 deletions deploy/helm/sumologic/templates/_helpers/_events.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,10 @@ sumologic.com/component: events
{{ template "sumologic.label.scrape" . }}
{{ template "sumologic.labels.events" . }}
{{- end -}}

{{/*
Return the otelcol events image
*/}}
{{- define "sumologic.events.image" -}}
{{ template "utils.getOtelImage" (dict "overrideImage" .Values.otelevents.image "defaultImage" .Values.sumologic.otelcolImage) }}
{{- end -}}
9 changes: 8 additions & 1 deletion deploy/helm/sumologic/templates/_helpers/_logs.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -292,4 +292,11 @@ Example:
{{- end -}}
{{- end -}}
{{ print $excludeNamespaceRegex }}
{{- end -}}
{{- end -}}

{{/*
Return the otelcol log collector image
*/}}
{{- define "sumologic.logs.collector.image" -}}
{{ template "utils.getOtelImage" (dict "overrideImage" .Values.otellogs.image "defaultImage" .Values.sumologic.otelcolImage) }}
{{- end -}}
21 changes: 21 additions & 0 deletions deploy/helm/sumologic/templates/_helpers/_traces.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,27 @@ sumologic.com/component: instrumentation
{{ template "sumologic.fullname" . }}-otelagent
{{- end -}}

{{/*
Return the otelcol agent image
*/}}
{{- define "sumologic.instrumentation.otelagent.image" -}}
{{ template "utils.getOtelImage" (dict "overrideImage" .Values.otelcolInstrumentation.statefulset.image "defaultImage" .Values.sumologic.otelcolImage) }}
{{- end -}}

{{/*
Return the otelcol trace sampler image
*/}}
{{- define "sumologic.tracessampler.image" -}}
{{ template "utils.getOtelImage" (dict "overrideImage" .Values.tracesSampler.deployment.image "defaultImage" .Values.sumologic.otelcolImage) }}
{{- end -}}

{{/*
Return the otelcol gateway image
*/}}
{{- define "sumologic.tracesgateway.image" -}}
{{ template "utils.getOtelImage" (dict "overrideImage" .Values.tracesGateway.deployment.image "defaultImage" .Values.sumologic.otelcolImage) }}
{{- end -}}

{{/*
Create endpoint based on OTC Tracing deployment type
*/}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ spec:
{{- end }}
containers:
- name: otelcol
image: {{ .Values.otelevents.image.repository }}:{{ .Values.otelevents.image.tag }}
image: {{ template "sumologic.events.image" . }}
imagePullPolicy: {{ .Values.otelevents.image.pullPolicy }}
args:
- --config=/etc/otel/config.yaml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ spec:
{{- end }}
containers:
- name: otelcol
image: {{ $otelcolInstrumentation.statefulset.image.repository }}:{{ $otelcolInstrumentation.statefulset.image.tag }}
image: {{ template "sumologic.instrumentation.otelagent.image" . }}
imagePullPolicy: {{ $otelcolInstrumentation.statefulset.image.pullPolicy }}
args:
- "--config=/conf/otelcol.instrumentation.conf.yaml"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ spec:
restartPolicy: Always
containers:
- name: otelcol
image: {{ $tracesGateway.deployment.image.repository }}:{{ $tracesGateway.deployment.image.tag }}
image: {{ template "sumologic.tracesgateway.image" . }}
imagePullPolicy: {{ $tracesGateway.deployment.image.pullPolicy }}
args:
- "--config=/conf/traces.gateway.conf.yaml"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ spec:
{{- end }}
containers:
- name: otelcol
image: {{ $tracesSampler.deployment.image.repository }}:{{ $tracesSampler.deployment.image.tag }}
image: {{ template "sumologic.tracessampler.image" . }}
imagePullPolicy: {{ $tracesSampler.deployment.image.pullPolicy }}
args:
- --config=/conf/traces.sampler.conf.yaml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ spec:
{{- end }}
containers:
- name: otelcol
image: {{ .Values.metadata.image.repository }}:{{ .Values.metadata.image.tag }}
image: {{ template "sumologic.metadata.image" . }}
imagePullPolicy: {{ .Values.metadata.image.pullPolicy }}
args:
- --config=/etc/otelcol/config.yaml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ spec:
containers:
- args:
- --config=/etc/otelcol/config.yaml
image: {{ $.Values.otellogs.image.repository }}:{{ $.Values.otellogs.image.tag }}
image: {{ template "sumologic.logs.collector.image" $ctx }}
imagePullPolicy: {{ $.Values.otellogs.image.pullPolicy }}
name: otelcol
livenessProbe:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ spec:
{{- end }}
containers:
- name: otelcol
image: {{ .Values.metadata.image.repository }}:{{ .Values.metadata.image.tag }}
image: {{ template "sumologic.metadata.image" . }}
imagePullPolicy: {{ .Values.metadata.image.pullPolicy }}
args:
- --config=/etc/otel/config.yaml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ spec:
{{- end }}
containers:
- name: otelcol
image: {{ .Values.metadata.image.repository }}:{{ .Values.metadata.image.tag }}
image: {{ template "sumologic.metadata.image" . }}
imagePullPolicy: {{ .Values.metadata.image.pullPolicy }}
args:
- --config=/etc/otel/config.yaml
Expand Down
29 changes: 17 additions & 12 deletions deploy/helm/sumologic/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,11 @@ sumologic:
properties:
content_type: Zipkin

### Global configuration for OpenTelemetry Collector
otelcolImage:
repository: "public.ecr.aws/sumologic/sumologic-otel-collector"
tag: "0.76.1-sumo-0"

### Configuration for collection of Kubernetes events
events:
enabled: true
Expand Down Expand Up @@ -3483,8 +3488,8 @@ otelcolInstrumentation:
podAnnotations: {}

image:
repository: "public.ecr.aws/sumologic/sumologic-otel-collector"
tag: "0.76.1-sumo-0"
# repository: ""
# tag: ""
pullPolicy: IfNotPresent

## Set securityContext for containers running in pods in otelcol-instrumentation statefulset.
Expand Down Expand Up @@ -3713,8 +3718,8 @@ tracesSampler:
## Add custom annotations only to traces-sampler deployment.
podAnnotations: {}
image:
repository: "public.ecr.aws/sumologic/sumologic-otel-collector"
tag: "0.76.1-sumo-0"
# repository: ""
# tag: ""
pullPolicy: IfNotPresent

## Extra Environment Values - allows yaml definitions
Expand Down Expand Up @@ -3807,8 +3812,8 @@ tracesSampler:
metadata:
## Configure image for Opentelemetry Collector (for logs and metrics)
image:
repository: public.ecr.aws/sumologic/sumologic-otel-collector
tag: 0.76.1-sumo-0
# repository: ""
# tag: ""
pullPolicy: IfNotPresent

securityContext:
Expand Down Expand Up @@ -4062,8 +4067,8 @@ tracesGateway:
## Add custom annotations only to traces-gateway deployment.
podAnnotations: {}
image:
repository: "public.ecr.aws/sumologic/sumologic-otel-collector"
tag: "0.76.1-sumo-0"
# repository: ""
# tag: ""
pullPolicy: IfNotPresent
livenessProbe:
periodSeconds: 15
Expand Down Expand Up @@ -4168,8 +4173,8 @@ tracesGateway:
otelevents:
## Configure image for Opentelemetry Collector
image:
repository: public.ecr.aws/sumologic/sumologic-otel-collector
tag: 0.76.1-sumo-0
# repository: ""
# tag: ""
pullPolicy: IfNotPresent

logLevel: info
Expand Down Expand Up @@ -4316,8 +4321,8 @@ otellogs:

## Configure image for Opentelemetry Collector
image:
repository: "public.ecr.aws/sumologic/sumologic-otel-collector"
tag: "0.76.1-sumo-0"
# repository: ""
# tag: ""
pullPolicy: IfNotPresent

logLevel: info
Expand Down
23 changes: 3 additions & 20 deletions docs/security-best-practices.md
Original file line number Diff line number Diff line change
Expand Up @@ -375,26 +375,9 @@ set the FIPS compliant images.
For example, to use `0.76.1-sumo-0-fips` image with Helm Chart v3 use the following configuration:

```yaml
metadata:
image:
tag: 0.76.1-sumo-0-fips
otellogs:
image:
tag: 0.76.1-sumo-0-fips
otelevents:
image:
tag: 0.76.1-sumo-0-fips
otelcolInstrumentation:
statefulSet:
image:
tag: 0.76.1-sumo-0-fips
traceSampler:
deployment:
image:
tag: 0.76.1-sumo-0-fips
tracesGateway:
deployment:
image:
sumologic:
otelcol:
defaultImage:
tag: 0.76.1-sumo-0-fips
```

Expand Down
10 changes: 4 additions & 6 deletions docs/working-with-container-registries.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,10 @@ docker push ${REGISTRY_REPO_URL}:${TAG}
One can then use `${REGISTRY_REPO_URL}:${TAG}` in `user-values.yaml` as such:

```yaml
metadata:
...
image:
repository: ${REGISTRY_REPO_URL}
tag: ${TAG}
pullPolicy: IfNotPresent
sumologic:
otelcol:
defaultImage:
tag: 0.76.1-sumo-0-fips
```

## Upgrading while rehosting images
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ sumologic:
sumoLabel: sumoValue

otelevents:
image:
repository: my_repository
tag: my_tag
statefulset:
## Add custom labels only to logs sts pods
podLabels:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ spec:
fsGroup: 999
containers:
- name: otelcol
image: public.ecr.aws/sumologic/sumologic-otel-collector:0.76.1-sumo-0
image: my_repository:my_tag
imagePullPolicy: IfNotPresent
args:
- --config=/etc/otel/config.yaml
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
sumologic:
logs:
collector:
otelcloudwatch:
enabled: true

metadata:
image:
repository: my_repository
tag: my_tag
Loading

0 comments on commit 8a6ab3c

Please sign in to comment.