-
Notifications
You must be signed in to change notification settings - Fork 123
Add UpstreamSettingsPolicy CRD #2515
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
Merged
bjee19
merged 10 commits into
nginx:feature/upstream-settings-policy
from
bjee19:enh/upstream-settings-policy-crd
Sep 10, 2024
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
4fa4764
Add upstream settings policy crd
bjee19 fea6edb
Move around formatting
bjee19 0113078
Change connections minimum to 1
bjee19 5c4f1b5
Adjust TargetRefs group validation and add MinItems validation
bjee19 426aa4b
Revert "Adjust TargetRefs group validation and add MinItems validation"
bjee19 9592cc9
Adjust TargetRefs group validation and add MinItems validation
bjee19 c13d4f9
Remove period from validation message
bjee19 e892095
Fix validation typo
bjee19 9c53d99
Add example policy
bjee19 186f2bf
Fix rebase issues
bjee19 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
package v1alpha1 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
gatewayv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" | ||
) | ||
|
||
// +genclient | ||
// +kubebuilder:object:root=true | ||
// +kubebuilder:storageversion | ||
// +kubebuilder:subresource:status | ||
// +kubebuilder:resource:categories=nginx-gateway-fabric,scope=Namespaced,shortName=uspolicy | ||
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp` | ||
// +kubebuilder:metadata:labels="gateway.networking.k8s.io/policy=direct" | ||
|
||
// UpstreamSettingsPolicy is a Direct Attached Policy. It provides a way to configure the behavior of | ||
// the connection between NGINX and the upstream applications. | ||
type UpstreamSettingsPolicy struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
// Spec defines the desired state of the UpstreamSettingsPolicy. | ||
Spec UpstreamSettingsPolicySpec `json:"spec"` | ||
|
||
// Status defines the state of the UpstreamSettingsPolicy. | ||
Status gatewayv1alpha2.PolicyStatus `json:"status,omitempty"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
|
||
// UpstreamSettingsPolicyList contains a list of UpstreamSettingsPolicies. | ||
type UpstreamSettingsPolicyList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []UpstreamSettingsPolicy `json:"items"` | ||
} | ||
|
||
// UpstreamSettingsPolicySpec defines the desired state of the UpstreamSettingsPolicy. | ||
type UpstreamSettingsPolicySpec struct { | ||
// ZoneSize is the size of the shared memory zone used by the upstream. This memory zone is used to share | ||
// the upstream configuration between nginx worker processes. The more servers that an upstream has, | ||
// the larger memory zone is required. | ||
// Default: OSS: 512k, Plus: 1m. | ||
// Directive: https://nginx.org/en/docs/http/ngx_http_upstream_module.html#zone | ||
// | ||
// +optional | ||
ZoneSize *Size `json:"zoneSize,omitempty"` | ||
|
||
// KeepAlive defines the keep-alive settings. | ||
// | ||
// +optional | ||
KeepAlive *UpstreamKeepAlive `json:"keepAlive,omitempty"` | ||
|
||
// TargetRefs identifies API object(s) to apply the policy to. | ||
// Objects must be in the same namespace as the policy. | ||
// Support: Service | ||
// | ||
// +kubebuilder:validation:MinItems=1 | ||
// +kubebuilder:validation:MaxItems=16 | ||
// +kubebuilder:validation:XValidation:message="TargetRefs Kind must be: Service",rule="self.all(t, t.kind=='Service')" | ||
// +kubebuilder:validation:XValidation:message="TargetRefs Group must be core",rule="self.exists(t, t.group=='') || self.exists(t, t.group=='core')" | ||
//nolint:lll | ||
TargetRefs []gatewayv1alpha2.LocalPolicyTargetReference `json:"targetRefs"` | ||
} | ||
|
||
// UpstreamKeepAlive defines the keep-alive settings for upstreams. | ||
type UpstreamKeepAlive struct { | ||
// Connections sets the maximum number of idle keep-alive connections to upstream servers that are preserved | ||
// in the cache of each nginx worker process. When this number is exceeded, the least recently used | ||
// connections are closed. | ||
// Directive: https://nginx.org/en/docs/http/ngx_http_upstream_module.html#keepalive | ||
// | ||
// +optional | ||
// +kubebuilder:validation:Minimum=1 | ||
Connections *int32 `json:"connections,omitempty"` | ||
|
||
// Requests sets the maximum number of requests that can be served through one keep-alive connection. | ||
// After the maximum number of requests are made, the connection is closed. | ||
// Directive: https://nginx.org/en/docs/http/ngx_http_upstream_module.html#keepalive_requests | ||
// | ||
// +optional | ||
// +kubebuilder:validation:Minimum=0 | ||
Requests *int32 `json:"requests,omitempty"` | ||
|
||
// Time defines the maximum time during which requests can be processed through one keep-alive connection. | ||
// After this time is reached, the connection is closed following the subsequent request processing. | ||
// Directive: https://nginx.org/en/docs/http/ngx_http_upstream_module.html#keepalive_time | ||
// | ||
// +optional | ||
Time *Duration `json:"time,omitempty"` | ||
|
||
// Timeout defines the keep-alive timeout for upstreams. | ||
// Directive: https://nginx.org/en/docs/http/ngx_http_upstream_module.html#keepalive_timeout | ||
// | ||
// +optional | ||
Timeout *Duration `json:"timeout,omitempty"` | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.