From 0d4772f4f5f71199f89e6a9d11dbe1737ab1a01c Mon Sep 17 00:00:00 2001 From: somaz Date: Fri, 3 Jul 2026 18:05:52 +0900 Subject: [PATCH 1/2] [alertmanager-snmp-notifier] Add Gateway API HTTPRoute support Signed-off-by: somaz --- charts/alertmanager-snmp-notifier/Chart.yaml | 2 +- .../ci/httproute-values.yaml | 20 +++++++ .../templates/_helpers.tpl | 11 ++++ .../templates/route.yaml | 47 ++++++++++++++++ charts/alertmanager-snmp-notifier/values.yaml | 54 +++++++++++++++++++ 5 files changed, 133 insertions(+), 1 deletion(-) create mode 100644 charts/alertmanager-snmp-notifier/ci/httproute-values.yaml create mode 100644 charts/alertmanager-snmp-notifier/templates/route.yaml diff --git a/charts/alertmanager-snmp-notifier/Chart.yaml b/charts/alertmanager-snmp-notifier/Chart.yaml index e5cc6c571973..68ed34801a21 100644 --- a/charts/alertmanager-snmp-notifier/Chart.yaml +++ b/charts/alertmanager-snmp-notifier/Chart.yaml @@ -5,7 +5,7 @@ home: https://github.com/maxwo/snmp_notifier sources: - https://github.com/maxwo/snmp_notifier type: application -version: 2.1.0 +version: 2.2.0 # renovate: github-releases=maxwo/snmp_notifier appVersion: v2.1.0 kubeVersion: ">=1.23.0-0" diff --git a/charts/alertmanager-snmp-notifier/ci/httproute-values.yaml b/charts/alertmanager-snmp-notifier/ci/httproute-values.yaml new file mode 100644 index 000000000000..e0c412866101 --- /dev/null +++ b/charts/alertmanager-snmp-notifier/ci/httproute-values.yaml @@ -0,0 +1,20 @@ +--- +## Test case: httproute +route: + main: + enabled: true + hostnames: + - "an.example.com" + parentRefs: + - name: contour + filters: + - type: RequestHeaderModifier + requestHeaderModifier: + set: + - name: my-header-name + value: my-new-header-value + additionalRules: + - filters: + - type: RequestHeaderModifier + requestHeaderModifier: + remove: ["x-request-id"] diff --git a/charts/alertmanager-snmp-notifier/templates/_helpers.tpl b/charts/alertmanager-snmp-notifier/templates/_helpers.tpl index 5eb25321934e..edf9aea1c9d5 100644 --- a/charts/alertmanager-snmp-notifier/templates/_helpers.tpl +++ b/charts/alertmanager-snmp-notifier/templates/_helpers.tpl @@ -60,3 +60,14 @@ Create the name of the service account to use {{- default "default" .Values.serviceAccount.name }} {{- end }} {{- end }} + +{{/* +Allow the release namespace to be overridden +*/}} +{{- define "alertmanager-snmp-notifier.namespace" -}} + {{- if .Values.namespaceOverride -}} + {{- .Values.namespaceOverride -}} + {{- else -}} + {{- .Release.Namespace -}} + {{- end -}} +{{- end -}} diff --git a/charts/alertmanager-snmp-notifier/templates/route.yaml b/charts/alertmanager-snmp-notifier/templates/route.yaml new file mode 100644 index 000000000000..e343a40326f1 --- /dev/null +++ b/charts/alertmanager-snmp-notifier/templates/route.yaml @@ -0,0 +1,47 @@ +{{- 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: {{ include "alertmanager-snmp-notifier.fullname" $ }} + namespace: {{ include "alertmanager-snmp-notifier.namespace" $ }} + labels: + {{- include "alertmanager-snmp-notifier.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: + {{- with $route.additionalRules }} + {{- tpl (toYaml .) $ | nindent 4 }} + {{- end }} + {{- if $route.httpsRedirect }} + - filters: + - type: RequestRedirect + requestRedirect: + scheme: https + statusCode: 301 + {{- else }} + - name: {{ $route.name | default $name }} + backendRefs: + - name: {{ include "alertmanager-snmp-notifier.fullname" $ }} + port: {{ $.Values.service.port }} + {{- with $route.filters }} + filters: {{ toYaml . | nindent 8 }} + {{- end }} + {{- with $route.matches }} + matches: {{ toYaml . | nindent 8 }} + {{- end }} + {{- end }} +{{- end }} +{{- end }} diff --git a/charts/alertmanager-snmp-notifier/values.yaml b/charts/alertmanager-snmp-notifier/values.yaml index cd7259383a0e..b912fadc032b 100644 --- a/charts/alertmanager-snmp-notifier/values.yaml +++ b/charts/alertmanager-snmp-notifier/values.yaml @@ -92,6 +92,9 @@ securityContext: {} # runAsNonRoot: true # runAsUser: 1000 +## Provide a namespace to substitute for the namespace on resources +namespaceOverride: "" + service: type: ClusterIP port: 9464 @@ -116,6 +119,57 @@ ingress: # hosts: # - snmp-notifier.local +## A HTTPRoute (Gateway API) resource is an alternative to Ingress for routing +## external HTTP traffic to the SNMP notifier Service. +## ref: https://gateway-api.sigs.k8s.io/api-types/httproute/ +route: + main: + ## Enable this route + enabled: false + + ## ApiVersion set by default to "gateway.networking.k8s.io/v1" + apiVersion: "" + ## kind set by default to HTTPRoute + kind: "" + + ## Optional name for the default rule in the rendered HTTPRoute. + name: "" + + ## Annotations to attach to the HTTPRoute resource + annotations: {} + ## Labels to attach to the HTTPRoute resource + labels: {} + + ## ParentRefs refers to resources this HTTPRoute is to be attached to (Gateways) + parentRefs: [] + # - name: contour + # sectionName: http + + ## Hostnames (templated) defines a set of hostnames that should match against the HTTP Host + ## header to select a HTTPRoute used to process the request + hostnames: [] + # - my.example.com + + ## additionalRules (templated) allows adding custom rules to the route + additionalRules: [] + + ## Filters define the filters that are applied to requests that match + ## this rule + filters: [] + + ## Matches define conditions used for matching the rule against incoming + ## HTTP requests + matches: + - path: + type: PathPrefix + value: / + + ## httpsRedirect adds a filter for redirecting to https (HTTP 301 Moved Permanently). + ## To redirect HTTP traffic to HTTPS, you need to have a Gateway with both HTTP and HTTPS listeners. + ## Matches and filters do not take effect if enabled. + ## Ref. https://gateway-api.sigs.k8s.io/guides/http-redirect-rewrite/ + httpsRedirect: false + resources: {} # We usually recommend not to specify default resources and to leave this as a conscious # choice for the user. This also increases chances charts run on environments with little From 53385dc608f53f68bb14f40d5b921a412a211d14 Mon Sep 17 00:00:00 2001 From: somaz Date: Fri, 3 Jul 2026 18:26:23 +0900 Subject: [PATCH 2/2] [alertmanager-snmp-notifier] Fix codespell typo and add SNMP destination to httproute CI values Signed-off-by: somaz --- charts/alertmanager-snmp-notifier/ci/httproute-values.yaml | 4 ++++ charts/alertmanager-snmp-notifier/values.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/charts/alertmanager-snmp-notifier/ci/httproute-values.yaml b/charts/alertmanager-snmp-notifier/ci/httproute-values.yaml index e0c412866101..903be4576397 100644 --- a/charts/alertmanager-snmp-notifier/ci/httproute-values.yaml +++ b/charts/alertmanager-snmp-notifier/ci/httproute-values.yaml @@ -1,5 +1,9 @@ --- ## Test case: httproute +snmpNotifier: + snmpDestinations: + - 127.0.0.1:162 + route: main: enabled: true diff --git a/charts/alertmanager-snmp-notifier/values.yaml b/charts/alertmanager-snmp-notifier/values.yaml index b912fadc032b..769691507e95 100644 --- a/charts/alertmanager-snmp-notifier/values.yaml +++ b/charts/alertmanager-snmp-notifier/values.yaml @@ -19,7 +19,7 @@ snmpNotifier: snmpDestinations: - snmp-server:162 - # SNMP authentication secrets, that may be instanciated by the chart, or may use an already created secret + # SNMP authentication secrets, that may be instantiated by the chart, or may use an already created secret # snmpCommunity: public # snmpAuthenticationUsername: my_authentication_username # snmpAuthenticationPassword: my_authentication_password