From 2a921402596dc5d4b95a068824794399d0923a94 Mon Sep 17 00:00:00 2001 From: Paolo Gallina Date: Mon, 27 May 2024 14:51:34 +0200 Subject: [PATCH] chore(super-agent): remove jobs --- .codespellrc | 2 +- charts/super-agent/Chart.lock | 7 +- charts/super-agent/Chart.yaml | 6 +- charts/super-agent/README.md | 16 +- charts/super-agent/ci/test-values.yaml | 25 ++- .../super-agent/templates/_helm-release.yaml | 49 ------ .../templates/_helm-repository.yaml | 23 --- charts/super-agent/templates/install-job.yaml | 49 ------ .../super-agent/templates/job-manifests.yaml | 34 ----- .../super-agent/templates/uninstall-job.yaml | 37 ----- charts/super-agent/values.yaml | 144 +++++------------- 11 files changed, 73 insertions(+), 319 deletions(-) delete mode 100644 charts/super-agent/templates/_helm-release.yaml delete mode 100644 charts/super-agent/templates/_helm-repository.yaml delete mode 100644 charts/super-agent/templates/install-job.yaml delete mode 100644 charts/super-agent/templates/job-manifests.yaml delete mode 100644 charts/super-agent/templates/uninstall-job.yaml diff --git a/.codespellrc b/.codespellrc index 2de26622e..2bdd8c909 100644 --- a/.codespellrc +++ b/.codespellrc @@ -1,5 +1,5 @@ [codespell] skip = ./.git -ignore-words-list = enver +ignore-words-list = enver,notin check-filenames = check-hidden = diff --git a/charts/super-agent/Chart.lock b/charts/super-agent/Chart.lock index c1a5c8599..a7170f6f4 100644 --- a/charts/super-agent/Chart.lock +++ b/charts/super-agent/Chart.lock @@ -5,5 +5,8 @@ dependencies: - name: common-library repository: https://helm-charts.newrelic.com version: 1.1.1 -digest: sha256:b8accc892d1405e664f9b1d47ad5246d9c9c1f266eb003608bc05423f56c4a26 -generated: "2024-01-25T16:36:14.618519184Z" +- name: super-agent-deployment + repository: https://helm-charts.newrelic.com + version: 0.0.16-beta +digest: sha256:c7b1eafa4e10cd193826db2d674e6da9ff7a7f5795991ff316e8f175306bfe0f +generated: "2024-05-27T14:58:00.756624+02:00" diff --git a/charts/super-agent/Chart.yaml b/charts/super-agent/Chart.yaml index 8ef7406fa..1fe25e243 100644 --- a/charts/super-agent/Chart.yaml +++ b/charts/super-agent/Chart.yaml @@ -3,7 +3,7 @@ name: super-agent description: Bootstraps New Relic' Super Agent type: application -version: 0.0.6-beta +version: 0.0.7-beta dependencies: - name: flux2 @@ -13,6 +13,10 @@ dependencies: - name: common-library version: 1.1.1 repository: https://helm-charts.newrelic.com + - name: super-agent-deployment + version: 0.0.16-beta + repository: https://helm-charts.newrelic.com + condition: super-agent-deployment.enabled keywords: - newrelic diff --git a/charts/super-agent/README.md b/charts/super-agent/README.md index 469218bb3..84b955cb9 100644 --- a/charts/super-agent/README.md +++ b/charts/super-agent/README.md @@ -47,20 +47,8 @@ As of the creation of the chart, it has no particularities and this section can | flux2.rbac | object | Enabled (See `values.yaml`) | Create RBAC rules for FluxCD is able to deploy all kind of workloads on the cluster. | | flux2.sourceController | object | Enabled | Source controller provides a way to fetch artifacts to the rest of controllers. The source API (which reference [can be read here](https://fluxcd.io/flux/components/source/api/v1/)) is used by admins and various automated operators to offload the Git, OCO, and Helm repositories management. | | flux2.watchAllNamespaces | bool | `false` | As we are using Flux as a tool from the super agent to release new workloads, we do not want Flux to listen to all CRs created on the whole cluster. If the user does not want to use Flux and is only using it because of the super agent, this is the way to go so the cluster has deployed all operators needed by the super agent. But if the user want to use Flux for other purposes besides the super agent, this toggle can be used to allow Flux to work on the whole cluster. | -| helm.create | bool | `true` | Enable the installation of the CRs so FluxCD deploy the Super Agent is deployed. This an advanced/debug flag. It should be always be true unless you know what you are going. | -| helm.release | object | See `values.yaml` | Values related to the super agent's Helm chart release. | -| helm.release.chart | string | `"super-agent-deployment"` | The Helm chart of the super-agent. This values is meant to be changed only on air-gapped environments or for development/testing purposes. | -| helm.release.install | object | See `values.yaml` | Change the behavior of the operator while installing the chart for the first time. This should only be changed by advanced users that know what they are doing. Exposes the remediations that the operator is going to try before give up installing the chart in case it hits an error. | -| helm.release.rollback | object | See `values.yaml` | Optional configuration of rollback strategy when upgrading. This should only be changed by advanced users that know what they are doing. | -| helm.release.upgrade | object | See `values.yaml` | Change the behavior of the operator while upgrading the chart. This should only be changed by advanced users that know what they are doing. Exposes the remediations that the operator is going to try before give up installing the chart in case it hits an error. | -| helm.release.values | string | `{}`. Examples on the `values.yaml` | Set values to the super agent helm release directly from this `values.yaml` file. Refer to https://fluxcd.io/flux/components/helm/helmreleases/#values-overrides | -| helm.release.valuesFrom | string | empty | Set values from a `configMap` or a `secret`. You can see examples and better documentation inside the `values.yaml` file. Also refer to https://fluxcd.io/flux/components/helm/helmreleases/#values-overrides | -| helm.release.version | string | `"0.0.12-beta"` | The Helm chart of the super-agent. This values is meant to be changed only on air-gapped environments or for development/testing purposes. TODO: Point renovatebot here. | -| helm.repository | object | See `values.yaml` | Values related to the Helm repository where to download the super agent's chart. | -| helm.repository.certSecretRef | string | `nil` (no secret reference) | secret of type `kubernetes.io/tls` with the standard keys `tls.crt`, `tls.key`, and `ca.crt` | -| helm.repository.secretRef | string | `nil` (no secret reference) | A reference to a secret with the keys username and password to authenticate to the repository. | -| helm.repository.updateInterval | string | `"24h"` | Sets the interval the repository is going to be updated on the controller. | -| helm.repository.url | string | `"https://helm-charts.newrelic.com"` | The repository where the super-agent has the chart. This values is meant to be changed only on air-gapped environments or for development/testing purposes. | +| super-agent-deployment | object | See `values.yaml` | Values related to the super agent's Helm chart release. | +| super-agent-deployment.enabled | bool | `true` | Enable the installation of the Super Agent. This an advanced/debug flag. It should be always be true unless you know what you are going. | ## Maintainers diff --git a/charts/super-agent/ci/test-values.yaml b/charts/super-agent/ci/test-values.yaml index 42659f60a..5ee3fb055 100644 --- a/charts/super-agent/ci/test-values.yaml +++ b/charts/super-agent/ci/test-values.yaml @@ -1,5 +1,20 @@ -# chart-testing need values files to test that the chart is installable and upgradable. -# The values file is needed to be populated. As we have nothing to test for now, I am filling this files with gibberish -# so the test triggers at the same time that it does not affect the default values file or any other function of the -# chart of the common library. -fake: values +super-agent-deployment: + cluster: sa-cluster + config: + superAgent: + content: + agents: {} + subAgents: + test-0: + content: + a: test + value: 0 + test-1: + content: + a: test + value: 1 + test-2: + content: + a: test + aYAML: + canI: HaveSomeYAML diff --git a/charts/super-agent/templates/_helm-release.yaml b/charts/super-agent/templates/_helm-release.yaml deleted file mode 100644 index d42c070f8..000000000 --- a/charts/super-agent/templates/_helm-release.yaml +++ /dev/null @@ -1,49 +0,0 @@ -{{- define "newrelic-super-agent.helm.release" -}} -{{- $releaseName := include "newrelic.common.naming.truncateToDNSWithSuffix" ( dict "name" (include "newrelic.common.naming.fullname" .) "suffix" "deployment" ) -}} -{{- /* -To understand why this manifest is a template function instead of a manifest that is appyed directly, read the comment at `job-manifests.yaml`. -*/ -}} -apiVersion: helm.toolkit.fluxcd.io/v2beta1 -kind: HelmRelease -metadata: - labels: - {{- include "newrelic.common.labels" . | nindent 4 }} - name: {{ $releaseName }} - namespace: {{ .Release.Namespace }} -spec: - interval: {{ .Values.helm.repository.updateInterval }} - chart: - spec: - chart: {{ .Values.helm.release.chart }} - version: {{ .Values.helm.release.version }} - sourceRef: - kind: HelmRepository - name: newrelic - namespace: {{ .Release.Namespace }} - interval: {{ .Values.helm.repository.updateInterval }} - values: - fullnameOverride: super-agent - {{- with .Values.helm.release.values }} - {{- . | toYaml | nindent 4 }} - {{- end }} - {{- with .Values.helm.release.valuesFrom }} - valuesFrom: - {{- . | toYaml | nindent 4 }} - {{- end }} - - {{- with .Values.helm.release.install }} - install: - {{- . | toYaml | nindent 4 }} - {{- end }} - {{- with .Values.helm.release.upgrade }} - upgrade: - {{- . | toYaml | nindent 4 }} - {{- end }} - {{- with .Values.helm.release.rollback }} - rollback: - {{- . | toYaml | nindent 4 }} - {{- end }} - uninstall: # This is setup explicitly since executing hooks and waiting for uninstall termination is needed to remove super-agent managed resources - disableWait: false - disableHooks: false -{{- end -}} diff --git a/charts/super-agent/templates/_helm-repository.yaml b/charts/super-agent/templates/_helm-repository.yaml deleted file mode 100644 index bff2586b8..000000000 --- a/charts/super-agent/templates/_helm-repository.yaml +++ /dev/null @@ -1,23 +0,0 @@ -{{- define "newrelic-super-agent.helm.repository" -}} -{{- /* -To understand why this manifest is a template function instead of a manifest that is appyed directly, read the comment at `job-manifests.yaml`. -*/ -}} -apiVersion: source.toolkit.fluxcd.io/v1beta2 -kind: HelmRepository -metadata: - labels: - {{- include "newrelic.common.labels" . | nindent 4 }} - name: newrelic - namespace: {{ .Release.Namespace }} -spec: - interval: {{ .Values.helm.repository.updateInterval }} - url: {{ .Values.helm.repository.url }} - {{- with .Values.helm.repository.secretRef }} - secretRef: - {{- . | toYaml | nindent 4 }} - {{- end }} - {{- with .Values.helm.repository.certSecretRef }} - certSecretRef: - {{- . | toYaml | nindent 4 }} - {{- end }} -{{- end -}} diff --git a/charts/super-agent/templates/install-job.yaml b/charts/super-agent/templates/install-job.yaml deleted file mode 100644 index faa9431df..000000000 --- a/charts/super-agent/templates/install-job.yaml +++ /dev/null @@ -1,49 +0,0 @@ -{{- if .Values.helm.create -}} -{{- $installJobName := include "newrelic.common.naming.truncateToDNSWithSuffix" ( dict "name" (include "newrelic.common.naming.fullname" .) "suffix" "install-job" ) -}} -{{- $configMapName := include "newrelic.common.naming.truncateToDNSWithSuffix" ( dict "name" (include "newrelic.common.naming.fullname" .) "suffix" "job-manifests" ) -}} -{{- /* -To understand why this job installs manifests instead of using Helm, read the comment at `job-manifests.yaml`. -*/ -}} -apiVersion: batch/v1 -kind: Job -metadata: - annotations: - helm.sh/hook: post-install,post-upgrade - helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded - helm.sh/hook-weight: "10010" - name: {{ $installJobName }} - namespace: {{ .Release.Namespace }} -spec: - ttlSecondsAfterFinished: 120 - backoffLimit: 1 - template: - spec: - restartPolicy: Never - serviceAccountName: helm-controller # Hardcoded on flux2 chart. - containers: - - name: apply-crs - image: bitnami/kubectl - command: [ "/bin/bash","-c" ] - args: - - | - set -o pipefail - - ERROR_OUTPUT=$(kubectl apply -f /manifests/ 2>&1) - EXIT_CODE=$? - - # Check if kubectl command was successful or if it contains success keywords - if [ $EXIT_CODE -ne 0 ] || ! echo "$ERROR_OUTPUT"; then - echo "Applying CRs failed. Please check the values YAML syntax and Kubernetes resource definitions." - echo "Error details: $ERROR_OUTPUT" - exit $EXIT_CODE - fi - - echo "Manifests applied successfully." - volumeMounts: - - name: manifests-configmap - mountPath: /manifests - volumes: - - name: manifests-configmap - configMap: - name: {{ $configMapName }} -{{- end }} diff --git a/charts/super-agent/templates/job-manifests.yaml b/charts/super-agent/templates/job-manifests.yaml deleted file mode 100644 index ed30e940a..000000000 --- a/charts/super-agent/templates/job-manifests.yaml +++ /dev/null @@ -1,34 +0,0 @@ -{{- if .Values.helm.create -}} -{{- $configMapName := include "newrelic.common.naming.truncateToDNSWithSuffix" ( dict "name" (include "newrelic.common.naming.fullname" .) "suffix" "job-manifests" ) -}} ---- -apiVersion: v1 -kind: ConfigMap -metadata: - annotations: - helm.sh/hook: pre-delete,post-install,post-upgrade - helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded - helm.sh/hook-weight: "10000" - name: {{ $configMapName }} - namespace: {{ .Release.Namespace }} -data: -{{- /* -Let's start with some background that allow to understand why configmap has manifests on it. - -Helm behaves differently depending on where you place your CRD manifests: - * If you set your CRDs on `crds`, Helm apply them before applying the other templates. - Pros: CRDs exist at apply time so you can apply CRs without any issue. - Cons: Helm does not update CRDs on chart upgrade so it is user's work to maintain them. - * If you set your CRDs on `templates`. Helm will apply them at the same time that the other templates of the chart. - Pros: Helm follows the manifest so it is able to create, upgrade and delete the CRDs - Cons: Helm will do a dry run of all the manifests before applying them in order. CRs will fail because CRDs do not exist on the server (yet) - -Flux have it CRDs on the `template` folder, So we cannot have the CRs we need on our template folder. They will fail to apply. - -To be able to apply them, we have a post-installation hook that run `kubectl apply` with the manifests after the CRDs exist on the cluster. -To delete them, there is a pre-delete hook that removes them. -*/}} - helm-release.yaml: | - {{- include "newrelic-super-agent.helm.release" . | nindent 4 }} - helm-repository.yaml: | - {{- include "newrelic-super-agent.helm.repository" . | nindent 4 }} -{{- end }} diff --git a/charts/super-agent/templates/uninstall-job.yaml b/charts/super-agent/templates/uninstall-job.yaml deleted file mode 100644 index d30c3fa7a..000000000 --- a/charts/super-agent/templates/uninstall-job.yaml +++ /dev/null @@ -1,37 +0,0 @@ -{{- if .Values.helm.create -}} -{{- $installJobName := include "newrelic.common.naming.truncateToDNSWithSuffix" ( dict "name" (include "newrelic.common.naming.fullname" .) "suffix" "uninstall-job" ) -}} -{{- $configMapName := include "newrelic.common.naming.truncateToDNSWithSuffix" ( dict "name" (include "newrelic.common.naming.fullname" .) "suffix" "job-manifests" ) -}} -{{- /* -To understand why this job installs manifests instead of using Helm, read the comment at `job-manifests.yaml`. -*/ -}} -apiVersion: batch/v1 -kind: Job -metadata: - annotations: - helm.sh/hook: pre-delete - helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded - helm.sh/hook-weight: "10010" - name: {{ $installJobName }} - namespace: {{ .Release.Namespace }} -spec: - ttlSecondsAfterFinished: 120 - template: - spec: - restartPolicy: Never - serviceAccountName: helm-controller # Hardcoded on flux2 chart. - containers: - - name: delete-crs - image: bitnami/kubectl - command: - - kubectl - - delete - - -f - - /manifests/ - volumeMounts: - - name: manifests-configmap - mountPath: /manifests - volumes: - - name: manifests-configmap - configMap: - name: {{ $configMapName }} -{{- end }} diff --git a/charts/super-agent/values.yaml b/charts/super-agent/values.yaml index b9d5bb759..92b45207d 100644 --- a/charts/super-agent/values.yaml +++ b/charts/super-agent/values.yaml @@ -1,108 +1,44 @@ -helm: - # -- Enable the installation of the CRs so FluxCD deploy the Super Agent is deployed. This an advanced/debug flag. It - # should be always be true unless you know what you are going. - create: true - - # -- Values related to the Helm repository where to download the super agent's chart. - # @default -- See `values.yaml` - repository: - # -- Sets the interval the repository is going to be updated on the controller. - updateInterval: 24h - # -- The repository where the super-agent has the chart. This values is meant to be changed only on air-gapped - # environments or for development/testing purposes. - url: https://helm-charts.newrelic.com - - # -- A reference to a secret with the keys username and password to authenticate to the repository. - # @default -- `nil` (no secret reference) - secretRef: - # name: name-of-the-secret - # -- secret of type `kubernetes.io/tls` with the standard keys `tls.crt`, `tls.key`, and `ca.crt` - # @default -- `nil` (no secret reference) - certSecretRef: - # name: name-of-the-secret - - # -- Values related to the super agent's Helm chart release. - # @default -- See `values.yaml` - release: - # -- The Helm chart of the super-agent. This values is meant to be changed only on air-gapped environments or for - # development/testing purposes. - chart: super-agent-deployment - # -- The Helm chart of the super-agent. This values is meant to be changed only on air-gapped environments or for - # development/testing purposes. - # - # TODO: Point renovatebot here. - version: "0.0.12-beta" - - # -- Set values to the super agent helm release directly from this `values.yaml` file. Refer to https://fluxcd.io/flux/components/helm/helmreleases/#values-overrides - # @default -- `{}`. Examples on the `values.yaml` - values: - # These values are the values that the values that are going to be provided to the helm release as user-supplied. - # Here you have a example snippet of values that are being used upstream: - # - # image: - # registry: - # repository: newrelic/newrelic-super-agent - # tag: "" - # config: - # create: true - # name: "" - # key: "" - # content: - # opamp: - # headers: - # some-key: LICENSEKEY - # agents: - # agent_1: - # agent_type: namespace/agent_type:0.0.1 - - # -- Set values from a `configMap` or a `secret`. You can see examples and better documentation inside the - # `values.yaml` file. Also refer to https://fluxcd.io/flux/components/helm/helmreleases/#values-overrides - # @default -- empty - valuesFrom: - - # - kind: ConfigMap or Secret - # name: Name of the values referent, in the same namespace as the HelmRelease. - # valuesKey (Optional): The data key where the values.yaml or a specific value can be found. - # Defaults to `values.yaml` when omitted. - # targetPath (Optional): The YAML dot notation path at which the value should be merged. When set, the - # valuesKey is expected to be a single flat value. Defaults to `nil` when omitted, which - # results in the values getting merged at the root. - - # Examples: - # - kind: ConfigMap - # name: prod-env-values - # valuesKey: values-prod.yaml - # - kind: Secret - # name: prod-tls-values - # valuesKey: crt - # targetPath: tls.crt - - # -- Change the behavior of the operator while installing the chart for the first time. This should only be changed - # by advanced users that know what they are doing. Exposes the remediations that the operator is going to try - # before give up installing the chart in case it hits an error. - # @default -- See `values.yaml` - install: - disableWait: true # Prevents blocking the modification/deletions of the HelmRelease - replace: true # Tells the Helm install action to reuse the ‘ReleaseName’, but only if that name is a deleted release which remains in the history. - remediation: - retries: 3 # Retries is the number of retries that should be attempted on failures before givin up. An uninstall is performed between each attempt. - - # -- Change the behavior of the operator while upgrading the chart. This should only be changed by advanced users - # that know what they are doing. Exposes the remediations that the operator is going to try before give up - # installing the chart in case it hits an error. - # @default -- See `values.yaml` - upgrade: - disableWait: true # Prevents blocking the modification/deletions of the HelmRelease - force: true # Force forces resource updates through a replacement strategy. - cleanupOnFail: true # Allows deletion of new resources created during the Helm upgrade action when it fails. - remediation: - retries: 3 # Retries is the number of retries that should be attempted on failures before givin up. An uninstall is performed between each attempt. - strategy: rollback # rollback or uninstall. +# -- Values related to the super agent's Helm chart release. +# @default -- See `values.yaml` +super-agent-deployment: + # -- Enable the installation of the Super Agent. This an advanced/debug flag. It should be always be true unless + # you know what you are going. + enabled: true - # -- Optional configuration of rollback strategy when upgrading. This should only be changed by advanced users that know what they are doing. - # @default -- See `values.yaml` - rollback: - disableWait: true # Prevents blocking the modification/deletions of the HelmRelease + # These values are the values that the values that are going to be provided to the helm release as user-supplied. + # Here you have a example snippet of values that are being used upstream: + # + # image: + # registry: + # repository: newrelic/newrelic-super-agent + # tag: "" + # config: + # superAgent: + # create: true + # name: "" + # key: "" + # content: + # agents: + # open-telemetry: + # agent_type: newrelic/io.opentelemetry.collector:0.1.0 + # opamp: + # endpoint: https://opamp.service.newrelic.com/v1/opamp + # headers: + # api-key: LICENSE_KEY + # -- This option enables a status server that can be useful for troubleshooting. + # -- Port-forward it `$ kubectl port-forward pod/{pod-name} 51200:51200` + # -- And query it as `$ curl localhost:51200/status` + # server: + # enabled: true + # port: 51200 + # subAgents: + # open-telemetry: + # content: + # chart_values: + # mode: deployment + # config: + # exporters: + # logging: {} # -- Values for the Flux chat. Ref.: https://github.com/fluxcd-community/helm-charts/blob/flux2-2.10.2/charts/flux2/values.yaml # @default -- See `values.yaml`