Skip to content

Commit 7641762

Browse files
Added l4lb resource (#25)
* fix: use vnet name in log messages instead of vnetmeta name * test: update deprecated zap logger code * feat: add ebgp crd. describe ebgp structs * update: netrisapi package update * update: netrisapi package update * update: netrisapi package update * update: netrisapi package update * feat: add ebgp store in netris storage * feat: create ebgpmeta crd * ebgp controller logic template * ebgp reconcile logic. delete ebgp, delete CRs. status patch * feat: ebgp to ebgpMeta translations * license: change year of copyright. * update: netrisapi package update * added l4lb sample * feat: add l4lb CR * fix: l4lb logger default * fix: comment ebgp unused code * feat: add l4lbmeta CR * feat: add l4lb CR reconcile logic * added rbac for pod, node and svc * feat: add l4lband l4lbmeta reconcile logic and data translations * refactor: fix l4lb and l4lbmeta reconcile logic and data translations * feat: add l4lb internal field in sample readme * feat: l4lb internal field support * update: netrisapi package update * feat: status messages improvement * update: netrisapi package update * update: netrisapi package update * feat: add l4lb backends comparison * fix: internl field default value in samples readme * fix: remove 'internal' field from l4lb * fix: remove 'internal' field from l4lb CRD * fix: l4lb: set healthchekc default values * fix: l4lb: set default value for protocol field * fix: l4lb: protocol field related validations and default values * fix: delete subnet field from l4lb frontend section * fix: l4lb: handle automatic and manual ip addresses assignment * type: l4lb samples Co-authored-by: Artashes Balabekyan <[email protected]>
1 parent 3fff74a commit 7641762

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+4137
-70
lines changed

PROJECT

+12
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@ resources:
99
- group: k8s
1010
kind: VNetMeta
1111
version: v1alpha1
12+
- group: k8s
13+
kind: EBGP
14+
version: v1alpha1
15+
- group: k8s
16+
kind: EBGPMeta
17+
version: v1alpha1
18+
- group: k8s
19+
kind: L4LB
20+
version: v1alpha1
21+
- group: k8s
22+
kind: L4LBMeta
23+
version: v1alpha1
1224
version: 3-alpha
1325
plugins:
1426
go.sdk.operatorframework.io/v2-alpha: {}

api/v1alpha1/ebgp_types.go

+113
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
/*
2+
Copyright 2021. Netris, Inc.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1alpha1
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
)
22+
23+
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
24+
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
25+
26+
// EBGPStatus defines the observed state of EBGP
27+
type EBGPStatus struct {
28+
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
29+
// Important: Run "make" to regenerate code after modifying this file
30+
31+
Status string `json:"status,omitempty"`
32+
Message string `json:"message,omitempty"`
33+
}
34+
35+
// EBGPSpec defines the desired state of EBGP
36+
type EBGPSpec struct {
37+
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
38+
// Important: Run "make" to regenerate code after modifying this file
39+
40+
Site string `json:"site"`
41+
Softgate string `json:"softgate"`
42+
NeighborAS int `json:"neighborAs"`
43+
Transport EBGPTransport `json:"transport"`
44+
45+
// +kubebuilder:validation:Pattern=`(^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\/([0-9]|[12]\d|3[0-2]))?$)|(^((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?(\/([1-9]|[1-5][0-9]|6[0-4]))?$)`
46+
LocalIP string `json:"localIP"`
47+
48+
// +kubebuilder:validation:Pattern=`(^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0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,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?(\/([1-9]|[1-5][0-9]|6[0-4]))?$)`
49+
RemoteIP string `json:"remoteIP"`
50+
Description string `json:"description,omitempty"`
51+
52+
// +kubebuilder:validation:Enum=enabled;disabled
53+
State string `json:"state,omitempty"`
54+
TerminateOnSwitch bool `json:"terminateOnSwitch,omitempty"`
55+
Multihop EBGPMultihop `json:"multihop,omitempty"`
56+
BGPPassword string `json:"bgpPassword,omitempty"`
57+
AllowAsIn int `json:"allowAsIn,omitempty"`
58+
DefaultOriginate bool `json:"defaultOriginate,omitempty"`
59+
PrefixInboundMax int `json:"prefixInboundMax,omitempty"`
60+
InboundRouteMap string `json:"inboundRouteMap,omitempty"`
61+
OutboundRouteMap string `json:"outboundRouteMap,omitempty"`
62+
LocalPreference int `json:"localPreference,omitempty"`
63+
Weight int `json:"weight,omitempty"`
64+
PrependInbound int `json:"prependInbound,omitempty"`
65+
PrependOutbound int `json:"prependOutbound,omitempty"`
66+
PrefixListInbound []string `json:"prefixListInbound,omitempty"`
67+
PrefixListOutbound []string `json:"prefixListOutbound,omitempty"`
68+
SendBGPCommunity []string `json:"sendBGPCommunity,omitempty"`
69+
}
70+
71+
// EBGPMultihop .
72+
type EBGPMultihop struct {
73+
// +kubebuilder:validation:Pattern=`(^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\/([0-9]|[12]\d|3[0-2]))?$)|(^((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?(\/([1-9]|[1-5][0-9]|6[0-4]))?$)`
74+
NeighborAddress string `json:"neighborAddress,omitempty"`
75+
76+
// +kubebuilder:validation:Pattern=`(^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0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,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?(\/([1-9]|[1-5][0-9]|6[0-4]))?$)`
77+
UpdateSource string `json:"updateSource,omitempty"`
78+
Hops int `json:"hops,omitempty"`
79+
}
80+
81+
// EBGPTransport .
82+
type EBGPTransport struct {
83+
// +kubebuilder:validation:Enum=port;vnet
84+
Type string `json:"type,omitempty"`
85+
// +kubebuilder:validation:Pattern=`(^[a-zA-Z0-9]+@[a-zA-Z0-9-]+$)|(^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$)`
86+
Name string `json:"name"`
87+
VlanID int `json:"vlanId,omitempty"`
88+
}
89+
90+
// +kubebuilder:object:root=true
91+
// +kubebuilder:subresource:status
92+
93+
// EBGP is the Schema for the ebgps API
94+
type EBGP struct {
95+
metav1.TypeMeta `json:",inline"`
96+
metav1.ObjectMeta `json:"metadata,omitempty"`
97+
98+
Spec EBGPSpec `json:"spec,omitempty"`
99+
Status EBGPStatus `json:"status,omitempty"`
100+
}
101+
102+
// +kubebuilder:object:root=true
103+
104+
// EBGPList contains a list of EBGP
105+
type EBGPList struct {
106+
metav1.TypeMeta `json:",inline"`
107+
metav1.ListMeta `json:"metadata,omitempty"`
108+
Items []EBGP `json:"items"`
109+
}
110+
111+
func init() {
112+
SchemeBuilder.Register(&EBGP{}, &EBGPList{})
113+
}

api/v1alpha1/ebgpmeta_types.go

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
/*
2+
Copyright 2021. Netris, Inc.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1alpha1
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
)
22+
23+
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
24+
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
25+
26+
// EBGPMetaSpec defines the desired state of EBGPMeta
27+
type EBGPMetaSpec struct {
28+
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
29+
// Important: Run "make" to regenerate code after modifying this file
30+
Imported bool `json:"imported"`
31+
EBGPCRGeneration int64 `json:"ebgpGeneration"`
32+
ID int `json:"id"`
33+
EBGPName string `json:"ebgpName"`
34+
35+
AllowasIn int `json:"allowas_in"`
36+
BgpPassword string `json:"bgp_password"`
37+
Community string `json:"community"`
38+
Description string `json:"description"`
39+
InboundRouteMap int `json:"inboundRouteMap"`
40+
Internal string `json:"internal"`
41+
IPVersion string `json:"ip_version"`
42+
LocalIP string `json:"local_ip"`
43+
LocalPreference int `json:"local_preference"`
44+
Multihop int `json:"multihop"`
45+
Name string `json:"name"`
46+
NeighborAddress string `json:"neighbor_address"`
47+
NeighborAs int `json:"neighbor_as"`
48+
NfvID int `json:"nfv_id"`
49+
NfvPortID int `json:"nfv_port_id"`
50+
Originate string `json:"originate"`
51+
OutboundRouteMap int `json:"outboundRouteMap"`
52+
PrefixLength int `json:"prefix_length"`
53+
PrefixLimit int `json:"prefix_limit"`
54+
PrefixListInbound string `json:"prefix_list_inbound"`
55+
PrefixListOutbound string `json:"prefix_list_outbound"`
56+
PrependInbound int `json:"prepend_inbound"`
57+
PrependOutbound int `json:"prepend_outbound"`
58+
RcircuitID int `json:"rcircuit_id"`
59+
RemoteIP string `json:"remote_ip"`
60+
SiteID int `json:"site_id"`
61+
Status string `json:"status"`
62+
SwitchID int `json:"switch_id"`
63+
SwitchName string `json:"switch_name"`
64+
SwitchPortID int `json:"switch_port_id"`
65+
TermSwitchID int `json:"term_switch_id"`
66+
TermSwitchName string `json:"term_switch_name"`
67+
TerminateOnSwitch string `json:"terminate_on_switch"`
68+
UpdateSource string `json:"update_source"`
69+
Vlan int `json:"vlan"`
70+
Weight int `json:"weight"`
71+
}
72+
73+
// EBGPMetaStatus defines the observed state of EBGPMeta
74+
type EBGPMetaStatus struct { // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
75+
// Important: Run "make" to regenerate code after modifying this file
76+
}
77+
78+
// +kubebuilder:object:root=true
79+
// +kubebuilder:subresource:status
80+
81+
// EBGPMeta is the Schema for the ebgpmeta API
82+
type EBGPMeta struct {
83+
metav1.TypeMeta `json:",inline"`
84+
metav1.ObjectMeta `json:"metadata,omitempty"`
85+
86+
Spec EBGPMetaSpec `json:"spec,omitempty"`
87+
Status EBGPMetaStatus `json:"status,omitempty"`
88+
}
89+
90+
// +kubebuilder:object:root=true
91+
92+
// EBGPMetaList contains a list of EBGPMeta
93+
type EBGPMetaList struct {
94+
metav1.TypeMeta `json:",inline"`
95+
metav1.ListMeta `json:"metadata,omitempty"`
96+
Items []EBGPMeta `json:"items"`
97+
}
98+
99+
func init() {
100+
SchemeBuilder.Register(&EBGPMeta{}, &EBGPMetaList{})
101+
}

api/v1alpha1/groupversion_info.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2020.
2+
Copyright 2021. Netris, Inc.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.

api/v1alpha1/l4lb_types.go

+109
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
/*
2+
Copyright 2021. Netris, Inc.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1alpha1
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
)
22+
23+
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
24+
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
25+
26+
// L4LBSpec defines the desired state of L4LB
27+
type L4LBSpec struct {
28+
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
29+
// Important: Run "make" to regenerate code after modifying this file
30+
// +kubebuilder:validation:Enum=active;disable
31+
State string `json:"state,omitempty"`
32+
33+
Check L4LBCheck `json:"check,omitempty"`
34+
OwnerTenant string `json:"ownerTenant"`
35+
Site string `json:"site"`
36+
37+
// +kubebuilder:validation:Enum=tcp;udp
38+
Protocol string `json:"protocol,omitempty"`
39+
40+
Frontend L4LBFrontend `json:"frontend"`
41+
Backend []L4LBBackend `json:"backend"`
42+
}
43+
44+
// L4LBCheck .
45+
type L4LBCheck struct {
46+
// +kubebuilder:validation:Enum=tcp;http
47+
Type string `json:"type,omitempty"`
48+
Timeout int `json:"timeout,omitempty"`
49+
RequestPath string `json:"requestPath,omitempty"`
50+
}
51+
52+
// L4LBBackend .
53+
// +kubebuilder:validation:Pattern=`^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]):([1-9]|[1-9][0-9]{1,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-4])$`
54+
type L4LBBackend string
55+
56+
// L4LBFrontend .
57+
type L4LBFrontend struct {
58+
// +kubebuilder:validation:Minimum=0
59+
// +kubebuilder:validation:Maximum=65534
60+
Port int `json:"port"`
61+
62+
// +kubebuilder:validation:Pattern=`^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$`
63+
IP string `json:"ip,omitempty"`
64+
}
65+
66+
// L4LBStatus defines the observed state of L4LB
67+
type L4LBStatus struct { // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
68+
// Important: Run "make" to regenerate code after modifying this file
69+
70+
Status string `json:"status,omitempty"`
71+
State string `json:"state,omitempty"`
72+
Message string `json:"message,omitempty"`
73+
ModifiedDate metav1.Time `json:"modified,omitempty"`
74+
IP string `json:"ip,omitempty"`
75+
Port string `json:"port,omitempty"`
76+
}
77+
78+
// +kubebuilder:object:root=true
79+
// +kubebuilder:subresource:status
80+
// +kubebuilder:printcolumn:name="State",type=string,JSONPath=`.status.state`
81+
// +kubebuilder:printcolumn:name="Frontend",type=string,JSONPath=".status.ip"
82+
// +kubebuilder:printcolumn:name="Port",type=string,JSONPath=".status.port"
83+
// +kubebuilder:printcolumn:name="Site",type=string,JSONPath=".spec.site"
84+
// +kubebuilder:printcolumn:name="Tenant",type=string,JSONPath=`.spec.ownerTenant`
85+
// +kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.status`
86+
// +kubebuilder:printcolumn:name="Modified",type=date,JSONPath=`.status.modified`,priority=1
87+
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`
88+
89+
// L4LB is the Schema for the l4lbs API
90+
type L4LB struct {
91+
metav1.TypeMeta `json:",inline"`
92+
metav1.ObjectMeta `json:"metadata,omitempty"`
93+
94+
Spec L4LBSpec `json:"spec,omitempty"`
95+
Status L4LBStatus `json:"status,omitempty"`
96+
}
97+
98+
// +kubebuilder:object:root=true
99+
100+
// L4LBList contains a list of L4LB
101+
type L4LBList struct {
102+
metav1.TypeMeta `json:",inline"`
103+
metav1.ListMeta `json:"metadata,omitempty"`
104+
Items []L4LB `json:"items"`
105+
}
106+
107+
func init() {
108+
SchemeBuilder.Register(&L4LB{}, &L4LBList{})
109+
}

0 commit comments

Comments
 (0)