Skip to content

Commit ec68d7e

Browse files
committed
Add ProxySettingPolicy API and CRDs
1 parent 0212980 commit ec68d7e

File tree

7 files changed

+1110
-0
lines changed

7 files changed

+1110
-0
lines changed

apis/v1alpha1/policy_methods.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,18 @@ func (p *ClientSettingsPolicy) SetPolicyStatus(status gatewayv1.PolicyStatus) {
2020
p.Status = status
2121
}
2222

23+
func (p *ProxySettingsPolicy) GetTargetRefs() []gatewayv1.LocalPolicyTargetReference {
24+
return p.Spec.TargetRefs
25+
}
26+
27+
func (p *ProxySettingsPolicy) GetPolicyStatus() gatewayv1.PolicyStatus {
28+
return p.Status
29+
}
30+
31+
func (p *ProxySettingsPolicy) SetPolicyStatus(status gatewayv1.PolicyStatus) {
32+
p.Status = status
33+
}
34+
2335
func (p *UpstreamSettingsPolicy) GetTargetRefs() []gatewayv1.LocalPolicyTargetReference {
2436
return p.Spec.TargetRefs
2537
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
package v1alpha1
2+
3+
import (
4+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
5+
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"
6+
)
7+
8+
// +genclient
9+
// +kubebuilder:object:root=true
10+
// +kubebuilder:storageversion
11+
// +kubebuilder:subresource:status
12+
// +kubebuilder:resource:categories=nginx-gateway-fabric,shortName=pspolicy
13+
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`
14+
// +kubebuilder:metadata:labels="gateway.networking.k8s.io/policy=inherited"
15+
16+
// ProxySettingsPolicy is an Inherited Attached Policy. It provides a way to configure the behavior of the connection
17+
// between NGINX Gateway Fabric and the upstream applications (backends).
18+
type ProxySettingsPolicy struct {
19+
metav1.TypeMeta `json:",inline"`
20+
metav1.ObjectMeta `json:"metadata,omitempty"`
21+
22+
// Spec defines the desired state of the ProxySettingsPolicy.
23+
Spec ProxySettingsPolicySpec `json:"spec"`
24+
25+
// Status defines the state of the ProxySettingsPolicy.
26+
Status gatewayv1.PolicyStatus `json:"status,omitempty"`
27+
}
28+
29+
// +kubebuilder:object:root=true
30+
31+
// ProxySettingsPolicyList contains a list of ProxySettingsPolicies.
32+
type ProxySettingsPolicyList struct {
33+
metav1.TypeMeta `json:",inline"`
34+
metav1.ListMeta `json:"metadata,omitempty"`
35+
Items []ProxySettingsPolicy `json:"items"`
36+
}
37+
38+
// ProxySettingsPolicySpec defines the desired state of the ProxySettingsPolicy.
39+
type ProxySettingsPolicySpec struct {
40+
Buffering *ProxyBuffering `json:"buffering,omitempty"`
41+
TargetRefs []gatewayv1.LocalPolicyTargetReference `json:"targetRefs"`
42+
}
43+
44+
// ProxyBuffering contains the settings for proxy buffering.
45+
type ProxyBuffering struct {
46+
// Disable enables or disables buffering of responses from the proxied server.
47+
// If Disable is true, buffering is disabled. If Disable is false, or if Disable is not set, buffering is enabled.
48+
// Directive: https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_buffering
49+
//
50+
// +optional
51+
Disable *bool `json:"disable,omitempty"`
52+
53+
// BufferSize sets the size of the buffer used for reading the first part of the response received from
54+
// the proxied server. This part usually contains a small response header.
55+
// Default: https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_buffer_size
56+
// Directive: https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_buffer_size
57+
//
58+
// +optional
59+
BufferSize *Size `json:"bufferSize,omitempty"`
60+
61+
// Buffers sets the number and size of buffers used for reading a response from the proxied server,
62+
// for a single connection.
63+
// Default: https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_buffers
64+
// Directive: https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_buffers
65+
//
66+
// +optional
67+
Buffers *ProxyBuffers `json:"buffers,omitempty"`
68+
69+
// BusyBuffersSize sets the total size of buffers that can be busy sending a response to the client,
70+
// while the response is not yet fully read.
71+
// Default: https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_busy_buffers_size
72+
// Directive: https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_busy_buffers_size
73+
//
74+
// +optional
75+
BusyBuffersSize *Size `json:"busyBuffersSize,omitempty"`
76+
}
77+
78+
// ProxyBuffers defines the number and size of the proxy buffers.
79+
type ProxyBuffers struct {
80+
Size Size `json:"size"`
81+
Number int32 `json:"number"`
82+
}

apis/v1alpha1/register.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ func addKnownTypes(scheme *runtime.Scheme) error {
3636
&NginxGatewayList{},
3737
&ClientSettingsPolicy{},
3838
&ClientSettingsPolicyList{},
39+
&ProxySettingsPolicy{},
40+
&ProxySettingsPolicyList{},
3941
&SnippetsFilter{},
4042
&SnippetsFilterList{},
4143
&UpstreamSettingsPolicy{},

apis/v1alpha1/zz_generated.deepcopy.go

Lines changed: 134 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)