Skip to content

Commit

Permalink
[super-agent-deployment] Removing volume mounts (#1319)
Browse files Browse the repository at this point in the history
#### Is this a new chart
no
#### What this PR does / why we need it:

This PR depends on
newrelic/newrelic-super-agent#525 and is used
there already for e2e test, we should not merge it for now
  • Loading branch information
paologallinaharbur authored Apr 18, 2024
1 parent c0caf1d commit b7cfd51
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 99 deletions.
4 changes: 2 additions & 2 deletions charts/super-agent-deployment/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ description: A Helm chart to install New Relic Super agent on Kubernetes

type: application

version: 0.0.12-beta
appVersion: 0.8.0
version: 0.0.13-beta
appVersion: 0.13.1

dependencies:
- name: common-library
Expand Down
4 changes: 1 addition & 3 deletions charts/super-agent-deployment/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# super-agent-deployment

![Version: 0.0.12-beta](https://img.shields.io/badge/Version-0.0.12--beta-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.8.0](https://img.shields.io/badge/AppVersion-0.8.0-informational?style=flat-square)
![Version: 0.0.13-beta](https://img.shields.io/badge/Version-0.0.13--beta-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.13.1](https://img.shields.io/badge/AppVersion-0.13.1-informational?style=flat-square)

A Helm chart to install New Relic Super agent on Kubernetes

Expand Down Expand Up @@ -41,8 +41,6 @@ At the point of the creation of the chart, it has no particularities and this se
| config.superAgent | object | See `values.yaml` | Configuration for the Super Agent. |
| config.superAgent.content | string | See `values.yaml` for examples | Here you can set New Relic' Super Agent configuration. |
| config.superAgent.create | bool | `true` | Set if the configMap is going to be created by this chart or the user will provide its own. |
| config.superAgent.key | string | `""` | The key in the configMap that has the configuration for the Super Agent. |
| config.superAgent.name | string | `""` | The name the configMap is going to have. If create is set to false, the name of an existing configMap that will be used to config the Super Agent. |
| containerSecurityContext | object | `{}` | Sets security context (at container level). Can be configured also with `global.containerSecurityContext` |
| customAttributes | object | `{}` | TODO: Adds extra attributes to the cluster and all the metrics emitted to the backend. Can be configured also with `global.customAttributes` |
| customSecretLicenseKey | string | `""` | TODO: 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` |
Expand Down
11 changes: 1 addition & 10 deletions charts/super-agent-deployment/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,9 @@
Return the name of the configMap holding the Super Agent's config. Defaults to release's fill name suffiexed with "-config"
*/ -}}
{{- define "newrelic-super-agent.config.name" -}}
{{- .Values.config.superAgent.name | default (include "newrelic.common.naming.truncateToDNSWithSuffix" ( dict "name" (include "newrelic.common.naming.fullname" .) "suffix" "superagent-config" )) -}}
{{- (include "newrelic.common.naming.truncateToDNSWithSuffix" ( dict "name" "local-data" "suffix" "superagent-config" )) -}}
{{- end -}}


{{- /*
Return the key name of the configMap holding the Super Agent's config. Defaults to "config.yaml"
*/ -}}
{{- define "newrelic-super-agent.config.key" -}}
{{- .Values.config.superAgent.key | default "config.yaml" -}}
{{- end -}}
{{- /*
Builds the configuration from config on the values and add more config options like
cluster name, licenses, and custom attributes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{{- range $subAgentName, $subAgentConfig := .Values.config.subAgents -}}
{{- $releasePrefix := include "newrelic.common.naming.fullname" $ -}}
{{- $name := include "newrelic.common.naming.truncateToDNSWithSuffix" (dict "name" $releasePrefix "suffix" $subAgentName) }}
{{- $name := include "newrelic.common.naming.truncateToDNSWithSuffix" (dict "name" "local-data" "suffix" $subAgentName) }}
---
kind: ConfigMap
metadata:
Expand All @@ -11,6 +10,6 @@ metadata:
subagent: {{ $subAgentName }}
apiVersion: v1
data:
values.yaml: |
local_config: |
{{- $subAgentConfig.content | toYaml | nindent 4 }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
---
kind: ConfigMap
metadata:
name: {{ include "newrelic-super-agent.config.name" . }}
name: local-data-super-agent
namespace: {{ .Release.Namespace }}
labels:
{{- include "newrelic.common.labels" . | nindent 4 }}
apiVersion: v1
data:
{{ include "newrelic-super-agent.config.key" . }}: |
local_config: |
{{- include "newrelic-super-agent.config.content" . | nindent 4 }}
{{- end }}
19 changes: 2 additions & 17 deletions charts/super-agent-deployment/templates/deployment-superagent.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,6 @@ spec:
- name: super-agent-config
mountPath: /etc/newrelic-super-agent
readOnly: true
{{- range $subAgentName, $subAgentConfig := .Values.config.subAgents }}
{{- $releaseSuffx := include "newrelic.common.naming.fullname" $ }}
{{- $name := include "newrelic.common.naming.truncateToDNSWithSuffix" (dict "name" $releaseSuffx "suffix" $subAgentName) }}
- name: {{ $name }}
mountPath: /etc/newrelic-super-agent/fleet/agents.d/{{ $subAgentName }}/values
readOnly: true
{{- end }}
# TODO: when releasing we should check if this is still needed and if we need to persist the data.
- mountPath: /var/lib/newrelic-super-agent
name: var-lib-newrelic-super-agent
Expand All @@ -88,18 +81,10 @@ spec:
volumes:
- name: super-agent-config
configMap:
name: {{ include "newrelic-super-agent.config.name" . }}
name: local-data-super-agent
items:
- key: {{ include "newrelic-super-agent.config.key" . }}
- key: local_config
path: config.yaml
{{- range $subAgentName, $subAgentConfig := .Values.config.subAgents }}
{{- $releaseSuffx := include "newrelic.common.naming.fullname" $ }}
{{- $name := include "newrelic.common.naming.truncateToDNSWithSuffix" (dict "name" $releaseSuffx "suffix" $subAgentName) }}
- name: {{ $name }}
configMap:
name: {{ $name }}
{{- end }}

- name: var-lib-newrelic-super-agent
emptyDir: {}
{{- with .Values.extraVolumes }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,32 +33,32 @@ tests:
- documentIndex: 0
equal:
path: metadata.name
value: my-release-super-agent-deployment-test-0
value: local-data-test-0
- documentIndex: 0
equal:
path: data["values.yaml"]
path: data["local_config"]
value: |
a: test
value: 0
- documentIndex: 1
equal:
path: metadata.name
value: my-release-super-agent-deployment-test-1
value: local-data-test-1
- documentIndex: 1
equal:
path: data["values.yaml"]
path: data["local_config"]
value: |
a: test
value: 1
- documentIndex: 2
equal:
path: metadata.name
value: my-release-super-agent-deployment-test-2
value: local-data-test-2
- documentIndex: 2
equal:
path: data["values.yaml"]
path: data["local_config"]
value: |
a: test
aYAML:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ tests:
superAgent: {}
asserts:
- equal:
path: data["config.yaml"]
path: data["local_config"]
value: |
k8s:
cluster_name: my-cluster
Expand All @@ -35,7 +35,7 @@ tests:
test2: value2
asserts:
- equal:
path: data["config.yaml"]
path: data["local_config"]
value: |
k8s:
cluster_name: my-cluster
Expand All @@ -55,7 +55,7 @@ tests:
namespace: config-namespace
asserts:
- equal:
path: data["config.yaml"]
path: data["local_config"]
value: |
k8s:
cluster_name: config-cluster
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,7 @@ release:
namespace: my-namespace
tests:

- it: there are no subagent configurations by default
set:
cluster: test
asserts:
- template: templates/deployment-superagent.yaml
equal:
path: spec.template.spec.containers[0].volumeMounts
value:
- name: super-agent-config
mountPath: /etc/newrelic-super-agent
readOnly: true
- mountPath: /var/lib/newrelic-super-agent
name: var-lib-newrelic-super-agent
readOnly: false
- template: templates/deployment-superagent.yaml
equal:
path: spec.template.spec.volumes
value:
- name: super-agent-config
configMap:
name: my-release-super-agent-deployment-superagent-config
items:
- key: config.yaml
path: config.yaml
- name: var-lib-newrelic-super-agent
emptyDir: {}

- it: subagent configurations template file mounts
- it: there is no subagent configuration
set:
cluster: test
config:
Expand All @@ -61,15 +34,6 @@ tests:
- name: super-agent-config
mountPath: /etc/newrelic-super-agent
readOnly: true
- name: my-release-super-agent-deployment-test-0
mountPath: /etc/newrelic-super-agent/fleet/agents.d/test-0/values
readOnly: true
- name: my-release-super-agent-deployment-test-1
mountPath: /etc/newrelic-super-agent/fleet/agents.d/test-1/values
readOnly: true
- name: my-release-super-agent-deployment-test-2
mountPath: /etc/newrelic-super-agent/fleet/agents.d/test-2/values
readOnly: true
- mountPath: /var/lib/newrelic-super-agent
name: var-lib-newrelic-super-agent
readOnly: false
Expand All @@ -79,19 +43,10 @@ tests:
value:
- name: super-agent-config
configMap:
name: my-release-super-agent-deployment-superagent-config
name: local-data-super-agent
items:
- key: config.yaml
- key: local_config
path: config.yaml
- name: my-release-super-agent-deployment-test-0
configMap:
name: my-release-super-agent-deployment-test-0
- name: my-release-super-agent-deployment-test-1
configMap:
name: my-release-super-agent-deployment-test-1
- name: my-release-super-agent-deployment-test-2
configMap:
name: my-release-super-agent-deployment-test-2
- name: var-lib-newrelic-super-agent
emptyDir: {}

Expand Down
6 changes: 1 addition & 5 deletions charts/super-agent-deployment/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,12 @@ config:
superAgent:
# -- Set if the configMap is going to be created by this chart or the user will provide its own.
create: true
# -- The name the configMap is going to have. If create is set to false, the name of an existing configMap that will be used to config the Super Agent.
name: ""
# -- The key in the configMap that has the configuration for the Super Agent.
key: ""
# -- Here you can set New Relic' Super Agent configuration.
# @default -- See `values.yaml` for examples
content:
# agents:
# open-telemetry:
# agent_type: newrelic/io.opentelemetry.collector:0.0.1
# agent_type: newrelic/io.opentelemetry.collector:0.1.0
# opamp:
# endpoint: https://opamp.service.newrelic.com/v1/opamp
# headers:
Expand Down

0 comments on commit b7cfd51

Please sign in to comment.