Skip to content

Commit 2cb0c52

Browse files
committed
Network: gateway routes
1 parent fd4eeb0 commit 2cb0c52

Some content is hidden

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

41 files changed

+1161
-47
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(),

cmd/liqo-controller-manager/main.go

+35-2
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,14 @@ import (
6868
clientoperator "github.com/liqotech/liqo/pkg/liqo-controller-manager/external-network/client-operator"
6969
configurationcontroller "github.com/liqotech/liqo/pkg/liqo-controller-manager/external-network/configuration-controller"
7070
externalnetworkcontroller "github.com/liqotech/liqo/pkg/liqo-controller-manager/external-network/externalnetwork-controller"
71+
externalnetworkroute "github.com/liqotech/liqo/pkg/liqo-controller-manager/external-network/route"
7172
serveroperator "github.com/liqotech/liqo/pkg/liqo-controller-manager/external-network/server-operator"
7273
wggatewaycontrollers "github.com/liqotech/liqo/pkg/liqo-controller-manager/external-network/wireguard"
7374
foreignclusteroperator "github.com/liqotech/liqo/pkg/liqo-controller-manager/foreign-cluster-operator"
7475
internalclientcontroller "github.com/liqotech/liqo/pkg/liqo-controller-manager/internal-network/client-controller"
7576
internalfabriccontroller "github.com/liqotech/liqo/pkg/liqo-controller-manager/internal-network/internalfabric-controller"
7677
nodecontroller "github.com/liqotech/liqo/pkg/liqo-controller-manager/internal-network/node-controller"
78+
internalnetworkroute "github.com/liqotech/liqo/pkg/liqo-controller-manager/internal-network/route"
7779
internalservercontroller "github.com/liqotech/liqo/pkg/liqo-controller-manager/internal-network/server-controller"
7880
ipctrl "github.com/liqotech/liqo/pkg/liqo-controller-manager/ip-controller"
7981
mapsctrl "github.com/liqotech/liqo/pkg/liqo-controller-manager/namespacemap-controller"
@@ -676,12 +678,43 @@ func main() {
676678
os.Exit(1)
677679
}
678680

679-
cfgr := configurationcontroller.NewConfigurationReconciler(mgr.GetClient(), mgr.GetScheme(), mgr.GetEventRecorderFor("configuration-controller"))
680-
if err = cfgr.SetupWithManager(mgr); err != nil {
681+
intCfg := configurationcontroller.NewConfigurationReconciler(mgr.GetClient(), mgr.GetScheme(),
682+
mgr.GetEventRecorderFor("internal-configuration-controller"))
683+
if err = intCfg.SetupWithManager(mgr); err != nil {
681684
klog.Errorf("unable to create controller ConfigurationReconciler: %s", err)
682685
os.Exit(1)
683686
}
684687

688+
extCfg := externalnetworkroute.NewConfigurationReconciler(mgr.GetClient(), mgr.GetScheme(),
689+
mgr.GetEventRecorderFor("external-configuration-controller"))
690+
if err = extCfg.SetupWithManager(mgr); err != nil {
691+
klog.Errorf("unable to create controller ExternalConfigurationReconciler: %s", err)
692+
os.Exit(1)
693+
}
694+
695+
allpodmgr, err := ctrl.NewManager(config, ctrl.Options{
696+
MapperProvider: mapper.LiqoMapperProvider(scheme),
697+
Scheme: scheme,
698+
Metrics: server.Options{BindAddress: "0"}, // Disable the metrics of the auxiliary manager to prevent conflicts.
699+
})
700+
701+
if err != nil {
702+
klog.Errorf("Unable to create auxiliary manager: %w", err)
703+
os.Exit(1)
704+
}
705+
706+
if err := mgr.Add(allpodmgr); err != nil {
707+
klog.Errorf("Unable to add the ExternalNetworkPods auxiliary manager to the main one: %w", err)
708+
os.Exit(1)
709+
}
710+
711+
intPod := internalnetworkroute.NewPodReconciler(allpodmgr.GetClient(), allpodmgr.GetScheme(),
712+
allpodmgr.GetEventRecorderFor("internal-pod-controller"), &internalnetworkroute.Options{Namespace: *liqoNamespace})
713+
if err = intPod.SetupWithManager(allpodmgr); err != nil {
714+
klog.Errorf("unable to create controller InternalPodReconciler: %s", err)
715+
os.Exit(1)
716+
}
717+
685718
wgServerRec := wggatewaycontrollers.NewWgGatewayServerReconciler(
686719
mgr.GetClient(), mgr.GetScheme(), auxmgrExtNetworkPods.GetClient(), wgGatewayServerClusterRoleName)
687720
if err = wgServerRec.SetupWithManager(mgr); err != nil {

deployments/liqo/charts/liqo-crds/crds/networking.liqo.io_routeconfigurations.yaml

+126
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,53 @@ spec:
9191
description: Src is the source of the RouteConfiguration.
9292
pattern: ^(([1-9]{0,1}[0-9]{0,2}|2[0-4][0-9]|25[0-5])\.){3}([1-9]{0,1}[0-9]{0,2}|2[0-4][0-9]|25[0-5])$
9393
type: string
94+
targetRef:
95+
description: TargetRef is the reference to the target
96+
object of the route. It is optional and it can be
97+
used for custom purposes.
98+
properties:
99+
apiVersion:
100+
description: API version of the referent.
101+
type: string
102+
fieldPath:
103+
description: 'If referring to a piece of an object
104+
instead of an entire object, this string should
105+
contain a valid JSON/Go field access statement,
106+
such as desiredState.manifest.containers[2].
107+
For example, if the object reference is to a
108+
container within a pod, this would take on a
109+
value like: "spec.containers{name}" (where "name"
110+
refers to the name of the container that triggered
111+
the event) or if no container name is specified
112+
"spec.containers[2]" (container with index 2
113+
in this pod). This syntax is chosen only to
114+
have some well-defined way of referencing a
115+
part of an object. TODO: this design is not
116+
final and this field is subject to change in
117+
the future.'
118+
type: string
119+
kind:
120+
description: 'Kind of the referent. More info:
121+
https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
122+
type: string
123+
name:
124+
description: 'Name of the referent. More info:
125+
https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
126+
type: string
127+
namespace:
128+
description: 'Namespace of the referent. More
129+
info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/'
130+
type: string
131+
resourceVersion:
132+
description: 'Specific resourceVersion to which
133+
this reference is made, if any. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency'
134+
type: string
135+
uid:
136+
description: 'UID of the referent. More info:
137+
https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids'
138+
type: string
139+
type: object
140+
x-kubernetes-map-type: atomic
94141
required:
95142
- dst
96143
type: object
@@ -100,11 +147,90 @@ spec:
100147
description: Src is the source of the Rule.
101148
pattern: ^(([1-9]{0,1}[0-9]{0,2}|2[0-4][0-9]|25[0-5])\.){3}([1-9]{0,1}[0-9]{0,2}|2[0-4][0-9]|25[0-5])\/([0-9]|[1-2][0-9]|3[0-2])$
102149
type: string
150+
targetRef:
151+
description: TargetRef is the reference to the target object
152+
of the route. It is optional and it can be used for custom
153+
purposes.
154+
properties:
155+
apiVersion:
156+
description: API version of the referent.
157+
type: string
158+
fieldPath:
159+
description: 'If referring to a piece of an object instead
160+
of an entire object, this string should contain a
161+
valid JSON/Go field access statement, such as desiredState.manifest.containers[2].
162+
For example, if the object reference is to a container
163+
within a pod, this would take on a value like: "spec.containers{name}"
164+
(where "name" refers to the name of the container
165+
that triggered the event) or if no container name
166+
is specified "spec.containers[2]" (container with
167+
index 2 in this pod). This syntax is chosen only to
168+
have some well-defined way of referencing a part of
169+
an object. TODO: this design is not final and this
170+
field is subject to change in the future.'
171+
type: string
172+
kind:
173+
description: 'Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
174+
type: string
175+
name:
176+
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
177+
type: string
178+
namespace:
179+
description: 'Namespace of the referent. More info:
180+
https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/'
181+
type: string
182+
resourceVersion:
183+
description: 'Specific resourceVersion to which this
184+
reference is made, if any. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency'
185+
type: string
186+
uid:
187+
description: 'UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids'
188+
type: string
189+
type: object
190+
x-kubernetes-map-type: atomic
103191
required:
104192
- routes
105193
type: object
106194
minItems: 1
107195
type: array
196+
targetRef:
197+
description: TargetRef is the reference to the target object of
198+
the route. It is optional and it can be used for custom purposes.
199+
properties:
200+
apiVersion:
201+
description: API version of the referent.
202+
type: string
203+
fieldPath:
204+
description: 'If referring to a piece of an object instead
205+
of an entire object, this string should contain a valid
206+
JSON/Go field access statement, such as desiredState.manifest.containers[2].
207+
For example, if the object reference is to a container within
208+
a pod, this would take on a value like: "spec.containers{name}"
209+
(where "name" refers to the name of the container that triggered
210+
the event) or if no container name is specified "spec.containers[2]"
211+
(container with index 2 in this pod). This syntax is chosen
212+
only to have some well-defined way of referencing a part
213+
of an object. TODO: this design is not final and this field
214+
is subject to change in the future.'
215+
type: string
216+
kind:
217+
description: 'Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
218+
type: string
219+
name:
220+
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
221+
type: string
222+
namespace:
223+
description: 'Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/'
224+
type: string
225+
resourceVersion:
226+
description: 'Specific resourceVersion to which this reference
227+
is made, if any. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency'
228+
type: string
229+
uid:
230+
description: 'UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids'
231+
type: string
232+
type: object
233+
x-kubernetes-map-type: atomic
108234
required:
109235
- name
110236
- rules

0 commit comments

Comments
 (0)