diff --git a/charts/o-neko-catnip/Chart.yaml b/charts/o-neko-catnip/Chart.yaml index b303bb3b..7e55a3d9 100644 --- a/charts/o-neko-catnip/Chart.yaml +++ b/charts/o-neko-catnip/Chart.yaml @@ -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: diff --git a/charts/o-neko-catnip/templates/httproute.yaml b/charts/o-neko-catnip/templates/httproute.yaml index 56da5449..20692fde 100644 --- a/charts/o-neko-catnip/templates/httproute.yaml +++ b/charts/o-neko-catnip/templates/httproute.yaml @@ -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 }} \ No newline at end of file diff --git a/charts/o-neko-catnip/tests/httproute_test.yaml b/charts/o-neko-catnip/tests/httproute_test.yaml index 514e7179..b55ce5c7 100644 --- a/charts/o-neko-catnip/tests/httproute_test.yaml +++ b/charts/o-neko-catnip/tests/httproute_test.yaml @@ -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 @@ -35,7 +42,8 @@ tests: annotations: example.com/test: "simple" example.com/text: some text value - - equal: + - documentIndex: 0 + equal: path: spec value: parentRefs: @@ -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: {} diff --git a/charts/o-neko-catnip/tests/values/httproute.yaml b/charts/o-neko-catnip/tests/values/httproute.yaml index fa51e6cc..ee550638 100644 --- a/charts/o-neko-catnip/tests/values/httproute.yaml +++ b/charts/o-neko-catnip/tests/values/httproute.yaml @@ -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 \ No newline at end of file diff --git a/charts/o-neko-catnip/values.yaml b/charts/o-neko-catnip/values.yaml index 282e7730..1b082914 100644 --- a/charts/o-neko-catnip/values.yaml +++ b/charts/o-neko-catnip/values.yaml @@ -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" -> "-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 ## diff --git a/charts/o-neko/Chart.yaml b/charts/o-neko/Chart.yaml index 750ee4da..f581de7f 100644 --- a/charts/o-neko/Chart.yaml +++ b/charts/o-neko/Chart.yaml @@ -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: diff --git a/charts/o-neko/templates/httproute.yaml b/charts/o-neko/templates/httproute.yaml index bbd7ad89..2aeffff5 100644 --- a/charts/o-neko/templates/httproute.yaml +++ b/charts/o-neko/templates/httproute.yaml @@ -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 }} \ No newline at end of file diff --git a/charts/o-neko/tests/httproute_test.yaml b/charts/o-neko/tests/httproute_test.yaml index 384b2f3d..92ee3fe1 100644 --- a/charts/o-neko/tests/httproute_test.yaml +++ b/charts/o-neko/tests/httproute_test.yaml @@ -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 - - equal: + name: values-test-release-o-neko-primary + - documentIndex: 1 + containsDocument: + kind: HTTPRoute + apiVersion: gateway.networking.k8s.io/v1 + name: values-test-release-o-neko-secondary + - documentIndex: 0 + equal: path: metadata value: - name: values-test-release-o-neko + name: values-test-release-o-neko-primary labels: helm.sh/chart: o-neko-0.9.8 app.kubernetes.io/name: o-neko @@ -35,7 +42,8 @@ tests: annotations: example.com/test: "simple" example.com/text: some text value - - equal: + - documentIndex: 0 + equal: path: spec value: parentRefs: @@ -58,4 +66,28 @@ tests: - path: type: PathPrefix value: / + - documentIndex: 1 + equal: + path: metadata + value: + name: values-test-release-o-neko-secondary + labels: + helm.sh/chart: o-neko-0.9.8 + app.kubernetes.io/name: o-neko + 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 + port: 8080 - notFailedTemplate: {} diff --git a/charts/o-neko/tests/values/httproute.yaml b/charts/o-neko/tests/values/httproute.yaml index fa51e6cc..ee550638 100644 --- a/charts/o-neko/tests/values/httproute.yaml +++ b/charts/o-neko/tests/values/httproute.yaml @@ -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 \ No newline at end of file diff --git a/charts/o-neko/values.yaml b/charts/o-neko/values.yaml index d2f81974..3939032f 100644 --- a/charts/o-neko/values.yaml +++ b/charts/o-neko/values.yaml @@ -148,38 +148,31 @@ ingress: # ingress.annotations annotations for the ingress annotations: {} -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" -> "-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 ## diff --git a/charts/planr-tools/Chart.yaml b/charts/planr-tools/Chart.yaml index cfcafdff..65ea88f7 100644 --- a/charts/planr-tools/Chart.yaml +++ b/charts/planr-tools/Chart.yaml @@ -2,12 +2,12 @@ apiVersion: v2 name: planr-tools description: A Helm chart for deploying the planr-tools applications type: application -version: 1.0.0 +version: 1.1.0 appVersion: "5.1.1" annotations: artifacthub.io/changes: | - - kind: added - description: Initial release of the planr-tools chart. + - kind: changed + description: "HTTPRoute configuration changed to a map of routes via httpRoutes{}. The previous httpRoute field has been removed (breaking change)!" sources: - https://github.com/subshell/helm-charts/tree/main/charts/planr-tools home: https://gitlab.com/subshell/kunden/planr-tools diff --git a/charts/planr-tools/templates/httproute.yaml b/charts/planr-tools/templates/httproute.yaml index b94e5e08..79945e2a 100644 --- a/charts/planr-tools/templates/httproute.yaml +++ b/charts/planr-tools/templates/httproute.yaml @@ -1,36 +1,40 @@ -{{- if .Values.httpRoute.enabled }} +{{- $fullName := include "planr-tools.fullname" . }} +{{- $labels := include "planr-tools.labels" (dict "root" . "component" (dict "name" "gateway")) -}} +{{- range $key := (.Values.httpRoutes | keys | sortAlpha) }} +{{- $httpRoute := index $.Values.httpRoutes $key }} apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: - name: {{ include "planr-tools.fullname" . }} + name: {{ printf "%s-%s" $fullName $key | trunc 63 | trimSuffix "-" }} labels: - {{- include "planr-tools.labels" (dict "root" . "component" (dict "name" "gateway")) | nindent 4 }} - {{- with .Values.httpRoute.annotations }} + {{- $labels | nindent 4 }} + {{- with $httpRoute.annotations }} annotations: {{- toYaml . | nindent 4 }} {{- end }} spec: - {{- with .Values.httpRoute.parentRefs }} + {{- with $httpRoute.parentRefs }} parentRefs: - {{- toYaml . | nindent 4 }} + {{- toYaml . | nindent 4 }} {{- end }} - {{- with .Values.httpRoute.hostnames }} + {{- if $httpRoute.hostnames }} hostnames: - {{- range . }} + {{- range $httpRoute.hostnames }} - {{ . | quote }} - {{- end }} + {{- end }} {{- end }} rules: {{- range $appKey := (include "planr-tools.app-keys" $ | fromYaml).keys }} {{- $component := index $.Values.applications $appKey }} {{- if $component.enabled }} - - matches: + - backendRefs: + - name: {{ include "planr-tools.componentFullname" (dict "root" $ "component" $component) }} + port: {{ $component.service.port }} + matches: - path: type: PathPrefix value: {{ $component.exposure.path | quote }} - backendRefs: - - name: {{ include "planr-tools.componentFullname" (dict "root" $ "component" $component) }} - port: {{ $component.service.port }} + {{- if or (ne $component.exposure.path "/") $httpRoute.filters }} filters: {{- if ne $component.exposure.path "/" }} {{/* Strip the path prefix so apps receive requests at their own root, same as the Ingress rewrite. */}} @@ -40,9 +44,11 @@ spec: type: ReplacePrefixMatch replacePrefixMatch: / {{- end }} - {{- with $.Values.httpRoute.filters }} - {{- toYaml . | nindent 8 }} - {{- end }} - {{- end }} - {{- end }} -{{- end }} + {{- with $httpRoute.filters }} + {{- toYaml . | nindent 8 }} + {{- end }} + {{- end }} + {{- end }} + {{- end }} +--- +{{- end }} \ No newline at end of file diff --git a/charts/planr-tools/tests/httproute_test.yaml b/charts/planr-tools/tests/httproute_test.yaml index 9359a024..8ed1d583 100644 --- a/charts/planr-tools/tests/httproute_test.yaml +++ b/charts/planr-tools/tests/httproute_test.yaml @@ -2,8 +2,8 @@ suite: test httproute templates: - httproute.yaml chart: - version: 1.0.0 - appVersion: 5.1.1 + version: 0.9.8 + appVersion: 1.2.3 tests: - it: should not create httproute by default asserts: @@ -17,43 +17,145 @@ tests: - ./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-planr-tools - - equal: - path: metadata.annotations + name: values-test-release-planr-tools-primary + - documentIndex: 1 + containsDocument: + kind: HTTPRoute + apiVersion: gateway.networking.k8s.io/v1 + name: values-test-release-planr-tools-secondary + - documentIndex: 0 + equal: + path: metadata + value: + name: values-test-release-planr-tools-primary + labels: + helm.sh/chart: planr-tools-0.9.8 + app.kubernetes.io/name: planr-tools + app.kubernetes.io/version: 1.2.3 + app.kubernetes.io/component: gateway + app.kubernetes.io/instance: values-test-release + app.kubernetes.io/managed-by: Helm + annotations: + example.com/test: "simple" + example.com/text: some text value + - documentIndex: 0 + equal: + path: spec + value: + parentRefs: + - name: my-gateway + namespace: gateway-namespace + hostnames: + - my-service.example.com + - other.example.com + rules: + - backendRefs: + - name: values-test-release-planr-tools-newsroom-document-creator + port: 8080 + filters: + - type: URLRewrite + urlRewrite: + path: + type: ReplacePrefixMatch + replacePrefixMatch: / + - type: RequestHeaderModifier + requestHeaderModifier: + set: + - name: X-Custom-Header + value: custom-value + matches: + - path: + type: PathPrefix + value: /document-creator + - backendRefs: + - name: values-test-release-planr-tools-newsroom-feed + port: 8081 + filters: + - type: URLRewrite + urlRewrite: + path: + type: ReplacePrefixMatch + replacePrefixMatch: / + - type: RequestHeaderModifier + requestHeaderModifier: + set: + - name: X-Custom-Header + value: custom-value + matches: + - path: + type: PathPrefix + value: /feed + - backendRefs: + - name: values-test-release-planr-tools-newsroom-widget + port: 8082 + filters: + - type: RequestHeaderModifier + requestHeaderModifier: + set: + - name: X-Custom-Header + value: custom-value + matches: + - path: + type: PathPrefix + value: / + - documentIndex: 1 + equal: + path: metadata value: - example.com/test: "true" - - equal: - path: spec.hostnames + name: values-test-release-planr-tools-secondary + labels: + helm.sh/chart: planr-tools-0.9.8 + app.kubernetes.io/name: planr-tools + app.kubernetes.io/version: 1.2.3 + app.kubernetes.io/component: gateway + app.kubernetes.io/instance: values-test-release + app.kubernetes.io/managed-by: Helm + - documentIndex: 1 + equal: + path: spec value: - - planr-tools.example.com - - equal: - path: spec.rules[0].backendRefs[0].name - value: values-test-release-planr-tools-newsroom-document-creator - - equal: - path: spec.rules[1].backendRefs[0].name - value: values-test-release-planr-tools-newsroom-feed - - equal: - path: spec.rules[2].backendRefs[0].name - value: values-test-release-planr-tools-newsroom-widget - - equal: - path: spec.rules[0].matches[0].path.value - value: /document-creator - - equal: - path: spec.rules[1].matches[0].path.value - value: /feed - - equal: - path: spec.rules[2].matches[0].path.value - value: / - - equal: - path: spec.rules[0].filters[0].type - value: URLRewrite - - equal: - path: spec.rules[1].filters[0].type - value: URLRewrite - - notExists: - path: spec.rules[2].filters[0].urlRewrite + parentRefs: + - name: my-gateway + namespace: gateway-namespace + hostnames: + - second.example.com + rules: + - backendRefs: + - name: values-test-release-planr-tools-newsroom-document-creator + port: 8080 + filters: + - type: URLRewrite + urlRewrite: + path: + type: ReplacePrefixMatch + replacePrefixMatch: / + matches: + - path: + type: PathPrefix + value: /document-creator + - backendRefs: + - name: values-test-release-planr-tools-newsroom-feed + port: 8081 + filters: + - type: URLRewrite + urlRewrite: + path: + type: ReplacePrefixMatch + replacePrefixMatch: / + matches: + - path: + type: PathPrefix + value: /feed + - backendRefs: + - name: values-test-release-planr-tools-newsroom-widget + port: 8082 + matches: + - path: + type: PathPrefix + value: / - notFailedTemplate: {} diff --git a/charts/planr-tools/tests/values/httproute.yaml b/charts/planr-tools/tests/values/httproute.yaml index a3326e67..f5bd901d 100644 --- a/charts/planr-tools/tests/values/httproute.yaml +++ b/charts/planr-tools/tests/values/httproute.yaml @@ -1,15 +1,23 @@ -httpRoute: - enabled: true - parentRefs: +httpRoutes: + primary: + parentRefs: - name: my-gateway namespace: gateway-namespace - hostnames: - - planr-tools.example.com - filters: + hostnames: + - my-service.example.com + - other.example.com + filters: - type: RequestHeaderModifier requestHeaderModifier: set: - - name: X-Custom-Header - value: custom-value - annotations: - example.com/test: "true" + - 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 \ No newline at end of file diff --git a/charts/planr-tools/values.yaml b/charts/planr-tools/values.yaml index 0fe3f192..e74e896e 100644 --- a/charts/planr-tools/values.yaml +++ b/charts/planr-tools/values.yaml @@ -53,12 +53,26 @@ ingress: hosts: annotations: {} -httpRoute: - enabled: false - parentRefs: [] - hostnames: [] - filters: [] - 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" -> "-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.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: {} applications: documentCreator: diff --git a/charts/sophora-admin-dashboard/Chart.yaml b/charts/sophora-admin-dashboard/Chart.yaml index e821fe2b..bda5bd84 100644 --- a/charts/sophora-admin-dashboard/Chart.yaml +++ b/charts/sophora-admin-dashboard/Chart.yaml @@ -13,8 +13,8 @@ icon: https://subshell.com/logos/admindashboard104~1x1.1683631966185.png # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 1.6.0 +version: 1.7.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)!" diff --git a/charts/sophora-admin-dashboard/templates/httproute.yaml b/charts/sophora-admin-dashboard/templates/httproute.yaml index 9f6b1aa5..a7747ad3 100644 --- a/charts/sophora-admin-dashboard/templates/httproute.yaml +++ b/charts/sophora-admin-dashboard/templates/httproute.yaml @@ -1,24 +1,26 @@ -{{- if .Values.httpRoute.enabled -}} {{- $fullName := include "sophora-admin-dashboard.fullname" . -}} +{{- $labels := include "sophora-admin-dashboard.labels" . -}} {{- $svcPort := .Values.service.port -}} +{{- range $key := (.Values.httpRoutes | keys | sortAlpha) }} +{{- $httpRoute := index $.Values.httpRoutes $key }} apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: - name: {{ $fullName }} + name: {{ printf "%s-%s" $fullName $key | trunc 63 | trimSuffix "-" }} labels: - {{- include "sophora-admin-dashboard.labels" . | nindent 4 }} - {{- with .Values.httpRoute.annotations }} + {{- $labels | nindent 4 }} + {{- with $httpRoute.annotations }} annotations: {{- 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 }} + {{- range $httpRoute.hostnames }} - {{ . | quote }} {{- end }} {{- end }} @@ -26,12 +28,13 @@ spec: - backendRefs: - name: {{ $fullName }} port: {{ $svcPort }} - {{- with .Values.httpRoute.matches }} + {{- with $httpRoute.matches }} matches: {{- toYaml . | nindent 8 }} {{- end }} - {{- with .Values.httpRoute.filters }} + {{- with $httpRoute.filters }} filters: {{- toYaml . | nindent 8 }} {{- end }} -{{- end }} +--- +{{- end }} \ No newline at end of file diff --git a/charts/sophora-admin-dashboard/tests/httproute_test.yaml b/charts/sophora-admin-dashboard/tests/httproute_test.yaml index 1737dfaa..7ea3a220 100644 --- a/charts/sophora-admin-dashboard/tests/httproute_test.yaml +++ b/charts/sophora-admin-dashboard/tests/httproute_test.yaml @@ -9,22 +9,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-sophora-admin-dashboard - - equal: + name: values-test-release-sophora-admin-dashboard-primary + - documentIndex: 1 + containsDocument: + kind: HTTPRoute + apiVersion: gateway.networking.k8s.io/v1 + name: values-test-release-sophora-admin-dashboard-secondary + - documentIndex: 0 + equal: path: metadata value: - name: values-test-release-sophora-admin-dashboard + name: values-test-release-sophora-admin-dashboard-primary labels: helm.sh/chart: sophora-admin-dashboard-0.9.8 app.kubernetes.io/name: sophora-admin-dashboard @@ -33,7 +40,8 @@ tests: annotations: example.com/test: "simple" example.com/text: some text value - - equal: + - documentIndex: 0 + equal: path: spec value: parentRefs: @@ -56,4 +64,27 @@ tests: - path: type: PathPrefix value: / + - documentIndex: 1 + equal: + path: metadata + value: + name: values-test-release-sophora-admin-dashboard-secondary + labels: + helm.sh/chart: sophora-admin-dashboard-0.9.8 + app.kubernetes.io/name: sophora-admin-dashboard + 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-sophora-admin-dashboard + port: 80 - notFailedTemplate: {} diff --git a/charts/sophora-admin-dashboard/tests/values/httproute.yaml b/charts/sophora-admin-dashboard/tests/values/httproute.yaml index fa51e6cc..ee550638 100644 --- a/charts/sophora-admin-dashboard/tests/values/httproute.yaml +++ b/charts/sophora-admin-dashboard/tests/values/httproute.yaml @@ -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 \ No newline at end of file diff --git a/charts/sophora-admin-dashboard/values.yaml b/charts/sophora-admin-dashboard/values.yaml index 9e84dd81..f587b2c3 100644 --- a/charts/sophora-admin-dashboard/values.yaml +++ b/charts/sophora-admin-dashboard/values.yaml @@ -208,38 +208,31 @@ ingress: # hosts: # - chart-example.local -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" -> "-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: {} resources: requests: diff --git a/charts/sophora-ai/Chart.yaml b/charts/sophora-ai/Chart.yaml index a9a87925..1bd3f1a7 100644 --- a/charts/sophora-ai/Chart.yaml +++ b/charts/sophora-ai/Chart.yaml @@ -2,11 +2,11 @@ apiVersion: v2 name: sophora-ai description: Sophora AI type: application -version: 2.3.0 +version: 2.4.0 annotations: artifacthub.io/changes: | - - kind: added - description: added configuration for the upcoming Spell Check feature (requires Sophora AI >1.7.0) + - kind: changed + description: "HTTPRoute configuration changed to a map of routes via httpRoutes{}. The previous httpRoute field has been removed (breaking change)!" appVersion: 1.7.0 sources: - https://github.com/subshell/helm-charts/tree/main/charts/sophora-ai diff --git a/charts/sophora-ai/templates/httproute.yaml b/charts/sophora-ai/templates/httproute.yaml index 499acc76..00e259db 100644 --- a/charts/sophora-ai/templates/httproute.yaml +++ b/charts/sophora-ai/templates/httproute.yaml @@ -1,24 +1,26 @@ -{{- if .Values.httpRoute.enabled -}} - {{- $fullName := include "sophora-ai.fullname" . -}} - {{- $svcPort := .Values.service.port -}} +{{- $fullName := include "sophora-ai.fullname" . -}} +{{- $labels := include "sophora-ai.labels" . -}} +{{- $svcPort := .Values.service.port -}} +{{- range $key := (.Values.httpRoutes | keys | sortAlpha) }} +{{- $httpRoute := index $.Values.httpRoutes $key }} apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: - name: {{ $fullName }} + name: {{ printf "%s-%s" $fullName $key | trunc 63 | trimSuffix "-" }} labels: - {{- include "sophora-ai.labels" . | nindent 4 }} - {{- with .Values.httpRoute.annotations }} + {{- $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 }} + {{- range $httpRoute.hostnames }} - {{ . | quote }} {{- end }} {{- end }} @@ -26,12 +28,13 @@ spec: - backendRefs: - name: {{ $fullName }} port: {{ $svcPort }} - {{- with .Values.httpRoute.matches }} + {{- with $httpRoute.matches }} matches: {{- toYaml . | nindent 8 }} {{- end }} - {{- with .Values.httpRoute.filters }} + {{- with $httpRoute.filters }} filters: {{- toYaml . | nindent 8 }} {{- end }} -{{- end }} +--- +{{- end }} \ No newline at end of file diff --git a/charts/sophora-ai/tests/httproute_test.yaml b/charts/sophora-ai/tests/httproute_test.yaml index 5f8b8a0c..bac01425 100644 --- a/charts/sophora-ai/tests/httproute_test.yaml +++ b/charts/sophora-ai/tests/httproute_test.yaml @@ -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-sophora-ai - - equal: + name: values-test-release-sophora-ai-primary + - documentIndex: 1 + containsDocument: + kind: HTTPRoute + apiVersion: gateway.networking.k8s.io/v1 + name: values-test-release-sophora-ai-secondary + - documentIndex: 0 + equal: path: metadata value: - name: values-test-release-sophora-ai + name: values-test-release-sophora-ai-primary labels: helm.sh/chart: sophora-ai-0.9.8 app.kubernetes.io/name: sophora-ai @@ -35,7 +42,8 @@ tests: annotations: example.com/test: "simple" example.com/text: some text value - - equal: + - documentIndex: 0 + equal: path: spec value: parentRefs: @@ -58,4 +66,28 @@ tests: - path: type: PathPrefix value: / + - documentIndex: 1 + equal: + path: metadata + value: + name: values-test-release-sophora-ai-secondary + labels: + helm.sh/chart: sophora-ai-0.9.8 + app.kubernetes.io/name: sophora-ai + 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-sophora-ai + port: 8080 - notFailedTemplate: {} diff --git a/charts/sophora-ai/tests/values/httproute.yaml b/charts/sophora-ai/tests/values/httproute.yaml index fa51e6cc..ee550638 100644 --- a/charts/sophora-ai/tests/values/httproute.yaml +++ b/charts/sophora-ai/tests/values/httproute.yaml @@ -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 \ No newline at end of file diff --git a/charts/sophora-ai/values.yaml b/charts/sophora-ai/values.yaml index 95775642..364316cf 100644 --- a/charts/sophora-ai/values.yaml +++ b/charts/sophora-ai/values.yaml @@ -219,38 +219,31 @@ ingress: hosts: tls: [] -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" -> "-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: {} extraDeploy: [] diff --git a/charts/sophora-contentapi/Chart.yaml b/charts/sophora-contentapi/Chart.yaml index caaea069..bdf1f0ee 100644 --- a/charts/sophora-contentapi/Chart.yaml +++ b/charts/sophora-contentapi/Chart.yaml @@ -2,11 +2,11 @@ apiVersion: v2 name: sophora-contentapi description: Sophora Content API type: application -version: 1.1.0 +version: 1.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: 6.0.0 sources: diff --git a/charts/sophora-contentapi/templates/httproute.yaml b/charts/sophora-contentapi/templates/httproute.yaml index 56e0efbc..d86e3972 100644 --- a/charts/sophora-contentapi/templates/httproute.yaml +++ b/charts/sophora-contentapi/templates/httproute.yaml @@ -1,24 +1,26 @@ -{{- if .Values.httpRoute.enabled -}} - {{- $fullName := include "sophora-contentapi.fullname" . -}} - {{- $svcPort := .Values.service.port -}} +{{- $fullName := include "sophora-contentapi.fullname" . -}} +{{- $labels := include "sophora-contentapi.labels" . -}} +{{- $svcPort := .Values.service.port -}} +{{- range $key := (.Values.httpRoutes | keys | sortAlpha) }} +{{- $httpRoute := index $.Values.httpRoutes $key }} apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: - name: {{ $fullName }} + name: {{ printf "%s-%s" $fullName $key | trunc 63 | trimSuffix "-" }} labels: - {{- include "sophora-contentapi.labels" . | nindent 4 }} - {{- with .Values.httpRoute.annotations }} + {{- $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 }} + {{- range $httpRoute.hostnames }} - {{ . | quote }} {{- end }} {{- end }} @@ -26,12 +28,13 @@ spec: - backendRefs: - name: {{ $fullName }} port: {{ $svcPort }} - {{- with .Values.httpRoute.matches }} + {{- with $httpRoute.matches }} matches: {{- toYaml . | nindent 8 }} {{- end }} - {{- with .Values.httpRoute.filters }} + {{- with $httpRoute.filters }} filters: {{- toYaml . | nindent 8 }} {{- end }} -{{- end }} +--- +{{- end }} \ No newline at end of file diff --git a/charts/sophora-contentapi/tests/httproute_test.yaml b/charts/sophora-contentapi/tests/httproute_test.yaml index c3c0084b..e59d4bd1 100644 --- a/charts/sophora-contentapi/tests/httproute_test.yaml +++ b/charts/sophora-contentapi/tests/httproute_test.yaml @@ -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-sophora-contentapi - - equal: + name: values-test-release-sophora-contentapi-primary + - documentIndex: 1 + containsDocument: + kind: HTTPRoute + apiVersion: gateway.networking.k8s.io/v1 + name: values-test-release-sophora-contentapi-secondary + - documentIndex: 0 + equal: path: metadata value: - name: values-test-release-sophora-contentapi + name: values-test-release-sophora-contentapi-primary labels: helm.sh/chart: sophora-contentapi-0.9.8 app.kubernetes.io/name: sophora-contentapi @@ -35,7 +42,8 @@ tests: annotations: example.com/test: "simple" example.com/text: some text value - - equal: + - documentIndex: 0 + equal: path: spec value: parentRefs: @@ -58,4 +66,28 @@ tests: - path: type: PathPrefix value: / + - documentIndex: 1 + equal: + path: metadata + value: + name: values-test-release-sophora-contentapi-secondary + labels: + helm.sh/chart: sophora-contentapi-0.9.8 + app.kubernetes.io/name: sophora-contentapi + 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-sophora-contentapi + port: 8080 - notFailedTemplate: {} diff --git a/charts/sophora-contentapi/tests/values/httproute.yaml b/charts/sophora-contentapi/tests/values/httproute.yaml index fa51e6cc..ee550638 100644 --- a/charts/sophora-contentapi/tests/values/httproute.yaml +++ b/charts/sophora-contentapi/tests/values/httproute.yaml @@ -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 \ No newline at end of file diff --git a/charts/sophora-contentapi/values.yaml b/charts/sophora-contentapi/values.yaml index a36fe0af..7b549547 100644 --- a/charts/sophora-contentapi/values.yaml +++ b/charts/sophora-contentapi/values.yaml @@ -70,38 +70,31 @@ ingress: hosts: tls: [] -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" -> "-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: {} extraDeploy: [] diff --git a/charts/sophora-image-access-service/Chart.yaml b/charts/sophora-image-access-service/Chart.yaml index 3433b4e0..d0d590e1 100644 --- a/charts/sophora-image-access-service/Chart.yaml +++ b/charts/sophora-image-access-service/Chart.yaml @@ -15,11 +15,11 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 1.6.0 +version: 1.7.0 annotations: artifacthub.io/changes: | - - kind: added - description: "Added affinity" + - kind: changed + description: "HTTPRoute configuration changed to a map of routes via httpRoutes{}. The previous httpRoute and extraHttpRoutes fields have been removed (breaking change)!" # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/charts/sophora-image-access-service/templates/httproute.yaml b/charts/sophora-image-access-service/templates/httproute.yaml index 969beea5..74c91df5 100644 --- a/charts/sophora-image-access-service/templates/httproute.yaml +++ b/charts/sophora-image-access-service/templates/httproute.yaml @@ -1,19 +1,17 @@ -{{ $allHTTPRoutes := .Values.extraHttpRoutes -}} -{{ if .Values.httpRoute.enabled -}} - {{ $allHTTPRoutes = prepend $allHTTPRoutes .Values.httpRoute -}} -{{ end -}} {{ $fullName := include "access-service.fullname" $ -}} -{{ $svcPort := $.Values.service.httpPort -}} -{{ range $index, $httpRoute := $allHTTPRoutes -}} +{{- $labels := include "access-service.labels" . -}} +{{- $svcPort := .Values.service.httpPort -}} +{{- range $key := (.Values.httpRoutes | keys | sortAlpha) }} +{{- $httpRoute := index $.Values.httpRoutes $key }} apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: - name: {{ $fullName }}{{ eq $index 0 | ternary "" (printf "-%d" $index) }} + name: {{ printf "%s-%s" $fullName $key | trunc 63 | trimSuffix "-" }} labels: - {{- include "access-service.labels" $ | nindent 4 }} + {{- $labels | nindent 4 }} {{- with $httpRoute.annotations }} annotations: - {{- toYaml . | nindent 4 }} + {{- toYaml . | nindent 4 }} {{- end }} spec: {{- with $httpRoute.parentRefs }} @@ -39,4 +37,4 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} --- -{{- end }} +{{- end }} \ No newline at end of file diff --git a/charts/sophora-image-access-service/tests/httproute_test.yaml b/charts/sophora-image-access-service/tests/httproute_test.yaml index a4fcd67d..7e3b588e 100644 --- a/charts/sophora-image-access-service/tests/httproute_test.yaml +++ b/charts/sophora-image-access-service/tests/httproute_test.yaml @@ -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: sophora-image-access-service - - equal: + name: sophora-image-access-service-primary + - documentIndex: 1 + containsDocument: + kind: HTTPRoute + apiVersion: gateway.networking.k8s.io/v1 + name: sophora-image-access-service-secondary + - documentIndex: 0 + equal: path: metadata value: - name: sophora-image-access-service + name: sophora-image-access-service-primary labels: helm.sh/chart: sophora-image-access-service-0.9.8 app.kubernetes.io/name: sophora-image-access-service @@ -35,7 +42,8 @@ tests: annotations: example.com/test: "simple" example.com/text: some text value - - equal: + - documentIndex: 0 + equal: path: spec value: parentRefs: @@ -58,4 +66,28 @@ tests: - path: type: PathPrefix value: / - - notFailedTemplate: {} + - documentIndex: 1 + equal: + path: metadata + value: + name: sophora-image-access-service-secondary + labels: + helm.sh/chart: sophora-image-access-service-0.9.8 + app.kubernetes.io/name: sophora-image-access-service + 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: sophora-image-access-service + port: 8080 + - notFailedTemplate: {} \ No newline at end of file diff --git a/charts/sophora-image-access-service/tests/values/httproute.yaml b/charts/sophora-image-access-service/tests/values/httproute.yaml index fa51e6cc..ee550638 100644 --- a/charts/sophora-image-access-service/tests/values/httproute.yaml +++ b/charts/sophora-image-access-service/tests/values/httproute.yaml @@ -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 \ No newline at end of file diff --git a/charts/sophora-image-access-service/values.yaml b/charts/sophora-image-access-service/values.yaml index 9005b007..1cb593ed 100644 --- a/charts/sophora-image-access-service/values.yaml +++ b/charts/sophora-image-access-service/values.yaml @@ -81,47 +81,31 @@ extraIngress: [] # hosts: # tls: [] -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: {} - -extraHttpRoutes: [] - #- parentRefs: - # - name: my-gateway - # hostnames: - # - example.com - # matches: [] - # filters: [] - # 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" -> "-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: {} serviceAccount: create: false diff --git a/charts/sophora-image-ai/Chart.yaml b/charts/sophora-image-ai/Chart.yaml index a7b52ea1..8bbb6f55 100644 --- a/charts/sophora-image-ai/Chart.yaml +++ b/charts/sophora-image-ai/Chart.yaml @@ -2,11 +2,11 @@ apiVersion: v2 name: sophora-image-ai description: Sophora Image AI type: application -version: 2.2.0 +version: 2.3.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: 5.1.0 sources: diff --git a/charts/sophora-image-ai/templates/httproute.yaml b/charts/sophora-image-ai/templates/httproute.yaml index d0716f24..8ce1844e 100644 --- a/charts/sophora-image-ai/templates/httproute.yaml +++ b/charts/sophora-image-ai/templates/httproute.yaml @@ -1,24 +1,26 @@ -{{- if .Values.httpRoute.enabled -}} - {{- $fullName := include "sophora-image-ai.fullname" . -}} - {{- $svcPort := .Values.service.port -}} +{{- $fullName := include "sophora-image-ai.fullname" . -}} +{{- $labels := include "sophora-image-ai.labels" . -}} +{{- $svcPort := .Values.service.port -}} +{{- range $key := (.Values.httpRoutes | keys | sortAlpha) }} +{{- $httpRoute := index $.Values.httpRoutes $key }} apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: - name: {{ $fullName }} + name: {{ printf "%s-%s" $fullName $key | trunc 63 | trimSuffix "-" }} labels: - {{- include "sophora-image-ai.labels" . | nindent 4 }} - {{- with .Values.httpRoute.annotations }} + {{- $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 }} + {{- range $httpRoute.hostnames }} - {{ . | quote }} {{- end }} {{- end }} @@ -26,12 +28,13 @@ spec: - backendRefs: - name: {{ $fullName }} port: {{ $svcPort }} - {{- with .Values.httpRoute.matches }} + {{- with $httpRoute.matches }} matches: {{- toYaml . | nindent 8 }} {{- end }} - {{- with .Values.httpRoute.filters }} + {{- with $httpRoute.filters }} filters: {{- toYaml . | nindent 8 }} {{- end }} -{{- end }} +--- +{{- end }} \ No newline at end of file diff --git a/charts/sophora-image-ai/tests/httproute_test.yaml b/charts/sophora-image-ai/tests/httproute_test.yaml index 09bb1691..4663ddb6 100644 --- a/charts/sophora-image-ai/tests/httproute_test.yaml +++ b/charts/sophora-image-ai/tests/httproute_test.yaml @@ -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-sophora-image-ai - - equal: + name: values-test-release-sophora-image-ai-primary + - documentIndex: 1 + containsDocument: + kind: HTTPRoute + apiVersion: gateway.networking.k8s.io/v1 + name: values-test-release-sophora-image-ai-secondary + - documentIndex: 0 + equal: path: metadata value: - name: values-test-release-sophora-image-ai + name: values-test-release-sophora-image-ai-primary labels: helm.sh/chart: sophora-image-ai-0.9.8 app.kubernetes.io/name: sophora-image-ai @@ -35,7 +42,8 @@ tests: annotations: example.com/test: "simple" example.com/text: some text value - - equal: + - documentIndex: 0 + equal: path: spec value: parentRefs: @@ -58,4 +66,28 @@ tests: - path: type: PathPrefix value: / + - documentIndex: 1 + equal: + path: metadata + value: + name: values-test-release-sophora-image-ai-secondary + labels: + helm.sh/chart: sophora-image-ai-0.9.8 + app.kubernetes.io/name: sophora-image-ai + 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-sophora-image-ai + port: 8080 - notFailedTemplate: {} diff --git a/charts/sophora-image-ai/tests/values/httproute.yaml b/charts/sophora-image-ai/tests/values/httproute.yaml index fa51e6cc..ee550638 100644 --- a/charts/sophora-image-ai/tests/values/httproute.yaml +++ b/charts/sophora-image-ai/tests/values/httproute.yaml @@ -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 \ No newline at end of file diff --git a/charts/sophora-image-ai/values.yaml b/charts/sophora-image-ai/values.yaml index a47c3900..18a2e55f 100644 --- a/charts/sophora-image-ai/values.yaml +++ b/charts/sophora-image-ai/values.yaml @@ -63,38 +63,31 @@ ingress: hosts: tls: [] -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" -> "-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: {} extraDeploy: [] diff --git a/charts/sophora-importer/Chart.yaml b/charts/sophora-importer/Chart.yaml index 1831e6c0..aed9d17b 100644 --- a/charts/sophora-importer/Chart.yaml +++ b/charts/sophora-importer/Chart.yaml @@ -15,11 +15,11 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 2.6.0 +version: 2.7.0 annotations: artifacthub.io/changes: | - - kind: added - description: "Added probes" + - kind: changed + description: "HTTPRoute configuration changed to a map of routes via httpRoutes{}. The previous httpRoute field has been removed (breaking change)!" # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/charts/sophora-importer/templates/httproute.yaml b/charts/sophora-importer/templates/httproute.yaml index 19af18bd..f4dd37cf 100644 --- a/charts/sophora-importer/templates/httproute.yaml +++ b/charts/sophora-importer/templates/httproute.yaml @@ -1,43 +1,40 @@ -{{- if .Values.httpRoute.enabled -}} {{- $fullName := include "sophora-importer.fullname" . -}} +{{- $labels := include "sophora-importer.labels" . -}} {{- $svcPort := .Values.service.httpPort -}} -{{- $rules := list (dict) -}} -{{/* backward compatible to version 2.4.x */}} -{{- $firstRule := dict -}} -{{- if .Values.httpRoute.rules -}} - {{- $firstRule = first .Values.httpRoute.rules -}} -{{- else if or .Values.httpRoute.matches .Values.httpRoute.filters -}} - {{- $firstRule = dict "matches" .Values.httpRoute.matches "filters" .Values.httpRoute.filters -}} -{{- end -}} +{{- range $key := (.Values.httpRoutes | keys | sortAlpha) }} +{{- $httpRoute := index $.Values.httpRoutes $key }} apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: - name: {{ $fullName }} + name: {{ printf "%s-%s" $fullName $key | trunc 63 | trimSuffix "-" }} labels: - {{- include "sophora-importer.labels" . | nindent 4 }} - {{- with .Values.httpRoute.annotations }} + {{- $labels | nindent 4 }} + {{- with $httpRoute.annotations }} annotations: {{- toYaml . | nindent 4 }} {{- end }} spec: + {{- with $httpRoute.parentRefs }} parentRefs: - {{- with .Values.httpRoute.parentRefs }} - {{- toYaml . | nindent 4 }} - {{- end }} - {{- with .Values.httpRoute.hostnames }} + {{- toYaml . | nindent 4 }} + {{- end }} + {{- if $httpRoute.hostnames }} hostnames: - {{- toYaml . | nindent 4 }} + {{- range $httpRoute.hostnames }} + - {{ . | quote }} + {{- end }} {{- end }} rules: - backendRefs: - name: {{ $fullName }} port: {{ $svcPort }} - {{- with $firstRule.matches }} + {{- with $httpRoute.matches }} matches: {{- toYaml . | nindent 8 }} {{- end }} - {{- with $firstRule.filters }} + {{- with $httpRoute.filters }} filters: {{- toYaml . | nindent 8 }} {{- end }} +--- {{- end }} diff --git a/charts/sophora-importer/tests/httproute_test.yaml b/charts/sophora-importer/tests/httproute_test.yaml index 9dbb5836..dfcc9d04 100644 --- a/charts/sophora-importer/tests/httproute_test.yaml +++ b/charts/sophora-importer/tests/httproute_test.yaml @@ -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-sophora-importer - - equal: + name: values-test-release-sophora-importer-primary + - documentIndex: 1 + containsDocument: + kind: HTTPRoute + apiVersion: gateway.networking.k8s.io/v1 + name: values-test-release-sophora-importer-secondary + - documentIndex: 0 + equal: path: metadata value: - name: values-test-release-sophora-importer + name: values-test-release-sophora-importer-primary labels: helm.sh/chart: sophora-importer-0.9.8 app.kubernetes.io/name: sophora-importer @@ -35,7 +42,8 @@ tests: annotations: example.com/test: "simple" example.com/text: some text value - - equal: + - documentIndex: 0 + equal: path: spec value: parentRefs: @@ -58,4 +66,28 @@ tests: - path: type: PathPrefix value: / + - documentIndex: 1 + equal: + path: metadata + value: + name: values-test-release-sophora-importer-secondary + labels: + helm.sh/chart: sophora-importer-0.9.8 + app.kubernetes.io/name: sophora-importer + 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-sophora-importer + port: 80 - notFailedTemplate: {} diff --git a/charts/sophora-importer/tests/values/httproute.yaml b/charts/sophora-importer/tests/values/httproute.yaml index fa51e6cc..ee550638 100644 --- a/charts/sophora-importer/tests/values/httproute.yaml +++ b/charts/sophora-importer/tests/values/httproute.yaml @@ -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 \ No newline at end of file diff --git a/charts/sophora-importer/values.yaml b/charts/sophora-importer/values.yaml index 92dff86e..61217eed 100644 --- a/charts/sophora-importer/values.yaml +++ b/charts/sophora-importer/values.yaml @@ -152,43 +152,28 @@ additionalVolumeMounts: # This option can be used to create a pvc for the local import folders importPvcSpec: -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.rules !DEPRECATED use matches and filters instead! This will override matches/filters. List of rules and filters applied. - # e.g. - # rules: - # - matches: - # - path: - # type: PathPrefix - # value: /headers - rules: [] - # 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" -> "-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: {} diff --git a/charts/sophora-indexing-service/Chart.yaml b/charts/sophora-indexing-service/Chart.yaml index e4760fd3..cf36e5e0 100644 --- a/charts/sophora-indexing-service/Chart.yaml +++ b/charts/sophora-indexing-service/Chart.yaml @@ -2,11 +2,11 @@ apiVersion: v2 name: sophora-indexing-service description: Sophora Indexing Service (SISI) type: application -version: 1.6.0 +version: 1.7.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: '5.4.1' sources: diff --git a/charts/sophora-indexing-service/templates/httproute.yaml b/charts/sophora-indexing-service/templates/httproute.yaml index 3608ff89..f005c9da 100644 --- a/charts/sophora-indexing-service/templates/httproute.yaml +++ b/charts/sophora-indexing-service/templates/httproute.yaml @@ -1,24 +1,26 @@ -{{- if .Values.httpRoute.enabled -}} - {{- $fullName := include "sophora-indexing-service.fullname" . -}} - {{- $svcPort := .Values.service.port -}} +{{- $fullName := include "sophora-indexing-service.fullname" . -}} +{{- $labels := include "sophora-indexing-service.labels" . -}} +{{- $svcPort := .Values.service.port -}} +{{- range $key := (.Values.httpRoutes | keys | sortAlpha) }} +{{- $httpRoute := index $.Values.httpRoutes $key }} apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: - name: {{ $fullName }} + name: {{ printf "%s-%s" $fullName $key | trunc 63 | trimSuffix "-" }} labels: - {{- include "sophora-indexing-service.labels" . | nindent 4 }} - {{- with .Values.httpRoute.annotations }} + {{- $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 }} + {{- range $httpRoute.hostnames }} - {{ . | quote }} {{- end }} {{- end }} @@ -26,12 +28,13 @@ spec: - backendRefs: - name: {{ $fullName }} port: {{ $svcPort }} - {{- with .Values.httpRoute.matches }} + {{- with $httpRoute.matches }} matches: {{- toYaml . | nindent 8 }} {{- end }} - {{- with .Values.httpRoute.filters }} + {{- with $httpRoute.filters }} filters: {{- toYaml . | nindent 8 }} {{- end }} -{{- end }} +--- +{{- end }} \ No newline at end of file diff --git a/charts/sophora-indexing-service/tests/httproute_test.yaml b/charts/sophora-indexing-service/tests/httproute_test.yaml index de35181c..6170b6a9 100644 --- a/charts/sophora-indexing-service/tests/httproute_test.yaml +++ b/charts/sophora-indexing-service/tests/httproute_test.yaml @@ -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-sophora-indexing-service - - equal: + name: values-test-release-sophora-indexing-service-primary + - documentIndex: 1 + containsDocument: + kind: HTTPRoute + apiVersion: gateway.networking.k8s.io/v1 + name: values-test-release-sophora-indexing-service-secondary + - documentIndex: 0 + equal: path: metadata value: - name: values-test-release-sophora-indexing-service + name: values-test-release-sophora-indexing-service-primary labels: helm.sh/chart: sophora-indexing-service-0.9.8 app.kubernetes.io/name: sophora-indexing-service @@ -35,7 +42,8 @@ tests: annotations: example.com/test: "simple" example.com/text: some text value - - equal: + - documentIndex: 0 + equal: path: spec value: parentRefs: @@ -58,4 +66,28 @@ tests: - path: type: PathPrefix value: / + - documentIndex: 1 + equal: + path: metadata + value: + name: values-test-release-sophora-indexing-service-secondary + labels: + helm.sh/chart: sophora-indexing-service-0.9.8 + app.kubernetes.io/name: sophora-indexing-service + 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-sophora-indexing-service + port: 1837 - notFailedTemplate: {} diff --git a/charts/sophora-indexing-service/tests/values/httproute.yaml b/charts/sophora-indexing-service/tests/values/httproute.yaml index fa51e6cc..ee550638 100644 --- a/charts/sophora-indexing-service/tests/values/httproute.yaml +++ b/charts/sophora-indexing-service/tests/values/httproute.yaml @@ -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 \ No newline at end of file diff --git a/charts/sophora-indexing-service/values.yaml b/charts/sophora-indexing-service/values.yaml index 1c523275..bb648d0c 100644 --- a/charts/sophora-indexing-service/values.yaml +++ b/charts/sophora-indexing-service/values.yaml @@ -93,38 +93,31 @@ ingress: hosts: tls: [] -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" -> "-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: {} resources: requests: diff --git a/charts/sophora-linkchecker/Chart.yaml b/charts/sophora-linkchecker/Chart.yaml index 86a32604..08bcb6f6 100644 --- a/charts/sophora-linkchecker/Chart.yaml +++ b/charts/sophora-linkchecker/Chart.yaml @@ -2,11 +2,11 @@ apiVersion: v2 name: sophora-linkchecker description: Sophora Link Checker type: application -version: 0.2.0 +version: 0.3.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: 6.0.0 sources: diff --git a/charts/sophora-linkchecker/templates/httproute.yaml b/charts/sophora-linkchecker/templates/httproute.yaml index 9a7c459e..ce18fce1 100644 --- a/charts/sophora-linkchecker/templates/httproute.yaml +++ b/charts/sophora-linkchecker/templates/httproute.yaml @@ -1,24 +1,26 @@ -{{- if .Values.httpRoute.enabled -}} - {{- $fullName := include "sophora-linkchecker.fullname" . -}} - {{- $svcPort := .Values.service.port -}} +{{- $fullName := include "sophora-linkchecker.fullname" . -}} +{{- $labels := include "sophora-linkchecker.labels" . -}} +{{- $svcPort := .Values.service.port -}} +{{- range $key := (.Values.httpRoutes | keys | sortAlpha) }} +{{- $httpRoute := index $.Values.httpRoutes $key }} apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: - name: {{ $fullName }} + name: {{ printf "%s-%s" $fullName $key | trunc 63 | trimSuffix "-" }} labels: - {{- include "sophora-linkchecker.labels" . | nindent 4 }} - {{- with .Values.httpRoute.annotations }} + {{- $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 }} + {{- range $httpRoute.hostnames }} - {{ . | quote }} {{- end }} {{- end }} @@ -26,12 +28,13 @@ spec: - backendRefs: - name: {{ $fullName }} port: {{ $svcPort }} - {{- with .Values.httpRoute.matches }} + {{- with $httpRoute.matches }} matches: {{- toYaml . | nindent 8 }} {{- end }} - {{- with .Values.httpRoute.filters }} + {{- with $httpRoute.filters }} filters: {{- toYaml . | nindent 8 }} {{- end }} -{{- end }} +--- +{{- end }} \ No newline at end of file diff --git a/charts/sophora-linkchecker/tests/httproute_test.yaml b/charts/sophora-linkchecker/tests/httproute_test.yaml index bb99451c..596c366f 100644 --- a/charts/sophora-linkchecker/tests/httproute_test.yaml +++ b/charts/sophora-linkchecker/tests/httproute_test.yaml @@ -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-sophora-linkchecker - - equal: + name: values-test-release-sophora-linkchecker-primary + - documentIndex: 1 + containsDocument: + kind: HTTPRoute + apiVersion: gateway.networking.k8s.io/v1 + name: values-test-release-sophora-linkchecker-secondary + - documentIndex: 0 + equal: path: metadata value: - name: values-test-release-sophora-linkchecker + name: values-test-release-sophora-linkchecker-primary labels: helm.sh/chart: sophora-linkchecker-0.9.8 app.kubernetes.io/name: sophora-linkchecker @@ -35,7 +42,8 @@ tests: annotations: example.com/test: "simple" example.com/text: some text value - - equal: + - documentIndex: 0 + equal: path: spec value: parentRefs: @@ -58,4 +66,28 @@ tests: - path: type: PathPrefix value: / + - documentIndex: 1 + equal: + path: metadata + value: + name: values-test-release-sophora-linkchecker-secondary + labels: + helm.sh/chart: sophora-linkchecker-0.9.8 + app.kubernetes.io/name: sophora-linkchecker + 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-sophora-linkchecker + port: 8080 - notFailedTemplate: {} diff --git a/charts/sophora-linkchecker/tests/values/httproute.yaml b/charts/sophora-linkchecker/tests/values/httproute.yaml index fa51e6cc..ee550638 100644 --- a/charts/sophora-linkchecker/tests/values/httproute.yaml +++ b/charts/sophora-linkchecker/tests/values/httproute.yaml @@ -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 \ No newline at end of file diff --git a/charts/sophora-linkchecker/values.yaml b/charts/sophora-linkchecker/values.yaml index 88fa796b..3a7fbaa2 100644 --- a/charts/sophora-linkchecker/values.yaml +++ b/charts/sophora-linkchecker/values.yaml @@ -70,38 +70,31 @@ ingress: hosts: tls: [] -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" -> "-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: {} extraDeploy: [] diff --git a/charts/sophora-media-finder/Chart.yaml b/charts/sophora-media-finder/Chart.yaml index f1ab8795..ec6c5647 100644 --- a/charts/sophora-media-finder/Chart.yaml +++ b/charts/sophora-media-finder/Chart.yaml @@ -2,11 +2,11 @@ apiVersion: v2 name: sophora-media-finder description: A Helm chart for Sophora Media Finder type: application -version: 0.3.0 +version: 0.4.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: "5.x" sources: diff --git a/charts/sophora-media-finder/templates/httproute.yaml b/charts/sophora-media-finder/templates/httproute.yaml index 370f6b06..f45f83ad 100644 --- a/charts/sophora-media-finder/templates/httproute.yaml +++ b/charts/sophora-media-finder/templates/httproute.yaml @@ -1,24 +1,26 @@ -{{- if .Values.httpRoute.enabled -}} - {{- $fullName := include "sophora-media-finder.fullname" . -}} - {{- $svcPort := .Values.service.port -}} +{{- $fullName := include "sophora-media-finder.fullname" . -}} +{{- $labels := include "sophora-media-finder.labels" . -}} +{{- $svcPort := .Values.service.port -}} +{{- range $key := (.Values.httpRoutes | keys | sortAlpha) }} +{{- $httpRoute := index $.Values.httpRoutes $key }} apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: - name: {{ $fullName }} + name: {{ printf "%s-%s" $fullName $key | trunc 63 | trimSuffix "-" }} labels: - {{- include "sophora-media-finder.labels" . | nindent 4 }} - {{- with .Values.httpRoute.annotations }} + {{- $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 }} + {{- range $httpRoute.hostnames }} - {{ . | quote }} {{- end }} {{- end }} @@ -26,12 +28,13 @@ spec: - backendRefs: - name: {{ $fullName }} port: {{ $svcPort }} - {{- with .Values.httpRoute.matches }} + {{- with $httpRoute.matches }} matches: {{- toYaml . | nindent 8 }} {{- end }} - {{- with .Values.httpRoute.filters }} + {{- with $httpRoute.filters }} filters: {{- toYaml . | nindent 8 }} {{- end }} -{{- end }} +--- +{{- end }} \ No newline at end of file diff --git a/charts/sophora-media-finder/tests/httproute_test.yaml b/charts/sophora-media-finder/tests/httproute_test.yaml index 6e8c9b3e..c3d4db1e 100644 --- a/charts/sophora-media-finder/tests/httproute_test.yaml +++ b/charts/sophora-media-finder/tests/httproute_test.yaml @@ -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-sophora-media-finder - - equal: + name: values-test-release-sophora-media-finder-primary + - documentIndex: 1 + containsDocument: + kind: HTTPRoute + apiVersion: gateway.networking.k8s.io/v1 + name: values-test-release-sophora-media-finder-secondary + - documentIndex: 0 + equal: path: metadata value: - name: values-test-release-sophora-media-finder + name: values-test-release-sophora-media-finder-primary labels: helm.sh/chart: sophora-media-finder-0.9.8 app.kubernetes.io/name: sophora-media-finder @@ -35,7 +42,8 @@ tests: annotations: example.com/test: "simple" example.com/text: some text value - - equal: + - documentIndex: 0 + equal: path: spec value: parentRefs: @@ -58,4 +66,28 @@ tests: - path: type: PathPrefix value: / + - documentIndex: 1 + equal: + path: metadata + value: + name: values-test-release-sophora-media-finder-secondary + labels: + helm.sh/chart: sophora-media-finder-0.9.8 + app.kubernetes.io/name: sophora-media-finder + 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-sophora-media-finder + port: 8080 - notFailedTemplate: {} diff --git a/charts/sophora-media-finder/tests/values/httproute.yaml b/charts/sophora-media-finder/tests/values/httproute.yaml index fa51e6cc..ee550638 100644 --- a/charts/sophora-media-finder/tests/values/httproute.yaml +++ b/charts/sophora-media-finder/tests/values/httproute.yaml @@ -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 \ No newline at end of file diff --git a/charts/sophora-media-finder/values.yaml b/charts/sophora-media-finder/values.yaml index d78003ee..19e87206 100644 --- a/charts/sophora-media-finder/values.yaml +++ b/charts/sophora-media-finder/values.yaml @@ -34,38 +34,31 @@ ingress: hosts: tls: [] -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" -> "-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: {} startupProbe: path: /actuator/health diff --git a/charts/sophora-metadata-supplier/Chart.yaml b/charts/sophora-metadata-supplier/Chart.yaml index aff8d3b9..86cc9502 100644 --- a/charts/sophora-metadata-supplier/Chart.yaml +++ b/charts/sophora-metadata-supplier/Chart.yaml @@ -2,11 +2,11 @@ apiVersion: v2 name: sophora-metadata-supplier description: Sophora Metadata Supplier (SMS) type: application -version: 1.4.1 +version: 1.5.0 annotations: artifacthub.io/changes: | - kind: changed - description: "Alert for job queue ignores low priority queue." + description: "HTTPRoute configuration changed to a map of routes via httpRoutes{}. The previous httpRoute field has been removed (breaking change)!" appVersion: '4.14.0' sources: diff --git a/charts/sophora-metadata-supplier/templates/httproute.yaml b/charts/sophora-metadata-supplier/templates/httproute.yaml index 2641c0bc..b5507aa8 100644 --- a/charts/sophora-metadata-supplier/templates/httproute.yaml +++ b/charts/sophora-metadata-supplier/templates/httproute.yaml @@ -1,24 +1,26 @@ -{{- if .Values.httpRoute.enabled -}} - {{- $fullName := include "sophora-metadata-supplier.fullname" . -}} - {{- $svcPort := .Values.service.port -}} +{{- $fullName := include "sophora-metadata-supplier.fullname" . -}} +{{- $labels := include "sophora-metadata-supplier.labels" . -}} +{{- $svcPort := .Values.service.port -}} +{{- range $key := (.Values.httpRoutes | keys | sortAlpha) }} +{{- $httpRoute := index $.Values.httpRoutes $key }} apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: - name: {{ $fullName }} + name: {{ printf "%s-%s" $fullName $key | trunc 63 | trimSuffix "-" }} labels: - {{- include "sophora-metadata-supplier.labels" . | nindent 4 }} - {{- with .Values.httpRoute.annotations }} + {{- $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 }} + {{- range $httpRoute.hostnames }} - {{ . | quote }} {{- end }} {{- end }} @@ -26,12 +28,13 @@ spec: - backendRefs: - name: {{ $fullName }} port: {{ $svcPort }} - {{- with .Values.httpRoute.matches }} + {{- with $httpRoute.matches }} matches: {{- toYaml . | nindent 8 }} {{- end }} - {{- with .Values.httpRoute.filters }} + {{- with $httpRoute.filters }} filters: {{- toYaml . | nindent 8 }} {{- end }} -{{- end }} +--- +{{- end }} \ No newline at end of file diff --git a/charts/sophora-metadata-supplier/tests/httproute_test.yaml b/charts/sophora-metadata-supplier/tests/httproute_test.yaml index 84637fe7..fd239376 100644 --- a/charts/sophora-metadata-supplier/tests/httproute_test.yaml +++ b/charts/sophora-metadata-supplier/tests/httproute_test.yaml @@ -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-sophora-metadata-supplier - - equal: + name: values-test-release-sophora-metadata-supplier-primary + - documentIndex: 1 + containsDocument: + kind: HTTPRoute + apiVersion: gateway.networking.k8s.io/v1 + name: values-test-release-sophora-metadata-supplier-secondary + - documentIndex: 0 + equal: path: metadata value: - name: values-test-release-sophora-metadata-supplier + name: values-test-release-sophora-metadata-supplier-primary labels: helm.sh/chart: sophora-metadata-supplier-0.9.8 app.kubernetes.io/name: sophora-metadata-supplier @@ -35,7 +42,8 @@ tests: annotations: example.com/test: "simple" example.com/text: some text value - - equal: + - documentIndex: 0 + equal: path: spec value: parentRefs: @@ -58,4 +66,28 @@ tests: - path: type: PathPrefix value: / + - documentIndex: 1 + equal: + path: metadata + value: + name: values-test-release-sophora-metadata-supplier-secondary + labels: + helm.sh/chart: sophora-metadata-supplier-0.9.8 + app.kubernetes.io/name: sophora-metadata-supplier + 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-sophora-metadata-supplier + port: 8080 - notFailedTemplate: {} diff --git a/charts/sophora-metadata-supplier/tests/values/httproute.yaml b/charts/sophora-metadata-supplier/tests/values/httproute.yaml index fa51e6cc..ee550638 100644 --- a/charts/sophora-metadata-supplier/tests/values/httproute.yaml +++ b/charts/sophora-metadata-supplier/tests/values/httproute.yaml @@ -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 \ No newline at end of file diff --git a/charts/sophora-metadata-supplier/values.yaml b/charts/sophora-metadata-supplier/values.yaml index f0284b0b..c5867a19 100644 --- a/charts/sophora-metadata-supplier/values.yaml +++ b/charts/sophora-metadata-supplier/values.yaml @@ -99,38 +99,31 @@ ingress: hosts: tls: [] -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" -> "-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: {} prometheusRule: enabled: false diff --git a/charts/sophora-schema-docs/Chart.yaml b/charts/sophora-schema-docs/Chart.yaml index a02003cc..866f1487 100644 --- a/charts/sophora-schema-docs/Chart.yaml +++ b/charts/sophora-schema-docs/Chart.yaml @@ -2,11 +2,11 @@ apiVersion: v2 name: sophora-schema-docs description: Sophora Schema Docs type: application -version: 2.2.0 +version: 2.3.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: 5.0.0 sources: diff --git a/charts/sophora-schema-docs/templates/httproute.yaml b/charts/sophora-schema-docs/templates/httproute.yaml index 5b7c23c0..fa8f9586 100644 --- a/charts/sophora-schema-docs/templates/httproute.yaml +++ b/charts/sophora-schema-docs/templates/httproute.yaml @@ -1,24 +1,26 @@ -{{- if .Values.httpRoute.enabled -}} - {{- $fullName := include "sophora-schema-docs.fullname" . -}} - {{- $svcPort := .Values.service.port -}} +{{- $fullName := include "sophora-schema-docs.fullname" . -}} +{{- $labels := include "sophora-schema-docs.labels" . -}} +{{- $svcPort := .Values.service.port -}} +{{- range $key := (.Values.httpRoutes | keys | sortAlpha) }} +{{- $httpRoute := index $.Values.httpRoutes $key }} apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: - name: {{ $fullName }} + name: {{ printf "%s-%s" $fullName $key | trunc 63 | trimSuffix "-" }} labels: - {{- include "sophora-schema-docs.labels" . | nindent 4 }} - {{- with .Values.httpRoute.annotations }} + {{- $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 }} + {{- range $httpRoute.hostnames }} - {{ . | quote }} {{- end }} {{- end }} @@ -26,12 +28,13 @@ spec: - backendRefs: - name: {{ $fullName }} port: {{ $svcPort }} - {{- with .Values.httpRoute.matches }} + {{- with $httpRoute.matches }} matches: {{- toYaml . | nindent 8 }} {{- end }} - {{- with .Values.httpRoute.filters }} + {{- with $httpRoute.filters }} filters: {{- toYaml . | nindent 8 }} {{- end }} -{{- end }} +--- +{{- end }} \ No newline at end of file diff --git a/charts/sophora-schema-docs/tests/httproute_test.yaml b/charts/sophora-schema-docs/tests/httproute_test.yaml index f7c48446..5a7a7363 100644 --- a/charts/sophora-schema-docs/tests/httproute_test.yaml +++ b/charts/sophora-schema-docs/tests/httproute_test.yaml @@ -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-sophora-schema-docs - - equal: + name: values-test-release-sophora-schema-docs-primary + - documentIndex: 1 + containsDocument: + kind: HTTPRoute + apiVersion: gateway.networking.k8s.io/v1 + name: values-test-release-sophora-schema-docs-secondary + - documentIndex: 0 + equal: path: metadata value: - name: values-test-release-sophora-schema-docs + name: values-test-release-sophora-schema-docs-primary labels: helm.sh/chart: sophora-schema-docs-0.9.8 app.kubernetes.io/name: sophora-schema-docs @@ -35,7 +42,8 @@ tests: annotations: example.com/test: "simple" example.com/text: some text value - - equal: + - documentIndex: 0 + equal: path: spec value: parentRefs: @@ -58,4 +66,28 @@ tests: - path: type: PathPrefix value: / + - documentIndex: 1 + equal: + path: metadata + value: + name: values-test-release-sophora-schema-docs-secondary + labels: + helm.sh/chart: sophora-schema-docs-0.9.8 + app.kubernetes.io/name: sophora-schema-docs + 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-sophora-schema-docs + port: 8080 - notFailedTemplate: {} diff --git a/charts/sophora-schema-docs/tests/values/httproute.yaml b/charts/sophora-schema-docs/tests/values/httproute.yaml index fa51e6cc..ee550638 100644 --- a/charts/sophora-schema-docs/tests/values/httproute.yaml +++ b/charts/sophora-schema-docs/tests/values/httproute.yaml @@ -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 \ No newline at end of file diff --git a/charts/sophora-schema-docs/values.yaml b/charts/sophora-schema-docs/values.yaml index 008112ef..86bf6cd7 100644 --- a/charts/sophora-schema-docs/values.yaml +++ b/charts/sophora-schema-docs/values.yaml @@ -103,38 +103,31 @@ ingress: hosts: tls: [] -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" -> "-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: {} extraDeploy: [] diff --git a/charts/sophora-seo-check/Chart.yaml b/charts/sophora-seo-check/Chart.yaml index b6229407..8d2d9777 100644 --- a/charts/sophora-seo-check/Chart.yaml +++ b/charts/sophora-seo-check/Chart.yaml @@ -2,11 +2,11 @@ apiVersion: v2 name: sophora-seo-check description: Sophora SEO Check type: application -version: 1.1.0 +version: 1.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: 4.12.0 sources: diff --git a/charts/sophora-seo-check/templates/httproute.yaml b/charts/sophora-seo-check/templates/httproute.yaml index 2a3e3f32..00a45484 100644 --- a/charts/sophora-seo-check/templates/httproute.yaml +++ b/charts/sophora-seo-check/templates/httproute.yaml @@ -1,24 +1,26 @@ -{{- if .Values.httpRoute.enabled -}} - {{- $fullName := include "sophora-seo-check.fullname" . -}} - {{- $svcPort := .Values.service.port -}} +{{- $fullName := include "sophora-seo-check.fullname" . -}} +{{- $labels := include "sophora-seo-check.labels" . -}} +{{- $svcPort := .Values.service.port -}} +{{- range $key := (.Values.httpRoutes | keys | sortAlpha) }} +{{- $httpRoute := index $.Values.httpRoutes $key }} apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: - name: {{ $fullName }} + name: {{ printf "%s-%s" $fullName $key | trunc 63 | trimSuffix "-" }} labels: - {{- include "sophora-seo-check.labels" . | nindent 4 }} - {{- with .Values.httpRoute.annotations }} + {{- $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 }} + {{- range $httpRoute.hostnames }} - {{ . | quote }} {{- end }} {{- end }} @@ -26,12 +28,13 @@ spec: - backendRefs: - name: {{ $fullName }} port: {{ $svcPort }} - {{- with .Values.httpRoute.matches }} + {{- with $httpRoute.matches }} matches: {{- toYaml . | nindent 8 }} {{- end }} - {{- with .Values.httpRoute.filters }} + {{- with $httpRoute.filters }} filters: {{- toYaml . | nindent 8 }} {{- end }} -{{- end }} +--- +{{- end }} \ No newline at end of file diff --git a/charts/sophora-seo-check/values.yaml b/charts/sophora-seo-check/values.yaml index 46cac0b1..64758347 100644 --- a/charts/sophora-seo-check/values.yaml +++ b/charts/sophora-seo-check/values.yaml @@ -54,38 +54,31 @@ ingress: hosts: tls: [] -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" -> "-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: {} extraDeploy: [] diff --git a/charts/sophora-server/Chart.yaml b/charts/sophora-server/Chart.yaml index f5cd1fab..04ba74f3 100644 --- a/charts/sophora-server/Chart.yaml +++ b/charts/sophora-server/Chart.yaml @@ -15,11 +15,11 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 3.3.0 +version: 3.4.0 annotations: artifacthub.io/changes: | - - kind: "added" - description: "Added configuration for single volume support." + - kind: changed + description: "HTTPRoute configuration changed to a map of routes via httpRoutes{}. The previous httpRoute field has been removed (breaking change)!" # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/charts/sophora-server/templates/httproute.yaml b/charts/sophora-server/templates/httproute.yaml index 3d922fb3..60de7632 100644 --- a/charts/sophora-server/templates/httproute.yaml +++ b/charts/sophora-server/templates/httproute.yaml @@ -1,35 +1,40 @@ -{{- if .Values.httpRoute.enabled -}} - {{- $fullName := include "sophora-server.fullname" . -}} +{{- $fullName := include "sophora-server.fullname" . -}} +{{- $labels := include "sophora-server.labels" . -}} +{{- $svcPort := .Values.sophora.server.ports.http -}} +{{- range $key := (.Values.httpRoutes | keys | sortAlpha) }} +{{- $httpRoute := index $.Values.httpRoutes $key }} apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: - name: {{ $fullName }} - labels: {{ include "sophora-server.topLevelLabels" . | nindent 4 }} - {{- 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 }} + {{- range $httpRoute.hostnames }} - {{ . | quote }} {{- end }} {{- end }} rules: - backendRefs: - name: {{ $fullName }} - port: {{ .Values.sophora.server.ports.http }} - {{- 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 }} \ No newline at end of file diff --git a/charts/sophora-server/tests/httproute_test.yaml b/charts/sophora-server/tests/httproute_test.yaml index 2ceb5a99..4bb61625 100644 --- a/charts/sophora-server/tests/httproute_test.yaml +++ b/charts/sophora-server/tests/httproute_test.yaml @@ -3,38 +3,48 @@ templates: - httproute.yaml chart: version: 0.9.8 +set: + image.tag: 1.2.3 tests: - it: should not create httproute by default asserts: - 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-sophora-server - - equal: + name: values-test-release-sophora-server-primary + - documentIndex: 1 + containsDocument: + kind: HTTPRoute + apiVersion: gateway.networking.k8s.io/v1 + name: values-test-release-sophora-server-secondary + - documentIndex: 0 + equal: path: metadata value: - name: values-test-release-sophora-server + name: values-test-release-sophora-server-primary labels: helm.sh/chart: sophora-server-0.9.8 app.kubernetes.io/name: sophora-server - app.kubernetes.io/version: latest + app.kubernetes.io/version: 1.2.3 app.kubernetes.io/instance: values-test-release app.kubernetes.io/managed-by: Helm annotations: example.com/test: "simple" example.com/text: some text value - - equal: + - documentIndex: 0 + equal: path: spec value: parentRefs: @@ -57,4 +67,28 @@ tests: - path: type: PathPrefix value: / + - documentIndex: 1 + equal: + path: metadata + value: + name: values-test-release-sophora-server-secondary + labels: + helm.sh/chart: sophora-server-0.9.8 + app.kubernetes.io/name: sophora-server + 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-sophora-server + port: 1196 - notFailedTemplate: {} diff --git a/charts/sophora-server/tests/values/httproute.yaml b/charts/sophora-server/tests/values/httproute.yaml index fa51e6cc..ee550638 100644 --- a/charts/sophora-server/tests/values/httproute.yaml +++ b/charts/sophora-server/tests/values/httproute.yaml @@ -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 \ No newline at end of file diff --git a/charts/sophora-server/values.yaml b/charts/sophora-server/values.yaml index 448db7a9..4c9a48af 100644 --- a/charts/sophora-server/values.yaml +++ b/charts/sophora-server/values.yaml @@ -386,38 +386,31 @@ grpcIngress: # hosts: # - chart-example.local -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: [] - # httpRoute.matches Optional array of HTTPRouteMatch objects for matching HTTP requests - # e.g. - # matches: - # - path: - # type: PathPrefix - # value: / - matches: [] - # httpRoute.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" -> "-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: {} # This can be used to configure a different HttpRoute for the SRPC service as it might require different settings. Can be used with the same hostname as httpRoute, see https://gateway-api.sigs.k8s.io/api-types/grpcroute/#cross-serving. # The SRPC-communication relies on gRPC as communication protocol and e.g. nginx needs to be explicitly informed that the backend protocol is gRPC diff --git a/charts/sophora-ugc/Chart.yaml b/charts/sophora-ugc/Chart.yaml index 3aa861bc..bcb663a5 100644 --- a/charts/sophora-ugc/Chart.yaml +++ b/charts/sophora-ugc/Chart.yaml @@ -15,11 +15,11 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 2.2.1 +version: 2.3.0 annotations: artifacthub.io/changes: | - - kind: fixed - description: "Fixed backendRef of httpRoute" + - kind: changed + description: "HTTPRoute configuration changed to a map of routes via httpRoutes{}. The previous httpRoute field has been removed (breaking change)!" artifacthub.io/links: | - name: Documentation for Sophora UGC url: https://subshell.com/docs/ugc/ diff --git a/charts/sophora-ugc/templates/httproute.yaml b/charts/sophora-ugc/templates/httproute.yaml index fc2c26b1..fd83c4a0 100644 --- a/charts/sophora-ugc/templates/httproute.yaml +++ b/charts/sophora-ugc/templates/httproute.yaml @@ -1,36 +1,40 @@ -{{- if .Values.httpRoute.enabled -}} - {{- $fullName := include "sophora-ugc.fullname" . -}} +{{- $fullName := include "sophora-ugc.fullname" . -}} +{{- $labels := include "sophora-ugc.labels" . -}} +{{- $svcPort := 80 -}} +{{- range $key := (.Values.httpRoutes | keys | sortAlpha) }} +{{- $httpRoute := index $.Values.httpRoutes $key }} apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: - name: {{ $fullName }} + name: {{ printf "%s-%s" $fullName $key | trunc 63 | trimSuffix "-" }} labels: - {{- include "sophora-ugc.labels" . | nindent 4 }} - {{- with .Values.httpRoute.annotations }} + {{- $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 }} + {{- range $httpRoute.hostnames }} - {{ . | quote }} {{- end }} {{- end }} rules: - backendRefs: - name: {{ $fullName }}-webapp - port: 80 - {{- 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 }} \ No newline at end of file diff --git a/charts/sophora-ugc/tests/httproute_test.yaml b/charts/sophora-ugc/tests/httproute_test.yaml index 0e7ae47a..16e88ebb 100644 --- a/charts/sophora-ugc/tests/httproute_test.yaml +++ b/charts/sophora-ugc/tests/httproute_test.yaml @@ -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-sophora-ugc - - equal: + name: values-test-release-sophora-ugc-primary + - documentIndex: 1 + containsDocument: + kind: HTTPRoute + apiVersion: gateway.networking.k8s.io/v1 + name: values-test-release-sophora-ugc-secondary + - documentIndex: 0 + equal: path: metadata value: - name: values-test-release-sophora-ugc + name: values-test-release-sophora-ugc-primary labels: helm.sh/chart: sophora-ugc-0.9.8 app.kubernetes.io/name: sophora-ugc @@ -35,7 +42,8 @@ tests: annotations: example.com/test: "simple" example.com/text: some text value - - equal: + - documentIndex: 0 + equal: path: spec value: parentRefs: @@ -58,4 +66,28 @@ tests: - path: type: PathPrefix value: / + - documentIndex: 1 + equal: + path: metadata + value: + name: values-test-release-sophora-ugc-secondary + labels: + helm.sh/chart: sophora-ugc-0.9.8 + app.kubernetes.io/name: sophora-ugc + 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-sophora-ugc-webapp + port: 80 - notFailedTemplate: {} diff --git a/charts/sophora-ugc/tests/values/httproute.yaml b/charts/sophora-ugc/tests/values/httproute.yaml index fa51e6cc..ee550638 100644 --- a/charts/sophora-ugc/tests/values/httproute.yaml +++ b/charts/sophora-ugc/tests/values/httproute.yaml @@ -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 \ No newline at end of file diff --git a/charts/sophora-ugc/values.yaml b/charts/sophora-ugc/values.yaml index dc948859..dd47f066 100644 --- a/charts/sophora-ugc/values.yaml +++ b/charts/sophora-ugc/values.yaml @@ -24,38 +24,31 @@ ingress: hosts: annotations: {} -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" -> "-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: {} authentication: secret: diff --git a/charts/sophora-webclient/Chart.yaml b/charts/sophora-webclient/Chart.yaml index 8fd6cff1..7c3d3b25 100644 --- a/charts/sophora-webclient/Chart.yaml +++ b/charts/sophora-webclient/Chart.yaml @@ -6,11 +6,11 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 1.5.1 +version: 1.6.0 annotations: artifacthub.io/changes: | - - kind: fixed - description: "Fixed port of Ingress backend." + - kind: changed + description: "HTTPRoute configuration changed to a map of routes via httpRoutes{}. The previous httpRoute field has been removed (breaking change)!" # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/charts/sophora-webclient/templates/httproute.yaml b/charts/sophora-webclient/templates/httproute.yaml index 0f8820e3..ed201304 100644 --- a/charts/sophora-webclient/templates/httproute.yaml +++ b/charts/sophora-webclient/templates/httproute.yaml @@ -1,36 +1,40 @@ -{{- if .Values.httpRoute.enabled -}} {{- $fullName := include "webclient.fullname" . -}} +{{- $labels := include "webclient.labels" . -}} +{{- $svcPort := .Values.service.port -}} +{{- range $key := (.Values.httpRoutes | keys | sortAlpha) }} +{{- $httpRoute := index $.Values.httpRoutes $key }} apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: - name: {{ $fullName }} + name: {{ printf "%s-%s" $fullName $key | trunc 63 | trimSuffix "-" }} labels: - {{- include "webclient.labels" . | nindent 4 }} - {{- with .Values.httpRoute.annotations }} + {{- $labels | nindent 4 }} + {{- with $httpRoute.annotations }} annotations: {{- 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 }} + {{- range $httpRoute.hostnames }} - {{ . | quote }} {{- end }} {{- end }} rules: - backendRefs: - name: {{ $fullName }} - port: {{ .Values.service.port }} - {{- 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 }} \ No newline at end of file diff --git a/charts/sophora-webclient/tests/httproute_test.yaml b/charts/sophora-webclient/tests/httproute_test.yaml index 82734e69..f0642030 100644 --- a/charts/sophora-webclient/tests/httproute_test.yaml +++ b/charts/sophora-webclient/tests/httproute_test.yaml @@ -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-sophora-webclient - - equal: + name: values-test-release-sophora-webclient-primary + - documentIndex: 1 + containsDocument: + kind: HTTPRoute + apiVersion: gateway.networking.k8s.io/v1 + name: values-test-release-sophora-webclient-secondary + - documentIndex: 0 + equal: path: metadata value: - name: values-test-release-sophora-webclient + name: values-test-release-sophora-webclient-primary labels: helm.sh/chart: sophora-webclient-0.9.8 app.kubernetes.io/name: sophora-webclient @@ -35,7 +42,8 @@ tests: annotations: example.com/test: "simple" example.com/text: some text value - - equal: + - documentIndex: 0 + equal: path: spec value: parentRefs: @@ -58,4 +66,28 @@ tests: - path: type: PathPrefix value: / + - documentIndex: 1 + equal: + path: metadata + value: + name: values-test-release-sophora-webclient-secondary + labels: + helm.sh/chart: sophora-webclient-0.9.8 + app.kubernetes.io/name: sophora-webclient + 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-sophora-webclient + port: 8080 - notFailedTemplate: {} diff --git a/charts/sophora-webclient/tests/values/httproute.yaml b/charts/sophora-webclient/tests/values/httproute.yaml index fa51e6cc..ee550638 100644 --- a/charts/sophora-webclient/tests/values/httproute.yaml +++ b/charts/sophora-webclient/tests/values/httproute.yaml @@ -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 \ No newline at end of file diff --git a/charts/sophora-webclient/values.yaml b/charts/sophora-webclient/values.yaml index cb800fd8..e93fafd1 100644 --- a/charts/sophora-webclient/values.yaml +++ b/charts/sophora-webclient/values.yaml @@ -50,38 +50,31 @@ ingress: hosts: annotations: {} -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" -> "-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: {} service: type: ClusterIP diff --git a/charts/sophora-youtube-connector/Chart.yaml b/charts/sophora-youtube-connector/Chart.yaml index ef2aa418..f298c46c 100644 --- a/charts/sophora-youtube-connector/Chart.yaml +++ b/charts/sophora-youtube-connector/Chart.yaml @@ -15,11 +15,11 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 1.4.0 +version: 1.5.0 annotations: artifacthub.io/changes: | - - kind: added - description: "Added extraInitContainers variable." + - kind: changed + description: "HTTPRoute configuration changed to a map of routes via httpRoutes{}. The previous httpRoute field has been removed (breaking change)!" artifacthub.io/links: | - name: Documentation for the AV Tool url: https://subshell.com/docs/avtool/ diff --git a/charts/sophora-youtube-connector/templates/httproute.yaml b/charts/sophora-youtube-connector/templates/httproute.yaml index 0b1ba4af..a852f6d5 100644 --- a/charts/sophora-youtube-connector/templates/httproute.yaml +++ b/charts/sophora-youtube-connector/templates/httproute.yaml @@ -1,24 +1,26 @@ -{{- if .Values.httpRoute.enabled -}} - {{- $fullName := include "sophora-youtube-connector.fullname" . -}} - {{- $svcPort := .Values.service.httpPort -}} +{{- $fullName := include "sophora-youtube-connector.fullname" . -}} +{{- $labels := include "sophora-youtube-connector.labels" . -}} +{{- $svcPort := .Values.service.httpPort -}} +{{- range $key := (.Values.httpRoutes | keys | sortAlpha) }} +{{- $httpRoute := index $.Values.httpRoutes $key }} apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: - name: {{ $fullName }} + name: {{ printf "%s-%s" $fullName $key | trunc 63 | trimSuffix "-" }} labels: - {{- include "sophora-youtube-connector.labels" . | nindent 4 }} - {{- with .Values.httpRoute.annotations }} + {{- $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 }} + {{- range $httpRoute.hostnames }} - {{ . | quote }} {{- end }} {{- end }} @@ -26,12 +28,13 @@ spec: - backendRefs: - name: {{ $fullName }} port: {{ $svcPort }} - {{- with .Values.httpRoute.matches }} + {{- with $httpRoute.matches }} matches: {{- toYaml . | nindent 8 }} {{- end }} - {{- with .Values.httpRoute.filters }} + {{- with $httpRoute.filters }} filters: {{- toYaml . | nindent 8 }} {{- end }} +--- {{- end }} diff --git a/charts/sophora-youtube-connector/tests/httproute_test.yaml b/charts/sophora-youtube-connector/tests/httproute_test.yaml index 5939ef3d..a4de605f 100644 --- a/charts/sophora-youtube-connector/tests/httproute_test.yaml +++ b/charts/sophora-youtube-connector/tests/httproute_test.yaml @@ -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-sophora-youtube-connector - - equal: + name: values-test-release-sophora-youtube-connector-primary + - documentIndex: 1 + containsDocument: + kind: HTTPRoute + apiVersion: gateway.networking.k8s.io/v1 + name: values-test-release-sophora-youtube-connector-secondary + - documentIndex: 0 + equal: path: metadata value: - name: values-test-release-sophora-youtube-connector + name: values-test-release-sophora-youtube-connector-primary labels: helm.sh/chart: sophora-youtube-connector-0.9.8 app.kubernetes.io/name: sophora-youtube-connector @@ -35,7 +42,8 @@ tests: annotations: example.com/test: "simple" example.com/text: some text value - - equal: + - documentIndex: 0 + equal: path: spec value: parentRefs: @@ -58,4 +66,28 @@ tests: - path: type: PathPrefix value: / + - documentIndex: 1 + equal: + path: metadata + value: + name: values-test-release-sophora-youtube-connector-secondary + labels: + helm.sh/chart: sophora-youtube-connector-0.9.8 + app.kubernetes.io/name: sophora-youtube-connector + 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-sophora-youtube-connector + port: 8080 - notFailedTemplate: {} diff --git a/charts/sophora-youtube-connector/tests/values/httproute.yaml b/charts/sophora-youtube-connector/tests/values/httproute.yaml index fa51e6cc..ee550638 100644 --- a/charts/sophora-youtube-connector/tests/values/httproute.yaml +++ b/charts/sophora-youtube-connector/tests/values/httproute.yaml @@ -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 \ No newline at end of file diff --git a/charts/sophora-youtube-connector/values.yaml b/charts/sophora-youtube-connector/values.yaml index 656355b9..683bb4a5 100644 --- a/charts/sophora-youtube-connector/values.yaml +++ b/charts/sophora-youtube-connector/values.yaml @@ -46,38 +46,31 @@ ingress: hosts: tls: [] -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" -> "-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: {} serviceAccount: create: