From 34a5dd1d75607d2f827a3240383e17dad6ba5d8a Mon Sep 17 00:00:00 2001 From: John Allberg Date: Tue, 16 Apr 2024 08:13:28 +0200 Subject: [PATCH] chore: add kind test files for testing secureJsonData. --- .../resources/default/deployment-thanos.yaml | 43 +++++++++++++++++++ .../default/grafana-datasource-thanos.yaml | 29 +++++++++++++ .../kind/resources/default/kustomization.yaml | 5 +++ hack/kind/resources/default/secret.yaml | 7 +++ .../resources/default/serviceaccount.yaml | 6 +++ 5 files changed, 90 insertions(+) create mode 100644 hack/kind/resources/default/deployment-thanos.yaml create mode 100644 hack/kind/resources/default/grafana-datasource-thanos.yaml create mode 100644 hack/kind/resources/default/secret.yaml create mode 100644 hack/kind/resources/default/serviceaccount.yaml diff --git a/hack/kind/resources/default/deployment-thanos.yaml b/hack/kind/resources/default/deployment-thanos.yaml new file mode 100644 index 000000000..26e0d2d0d --- /dev/null +++ b/hack/kind/resources/default/deployment-thanos.yaml @@ -0,0 +1,43 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: thanos + labels: + app: thanos +spec: + selector: + matchLabels: + app: thanos + template: + metadata: + labels: + app: thanos + spec: + terminationGracePeriodSeconds: 3 + containers: + - name: netcat + image: alpine + command: + - sh + - -c + - | + set -eu + echo "Starting pod" + while true; do echo -e 'HTTP/1.1 200 OK\n\n{"asdf":"date"}' | nc -l -p 8080; done + ports: + - containerPort: 8080 + name: http + protocol: TCP +--- +apiVersion: v1 +kind: Service +metadata: + name: thanos +spec: + selector: + app: thanos + ports: + - port: 8080 + name: http + protocol: TCP + targetPort: 8080 diff --git a/hack/kind/resources/default/grafana-datasource-thanos.yaml b/hack/kind/resources/default/grafana-datasource-thanos.yaml new file mode 100644 index 000000000..7850393c6 --- /dev/null +++ b/hack/kind/resources/default/grafana-datasource-thanos.yaml @@ -0,0 +1,29 @@ +apiVersion: grafana.integreatly.org/v1beta1 +kind: GrafanaDatasource +metadata: + name: thanos +spec: + datasource: + access: proxy + basicAuth: false + editable: true + isDefault: true + jsonData: + httpHeaderName1: Authorization + timeInterval: 5s + tlsSkipVerify: true + name: Thanos + orgId: 1 + secureJsonData: + httpHeaderValue1: Bearer ${token} + type: prometheus + url: http://thanos.default.svc:8080 + instanceSelector: + matchLabels: + dashboards: grafana + valuesFrom: + - targetPath: 'secureJsonData.httpHeaderValue1' + valueFrom: + secretKeyRef: + name: grafana-instance-sa-token + key: token diff --git a/hack/kind/resources/default/kustomization.yaml b/hack/kind/resources/default/kustomization.yaml index ddecf6c73..d536d4b04 100644 --- a/hack/kind/resources/default/kustomization.yaml +++ b/hack/kind/resources/default/kustomization.yaml @@ -3,3 +3,8 @@ resources: - grafana-dashboard.yaml - grafana-datasource.yaml - grafana-contactpoint.yaml + + - grafana-datasource-thanos.yaml + - secret.yaml + - serviceaccount.yaml + - deployment-thanos.yaml diff --git a/hack/kind/resources/default/secret.yaml b/hack/kind/resources/default/secret.yaml new file mode 100644 index 000000000..b52021809 --- /dev/null +++ b/hack/kind/resources/default/secret.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: Secret +metadata: + name: grafana-instance-sa-token + annotations: + kubernetes.io/service-account.name: grafana-instance-sa +type: kubernetes.io/service-account-token diff --git a/hack/kind/resources/default/serviceaccount.yaml b/hack/kind/resources/default/serviceaccount.yaml new file mode 100644 index 000000000..a8327c8ef --- /dev/null +++ b/hack/kind/resources/default/serviceaccount.yaml @@ -0,0 +1,6 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: grafana-instance-sa +secrets: + - name: grafana-instance-sa-token