Skip to content

Commit a45b352

Browse files
cheina97aleoli
andcommitted
Network: gateway routes
Co-authored-by: Alessandro Olivero <[email protected]>
1 parent fd4eeb0 commit a45b352

File tree

68 files changed

+2166
-177
lines changed

Some content is hidden

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

68 files changed

+2166
-177
lines changed

.github/workflows/integration.yml

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88
- network-general
99
- network-external
1010
- network-internal
11+
- frc/gatewayroute
1112
repository_dispatch:
1213
types:
1314
- test-command

apis/networking/v1alpha1/internalfabric_types.go

+8
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,19 @@ type InternalFabricSpecInterfaceNode struct {
4040
Name string `json:"name"`
4141
}
4242

43+
// InternalFabricSpecInterfaceGateway contains the information about the gateway interface.
44+
type InternalFabricSpecInterfaceGateway struct {
45+
// IP is the IP of the interface added to the gateway.
46+
IP IP `json:"ip"`
47+
}
48+
4349
// InternalFabricSpecInterface contains the information about network interfaces.
4450
type InternalFabricSpecInterface struct {
4551
// Node contains the information about the node interface.
4652
// The node interface is created on every node to connect them to the gateway related with the internalfabric.
4753
Node InternalFabricSpecInterfaceNode `json:"node"`
54+
// Gateway contains the information about the gateway interface.
55+
Gateway InternalFabricSpecInterfaceGateway `json:"gateway"`
4856
}
4957

5058
// InternalFabricSpec defines the desired state of InternalFabric.

apis/networking/v1alpha1/internalnode_types.go

+8
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,19 @@ type InternalNodeSpecInterfaceGateway struct {
4040
Name string `json:"name"`
4141
}
4242

43+
// InternalNodeSpecInterfaceNode contains the information about the node interface.
44+
type InternalNodeSpecInterfaceNode struct {
45+
// IP is the IP of the interface added to the node.
46+
IP IP `json:"ip"`
47+
}
48+
4349
// InternalNodeSpecInterface contains the information about network interfaces.
4450
type InternalNodeSpecInterface struct {
4551
// Gateway contains the information about the gateway interface.
4652
// The gateway interface is created on every gateway to connect them to the node related with the internalnode.
4753
Gateway InternalNodeSpecInterfaceGateway `json:"gateway"`
54+
// Node contains the information about the node interface.
55+
Node InternalNodeSpecInterfaceNode `json:"node"`
4856
}
4957

5058
// InternalNodeSpec defines the desired state of InternalNode.

apis/networking/v1alpha1/routeconfiguration_types.go

+29
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package v1alpha1
1616

1717
import (
18+
corev1 "k8s.io/api/core/v1"
1819
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1920
"k8s.io/apimachinery/pkg/runtime/schema"
2021
)
@@ -34,6 +35,22 @@ var RouteConfigurationGroupResource = schema.GroupResource{Group: GroupVersion.G
3435
// RouteConfigurationGroupVersionResource is groupResourceVersion used to register these objects.
3536
var RouteConfigurationGroupVersionResource = GroupVersion.WithResource(RouteConfigurationResource)
3637

38+
// Scope is the scope of the route.
39+
type Scope string
40+
41+
const (
42+
// GlobalScope is the global scope of the RouteConfiguration.
43+
GlobalScope Scope = "global"
44+
// LinkScope is the link scope of the RouteConfiguration.
45+
LinkScope Scope = "link"
46+
// HostScope is the host scope of the RouteConfiguration.
47+
HostScope Scope = "host"
48+
// SiteScope is the site scope of the RouteConfiguration.
49+
SiteScope Scope = "site"
50+
// NowhereScope is the nowhere scope of the RouteConfiguration.
51+
NowhereScope Scope = "nowhere"
52+
)
53+
3754
// Route is the route of the RouteConfiguration.
3855
type Route struct {
3956
// Dst is the destination of the RouteConfiguration.
@@ -46,6 +63,12 @@ type Route struct {
4663
Dev *string `json:"dev,omitempty"`
4764
// Onlink enables the onlink falg inside the route.
4865
Onlink *bool `json:"onlink,omitempty"`
66+
// Scope is the scope of the RouteConfiguration.
67+
// +kubebuilder:validation:Enum=global;link;host;site;nowhere
68+
Scope *Scope `json:"scope,omitempty"`
69+
// TargetRef is the reference to the target object of the route.
70+
// It is optional and it can be used for custom purposes.
71+
TargetRef *corev1.ObjectReference `json:"targetRef,omitempty"`
4972
}
5073

5174
// Rule is the rule of the RouteConfiguration.
@@ -61,6 +84,9 @@ type Rule struct {
6184
// Routes is the list of routes of the Rule.
6285
// +kubebuilder:validation:MinItems=1
6386
Routes []Route `json:"routes"`
87+
// TargetRef is the reference to the target object of the route.
88+
// It is optional and it can be used for custom purposes.
89+
TargetRef *corev1.ObjectReference `json:"targetRef,omitempty"`
6490
}
6591

6692
// Table is the table of the RouteConfiguration.
@@ -70,6 +96,9 @@ type Table struct {
7096
// Rules is the list of rules of the RouteConfiguration.
7197
// +kubebuilder:validation:MinItems=1
7298
Rules []Rule `json:"rules"`
99+
// TargetRef is the reference to the target object of the route.
100+
// It is optional and it can be used for custom purposes.
101+
TargetRef *corev1.ObjectReference `json:"targetRef,omitempty"`
73102
}
74103

75104
// RouteConfigurationSpec defines the desired state of RouteConfiguration.

apis/networking/v1alpha1/zz_generated.deepcopy.go

+52
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/fabric/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ func run(cmd *cobra.Command, _ []string) error {
152152
mgr.GetClient(),
153153
mgr.GetScheme(),
154154
mgr.GetEventRecorderFor("route-controller"),
155-
fabric.ForgeRouteTargetLabels(),
155+
[]route.LabelsSet{fabric.ForgeRouteTargetLabels()},
156156
)
157157
if err != nil {
158158
return fmt.Errorf("unable to create route configuration reconciler: %w", err)

cmd/gateway/geneve/main.go

+4-18
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,16 @@ import (
3232

3333
networkingv1alpha1 "github.com/liqotech/liqo/apis/networking/v1alpha1"
3434
"github.com/liqotech/liqo/pkg/gateway"
35+
"github.com/liqotech/liqo/pkg/gateway/fabric"
3536
"github.com/liqotech/liqo/pkg/gateway/fabric/geneve"
36-
"github.com/liqotech/liqo/pkg/route"
3737
flagsutils "github.com/liqotech/liqo/pkg/utils/flags"
3838
"github.com/liqotech/liqo/pkg/utils/mapper"
3939
"github.com/liqotech/liqo/pkg/utils/restcfg"
4040
)
4141

4242
var (
4343
scheme = runtime.NewScheme()
44-
options = geneve.NewOptions(gateway.NewOptions())
44+
options = fabric.NewOptions(gateway.NewOptions())
4545
)
4646

4747
func init() {
@@ -62,8 +62,8 @@ func main() {
6262
klog.InitFlags(legacyflags)
6363
flagsutils.FromFlagToPflag(legacyflags, cmd.Flags())
6464

65-
geneve.InitFlags(cmd.Flags(), options)
66-
if err := geneve.MarkFlagsRequired(&cmd); err != nil {
65+
fabric.InitFlags(cmd.Flags(), options)
66+
if err := fabric.MarkFlagsRequired(&cmd); err != nil {
6767
klog.Error(err)
6868
os.Exit(1)
6969
}
@@ -113,20 +113,6 @@ func run(cmd *cobra.Command, _ []string) error {
113113
return fmt.Errorf("unable to create manager: %w", err)
114114
}
115115

116-
rcr, err := route.NewRouteConfigurationReconcilerWithoutFinalizer(
117-
mgr.GetClient(),
118-
mgr.GetScheme(),
119-
mgr.GetEventRecorderFor("routeconfiguration-controller"),
120-
geneve.ForgeRouteTargetLabels(options.GwOptions.Name),
121-
)
122-
if err != nil {
123-
return fmt.Errorf("unable to create routeconfiguration reconciler: %w", err)
124-
}
125-
126-
if err := rcr.SetupWithManager(mgr); err != nil {
127-
return fmt.Errorf("unable to setup routeconfiguration reconciler: %w", err)
128-
}
129-
130116
inr, err := geneve.NewInternalNodeReconciler(
131117
mgr.GetClient(),
132118
mgr.GetScheme(),

cmd/gateway/main.go

+25-6
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import (
2727
"k8s.io/client-go/tools/leaderelection/resourcelock"
2828
"k8s.io/klog/v2"
2929
ctrl "sigs.k8s.io/controller-runtime"
30-
"sigs.k8s.io/controller-runtime/pkg/cache"
3130
"sigs.k8s.io/controller-runtime/pkg/client/config"
3231
"sigs.k8s.io/controller-runtime/pkg/log"
3332
"sigs.k8s.io/controller-runtime/pkg/metrics/server"
@@ -37,8 +36,11 @@ import (
3736
"github.com/liqotech/liqo/pkg/gateway"
3837
"github.com/liqotech/liqo/pkg/gateway/connection"
3938
"github.com/liqotech/liqo/pkg/gateway/connection/conncheck"
39+
"github.com/liqotech/liqo/pkg/gateway/fabric"
4040
"github.com/liqotech/liqo/pkg/gateway/remapping"
41+
"github.com/liqotech/liqo/pkg/route"
4142
flagsutils "github.com/liqotech/liqo/pkg/utils/flags"
43+
"github.com/liqotech/liqo/pkg/utils/kernel"
4244
"github.com/liqotech/liqo/pkg/utils/mapper"
4345
"github.com/liqotech/liqo/pkg/utils/restcfg"
4446
)
@@ -98,6 +100,11 @@ func main() {
98100
func run(cmd *cobra.Command, _ []string) error {
99101
var err error
100102

103+
// Enable ip_forwarding.
104+
if err = kernel.EnableIPForwarding(); err != nil {
105+
return err
106+
}
107+
101108
// Set controller-runtime logger.
102109
log.SetLogger(klog.NewKlogr())
103110

@@ -108,11 +115,6 @@ func run(cmd *cobra.Command, _ []string) error {
108115
mgr, err := ctrl.NewManager(cfg, ctrl.Options{
109116
MapperProvider: mapper.LiqoMapperProvider(scheme),
110117
Scheme: scheme,
111-
Cache: cache.Options{
112-
DefaultNamespaces: map[string]cache.Config{
113-
connoptions.GwOptions.Namespace: {},
114-
},
115-
},
116118
Metrics: server.Options{
117119
BindAddress: "0", // Metrics are exposed by "connection" container.
118120
},
@@ -151,6 +153,23 @@ func run(cmd *cobra.Command, _ []string) error {
151153
}
152154
}
153155

156+
rcr, err := route.NewRouteConfigurationReconcilerWithoutFinalizer(
157+
mgr.GetClient(),
158+
mgr.GetScheme(),
159+
mgr.GetEventRecorderFor("routeconfiguration-controller"),
160+
[]route.LabelsSet{
161+
fabric.ForgeRouteExternalTargetLabels(connoptions.GwOptions.RemoteClusterID),
162+
fabric.ForgeRouteInternalTargetLabels(),
163+
},
164+
)
165+
if err != nil {
166+
return fmt.Errorf("unable to create routeconfiguration reconciler: %w", err)
167+
}
168+
169+
if err := rcr.SetupWithManager(mgr); err != nil {
170+
return fmt.Errorf("unable to setup routeconfiguration reconciler: %w", err)
171+
}
172+
154173
// Setup the firewall configuration controller.
155174
fwcr, err := firewall.NewFirewallConfigurationReconcilerWithoutFinalizer(
156175
mgr.GetClient(),

0 commit comments

Comments
 (0)