add gateway HTTPRoute support #829#831
Closed
DanielRaapDev wants to merge 5 commits into
Closed
Conversation
== Prompt for Copilot with Claude Sonnet 4.6:
This Kubernetes CustomResourceDefinition for a SolrCloud resource should be extended. Like the support for `Ingress` it should be possible to specify `HTTPRoute` settings of the Gateway API. The CRD should support a list of HTTPRoutes to optionally generate multiple kubernetes resources.
A simple example of a HTTPRoute resource looks like the following:
```
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: example-route
spec:
parentRefs:
- name: example-gateway
hostnames:
- "example.com"
rules:
- backendRefs:
- name: example-svc
port: 80
```
Some information about the gateway API about routing rules:
- The path-based routing rules of the Ingress resource map directly to the routing rules of the HTTPRoute.
- In Gateway API, TLS termination is a property of the Gateway listener, and similarly to the Ingress, a TLS certificate and key are also stored in a Secret.
- Because the listener is part of the Gateway resource, the cluster operator and application admin own TLS termination.
- HTTPRoutes are owned by the application developer.
- The Ingress default backend configures a backend that will respond to all unmatched HTTP requests related to that Ingress resource. Gateway API does not have a direct equivalent: it is necessary to define such a routing rule explicitly.
We just want support for HTTPRoutes as application developer. The Gateway specification is out of scope for this change.
Here is an example how to convert a Ingress to HTTPRoute:
The Ingress below will be converted as an example:
```
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: example-ingress
annotations:
example-ingress-controller.example.org/tls-redirect: "True"
spec:
ingressClassName: prod
tls:
- hosts:
- foo.example.com
- bar.example.com
secretName: example-com
rules:
- host: foo.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: foo-app
port:
number: 80
- path: /orders
pathType: Prefix
backend:
service:
name: foo-orders-app
port:
number: 80
- host: bar.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: bar-app
port:
number: 80
```
The Ingress is split into two HTTPRoutes – one for foo.example.com and one for bar.example.com hostnames.
```
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: foo
spec:
parentRefs:
- name: example-gateway
sectionName: https
hostnames:
- foo.example.com
rules:
- matches:
- path:
type: PathPrefix
value: /
backendRefs:
- name: foo-app
port: 80
- matches:
- path:
type: PathPrefix
value: /orders
backendRefs:
- name: foo-orders-app
port: 80
```
== Summary of Copilot changes
Changes Made
1. `api/v1beta1/common_types.go` — Two new types added:
• `HTTPRouteOptions`: Defines the options for a single HTTPRoute resource to be generated. Fields:
• name (required) — the name of the Kubernetes HTTPRoute resource
• annotations — metadata annotations
• labels — metadata labels
• parentRefs — list of parent Gateway references to attach the route to
• hostnames — hostnames this route should match
• `HTTPRouteParentReference`: Defines a reference to a parent Gateway resource. Fields:
• name (required) — Gateway name
• group — API group (defaults to gateway.networking.k8s.io)
• kind — resource kind (defaults to Gateway)
• namespace — Gateway namespace
• sectionName — specific listener name on the Gateway
• port — target port on the Gateway
2. `api/v1beta1/solrcloud_types.go` — Added to CustomSolrKubeOptions:
```
HTTPRouteOptions []HTTPRouteOptions `json:"httpRouteOptions,omitempty"`
```
A separate HTTPRoute Kubernetes resource will be generated for each entry in this list.
3. `api/v1beta1/zz_generated.deepcopy.go` — Added proper DeepCopyInto/DeepCopy implementations for both HTTPRouteOptions and HTTPRouteParentReference, and extended CustomSolrKubeOptions.DeepCopyInto to handle the new slice field.
4. `config/crd/bases/solr.apache.org_solrclouds.yaml` — Added the full OpenAPI v3 schema for httpRouteOptions (as an array) within the customSolrKubeOptions properties section.
Contributor
|
How is this related to #815 ? |
Contributor
Author
|
Oh I missed that PR. Seems this is a duplicate that is not as fully featured as that one. |
Contributor
|
I'll close this one then. Perhaps you want to lend a hand to get #815 over the finish line by reviewing and testing that solution? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
resolves #829
disclaimer: I am not a Go developer (but Java). I used Copilot (model Claude Sonnet 4.6) to generate this changes based on my specifications.
httpRouteOptionsto CRD ofSolrCloudHTTPRouteas specified.TODO