-
Notifications
You must be signed in to change notification settings - Fork 9
/
gateway_types.go
185 lines (150 loc) · 6.17 KB
/
gateway_types.go
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
/*
Copyright (c) 2022 Nordix Foundation
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 v1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
)
// GatewaySpec defines the desired state of Gateway
type GatewaySpec struct {
// Address of the Gateway Router
Address string `json:"address"`
// +kubebuilder:default=bgp
// +kubebuilder:validation:Enum=bgp;static
// The routing choice between the Gateway Router and Attractor FrontEnds.
// +optional
Protocol string `json:"protocol,omitempty"`
// Parameters to set up the BGP session to specified Address.
// If the Protocol is static, this property must be empty.
// If the Protocol is bgp, the minimal parameters to be defined in bgp properties
// are RemoteASN and LocalASN
// +optional
Bgp BgpSpec `json:"bgp,omitempty"`
// Parameters to work with the static routing configured on the Gateway Router with specified Address.
// If the Protocol is bgp, this property must be empty.
// +optional
Static StaticSpec `json:"static,omitempty"`
}
// BgpSpec defines the parameters to set up a BGP session
type BgpSpec struct {
// The ASN number of the Gateway Router
RemoteASN *uint32 `json:"remote-asn,omitempty"`
// The ASN number of the system where the Attractor FrontEnds locates
LocalASN *uint32 `json:"local-asn,omitempty"`
// BFD monitoring of BGP session.
// +optional
BFD BfdSpec `json:"bfd,omitempty"`
// Hold timer of the BGP session. Please refere to BGP material to understand what this implies.
// The value must be a valid duration format. For example, 90s, 1m, 1h.
// The duration will be rounded by second
// Minimum duration is 3s.
// +optional
HoldTime string `json:"hold-time,omitempty"`
// BGP listening port of the Gateway Router.
// +optional
RemotePort *uint16 `json:"remote-port,omitempty"`
// BGP listening port of the Attractor FrontEnds.
// +optional
LocalPort *uint16 `json:"local-port,omitempty"`
// BGP authentication (RFC2385).
// +optional
Auth *BgpAuth `json:"auth,omitempty"`
}
// StaticSpec defines the parameters to set up static routes
type StaticSpec struct {
// BFD monitoring of Static session.
// +optional
BFD BfdSpec `json:"bfd,omitempty"`
}
// Bfd defines the parameters to configure the BFD session
// The static gateways shares the same interface shall define the same bfd configuration
type BfdSpec struct {
// BFD monitoring.
// Valid values are:
// - false: no BFD monitoring;
// - true: turns on the BFD monitoring.
// When left empty, there is no BFD monitoring.
// +optional
Switch *bool `json:"switch,omitempty"`
// Min-tx timer of bfd session. Please refere to BFD material to understand what this implies.
// The value must be a valid duration format. For example, 300ms, 90s, 1m, 1h.
// The duration will be rounded by millisecond.
// +optional
MinTx string `json:"min-tx,omitempty"`
// Min-rx timer of bfd session. Please refere to BFD material to understand what this implies.
// The value must be a valid duration format. For example, 300ms, 90s, 1m, 1h.
// The duration will be rounded by millisecond.
// +optional
MinRx string `json:"min-rx,omitempty"`
// Multiplier of bfd session.
// When this number of bfd packets failed to receive, bfd session will go down.
// +optional
Multiplier *uint16 `json:"multiplier,omitempty"`
}
// BgpAuth defines the parameters to configure BGP authentication
type BgpAuth struct {
// +kubebuilder:validation:Type=string
// +kubebuilder:validation:Pattern=`^[-._a-zA-Z0-9]+$`
// Name of the BGP authentication key, used internally as a reference.
// KeyName is a key in the data section of a Secret. The associated value in
// the Secret is the password (pre-shared key) to be used for authentication.
// Must consist of alphanumeric characters, ".", "-" or "_".
KeyName string `json:"key-name,omitempty"`
// +kubebuilder:validation:Type=string
// +kubebuilder:validation:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$`
// +kubebuilder:validation:MaxLength=253
// Name of the kubernetes Secret containing the password (pre-shared key)
// that can be looked up based on KeyName.
// Must be a valid lowercase RFC 1123 subdomain. (Must consist of lower case alphanumeric
// characters, '-' or '.', and must start and end with an alphanumeric character.)
KeySource string `json:"key-source,omitempty"`
}
// GatewayStatus defines the observed state of Gateway
type GatewayStatus struct {
}
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:storageversion
//+kubebuilder:printcolumn:name="address",type=string,JSONPath=`.spec.address`
//+kubebuilder:printcolumn:name="protocol",type=string,JSONPath=`.spec.protocol`
//+kubebuilder:printcolumn:name="trench",type=string,JSONPath=`.metadata.labels.trench`
// Gateway is the Schema for the gateways API. It defines protocol settings
// enabling communication with Gateway Router through which traffic is to be conveyed.
type Gateway struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec GatewaySpec `json:"spec,omitempty"`
Status GatewayStatus `json:"status,omitempty"`
}
//+kubebuilder:object:root=true
// GatewayList contains a list of Gateway
type GatewayList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Gateway `json:"items"`
}
func (r *Gateway) GroupResource() schema.GroupResource {
return schema.GroupResource{
Group: r.GroupVersionKind().Group,
Resource: r.GroupVersionKind().Kind,
}
}
func (r *Gateway) GroupKind() schema.GroupKind {
return schema.GroupKind{
Group: r.GroupVersionKind().Group,
Kind: r.GroupVersionKind().Kind,
}
}
func init() {
SchemeBuilder.Register(&Gateway{}, &GatewayList{})
}