From 0a399094e337cc44e5b9400332e53706295d8de0 Mon Sep 17 00:00:00 2001 From: Mathieu Herbert Date: Mon, 20 May 2024 11:50:57 +0200 Subject: [PATCH 1/2] [synthetic-monitoring-agent] feat: add support for existing secret Signed-off-by: Mathieu Herbert --- charts/synthetic-monitoring-agent/Chart.yaml | 2 +- charts/synthetic-monitoring-agent/README.md | 5 +++-- charts/synthetic-monitoring-agent/templates/deployment.yaml | 2 +- charts/synthetic-monitoring-agent/templates/secret.yaml | 4 +++- charts/synthetic-monitoring-agent/values.yaml | 6 +++++- 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/charts/synthetic-monitoring-agent/Chart.yaml b/charts/synthetic-monitoring-agent/Chart.yaml index acf3ac73b5..f5d62363a7 100644 --- a/charts/synthetic-monitoring-agent/Chart.yaml +++ b/charts/synthetic-monitoring-agent/Chart.yaml @@ -15,4 +15,4 @@ name: synthetic-monitoring-agent sources: - https://github.com/grafana/synthetic-monitoring-agent type: application -version: 0.2.0 +version: 0.3.0 diff --git a/charts/synthetic-monitoring-agent/README.md b/charts/synthetic-monitoring-agent/README.md index 9e9a4192a1..415439a498 100644 --- a/charts/synthetic-monitoring-agent/README.md +++ b/charts/synthetic-monitoring-agent/README.md @@ -1,6 +1,6 @@ # synthetic-monitoring-agent -![Version: 0.2.0](https://img.shields.io/badge/Version-0.2.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v0.9.3-0-gcd7aadd](https://img.shields.io/badge/AppVersion-v0.9.3--0--gcd7aadd-informational?style=flat-square) +![Version: 0.3.0](https://img.shields.io/badge/Version-0.3.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v0.9.3-0-gcd7aadd](https://img.shields.io/badge/AppVersion-v0.9.3--0--gcd7aadd-informational?style=flat-square) Grafana's Synthetic Monitoring application. The agent provides probe functionality and executes network checks for monitoring remote targets. @@ -28,7 +28,7 @@ Kubernetes: `^1.16.0-0` |-----|------|---------|-------------| | affinity | object | `{}` | Node affinity for pod assignment. | | agent.apiServerAddress | string | `"synthetic-monitoring-grpc.grafana.net:443"` | Default server endpoint for receiving synthetic monitoring checks on Grafana's side. See https://grafana.com/docs/grafana-cloud/synthetic-monitoring/private-probes/#probe-api-server-url for more information. | -| agent.apiToken | string | `""` | **REQUIRED** API token from Grafana Cloud. | +| agent.apiToken | string | `""` | API token from Grafana Cloud when secret is created by the chart. | | agent.debug | bool | `false` | Enable / disable debug logging on the agent. | | agent.enableDisconnect | bool | `false` | Enable / disable the HTTP /disconnect endpoint | | agent.verbose | bool | `false` | Enable / disable verbose logging on the agent. | @@ -54,6 +54,7 @@ Kubernetes: `^1.16.0-0` | readinessProbe | object | `{"httpGet":{"path":"/ready","port":"http"}}` | Readiness probe for the agent | | replicaCount | int | `1` | Number of replicas to use; ignored if `autoscaling.enabled` is set to `true`. | | resources | object | `{}` | Default resources to apply. | +| secret.existingSecret | string | `""` | Reference an existing secret for API token | | securityContext | object | `{"capabilities":{"drop":["ALL"]},"readOnlyRootFilesystem":true,"runAsNonRoot":true,"runAsUser":65534}` | Security context for the container level. | | service.annotations | object | `{}` | Annotations for the service | | service.port | int | `4050` | Service port. | diff --git a/charts/synthetic-monitoring-agent/templates/deployment.yaml b/charts/synthetic-monitoring-agent/templates/deployment.yaml index 137177aabb..7fde2e0540 100644 --- a/charts/synthetic-monitoring-agent/templates/deployment.yaml +++ b/charts/synthetic-monitoring-agent/templates/deployment.yaml @@ -63,7 +63,7 @@ spec: valueFrom: secretKeyRef: key: api-token - name: {{ include "synthetic-monitoring-agent.fullname" . }} + name: {{ (tpl .Values.secret.existingSecret .) | default (include "synthetic-monitoring-agent.fullname" .) }} name: {{ .Chart.Name }} securityContext: {{- toYaml .Values.securityContext | nindent 12 }} diff --git a/charts/synthetic-monitoring-agent/templates/secret.yaml b/charts/synthetic-monitoring-agent/templates/secret.yaml index ce2ed51f73..1d363b7656 100644 --- a/charts/synthetic-monitoring-agent/templates/secret.yaml +++ b/charts/synthetic-monitoring-agent/templates/secret.yaml @@ -1,3 +1,4 @@ +{{- if not .Values.secret.existingSecret }} apiVersion: v1 kind: Secret metadata: @@ -6,4 +7,5 @@ metadata: {{- include "synthetic-monitoring-agent.labels" . | nindent 4 }} type: Opaque data: - api-token: {{ required "A valid .Values.agent.apiToken is required!" .Values.agent.apiToken | b64enc }} + api-token: {{ .Values.agent.apiToken | b64enc }} +{{- end }} \ No newline at end of file diff --git a/charts/synthetic-monitoring-agent/values.yaml b/charts/synthetic-monitoring-agent/values.yaml index f924c53634..970450d196 100644 --- a/charts/synthetic-monitoring-agent/values.yaml +++ b/charts/synthetic-monitoring-agent/values.yaml @@ -3,7 +3,7 @@ # Declare variables to be passed into your templates. agent: - # -- **REQUIRED** API token from Grafana Cloud. + # -- API token from Grafana Cloud when secret is created by the chart. apiToken: "" # -- Default server endpoint for receiving synthetic monitoring checks on Grafana's side. # See https://grafana.com/docs/grafana-cloud/synthetic-monitoring/private-probes/#probe-api-server-url for more information. @@ -148,3 +148,7 @@ affinity: {} # -- Add dynamic manifests via values: extraObjects: [] + +secret: +# -- Reference an existing secret for API token + existingSecret: "" \ No newline at end of file From 9c413df0312de44b93bde5fa18b0c81b1145a8e3 Mon Sep 17 00:00:00 2001 From: Mathieu Herbert Date: Mon, 20 May 2024 11:51:53 +0200 Subject: [PATCH 2/2] add values end of file Signed-off-by: Mathieu Herbert --- charts/synthetic-monitoring-agent/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/synthetic-monitoring-agent/values.yaml b/charts/synthetic-monitoring-agent/values.yaml index 970450d196..a6e534844c 100644 --- a/charts/synthetic-monitoring-agent/values.yaml +++ b/charts/synthetic-monitoring-agent/values.yaml @@ -151,4 +151,4 @@ extraObjects: [] secret: # -- Reference an existing secret for API token - existingSecret: "" \ No newline at end of file + existingSecret: ""