diff --git a/charts/nr-k8s-otel-collector/Chart.yaml b/charts/nr-k8s-otel-collector/Chart.yaml index 59930423a..a5319206a 100644 --- a/charts/nr-k8s-otel-collector/Chart.yaml +++ b/charts/nr-k8s-otel-collector/Chart.yaml @@ -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.6 +version: 0.7.7 dependencies: - name: common-library diff --git a/charts/nr-k8s-otel-collector/README.md b/charts/nr-k8s-otel-collector/README.md index 08c697d5d..748efb670 100644 --- a/charts/nr-k8s-otel-collector/README.md +++ b/charts/nr-k8s-otel-collector/README.md @@ -87,6 +87,8 @@ daemonset: | 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.envs | list | `[]` | Sets additional environment variables for the daemonset. | +| daemonset.envsFrom | list | `[]` | Sets additional environment variable sources for the daemonset. | | 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` | @@ -96,6 +98,8 @@ daemonset: | 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.envs | list | `[]` | Sets additional environment variables for the deployment. | +| deployment.envsFrom | list | `[]` | Sets additional environment variable sources for the deployment. | | deployment.nodeSelector | object | `{}` | Sets deployment pod node selector. Overrides `nodeSelector` and `global.nodeSelector` | | deployment.podAnnotations | object | `{}` | Annotations to be added to the deployment. | | deployment.podSecurityContext | object | `{}` | Sets security context (at pod level) for the deployment. Overrides `podSecurityContext` and `global.podSecurityContext` | @@ -163,6 +167,5 @@ Error scraping metrics {"kind": "receiver", "name": "hostmetrics", "data_type": ## Maintainers -* [juanjjaramillo](https://github.com/juanjjaramillo) * [csongnr](https://github.com/csongnr) * [dbudziwojskiNR](https://github.com/dbudziwojskiNR) diff --git a/charts/nr-k8s-otel-collector/templates/daemonset.yaml b/charts/nr-k8s-otel-collector/templates/daemonset.yaml index c6c79deec..396eeda26 100644 --- a/charts/nr-k8s-otel-collector/templates/daemonset.yaml +++ b/charts/nr-k8s-otel-collector/templates/daemonset.yaml @@ -44,6 +44,10 @@ spec: args: ["--config", "/config/daemonset-config.yaml"] resources: {{- toYaml .Values.daemonset.resources | nindent 12 }} + {{- with .Values.daemonset.envsFrom }} + envFrom: + {{- . | toYaml | nindent 12 }} + {{- end }} env: - name: HOST_IP valueFrom: @@ -71,6 +75,9 @@ spec: secretKeyRef: name: {{ include "newrelic.common.license.secretName" . }} key: {{ include "newrelic.common.license.secretKeyName" . }} + {{- with .Values.daemonset.envs }} + {{- . | toYaml | nindent 12 }} + {{- end }} volumeMounts: # TODO (chris): this is a linux specific configuration {{- if include "newrelic.common.privileged" . }} diff --git a/charts/nr-k8s-otel-collector/templates/deployment.yaml b/charts/nr-k8s-otel-collector/templates/deployment.yaml index 50583406d..c088d6db3 100644 --- a/charts/nr-k8s-otel-collector/templates/deployment.yaml +++ b/charts/nr-k8s-otel-collector/templates/deployment.yaml @@ -46,6 +46,10 @@ spec: args: ["--config", "/config/deployment-config.yaml"] resources: {{- toYaml .Values.deployment.resources | nindent 12 }} + {{- with .Values.deployment.envsFrom }} + envFrom: + {{- . | toYaml | nindent 12 }} + {{- end }} env: - name: KUBE_NODE_NAME valueFrom: @@ -62,6 +66,9 @@ spec: secretKeyRef: name: {{ include "newrelic.common.license.secretName" . }} key: {{ include "newrelic.common.license.secretKeyName" . }} + {{- with .Values.deployment.envs }} + {{- . | toYaml | nindent 12 }} + {{- end }} ports: - name: http containerPort: 4318 diff --git a/charts/nr-k8s-otel-collector/tests/env_vars_from_test.yaml b/charts/nr-k8s-otel-collector/tests/env_vars_from_test.yaml new file mode 100644 index 000000000..1f4e6b2a2 --- /dev/null +++ b/charts/nr-k8s-otel-collector/tests/env_vars_from_test.yaml @@ -0,0 +1,114 @@ +suite: envVarsFrom +templates: + - templates/deployment.yaml + - templates/deployment-configmap.yaml + - templates/daemonset.yaml + - templates/daemonset-configmap.yaml +release: + name: my-release + namespace: my-namespace +tests: + - it: does not set envFrom by default + set: + cluster: my-cluster + licenseKey: us-whatever + asserts: + - notExists: + path: spec.template.spec.containers[0].envFrom + template: templates/deployment.yaml + - notExists: + path: spec.template.spec.containers[0].envFrom + template: templates/daemonset.yaml + - it: adds additional deployment env sources from Values file using 'nr-otel-for-k8s-license' secret + set: + cluster: my-cluster + licenseKey: us-whatever + deployment: + envsFrom: + - secretRef: + name: test-secret-dep + - configMapRef: + name: test-configmap-dep + asserts: + - contains: + path: spec.template.spec.containers[0].envFrom + content: + secretRef: + name: test-secret-dep + template: templates/deployment.yaml + - contains: + path: spec.template.spec.containers[0].envFrom + content: + configMapRef: + name: test-configmap-dep + template: templates/deployment.yaml + - notExists: + path: spec.template.spec.containers[0].envFrom + template: templates/daemonset.yaml + - it: adds additional daemonset env sources from Values file using 'nr-otel-for-k8s-license' secret + set: + cluster: my-cluster + licenseKey: us-whatever + daemonset: + envsFrom: + - secretRef: + name: test-secret-dae + - configMapRef: + name: test-configmap-dae + asserts: + - contains: + path: spec.template.spec.containers[0].envFrom + content: + secretRef: + name: test-secret-dae + template: templates/daemonset.yaml + - contains: + path: spec.template.spec.containers[0].envFrom + content: + configMapRef: + name: test-configmap-dae + template: templates/daemonset.yaml + - notExists: + path: spec.template.spec.containers[0].envFrom + template: templates/deployment.yaml + - it: adds additional deployment and daemonset env sources from Values file using 'nr-otel-for-k8s-license' secret + set: + cluster: my-cluster + licenseKey: us-whatever + deployment: + envsFrom: + - secretRef: + name: test-secret-dep + - configMapRef: + name: test-configmap-dep + daemonset: + envsFrom: + - secretRef: + name: test-secret-dae + - configMapRef: + name: test-configmap-dae + asserts: + - contains: + path: spec.template.spec.containers[0].envFrom + content: + secretRef: + name: test-secret-dep + template: templates/deployment.yaml + - contains: + path: spec.template.spec.containers[0].envFrom + content: + configMapRef: + name: test-configmap-dep + template: templates/deployment.yaml + - contains: + path: spec.template.spec.containers[0].envFrom + content: + secretRef: + name: test-secret-dae + template: templates/daemonset.yaml + - contains: + path: spec.template.spec.containers[0].envFrom + content: + configMapRef: + name: test-configmap-dae + template: templates/daemonset.yaml \ No newline at end of file diff --git a/charts/nr-k8s-otel-collector/tests/env_vars_test.yaml b/charts/nr-k8s-otel-collector/tests/env_vars_test.yaml new file mode 100644 index 000000000..cdf1984aa --- /dev/null +++ b/charts/nr-k8s-otel-collector/tests/env_vars_test.yaml @@ -0,0 +1,94 @@ +suite: envVars +templates: + - templates/deployment.yaml + - templates/deployment-configmap.yaml + - templates/daemonset.yaml + - templates/daemonset-configmap.yaml +release: + name: my-release + namespace: my-namespace +tests: + - it: does not set pod environment variables by default + set: + cluster: my-cluster + licenseKey: us-whatever + asserts: + - lengthEqual: + path: spec.template.spec.containers[0].env + count: 3 + template: templates/deployment.yaml + - lengthEqual: + path: spec.template.spec.containers[0].env + count: 7 + template: templates/daemonset.yaml + - it: sets deployment pod environment variables from values + set: + cluster: my-cluster + licenseKey: us-whatever + deployment: + envs: + - name: "TEST_DEP_ENV_VAR" + value: "my-dep-value" + asserts: + - lengthEqual: + path: spec.template.spec.containers[0].env + count: 4 + template: templates/deployment.yaml + - contains: + path: spec.template.spec.containers[0].env + content: + name: "TEST_DEP_ENV_VAR" + value: "my-dep-value" + template: templates/deployment.yaml + - it: sets daemonset pod environment variables from values + set: + cluster: my-cluster + licenseKey: us-whatever + daemonset: + envs: + - name: "TEST_DAE_ENV_VAR" + value: "my-dae-value" + asserts: + - lengthEqual: + path: spec.template.spec.containers[0].env + count: 8 + template: templates/daemonset.yaml + - contains: + path: spec.template.spec.containers[0].env + content: + name: "TEST_DAE_ENV_VAR" + value: "my-dae-value" + template: templates/daemonset.yaml + - it: sets deployment and daemonset pod environment variables from values + set: + cluster: my-cluster + licenseKey: us-whatever + deployment: + envs: + - name: "TEST_DEP_ENV_VAR" + value: "my-dep-value" + daemonset: + envs: + - name: "TEST_DAE_ENV_VAR" + value: "my-dae-value" + asserts: + - lengthEqual: + path: spec.template.spec.containers[0].env + count: 4 + template: templates/deployment.yaml + - contains: + path: spec.template.spec.containers[0].env + content: + name: "TEST_DEP_ENV_VAR" + value: "my-dep-value" + template: templates/deployment.yaml + - lengthEqual: + path: spec.template.spec.containers[0].env + count: 8 + template: templates/daemonset.yaml + - contains: + path: spec.template.spec.containers[0].env + content: + name: "TEST_DAE_ENV_VAR" + value: "my-dae-value" + template: templates/daemonset.yaml \ No newline at end of file diff --git a/charts/nr-k8s-otel-collector/values.yaml b/charts/nr-k8s-otel-collector/values.yaml index a296909a4..055723f67 100644 --- a/charts/nr-k8s-otel-collector/values.yaml +++ b/charts/nr-k8s-otel-collector/values.yaml @@ -60,6 +60,10 @@ daemonset: privileged: true # -- Sets resources for the daemonset. resources: {} + # -- Sets additional environment variables for the daemonset. + envs: [] + # -- Sets additional environment variable sources for the daemonset. + envsFrom: [] # -- Settings for daemonset configmap # @default -- See `values.yaml` configMap: @@ -81,6 +85,10 @@ deployment: containerSecurityContext: {} # -- Sets resources for the deployment. resources: {} + # -- Sets additional environment variables for the deployment. + envs: [] + # -- Sets additional environment variable sources for the deployment. + envsFrom: [] # -- Settings for deployment configmap # @default -- See `values.yaml` configMap: