-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbackendtrafficpolicy_types.go
More file actions
91 lines (78 loc) · 3.38 KB
/
backendtrafficpolicy_types.go
File metadata and controls
91 lines (78 loc) · 3.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package v1alpha1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
gatewayv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2"
)
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
type BackendTrafficPolicy struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec BackendTrafficPolicySpec `json:"spec,omitempty"`
Status gatewayv1alpha2.PolicyStatus `json:"status,omitempty"`
}
type BackendTrafficPolicySpec struct {
// TargetRef identifies an API object to apply policy to.
// Currently, Backends (i.e. Service, ServiceImport, or any
// implementation-specific backendRef) are the only valid API
// target references.
// +listType=map
// +listMapKey=group
// +listMapKey=kind
// +listMapKey=name
// +kubebuilder:validation:MinItems=1
// +kubebuilder:validation:MaxItems=16
TargetRefs []gatewayv1alpha2.LocalPolicyTargetReferenceWithSectionName `json:"targetRefs"`
// LoadBalancer represents the load balancer configuration for Kubernetes Service.
// The default strategy is round robin.
LoadBalancer *LoadBalancer `json:"loadbalancer,omitempty" yaml:"loadbalancer,omitempty"`
// The scheme used to talk with the upstream.
//
// +kubebuilder:validation:Enum=http;https;grpc;grpcs;
// +kubebuilder:default=http
Scheme string `json:"scheme,omitempty" yaml:"scheme,omitempty"`
// How many times that the proxy (Apache APISIX) should do when
// errors occur (error, timeout or bad http status codes like 500, 502).
// +optional
Retries *int `json:"retries,omitempty" yaml:"retries,omitempty"`
// Timeout settings for the read, send and connect to the upstream.
Timeout *Timeout `json:"timeout,omitempty" yaml:"timeout,omitempty"`
// Configures the host when the request is forwarded to the upstream.
// Can be one of pass, node or rewrite.
//
// +kubebuilder:validation:Enum=pass;node;rewrite;
// +kubebuilder:default=pass
PassHost string `json:"pass_host,omitempty" yaml:"pass_host,omitempty"`
// Specifies the host of the Upstream request. This is only valid if
// the pass_host is set to rewrite
Host Hostname `json:"upstream_host,omitempty" yaml:"upstream_host,omitempty"`
}
// LoadBalancer describes the load balancing parameters.
// +kubebuilder:validation:XValidation:rule="!(has(self.key) && self.type != 'chash')"
type LoadBalancer struct {
// +kubebuilder:validation:Enum=roundrobin;chash;ewma;least_conn;
// +kubebuilder:default=roundrobin
// +kubebuilder:validation:Required
Type string `json:"type" yaml:"type"`
// The HashOn and Key fields are required when Type is "chash".
// HashOn represents the key fetching scope.
// +kubebuilder:validation:Enum=vars;header;cookie;consumer;vars_combinations;
// +kubebuilder:default=vars
HashOn string `json:"hashOn,omitempty" yaml:"hashOn,omitempty"`
// Key represents the hash key.
Key string `json:"key,omitempty" yaml:"key,omitempty"`
}
type Timeout struct {
Connect metav1.Duration `json:"connect,omitempty" yaml:"connect,omitempty"`
Send metav1.Duration `json:"send,omitempty" yaml:"send,omitempty"`
Read metav1.Duration `json:"read,omitempty" yaml:"read,omitempty"`
}
// +kubebuilder:object:root=true
type BackendTrafficPolicyList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []BackendTrafficPolicy `json:"items"`
}
func init() {
SchemeBuilder.Register(&BackendTrafficPolicy{}, &BackendTrafficPolicyList{})
}