-
Notifications
You must be signed in to change notification settings - Fork 742
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(gateway-api): Add custom backendRef and filters support for HTTPRoute #1742
Open
kahirokunn
wants to merge
2
commits into
fluxcd:main
Choose a base branch
from
kahirokunn:custom-http-route
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,221
−135
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
/* | ||
Copyright 2021 The Kubernetes Authors. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package v1beta1 | ||
|
||
import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
||
// +genclient | ||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
// +kubebuilder:object:root=true | ||
// +kubebuilder:resource:categories=gateway-api,shortName=refgrant | ||
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp` | ||
// +kubebuilder:storageversion | ||
|
||
// ReferenceGrant identifies kinds of resources in other namespaces that are | ||
// trusted to reference the specified kinds of resources in the same namespace | ||
// as the policy. | ||
// | ||
// Each ReferenceGrant can be used to represent a unique trust relationship. | ||
// Additional Reference Grants can be used to add to the set of trusted | ||
// sources of inbound references for the namespace they are defined within. | ||
// | ||
// All cross-namespace references in Gateway API (with the exception of cross-namespace | ||
// Gateway-route attachment) require a ReferenceGrant. | ||
// | ||
// ReferenceGrant is a form of runtime verification allowing users to assert | ||
// which cross-namespace object references are permitted. Implementations that | ||
// support ReferenceGrant MUST NOT permit cross-namespace references which have | ||
// no grant, and MUST respond to the removal of a grant by revoking the access | ||
// that the grant allowed. | ||
type ReferenceGrant struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
// Spec defines the desired state of ReferenceGrant. | ||
Spec ReferenceGrantSpec `json:"spec,omitempty"` | ||
|
||
// Note that `Status` sub-resource has been excluded at the | ||
// moment as it was difficult to work out the design. | ||
// `Status` sub-resource may be added in future. | ||
} | ||
|
||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
// +kubebuilder:object:root=true | ||
// ReferenceGrantList contains a list of ReferenceGrant. | ||
type ReferenceGrantList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []ReferenceGrant `json:"items"` | ||
} | ||
|
||
// ReferenceGrantSpec identifies a cross namespace relationship that is trusted | ||
// for Gateway API. | ||
type ReferenceGrantSpec struct { | ||
// From describes the trusted namespaces and kinds that can reference the | ||
// resources described in "To". Each entry in this list MUST be considered | ||
// to be an additional place that references can be valid from, or to put | ||
// this another way, entries MUST be combined using OR. | ||
// | ||
// Support: Core | ||
// | ||
// +kubebuilder:validation:MinItems=1 | ||
// +kubebuilder:validation:MaxItems=16 | ||
From []ReferenceGrantFrom `json:"from"` | ||
|
||
// To describes the resources that may be referenced by the resources | ||
// described in "From". Each entry in this list MUST be considered to be an | ||
// additional place that references can be valid to, or to put this another | ||
// way, entries MUST be combined using OR. | ||
// | ||
// Support: Core | ||
// | ||
// +kubebuilder:validation:MinItems=1 | ||
// +kubebuilder:validation:MaxItems=16 | ||
To []ReferenceGrantTo `json:"to"` | ||
} | ||
|
||
// ReferenceGrantFrom describes trusted namespaces and kinds. | ||
type ReferenceGrantFrom struct { | ||
// Group is the group of the referent. | ||
// When empty, the Kubernetes core API group is inferred. | ||
// | ||
// Support: Core | ||
Group Group `json:"group"` | ||
|
||
// Kind is the kind of the referent. Although implementations may support | ||
// additional resources, the following types are part of the "Core" | ||
// support level for this field. | ||
// | ||
// When used to permit a SecretObjectReference: | ||
// | ||
// * Gateway | ||
// | ||
// When used to permit a BackendObjectReference: | ||
// | ||
// * GRPCRoute | ||
// * HTTPRoute | ||
// * TCPRoute | ||
// * TLSRoute | ||
// * UDPRoute | ||
Kind Kind `json:"kind"` | ||
|
||
// Namespace is the namespace of the referent. | ||
// | ||
// Support: Core | ||
Namespace Namespace `json:"namespace"` | ||
} | ||
|
||
// ReferenceGrantTo describes what Kinds are allowed as targets of the | ||
// references. | ||
type ReferenceGrantTo struct { | ||
// Group is the group of the referent. | ||
// When empty, the Kubernetes core API group is inferred. | ||
// | ||
// Support: Core | ||
Group Group `json:"group"` | ||
|
||
// Kind is the kind of the referent. Although implementations may support | ||
// additional resources, the following types are part of the "Core" | ||
// support level for this field: | ||
// | ||
// * Secret when used to permit a SecretObjectReference | ||
// * Service when used to permit a BackendObjectReference | ||
Kind Kind `json:"kind"` | ||
|
||
// Name is the name of the referent. When unspecified, this policy | ||
// refers to all resources of the specified Group and Kind in the local | ||
// namespace. | ||
// | ||
// +optional | ||
Name *ObjectName `json:"name,omitempty"` | ||
} |
This file contains 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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets avoid adding this in the same place as kubernetes service configuration (
CustomMetadata
).BackendObjectReference
andFilters
fall under a different abstraction.my suggestion would be to add two fields to
CanaryService
,PrimaryHTTPBackendRef
andCanaryHTTPBackendRef
both of typev1.HTTPBackendRef
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your helpful suggestion. I will make the changes accordingly by introducing two new fields, PrimaryHTTPBackendRef and CanaryHTTPBackendRef, both of type v1.HTTPBackendRef, ensuring that they reside in the correct abstraction layer. Please let me know if there is anything else I can improve or clarify.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aryan9600 Thank you for the suggestion. However, when using
v1.HTTPBackendRef
, we are required to provide a name even if we only want to customize the filters, since the name field in BackendObjectReference is not optional. We feel this may not be the most optimal interface design, which is why we initially split backendRef and filters in our PR. What are your thoughts on addressing this concern?