Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions charts/o-neko-catnip/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ apiVersion: v2
name: o-neko-catnip
description: A Helm chart for the O-Neko URL trigger
type: application
version: 1.4.0
version: 1.5.0
annotations:
artifacthub.io/changes: |
- kind: added
description: "Added HTTPRoute support for Gateway API"
- kind: changed
description: "HTTPRoute configuration changed to a map of routes via httpRoutes{}. The previous httpRoute field has been removed (breaking change)!"

appVersion: "1.3.2"
sources:
Expand Down
31 changes: 18 additions & 13 deletions charts/o-neko-catnip/templates/httproute.yaml
Original file line number Diff line number Diff line change
@@ -1,35 +1,40 @@
{{- if .Values.httpRoute.enabled -}}
{{- $fullName := include "o-neko-catnip.fullname" . -}}
{{- $labels := include "o-neko-catnip.labels" . -}}
{{- $svcPort := 8080 -}}
{{- range $key := (.Values.httpRoutes | keys | sortAlpha) }}
{{- $httpRoute := index $.Values.httpRoutes $key }}
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
labels: {{- include "o-neko-catnip.labels" . | nindent 4 }}
name: {{ $fullName }}
{{- with .Values.httpRoute.annotations }}
name: {{ printf "%s-%s" $fullName $key | trunc 63 | trimSuffix "-" }}
labels:
{{- $labels | nindent 4 }}
{{- with $httpRoute.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- with .Values.httpRoute.parentRefs }}
{{- with $httpRoute.parentRefs }}
parentRefs:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- if .Values.httpRoute.hostnames }}
{{- if $httpRoute.hostnames }}
hostnames:
{{- range .Values.httpRoute.hostnames }}
- {{ required "A hostname for the HTTPRoute must be provided in .Values.httpRoute.hostnames" . | quote }}
{{- range $httpRoute.hostnames }}
- {{ . | quote }}
{{- end }}
{{- end }}
rules:
- backendRefs:
- name: {{ $fullName }}
port: 8080
{{- with .Values.httpRoute.matches }}
port: {{ $svcPort }}
{{- with $httpRoute.matches }}
matches:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.httpRoute.filters }}
{{- with $httpRoute.filters }}
filters:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
---
{{- end }}
46 changes: 39 additions & 7 deletions charts/o-neko-catnip/tests/httproute_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,29 @@ tests:
- hasDocuments:
count: 0

- it: should create httproute with values
- it: should create multiple httproutes with values
release:
name: values-test-release
values:
- ./values/httproute.yaml
asserts:
- hasDocuments:
count: 1
- containsDocument:
count: 2
- documentIndex: 0
containsDocument:
kind: HTTPRoute
apiVersion: gateway.networking.k8s.io/v1
name: values-test-release-o-neko-catnip
- equal:
name: values-test-release-o-neko-catnip-primary
- documentIndex: 1
containsDocument:
kind: HTTPRoute
apiVersion: gateway.networking.k8s.io/v1
name: values-test-release-o-neko-catnip-secondary
- documentIndex: 0
equal:
path: metadata
value:
name: values-test-release-o-neko-catnip
name: values-test-release-o-neko-catnip-primary
labels:
helm.sh/chart: o-neko-catnip-0.9.8
app.kubernetes.io/name: o-neko-catnip
Expand All @@ -35,7 +42,8 @@ tests:
annotations:
example.com/test: "simple"
example.com/text: some text value
- equal:
- documentIndex: 0
equal:
path: spec
value:
parentRefs:
Expand All @@ -58,4 +66,28 @@ tests:
- path:
type: PathPrefix
value: /
- documentIndex: 1
equal:
path: metadata
value:
name: values-test-release-o-neko-catnip-secondary
labels:
helm.sh/chart: o-neko-catnip-0.9.8
app.kubernetes.io/name: o-neko-catnip
app.kubernetes.io/version: 1.2.3
app.kubernetes.io/instance: values-test-release
app.kubernetes.io/managed-by: Helm
- documentIndex: 1
equal:
path: spec
value:
parentRefs:
- name: my-gateway
namespace: gateway-namespace
hostnames:
- second.example.com
rules:
- backendRefs:
- name: values-test-release-o-neko-catnip
port: 8080
- notFailedTemplate: {}
48 changes: 27 additions & 21 deletions charts/o-neko-catnip/tests/values/httproute.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
httpRoute:
enabled: true
parentRefs:
- name: my-gateway
namespace: gateway-namespace
hostnames:
- my-service.example.com
- other.example.com
matches:
- path:
type: PathPrefix
value: /
filters:
- type: RequestHeaderModifier
requestHeaderModifier:
set:
- name: X-Custom-Header
value: custom-value
annotations:
example.com/test: simple
example.com/text: some text value
httpRoutes:
primary:
parentRefs:
- name: my-gateway
namespace: gateway-namespace
hostnames:
- my-service.example.com
- other.example.com
matches:
- path:
type: PathPrefix
value: /
filters:
- type: RequestHeaderModifier
requestHeaderModifier:
set:
- name: X-Custom-Header
value: custom-value
annotations:
example.com/test: simple
example.com/text: some text value
secondary:
parentRefs:
- name: my-gateway
namespace: gateway-namespace
hostnames:
- second.example.com
57 changes: 25 additions & 32 deletions charts/o-neko-catnip/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,38 +119,31 @@ ingress:
defaultBackend:
enabled: false

httpRoute:
# httpRoute.enabled Whether to create an HTTPRoute resource (Gateway API)
enabled: false
# httpRoute.parentRefs References to the Gateway resources that the HTTPRoute should attach to
# e.g.
# parentRefs:
# - name: my-gateway
# namespace: gateway-namespace
parentRefs: []
# httpRoute.hostnames Array with hostnames used for the HTTPRoute
# e.g.
# hostnames:
# - "my-service.example.com"
hostnames: []
# matches Optional array of HTTPRouteMatch objects for matching HTTP requests
# e.g.
# matches:
# - path:
# type: PathPrefix
# value: /sophora.srpc
matches: []
# filters Optional array of HTTPRouteFilter objects for modifying requests/responses
# e.g.
# filters:
# - type: RequestHeaderModifier
# requestHeaderModifier:
# set:
# - name: X-Custom-Header
# value: custom-value
filters: []
# httpRoute.annotations annotations for the HTTPRoute
annotations: {}
# httpRoutes Map of HTTPRoute resources (Gateway API) to create.
# The map key is used as a suffix for the resource name, e.g. "web" -> "<fullname>-web".
httpRoutes: {}
# web:
# # httpRoutes.web.parentRefs References to the Gateway resources that the HTTPRoute should attach to
# parentRefs:
# - name: my-gateway
# namespace: gateway-namespace
# # httpRoutes.web.hostnames Array with hostnames used for the HTTPRoute
# hostnames:
# - "my-service.example.com"
# # httpRoutes.web.matches Optional array of HTTPRouteMatch objects for matching HTTP requests
# matches:
# - path:
# type: PathPrefix
# value: /
# # httpRoutes.web.filters Optional array of HTTPRouteFilter objects for modifying requests/responses
# filters:
# - type: RequestHeaderModifier
# requestHeaderModifier:
# set:
# - name: X-Custom-Header
# value: custom-value
# # httpRoutes.web.annotations annotations for the HTTPRoute
# annotations: {}

## @section Metrics and Alerting
##
Expand Down
6 changes: 3 additions & 3 deletions charts/o-neko/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ apiVersion: v2
name: o-neko
description: A Helm chart for O-Neko
type: application
version: 2.1.0
version: 2.2.0
annotations:
artifacthub.io/changes: |
- kind: added
description: "Added HTTPRoute support for Gateway API"
- kind: changed
description: "HTTPRoute configuration changed to a map of routes via httpRoutes{}. The previous httpRoute field has been removed (breaking change)!"

appVersion: "1.8.2"
sources:
Expand Down
31 changes: 18 additions & 13 deletions charts/o-neko/templates/httproute.yaml
Original file line number Diff line number Diff line change
@@ -1,35 +1,40 @@
{{- if .Values.httpRoute.enabled -}}
{{- $fullName := include "o-neko.fullname" . -}}
{{- $labels := include "o-neko.labels" . -}}
{{- $svcPort := 8080 -}}
{{- range $key := (.Values.httpRoutes | keys | sortAlpha) }}
{{- $httpRoute := index $.Values.httpRoutes $key }}
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
labels: {{- include "o-neko.labels" . | nindent 4 }}
name: {{ $fullName }}
{{- with .Values.httpRoute.annotations }}
name: {{ printf "%s-%s" $fullName $key | trunc 63 | trimSuffix "-" }}
labels:
{{- $labels | nindent 4 }}
{{- with $httpRoute.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- with .Values.httpRoute.parentRefs }}
{{- with $httpRoute.parentRefs }}
parentRefs:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- if .Values.httpRoute.hostnames }}
{{- if $httpRoute.hostnames }}
hostnames:
{{- range .Values.httpRoute.hostnames }}
- {{ required "A hostname for the HTTPRoute must be provided in .Values.httpRoute.hostnames" . | quote }}
{{- range $httpRoute.hostnames }}
- {{ . | quote }}
{{- end }}
{{- end }}
rules:
- backendRefs:
- name: {{ $fullName }}
port: 8080
{{- with .Values.httpRoute.matches }}
port: {{ $svcPort }}
{{- with $httpRoute.matches }}
matches:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.httpRoute.filters }}
{{- with $httpRoute.filters }}
filters:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
---
{{- end }}
Loading
Loading