Skip to content

Commit

Permalink
[nr-k8s-otel-collector] Custom ConfigMap Support (#1435)
Browse files Browse the repository at this point in the history
<!--
Thank you for contributing to New Relic's Helm charts. Before you submit
this PR we'd like to
make sure you are aware of our technical requirements:

*
https://github.com/newrelic-experimental/helm-charts/blob/master/CONTRIBUTING.md#technical-requirements

For a quick overview across what we will look at reviewing your PR,
please read
our review guidelines:

*
https://github.com/newrelic-experimental/helm-charts/blob/master/REVIEW_GUIDELINES.md

Following our best practices right from the start will accelerate the
review process and
help get your PR merged quicker.

When updates to your PR are requested, please add new commits and do not
squash the
history. This will make it easier to identify new changes. The PR will
be squashed
anyways when it is merged. Thanks.

For fast feedback, please @-mention maintainers that are listed in the
Chart.yaml file.

Please make sure you test your changes before you push them. Once
pushed, a Github Action
will run across your changes and do some initial checks and linting.
These checks run
very quickly. Please check the results. We would like these checks to
pass before we
even continue reviewing your changes.
-->
#### Is this a new chart

#### What this PR does / why we need it:

#### Which issue this PR fixes
*(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)`
format, will close that issue when PR gets merged)*
  -  #NR-273027

#### Special notes for your reviewer:

#### Checklist
[Place an '[x]' (no spaces) in all applicable fields. Please remove
unrelated fields.]
- [x] Chart Version bumped
- [x] Variables are documented in the README.md
- [x] Title of the PR starts with chart name (e.g. `[mychartname]`)
  • Loading branch information
dbudziwojskiNR authored Jul 24, 2024
1 parent a551c3d commit 45dea49
Show file tree
Hide file tree
Showing 11 changed files with 326 additions and 9 deletions.
2 changes: 1 addition & 1 deletion charts/nr-k8s-otel-collector/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.7.1
version: 0.7.2

dependencies:
- name: common-library
Expand Down
4 changes: 4 additions & 0 deletions charts/nr-k8s-otel-collector/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,17 @@ daemonset:
| customSecretLicenseKey | string | `""` | In case you don't want to have the license key in you values, this allows you to point to which secret key is the license key located. Can be configured also with `global.customSecretLicenseKey` |
| customSecretName | string | `""` | In case you don't want to have the license key in you values, this allows you to point to a user created secret to get the key from there. Can be configured also with `global.customSecretName` |
| daemonset.affinity | object | `{}` | Sets daemonset pod affinities. Overrides `affinity` and `global.affinity` |
| daemonset.configMap | object | See `values.yaml` | Settings for daemonset configmap |
| daemonset.configMap.config | object | `{}` | OpenTelemetry config for the daemonset. If set, overrides default config and disables configuration parameters for the daemonset. |
| daemonset.containerSecurityContext | object | `{"privileged":true}` | Sets security context (at container level) for the daemonset. Overrides `containerSecurityContext` and `global.containerSecurityContext` |
| daemonset.nodeSelector | object | `{}` | Sets daemonset pod node selector. Overrides `nodeSelector` and `global.nodeSelector` |
| daemonset.podAnnotations | object | `{}` | Annotations to be added to the daemonset. |
| daemonset.podSecurityContext | object | `{}` | Sets security context (at pod level) for the daemonset. Overrides `podSecurityContext` and `global.podSecurityContext` |
| daemonset.resources | object | `{}` | Sets resources for the daemonset. |
| daemonset.tolerations | list | `[]` | Sets daemonset pod tolerations. Overrides `tolerations` and `global.tolerations` |
| deployment.affinity | object | `{}` | Sets deployment pod affinities. Overrides `affinity` and `global.affinity` |
| deployment.configMap | object | See `values.yaml` | Settings for deployment configmap |
| deployment.configMap.config | object | `{}` | OpenTelemetry config for the deployment. If set, overrides default config and disables configuration parameters for the deployment. |
| deployment.containerSecurityContext | object | `{}` | Sets security context (at container level) for the deployment. Overrides `containerSecurityContext` and `global.containerSecurityContext` |
| deployment.nodeSelector | object | `{}` | Sets deployment pod node selector. Overrides `nodeSelector` and `global.nodeSelector` |
| deployment.podAnnotations | object | `{}` | Annotations to be added to the deployment. |
Expand Down
5 changes: 5 additions & 0 deletions charts/nr-k8s-otel-collector/README.md.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ daemonset:

**Note:** If all receivers are disabled in the deployment or in the daemonset, the agent will not start.

## Metrics

* [Metrics - Full list](https://github.com/newrelic/helm-charts/tree/master/charts/nr-k8s-otel-collector/docs/metrics-full.md)
* [Metrics - LowDataMode list](https://github.com/newrelic/helm-charts/tree/master/charts/nr-k8s-otel-collector/docs/metrics-lowDataMode.md)

## Common Errors

### Exporting Errors
Expand Down
22 changes: 22 additions & 0 deletions charts/nr-k8s-otel-collector/templates/_config_map.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{{- /* Defines if the deployment config map has to be created or not */ -}}
{{- define "nrKubernetesOtel.deployment.configMap.config" -}}

{{- /* Look for a local creation of a deployment config map */ -}}
{{- if get .Values.deployment "configMap" | kindIs "map" -}}
{{- if .Values.deployment.configMap.config -}}
{{- toYaml .Values.deployment.configMap.config -}}
{{- end -}}
{{- end -}}
{{- end -}}


{{- /* Defines if the daemonset config map has to be created or not */ -}}
{{- define "nrKubernetesOtel.daemonset.configMap.config" -}}

{{- /* Look for a local creation of a daemonset config map */ -}}
{{- if get .Values.daemonset "configMap" | kindIs "map" -}}
{{- if .Values.daemonset.configMap.config -}}
{{- toYaml .Values.daemonset.configMap.config -}}
{{- end -}}
{{- end -}}
{{- end -}}
4 changes: 2 additions & 2 deletions charts/nr-k8s-otel-collector/templates/_naming.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
{{- include "newrelic.common.naming.truncateToDNSWithSuffix" (dict "name" (include "newrelic.common.naming.fullname" .) "suffix" "daemonset") -}}
{{- end -}}

{{- define "nrKubernetesOtel.deployment.configmap.fullname" -}}
{{- define "nrKubernetesOtel.deployment.configMap.fullname" -}}
{{- include "newrelic.common.naming.truncateToDNSWithSuffix" (dict "name" (include "newrelic.common.naming.fullname" .) "suffix" "deployment-config") -}}
{{- end -}}

{{- define "nrKubernetesOtel.daemonset.configmap.fullname" -}}
{{- define "nrKubernetesOtel.daemonset.configMap.fullname" -}}
{{- include "newrelic.common.naming.truncateToDNSWithSuffix" (dict "name" (include "newrelic.common.naming.fullname" .) "suffix" "daemonset-config") -}}
{{- end -}}
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "nrKubernetesOtel.daemonset.configmap.fullname" . }}
name: {{ include "nrKubernetesOtel.daemonset.configMap.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "newrelic.common.labels" . | nindent 4 }}
data:
daemonset-config.yaml: |
{{- with include "nrKubernetesOtel.daemonset.configMap.config" . }}
{{- . | nindent 4 }}
{{- else }}
receivers:
hostmetrics:
# TODO (chris): this is a linux specific configuration
Expand Down Expand Up @@ -613,4 +616,5 @@ data:
- batch
exporters:
- otlphttp/newrelic
{{- end }}
{{- end }}
{{- end }}
2 changes: 1 addition & 1 deletion charts/nr-k8s-otel-collector/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ spec:
{{- end }}
- name: daemonset-config
configMap:
name: {{ include "nrKubernetesOtel.daemonset.configmap.fullname" . }}
name: {{ include "nrKubernetesOtel.daemonset.configMap.fullname" . }}
{{- with include "nrKubernetesOtel.daemonset.nodeSelector" . }}
nodeSelector:
{{- . | nindent 8 }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "nrKubernetesOtel.deployment.configmap.fullname" . }}
name: {{ include "nrKubernetesOtel.deployment.configMap.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "newrelic.common.labels" . | nindent 4 }}
data:
deployment-config.yaml: |
{{- with include "nrKubernetesOtel.deployment.configMap.config" . }}
{{- . | nindent 4 }}
{{- else }}
receivers:
otlp:
protocols:
Expand Down Expand Up @@ -578,3 +581,4 @@ data:
exporters:
- otlphttp/newrelic
{{- end }}
{{- end }}
2 changes: 1 addition & 1 deletion charts/nr-k8s-otel-collector/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ spec:
volumes:
- name: deployment-config
configMap:
name: {{ include "nrKubernetesOtel.deployment.configmap.fullname" . }}
name: {{ include "nrKubernetesOtel.deployment.configMap.fullname" . }}
{{- with include "nrKubernetesOtel.deployment.nodeSelector" . }}
nodeSelector:
{{- . | nindent 8 }}
Expand Down
Loading

0 comments on commit 45dea49

Please sign in to comment.