Skip to content

Commit c7ebd80

Browse files
committed
Network: gateway routes
1 parent fd4eeb0 commit c7ebd80

40 files changed

+1113
-160
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/routeconfiguration_types.go

+10
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
)
@@ -46,6 +47,9 @@ type Route struct {
4647
Dev *string `json:"dev,omitempty"`
4748
// Onlink enables the onlink falg inside the route.
4849
Onlink *bool `json:"onlink,omitempty"`
50+
// TargetRef is the reference to the target object of the route.
51+
// It is optional and it can be used for custom purposes.
52+
TargetRef *corev1.ObjectReference `json:"targetRef,omitempty"`
4953
}
5054

5155
// Rule is the rule of the RouteConfiguration.
@@ -61,6 +65,9 @@ type Rule struct {
6165
// Routes is the list of routes of the Rule.
6266
// +kubebuilder:validation:MinItems=1
6367
Routes []Route `json:"routes"`
68+
// TargetRef is the reference to the target object of the route.
69+
// It is optional and it can be used for custom purposes.
70+
TargetRef *corev1.ObjectReference `json:"targetRef,omitempty"`
6471
}
6572

6673
// Table is the table of the RouteConfiguration.
@@ -70,6 +77,9 @@ type Table struct {
7077
// Rules is the list of rules of the RouteConfiguration.
7178
// +kubebuilder:validation:MinItems=1
7279
Rules []Rule `json:"rules"`
80+
// TargetRef is the reference to the target object of the route.
81+
// It is optional and it can be used for custom purposes.
82+
TargetRef *corev1.ObjectReference `json:"targetRef,omitempty"`
7383
}
7484

7585
// RouteConfigurationSpec defines the desired state of RouteConfiguration.

apis/networking/v1alpha1/zz_generated.deepcopy.go

+15
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

-15
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import (
3333
networkingv1alpha1 "github.com/liqotech/liqo/apis/networking/v1alpha1"
3434
"github.com/liqotech/liqo/pkg/gateway"
3535
"github.com/liqotech/liqo/pkg/gateway/fabric/geneve"
36-
"github.com/liqotech/liqo/pkg/route"
3736
flagsutils "github.com/liqotech/liqo/pkg/utils/flags"
3837
"github.com/liqotech/liqo/pkg/utils/mapper"
3938
"github.com/liqotech/liqo/pkg/utils/restcfg"
@@ -113,20 +112,6 @@ func run(cmd *cobra.Command, _ []string) error {
113112
return fmt.Errorf("unable to create manager: %w", err)
114113
}
115114

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-
130115
inr, err := geneve.NewInternalNodeReconciler(
131116
mgr.GetClient(),
132117
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/geneve"
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+
geneve.ForgeRouteExternalTargetLabels(connoptions.GwOptions.RemoteClusterID),
162+
geneve.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)