From 961fccf9b1fbd4f4be890442996c04be8d3c67a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Otto=20Kr=C3=B6pke?= Date: Mon, 4 Nov 2024 20:49:31 +0100 Subject: [PATCH] [grafana] Implement Gateway API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jan-Otto Kröpke --- .github/workflows/lint-test.yaml | 4 ++ charts/grafana/Chart.yaml | 2 +- charts/grafana/ci/with-nondefault-values.yaml | 26 +++++++++++ charts/grafana/templates/route.yaml | 44 +++++++++++++++++++ charts/grafana/values.yaml | 36 +++++++++++++++ 5 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 charts/grafana/templates/route.yaml diff --git a/.github/workflows/lint-test.yaml b/.github/workflows/lint-test.yaml index b5134a83d4..f6e54f3047 100644 --- a/.github/workflows/lint-test.yaml +++ b/.github/workflows/lint-test.yaml @@ -72,6 +72,10 @@ jobs: kubectl_version: ${{ inputs.kind_kubectl_version }} node_image: ${{ inputs.kind_node_image }} + - name: Apply Gateway API CRDs + if: steps.list-changed.outputs.changed == 'true' + run: kubectl apply -k https://github.com/kubernetes-sigs/gateway-api/config/crd + - name: Run chart-testing (install) run: | changed=$(ct list-changed --config "${CT_CONFIGFILE}") diff --git a/charts/grafana/Chart.yaml b/charts/grafana/Chart.yaml index b7aa6bf080..2e3260979a 100644 --- a/charts/grafana/Chart.yaml +++ b/charts/grafana/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v2 name: grafana -version: 8.5.11 +version: 8.6.0 appVersion: 11.3.0 kubeVersion: "^1.8.0-0" description: The leading tool for querying and visualizing time series and metrics. diff --git a/charts/grafana/ci/with-nondefault-values.yaml b/charts/grafana/ci/with-nondefault-values.yaml index fb5c179409..48484895d0 100644 --- a/charts/grafana/ci/with-nondefault-values.yaml +++ b/charts/grafana/ci/with-nondefault-values.yaml @@ -4,3 +4,29 @@ ingress: enabled: true hosts: - monitoring-{{ .Values.global.environment }}.example.com + +route: + main: + enabled: true + labels: + app: monitoring-prometheus + hostnames: + - "*.example.com" + - "{{ .Values.global.environment }}.example.com" + filters: + - type: RequestHeaderModifier + requestHeaderModifier: + set: + - name: my-header-name + value: my-new-header-value + additionalRules: + - filters: + - type: RequestHeaderModifier + requestHeaderModifier: + set: + - name: my-header-name + value: my-new-header-value + matches: + - path: + type: PathPrefix + value: /foo/ diff --git a/charts/grafana/templates/route.yaml b/charts/grafana/templates/route.yaml new file mode 100644 index 0000000000..e8c98b3e87 --- /dev/null +++ b/charts/grafana/templates/route.yaml @@ -0,0 +1,44 @@ +{{- range $name, $route := .Values.route }} + {{- if $route.enabled -}} +--- +apiVersion: {{ $route.apiVersion | default "gateway.networking.k8s.io/v1" }} +kind: {{ $route.kind | default "HTTPRoute" }} +metadata: + {{- with $route.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} + name: {{ template "grafana.fullname" $ }}{{ if ne $name "main" }}-{{ $name }}{{ end }} + namespace: {{ template "grafana.namespace" $ }} + labels: + app: {{ template "grafana.name" $ }}-prometheus + {{- include "grafana.labels" $ | nindent 4 }} + {{- with $route.labels }} + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- with $route.parentRefs }} + parentRefs: + {{- toYaml . | nindent 4 }} + {{- end }} + {{- with $route.hostnames }} + hostnames: + {{- tpl (toYaml .) $ | nindent 4 }} + {{- end }} + rules: + {{- if $route.additionalRules }} + {{- tpl (toYaml $route.additionalRules) $ | nindent 4 }} + {{- end }} + - backendRefs: + - name: {{ include "grafana.fullname" $ }} + port: {{ $.Values.service.port }} + {{- with $route.filters }} + filters: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with $route.matches }} + matches: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- end }} +{{- end }} \ No newline at end of file diff --git a/charts/grafana/values.yaml b/charts/grafana/values.yaml index 98ebe9ad12..6467c4cc61 100644 --- a/charts/grafana/values.yaml +++ b/charts/grafana/values.yaml @@ -311,6 +311,42 @@ ingress: # hosts: # - chart-example.local +# -- BETA: Configure the gateway routes for the chart here. +# More routes can be added by adding a dictionary key like the 'main' route. +# Be aware that this is an early beta of this feature, +# kube-prometheus-stack does not guarantee this works and is subject to change. +# Being BETA this can/will change in the future without notice, do not use unless you want to take that risk +# [[ref]](https://gateway-api.sigs.k8s.io/references/spec/#gateway.networking.k8s.io%2fv1alpha2) +route: + main: + # -- Enables or disables the route + enabled: false + + # -- Set the route apiVersion, e.g. gateway.networking.k8s.io/v1 or gateway.networking.k8s.io/v1alpha2 + apiVersion: gateway.networking.k8s.io/v1 + # -- Set the route kind + # Valid options are GRPCRoute, HTTPRoute, TCPRoute, TLSRoute, UDPRoute + kind: HTTPRoute + + annotations: {} + labels: {} + + hostnames: [] + # - my-filter.example.com + parentRefs: [] + # - name: acme-gw + + matches: + - path: + type: PathPrefix + value: / + + ## Filters define the filters that are applied to requests that match this rule. + filters: [] + + ## Additional custom rules that can be added to the route + additionalRules: [] + resources: {} # limits: # cpu: 100m