Skip to content

Commit

Permalink
server controller
Browse files Browse the repository at this point in the history
  • Loading branch information
aleoli authored and cheina97 committed Nov 29, 2023
1 parent 8f893e1 commit 9cad580
Show file tree
Hide file tree
Showing 17 changed files with 638 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,29 +37,29 @@ var InternalFabricGroupVersionResource = GroupVersion.WithResource(InternalFabri
// InternalEndpoint defines the endpoint of the internal fabric.
type InternalEndpoint struct {
// IP is the IP address of the endpoint.
IP string `json:"ip,omitempty"`
IP IP `json:"ip,omitempty"`
// Port is the port of the endpoint.
Port int `json:"port,omitempty"`
Port int32 `json:"port,omitempty"`
}

// InternalFabricSpec defines the desired state of InternalFabric.
type InternalFabricSpec struct {
// MTU is the MTU of the internal fabric.
MTU int `json:"mtu,omitempty"`
// GatewayIP is the IP address to assign to the gateway internal interface.
GatewayIP string `json:"gatewayIP,omitempty"`
GatewayIP IP `json:"gatewayIP,omitempty"`
// RemoteCIDRs is the list of remote CIDRs to be routed through the gateway.
RemoteCIDRs []string `json:"remoteCIDRs,omitempty"`
RemoteCIDRs []CIDR `json:"remoteCIDRs,omitempty"`
// NodeName is the name of the node where the gateway is running.
NodeName string `json:"nodeName,omitempty"`
// Endpoint is the endpoint of the gateway.
Endpoint InternalEndpoint `json:"endpoint,omitempty"`
Endpoint *InternalEndpoint `json:"endpoint,omitempty"`
}

// InternalFabricStatus defines the observed state of InternalFabric.
type InternalFabricStatus struct {
// AssignedIPs is the list of IP addresses assigned to interfaces in the nodes.
AssignedIPs []string `json:"assignedIPs,omitempty"`
AssignedIPs []IP `json:"assignedIPs,omitempty"`
}

// +kubebuilder:object:root=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type InternalNodeSpec struct {
// FabricRef is the reference to the internal fabric.
FabricRef *corev1.ObjectReference `json:"fabricRef,omitempty"`
// IP is the IP address to assign to the internal interface.
IP string `json:"ip,omitempty"`
IP IP `json:"ip,omitempty"`
// IsGateway is true if the node is the gateway.
IsGateway bool `json:"isGateway,omitempty"`
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ var RouteGroupVersionResource = GroupVersion.WithResource(RouteResource)
// RouteDestination defines the destination of the route.
type RouteDestination struct {
// IP is the IP address of the destination. It is mutually exclusive with CIDR.
IP *string `json:"ip,omitempty"`
IP *IP `json:"ip,omitempty"`
// CIDR is the CIDR of the destination. It is mutually exclusive with IP.
CIDR *string `json:"cidr,omitempty"`
CIDR *CIDR `json:"cidr,omitempty"`
}

// RouteNextHop defines the next hop of the route.
type RouteNextHop struct {
// IP is the IP address of the next hop. It is mutually exclusive with Dev.
IP *string `json:"ip,omitempty"`
IP *IP `json:"ip,omitempty"`
// Dev is the name of the device of the next hop. It is mutually exclusive with IP.
Dev *string `json:"dev,omitempty"`
}
Expand Down
16 changes: 10 additions & 6 deletions apis/networking/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 36 additions & 22 deletions cmd/liqo-controller-manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ import (
serveroperator "github.com/liqotech/liqo/pkg/liqo-controller-manager/external-network/server-operator"
wggatewaycontrollers "github.com/liqotech/liqo/pkg/liqo-controller-manager/external-network/wireguard"
foreignclusteroperator "github.com/liqotech/liqo/pkg/liqo-controller-manager/foreign-cluster-operator"
internalclientcontroller "github.com/liqotech/liqo/pkg/liqo-controller-manager/internal-network/client-controller"
internalservercontroller "github.com/liqotech/liqo/pkg/liqo-controller-manager/internal-network/server-controller"
ipctrl "github.com/liqotech/liqo/pkg/liqo-controller-manager/ip-controller"
mapsctrl "github.com/liqotech/liqo/pkg/liqo-controller-manager/namespacemap-controller"
nsoffctrl "github.com/liqotech/liqo/pkg/liqo-controller-manager/namespaceoffloading-controller"
Expand Down Expand Up @@ -577,28 +579,6 @@ func main() {
klog.Fatal(err)
}

serverReconciler := serveroperator.NewServerReconciler(mgr.GetClient(),
dynClient, factory, mgr.GetScheme(), gatewayServerResources.StringList)
if err := serverReconciler.SetupWithManager(mgr); err != nil {
klog.Error(err)
os.Exit(1)
}

clientReconciler := clientoperator.NewClientReconciler(mgr.GetClient(),
dynClient, factory, mgr.GetScheme(), gatewayClientResources.StringList)
if err := clientReconciler.SetupWithManager(mgr); err != nil {
klog.Error(err)
os.Exit(1)
}

externalNetworkReconciler := externalnetworkcontroller.NewExternalNetworkReconciler(
mgr.GetClient(), mgr.GetScheme(), clientset, *liqoNamespace, &clusterIdentity,
corev1.ServiceType(*gatewayServiceType), int32(*gatewayServicePort), *gatewayMTU, *gatewayProxy)
if err := externalNetworkReconciler.SetupWithManager(mgr); err != nil {
klog.Error(err)
os.Exit(1)
}

// Start the handler to approve the virtual kubelet certificate signing requests.
csrWatcher := csr.NewWatcher(clientset, *resyncPeriod, labels.Everything(), fields.Everything())
csrWatcher.RegisterHandler(csr.ApproverHandler(clientset, "LiqoApproval", "This CSR was approved by Liqo",
Expand Down Expand Up @@ -712,6 +692,40 @@ func main() {
klog.Errorf("Unable to start the WgGatewayClientReconciler", err)
os.Exit(1)
}

serverReconciler := serveroperator.NewServerReconciler(mgr.GetClient(),
dynClient, factory, mgr.GetScheme(), gatewayServerResources.StringList)
if err := serverReconciler.SetupWithManager(mgr); err != nil {
klog.Error(err)
os.Exit(1)
}

clientReconciler := clientoperator.NewClientReconciler(mgr.GetClient(),
dynClient, factory, mgr.GetScheme(), gatewayClientResources.StringList)
if err := clientReconciler.SetupWithManager(mgr); err != nil {
klog.Error(err)
os.Exit(1)
}

externalNetworkReconciler := externalnetworkcontroller.NewExternalNetworkReconciler(
mgr.GetClient(), mgr.GetScheme(), clientset, *liqoNamespace, &clusterIdentity,
corev1.ServiceType(*gatewayServiceType), int32(*gatewayServicePort), *gatewayMTU, *gatewayProxy)
if err := externalNetworkReconciler.SetupWithManager(mgr); err != nil {
klog.Error(err)
os.Exit(1)
}

internalServerReconciler := internalservercontroller.NewServerReconciler(mgr.GetClient(), mgr.GetScheme())
if err := internalServerReconciler.SetupWithManager(mgr); err != nil {
klog.Error(err)
os.Exit(1)
}

internalClientReconciler := internalclientcontroller.NewClientReconciler(mgr.GetClient(), mgr.GetScheme())
if err := internalClientReconciler.SetupWithManager(mgr); err != nil {
klog.Error(err)
os.Exit(1)
}
}

klog.Info("starting manager as controller manager")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,17 @@ spec:
properties:
ip:
description: IP is the IP address of the endpoint.
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])$
type: string
port:
description: Port is the port of the endpoint.
format: int32
type: integer
type: object
gatewayIP:
description: GatewayIP is the IP address to assign to the gateway
internal interface.
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])$
type: string
mtu:
description: MTU is the MTU of the internal fabric.
Expand All @@ -76,6 +79,8 @@ spec:
description: RemoteCIDRs is the list of remote CIDRs to be routed
through the gateway.
items:
description: CIDR defines a syntax validated CIDR.
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])$
type: string
type: array
type: object
Expand All @@ -86,6 +91,8 @@ spec:
description: AssignedIPs is the list of IP addresses assigned to interfaces
in the nodes.
items:
description: IP defines a syntax validated IP.
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])$
type: string
type: array
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ spec:
x-kubernetes-map-type: atomic
ip:
description: IP is the IP address to assign to the internal interface.
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])$
type: string
isGateway:
description: IsGateway is true if the node is the gateway.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,12 @@ spec:
cidr:
description: CIDR is the CIDR of the destination. It is mutually
exclusive with IP.
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])$
type: string
ip:
description: IP is the IP address of the destination. It is mutually
exclusive with CIDR.
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])$
type: string
type: object
nextHop:
Expand All @@ -80,6 +82,7 @@ spec:
ip:
description: IP is the IP address of the next hop. It is mutually
exclusive with Dev.
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])$
type: string
type: object
table:
Expand Down
12 changes: 12 additions & 0 deletions deployments/liqo/files/liqo-controller-manager-ClusterRole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,18 @@ rules:
- get
- patch
- update
- apiGroups:
- networking.liqo.io
resources:
- internalfabrics
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- networking.liqo.io
resources:
Expand Down
Loading

0 comments on commit 9cad580

Please sign in to comment.