diff --git a/charts/super-agent/README.md b/charts/super-agent/README.md index 1261863ac..e1e995c0f 100644 --- a/charts/super-agent/README.md +++ b/charts/super-agent/README.md @@ -51,7 +51,6 @@ As of the creation of the chart, it has no particularities and this section can | super-agent-deployment.affinity | object | `{}` | Sets pod/node affinities. Can be configured also with `global.affinity` | | super-agent-deployment.cleanupManagedResources | bool | `true` | Enable the cleanup of super-agent managed resources when the chart is uninstalled. If disabled, agents and/or agent configurations managed by the super-agent will not be deleted when the chart is uninstalled. | | super-agent-deployment.cluster | string | `""` | Name of the Kubernetes cluster monitored. Can be configured also with `global.cluster`. | -| super-agent-deployment.config.auth.enabled | bool | `true` | Enables or disables the auth against fleet control. It implies to disable any fleet communication and running the agent in stand alone mode where only the agents specified on `.config.subAgents` will be launched. | | super-agent-deployment.config.auth.organization_id | string | `""` | Organization ID where fleets will live. | | super-agent-deployment.config.auth.secret.client_id.base64 | string | `nil` | In case `.config.auth.secret.create` is true, you can set these keys to set client ID directly as base64. This options is mutually exclusive with `plain`. | | super-agent-deployment.config.auth.secret.client_id.plain | string | `nil` | In case `.config.auth.secret.create` is true, you can set these keys to set client ID directly as plain text. This options is mutually exclusive with `base64`. | @@ -60,6 +59,7 @@ As of the creation of the chart, it has no particularities and this section can | super-agent-deployment.config.auth.secret.private_key.base64_pem | string | `nil` | In case `.config.auth.secret.create` is true, you can set these keys to set private key directly as base64. This options is mutually exclusive with `plain_pem`. | | super-agent-deployment.config.auth.secret.private_key.plain_pem | string | `nil` | In case `.config.auth.secret.create` is true, you can set these keys to set private key directly as plain text. This options is mutually exclusive with `base64_pem`. | | super-agent-deployment.config.auth.secret.private_key.secret_key | string | `private_key` | Key inside the secret containing the private key. | +| super-agent-deployment.config.opamp.enabled | bool | `true` | Enables or disables the auth against fleet control. It implies to disable any fleet communication and running the agent in stand alone mode where only the agents specified on `.config.subAgents` will be launched. | | super-agent-deployment.config.subAgents | string | {} (Empty. That defaults to configure the `newrelic/io.opentelemetry.collector` subagent) | Values that the fleet is going to have in the deployment. | | super-agent-deployment.config.superAgent | object | See `values.yaml` | Configuration for the Super Agent. | | super-agent-deployment.config.superAgent.content | object | `{}` | It you are a PowerUser, you can use this to override the configuration that has been created automatically by the chart. This configuration here will be **MERGED** with the configuration specified above. If you need to have you own configuration, disabled the creation of this configMap and create your own. | diff --git a/charts/super-agent/charts/super-agent-deployment/templates/_helpers.tpl b/charts/super-agent/charts/super-agent-deployment/templates/_helpers.tpl index 78bfc57ff..8c3d3613c 100644 --- a/charts/super-agent/charts/super-agent-deployment/templates/_helpers.tpl +++ b/charts/super-agent/charts/super-agent-deployment/templates/_helpers.tpl @@ -122,8 +122,8 @@ If you need a list of TODOs, just `grep TODO` on the `values.yaml` and look for {{- $k8s := (dict "cluster_name" (include "newrelic.common.cluster" .) "namespace" .Release.Namespace) -}} {{- $config = mustMerge $config (dict "k8s" $k8s) -}} -{{- /* Add opamp if auth enabled */ -}} -{{- if ((.Values.config).auth).enabled -}} +{{- /* Add opamp if enabled */ -}} +{{- if ((.Values.config).opamp).enabled -}} {{- $opamp := (dict "endpoint" (include "newrelic-super-agent.config.endpoints.opamp" .)) -}} {{- $auth_config := dict "token_url" (include "newrelic-super-agent.config.endpoints.tokenRenewal" .) "provider" "local" "private_key_path" "/etc/newrelic-super-agent/keys/from-secret.key" -}} @@ -205,7 +205,7 @@ Helper to toggle the creation of the job that creates and registers the system i {{- $privateKey := include "newrelic-super-agent.auth.secret.privateKey.data" . -}} {{- $clientId := include "newrelic-super-agent.auth.secret.clientId.data" . -}} -{{- if and ((.Values.config).auth).enabled (((.Values.config).auth).secret).create (not $privateKey) (not $clientId) -}} +{{- if and ((.Values.config).opamp).enabled (((.Values.config).auth).secret).create (not $privateKey) (not $clientId) -}} true {{- end -}} {{- end -}} @@ -216,7 +216,7 @@ Helper to toggle the creation of the job that creates and registers the system i Helper to toggle the creation of the secret that has the system identity as values. */ -}} {{- define "newrelic-super-agent.auth.secret.shouldTemplate" -}} -{{- if and ((.Values.config).auth).enabled (((.Values.config).auth).secret).create -}} +{{- if and ((.Values.config).opamp).enabled (((.Values.config).auth).secret).create -}} {{- $privateKey := include "newrelic-super-agent.auth.secret.privateKey.data" . -}} {{- $clientId := include "newrelic-super-agent.auth.secret.clientId.data" . -}} diff --git a/charts/super-agent/charts/super-agent-deployment/templates/deployment-superagent.yaml b/charts/super-agent/charts/super-agent-deployment/templates/deployment-superagent.yaml index c2419b6a6..2def77735 100644 --- a/charts/super-agent/charts/super-agent-deployment/templates/deployment-superagent.yaml +++ b/charts/super-agent/charts/super-agent-deployment/templates/deployment-superagent.yaml @@ -64,7 +64,7 @@ spec: imagePullPolicy: {{ .Values.image.pullPolicy }} env: - {{- if ((.Values.config).auth).enabled }} + {{- if ((.Values.config).opamp).enabled }} - name: NR_SA_OPAMP__AUTH_CONFIG__CLIENT_ID valueFrom: secretKeyRef: @@ -115,7 +115,7 @@ spec: - mountPath: /var/lib/newrelic-super-agent name: var-lib-newrelic-super-agent readOnly: false - {{- if ((.Values.config).auth).enabled }} + {{- if ((.Values.config).opamp).enabled }} - name: auth-secret-private-key mountPath: "/etc/newrelic-super-agent/keys/from-secret.key" subPath: {{ include "newrelic-super-agent.auth.secret.privateKey.key" . }} @@ -136,7 +136,7 @@ spec: path: config.yaml - name: var-lib-newrelic-super-agent emptyDir: {} - {{- if ((.Values.config).auth).enabled }} + {{- if ((.Values.config).opamp).enabled }} - name: auth-secret-private-key secret: secretName: {{ include "newrelic-super-agent.auth.secret.name" . }} diff --git a/charts/super-agent/charts/super-agent-deployment/tests/configmap_superagent_config_test.yaml b/charts/super-agent/charts/super-agent-deployment/tests/configmap_superagent_config_test.yaml index bd1581c29..a889a30cc 100644 --- a/charts/super-agent/charts/super-agent-deployment/tests/configmap_superagent_config_test.yaml +++ b/charts/super-agent/charts/super-agent-deployment/tests/configmap_superagent_config_test.yaml @@ -13,6 +13,26 @@ tests: asserts: - hasDocuments: count: 0 + + - it: opamp can be disabled + set: + cluster: my-cluster + config: + opamp: + enabled: false + asserts: + - equal: + path: data["local_config"] + value: | + agents: + open-telemetry: + agent_type: newrelic/io.opentelemetry.collector:0.2.0 + k8s: + cluster_name: my-cluster + namespace: my-namespace + server: + enabled: true + - it: super agent's config always include cluster_name, namespace and defaults set: cluster: my-cluster @@ -36,6 +56,7 @@ tests: endpoint: https://opamp.service.newrelic.com/v1/opamp server: enabled: true + - it: super agent's config templates set: cluster: my-cluster @@ -64,6 +85,7 @@ tests: enabled: true test: value test2: value2 + - it: cluster_name and namespace from config have precedence set: cluster: my-cluster @@ -95,6 +117,7 @@ tests: enabled: true test: value test2: value2 + - it: super agent's config always include cluster_name, namespace, defaults, and honor the EU endpoint. set: cluster: my-cluster diff --git a/charts/super-agent/values.yaml b/charts/super-agent/values.yaml index 6869b91df..d813146ae 100644 --- a/charts/super-agent/values.yaml +++ b/charts/super-agent/values.yaml @@ -132,10 +132,12 @@ super-agent-deployment: # chart_values: # # you can set here modifications to the open telemetry chart - auth: + opamp: # -- Enables or disables the auth against fleet control. It implies to disable any fleet communication and running the agent # in stand alone mode where only the agents specified on `.config.subAgents` will be launched. enabled: true + + auth: # -- Organization ID where fleets will live. organization_id: "" secret: