diff --git a/Makefile b/Makefile index 8f94b5bb6f..78852bbf99 100644 --- a/Makefile +++ b/Makefile @@ -49,14 +49,14 @@ purge: manifests ctl # Generate manifests e.g. CRD, RBAC etc. manifests: controller-gen rm -f deployments/liqo/crds/* - $(CONTROLLER_GEN) crd paths="./apis/..." crd:generateEmbeddedObjectMeta=true output:crd:artifacts:config=deployments/liqo/crds + $(CONTROLLER_GEN) paths="./apis/..." crd:generateEmbeddedObjectMeta=true output:crd:artifacts:config=deployments/liqo/crds #Generate RBAC for each controller rbacs: controller-gen rm -f deployments/liqo/files/* $(CONTROLLER_GEN) paths="./internal/liqonet/route-operator" rbac:roleName=liqo-route output:rbac:stdout | awk -v RS="---\n" 'NR>1{f="./deployments/liqo/files/liqo-route-" $$4 ".yaml";printf "%s",$$0 > f; close(f)}' && sed -i -n '/rules/,$$p' deployments/liqo/files/liqo-route-ClusterRole.yaml deployments/liqo/files/liqo-route-Role.yaml $(CONTROLLER_GEN) paths="./internal/liqonet/tunnel-operator" rbac:roleName=liqo-gateway output:rbac:stdout | awk -v RS="---\n" 'NR>1{f="./deployments/liqo/files/liqo-gateway-" $$4 ".yaml";printf "%s",$$0 > f; close(f)}' && sed -i -n '/rules/,$$p' deployments/liqo/files/liqo-gateway-ClusterRole.yaml deployments/liqo/files/liqo-gateway-Role.yaml - $(CONTROLLER_GEN) paths="./internal/liqonet/network-manager/..." rbac:roleName=liqo-network-manager output:rbac:stdout | awk -v RS="---\n" 'NR>1{f="./deployments/liqo/files/liqo-network-manager-" $$4 ".yaml";printf "%s",$$0 > f; close(f)}' && sed -i -n '/rules/,$$p' deployments/liqo/files/liqo-network-manager-ClusterRole.yaml deployments/liqo/files/liqo-network-manager-Role.yaml + $(CONTROLLER_GEN) paths="{./internal/liqonet/network-manager/...,./pkg/liqonet/...}" rbac:roleName=liqo-network-manager output:rbac:stdout | awk -v RS="---\n" 'NR>1{f="./deployments/liqo/files/liqo-network-manager-" $$4 ".yaml";printf "%s",$$0 > f; close(f)}' && sed -i -n '/rules/,$$p' deployments/liqo/files/liqo-network-manager-ClusterRole.yaml deployments/liqo/files/liqo-network-manager-Role.yaml $(CONTROLLER_GEN) paths="./internal/crdReplicator" rbac:roleName=liqo-crd-replicator output:rbac:stdout | awk -v RS="---\n" 'NR>1{f="./deployments/liqo/files/liqo-crd-replicator-" $$4 ".yaml";printf "%s",$$0 > f; close(f)}' && sed -i -n '/rules/,$$p' deployments/liqo/files/liqo-crd-replicator-ClusterRole.yaml deployments/liqo/files/liqo-crd-replicator-Role.yaml $(CONTROLLER_GEN) paths="./pkg/discoverymanager" rbac:roleName=liqo-discovery output:rbac:stdout | awk -v RS="---\n" 'NR>1{f="./deployments/liqo/files/liqo-discovery-" $$4 ".yaml";printf "%s",$$0 > f; close(f)}' && sed -i -n '/rules/,$$p' deployments/liqo/files/liqo-discovery-ClusterRole.yaml deployments/liqo/files/liqo-discovery-Role.yaml $(CONTROLLER_GEN) paths="./internal/auth-service" rbac:roleName=liqo-auth-service output:rbac:stdout | awk -v RS="---\n" 'NR>1{f="./deployments/liqo/files/liqo-auth-" $$4 ".yaml";printf "%s",$$0 > f; close(f)}' && sed -i -n '/rules/,$$p' deployments/liqo/files/liqo-auth-ClusterRole.yaml deployments/liqo/files/liqo-auth-Role.yaml @@ -169,7 +169,7 @@ PROTOC=$(shell which protoc) # download controller-gen if necessary controller-gen: ifeq (, $(shell which controller-gen)) - @go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.9.2 + @go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.13.0 CONTROLLER_GEN=$(GOBIN)/controller-gen else CONTROLLER_GEN=$(shell which controller-gen) diff --git a/apis/discovery/v1alpha1/zz_generated.deepcopy.go b/apis/discovery/v1alpha1/zz_generated.deepcopy.go index 3630a9eb3e..0e8ebb343d 100644 --- a/apis/discovery/v1alpha1/zz_generated.deepcopy.go +++ b/apis/discovery/v1alpha1/zz_generated.deepcopy.go @@ -1,5 +1,4 @@ //go:build !ignore_autogenerated -// +build !ignore_autogenerated // Copyright 2019-2023 The Liqo Authors // diff --git a/apis/ipam/v1alpha1/zz_generated.deepcopy.go b/apis/ipam/v1alpha1/zz_generated.deepcopy.go index 3e6627aca2..b5ca0aa7ab 100644 --- a/apis/ipam/v1alpha1/zz_generated.deepcopy.go +++ b/apis/ipam/v1alpha1/zz_generated.deepcopy.go @@ -1,5 +1,4 @@ //go:build !ignore_autogenerated -// +build !ignore_autogenerated // Copyright 2019-2023 The Liqo Authors // diff --git a/apis/net/v1alpha1/zz_generated.deepcopy.go b/apis/net/v1alpha1/zz_generated.deepcopy.go index 16bf7fc0f0..31d0b2a2f1 100644 --- a/apis/net/v1alpha1/zz_generated.deepcopy.go +++ b/apis/net/v1alpha1/zz_generated.deepcopy.go @@ -1,5 +1,4 @@ //go:build !ignore_autogenerated -// +build !ignore_autogenerated // Copyright 2019-2023 The Liqo Authors // @@ -125,7 +124,8 @@ func (in *IpamSpec) DeepCopyInto(out *IpamSpec) { if val == nil { (*out)[key] = nil } else { - in, out := &val, &outVal + inVal := (*in)[key] + in, out := &inVal, &outVal *out = make([]byte, len(*in)) copy(*out, *in) } diff --git a/apis/networking/v1alpha1/gatewayserver_types.go b/apis/networking/v1alpha1/gatewayserver_types.go index 1834cdd017..0ce447c860 100644 --- a/apis/networking/v1alpha1/gatewayserver_types.go +++ b/apis/networking/v1alpha1/gatewayserver_types.go @@ -62,7 +62,6 @@ type EndpointStatus struct { // Port specifies the port of the endpoint. Port int32 `json:"port,omitempty"` // Protocol specifies the protocol of the endpoint. - // +kubebuilder:default=TCP // +kubebuilder:validation:Enum=TCP;UDP Protocol corev1.Protocol `json:"protocol,omitempty"` } diff --git a/apis/networking/v1alpha1/zz_generated.deepcopy.go b/apis/networking/v1alpha1/zz_generated.deepcopy.go index ce1592957c..4f958ea82f 100644 --- a/apis/networking/v1alpha1/zz_generated.deepcopy.go +++ b/apis/networking/v1alpha1/zz_generated.deepcopy.go @@ -1,5 +1,4 @@ //go:build !ignore_autogenerated -// +build !ignore_autogenerated // Copyright 2019-2023 The Liqo Authors // diff --git a/apis/offloading/v1alpha1/zz_generated.deepcopy.go b/apis/offloading/v1alpha1/zz_generated.deepcopy.go index 7e7b796451..813657a8c5 100644 --- a/apis/offloading/v1alpha1/zz_generated.deepcopy.go +++ b/apis/offloading/v1alpha1/zz_generated.deepcopy.go @@ -1,5 +1,4 @@ //go:build !ignore_autogenerated -// +build !ignore_autogenerated // Copyright 2019-2023 The Liqo Authors // @@ -109,7 +108,8 @@ func (in *NamespaceOffloadingStatus) DeepCopyInto(out *NamespaceOffloadingStatus if val == nil { (*out)[key] = nil } else { - in, out := &val, &outVal + inVal := (*in)[key] + in, out := &inVal, &outVal *out = make(RemoteNamespaceConditions, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) diff --git a/apis/sharing/v1alpha1/zz_generated.deepcopy.go b/apis/sharing/v1alpha1/zz_generated.deepcopy.go index 80ac336702..0d93152946 100644 --- a/apis/sharing/v1alpha1/zz_generated.deepcopy.go +++ b/apis/sharing/v1alpha1/zz_generated.deepcopy.go @@ -1,5 +1,4 @@ //go:build !ignore_autogenerated -// +build !ignore_autogenerated // Copyright 2019-2023 The Liqo Authors // diff --git a/apis/virtualkubelet/v1alpha1/zz_generated.deepcopy.go b/apis/virtualkubelet/v1alpha1/zz_generated.deepcopy.go index 8a38134a7e..ddfc752a1d 100644 --- a/apis/virtualkubelet/v1alpha1/zz_generated.deepcopy.go +++ b/apis/virtualkubelet/v1alpha1/zz_generated.deepcopy.go @@ -1,5 +1,4 @@ //go:build !ignore_autogenerated -// +build !ignore_autogenerated // Copyright 2019-2023 The Liqo Authors // diff --git a/cmd/liqonet/network-manager.go b/cmd/liqonet/network-manager.go index 2883152346..9841da876c 100644 --- a/cmd/liqonet/network-manager.go +++ b/cmd/liqonet/network-manager.go @@ -30,6 +30,7 @@ import ( "github.com/liqotech/liqo/internal/liqonet/network-manager/netcfgcreator" "github.com/liqotech/liqo/internal/liqonet/network-manager/tunnelendpointcreator" liqoconst "github.com/liqotech/liqo/pkg/consts" + configurationcontroller "github.com/liqotech/liqo/pkg/liqonet/configuration-controller" liqonetIpam "github.com/liqotech/liqo/pkg/liqonet/ipam" liqonetutils "github.com/liqotech/liqo/pkg/liqonet/utils" "github.com/liqotech/liqo/pkg/utils/args" @@ -109,6 +110,8 @@ func runNetworkManager(commonFlags *liqonetCommonFlags, managerFlags *networkMan ExternalCIDR: externalCIDR, } + cfgr := configurationcontroller.NewConfigurationReconciler(mgr.GetClient(), mgr.GetScheme(), mgr.GetEventRecorderFor("configuration-controller")) + if err = tec.SetupWithManager(mgr); err != nil { klog.Errorf("unable to create controller TunnelEndpointCreator: %s", err) os.Exit(1) @@ -119,6 +122,11 @@ func runNetworkManager(commonFlags *liqonetCommonFlags, managerFlags *networkMan os.Exit(1) } + if err = cfgr.SetupWithManager(mgr); err != nil { + klog.Errorf("unable to create controller ConfigurationReconciler: %s", err) + os.Exit(1) + } + klog.Info("starting manager as liqo-network-manager") if err := mgr.Start(tec.SetupSignalHandlerForTunEndCreator()); err != nil { klog.Errorf("an error occurred while starting manager: %s", err) diff --git a/deployments/liqo/crds/discovery.liqo.io_foreignclusters.yaml b/deployments/liqo/crds/discovery.liqo.io_foreignclusters.yaml index b2432ec7be..fbea410db3 100644 --- a/deployments/liqo/crds/discovery.liqo.io_foreignclusters.yaml +++ b/deployments/liqo/crds/discovery.liqo.io_foreignclusters.yaml @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.9.2 - creationTimestamp: null + controller-gen.kubebuilder.io/version: v0.13.0 name: foreignclusters.discovery.liqo.io spec: group: discovery.liqo.io diff --git a/deployments/liqo/crds/discovery.liqo.io_resourcerequests.yaml b/deployments/liqo/crds/discovery.liqo.io_resourcerequests.yaml index 21a73dc1ff..1e240724d0 100644 --- a/deployments/liqo/crds/discovery.liqo.io_resourcerequests.yaml +++ b/deployments/liqo/crds/discovery.liqo.io_resourcerequests.yaml @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.9.2 - creationTimestamp: null + controller-gen.kubebuilder.io/version: v0.13.0 name: resourcerequests.discovery.liqo.io spec: group: discovery.liqo.io diff --git a/deployments/liqo/crds/ipam.liqo.io_ips.yaml b/deployments/liqo/crds/ipam.liqo.io_ips.yaml index 00ddee8198..d78ee90d19 100644 --- a/deployments/liqo/crds/ipam.liqo.io_ips.yaml +++ b/deployments/liqo/crds/ipam.liqo.io_ips.yaml @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.9.2 - creationTimestamp: null + controller-gen.kubebuilder.io/version: v0.13.0 name: ips.ipam.liqo.io spec: group: ipam.liqo.io diff --git a/deployments/liqo/crds/ipam.liqo.io_networks.yaml b/deployments/liqo/crds/ipam.liqo.io_networks.yaml index 8e4882c4be..3a9df598e1 100644 --- a/deployments/liqo/crds/ipam.liqo.io_networks.yaml +++ b/deployments/liqo/crds/ipam.liqo.io_networks.yaml @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.9.2 - creationTimestamp: null + controller-gen.kubebuilder.io/version: v0.13.0 name: networks.ipam.liqo.io spec: group: ipam.liqo.io diff --git a/deployments/liqo/crds/net.liqo.io_ipamstorages.yaml b/deployments/liqo/crds/net.liqo.io_ipamstorages.yaml index 1c3c5004aa..7b870c91fb 100644 --- a/deployments/liqo/crds/net.liqo.io_ipamstorages.yaml +++ b/deployments/liqo/crds/net.liqo.io_ipamstorages.yaml @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.9.2 - creationTimestamp: null + controller-gen.kubebuilder.io/version: v0.13.0 name: ipamstorages.net.liqo.io spec: group: net.liqo.io diff --git a/deployments/liqo/crds/net.liqo.io_natmappings.yaml b/deployments/liqo/crds/net.liqo.io_natmappings.yaml index 6f178fbc7e..559fa58384 100644 --- a/deployments/liqo/crds/net.liqo.io_natmappings.yaml +++ b/deployments/liqo/crds/net.liqo.io_natmappings.yaml @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.9.2 - creationTimestamp: null + controller-gen.kubebuilder.io/version: v0.13.0 name: natmappings.net.liqo.io spec: group: net.liqo.io diff --git a/deployments/liqo/crds/net.liqo.io_networkconfigs.yaml b/deployments/liqo/crds/net.liqo.io_networkconfigs.yaml index b46084d002..721ac85949 100644 --- a/deployments/liqo/crds/net.liqo.io_networkconfigs.yaml +++ b/deployments/liqo/crds/net.liqo.io_networkconfigs.yaml @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.9.2 - creationTimestamp: null + controller-gen.kubebuilder.io/version: v0.13.0 name: networkconfigs.net.liqo.io spec: group: net.liqo.io diff --git a/deployments/liqo/crds/net.liqo.io_tunnelendpoints.yaml b/deployments/liqo/crds/net.liqo.io_tunnelendpoints.yaml index 0da7ca882f..8b325010b7 100644 --- a/deployments/liqo/crds/net.liqo.io_tunnelendpoints.yaml +++ b/deployments/liqo/crds/net.liqo.io_tunnelendpoints.yaml @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.9.2 - creationTimestamp: null + controller-gen.kubebuilder.io/version: v0.13.0 name: tunnelendpoints.net.liqo.io spec: group: net.liqo.io diff --git a/deployments/liqo/crds/networking.liqo.io_configurations.yaml b/deployments/liqo/crds/networking.liqo.io_configurations.yaml index 5d6f3e297c..613227d132 100644 --- a/deployments/liqo/crds/networking.liqo.io_configurations.yaml +++ b/deployments/liqo/crds/networking.liqo.io_configurations.yaml @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.9.2 - creationTimestamp: null + controller-gen.kubebuilder.io/version: v0.13.0 name: configurations.networking.liqo.io spec: group: networking.liqo.io diff --git a/deployments/liqo/crds/networking.liqo.io_connections.yaml b/deployments/liqo/crds/networking.liqo.io_connections.yaml index 5845a07cb1..5feece34b9 100644 --- a/deployments/liqo/crds/networking.liqo.io_connections.yaml +++ b/deployments/liqo/crds/networking.liqo.io_connections.yaml @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.9.2 - creationTimestamp: null + controller-gen.kubebuilder.io/version: v0.13.0 name: connections.networking.liqo.io spec: group: networking.liqo.io @@ -95,9 +94,7 @@ spec: format: int32 type: integer protocol: - allOf: - - default: TCP - - default: TCP + default: TCP description: Protocol specifies the protocol of the endpoint. enum: - TCP diff --git a/deployments/liqo/crds/networking.liqo.io_firewallconfigurations.yaml b/deployments/liqo/crds/networking.liqo.io_firewallconfigurations.yaml index 144a587f3d..4bfef7a3a9 100644 --- a/deployments/liqo/crds/networking.liqo.io_firewallconfigurations.yaml +++ b/deployments/liqo/crds/networking.liqo.io_firewallconfigurations.yaml @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.9.2 - creationTimestamp: null + controller-gen.kubebuilder.io/version: v0.13.0 name: firewallconfigurations.networking.liqo.io spec: group: networking.liqo.io diff --git a/deployments/liqo/crds/networking.liqo.io_gatewayclients.yaml b/deployments/liqo/crds/networking.liqo.io_gatewayclients.yaml index 71702f25f2..61bf87d4a6 100644 --- a/deployments/liqo/crds/networking.liqo.io_gatewayclients.yaml +++ b/deployments/liqo/crds/networking.liqo.io_gatewayclients.yaml @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.9.2 - creationTimestamp: null + controller-gen.kubebuilder.io/version: v0.13.0 name: gatewayclients.networking.liqo.io spec: group: networking.liqo.io diff --git a/deployments/liqo/crds/networking.liqo.io_gatewayservers.yaml b/deployments/liqo/crds/networking.liqo.io_gatewayservers.yaml index c0ee1267a7..69d25831c6 100644 --- a/deployments/liqo/crds/networking.liqo.io_gatewayservers.yaml +++ b/deployments/liqo/crds/networking.liqo.io_gatewayservers.yaml @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.9.2 - creationTimestamp: null + controller-gen.kubebuilder.io/version: v0.13.0 name: gatewayservers.networking.liqo.io spec: group: networking.liqo.io @@ -112,9 +111,7 @@ spec: format: int32 type: integer protocol: - allOf: - - default: TCP - - default: TCP + default: TCP description: Protocol specifies the protocol of the endpoint. enum: - TCP diff --git a/deployments/liqo/crds/networking.liqo.io_publickeys.yaml b/deployments/liqo/crds/networking.liqo.io_publickeys.yaml index 5f2b54160c..8b4c3df4c0 100644 --- a/deployments/liqo/crds/networking.liqo.io_publickeys.yaml +++ b/deployments/liqo/crds/networking.liqo.io_publickeys.yaml @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.9.2 - creationTimestamp: null + controller-gen.kubebuilder.io/version: v0.13.0 name: publickeys.networking.liqo.io spec: group: networking.liqo.io diff --git a/deployments/liqo/crds/networking.liqo.io_wggatewayclients.yaml b/deployments/liqo/crds/networking.liqo.io_wggatewayclients.yaml index ce33354679..2d30432728 100644 --- a/deployments/liqo/crds/networking.liqo.io_wggatewayclients.yaml +++ b/deployments/liqo/crds/networking.liqo.io_wggatewayclients.yaml @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.9.2 - creationTimestamp: null + controller-gen.kubebuilder.io/version: v0.13.0 name: wggatewayclients.networking.liqo.io spec: group: networking.liqo.io diff --git a/deployments/liqo/crds/networking.liqo.io_wggatewayclienttemplates.yaml b/deployments/liqo/crds/networking.liqo.io_wggatewayclienttemplates.yaml index c3a05a4bf7..3d3ea94597 100644 --- a/deployments/liqo/crds/networking.liqo.io_wggatewayclienttemplates.yaml +++ b/deployments/liqo/crds/networking.liqo.io_wggatewayclienttemplates.yaml @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.9.2 - creationTimestamp: null + controller-gen.kubebuilder.io/version: v0.13.0 name: wggatewayclienttemplates.networking.liqo.io spec: group: networking.liqo.io diff --git a/deployments/liqo/crds/networking.liqo.io_wggatewayservers.yaml b/deployments/liqo/crds/networking.liqo.io_wggatewayservers.yaml index c639f9ff8d..97b3b22c19 100644 --- a/deployments/liqo/crds/networking.liqo.io_wggatewayservers.yaml +++ b/deployments/liqo/crds/networking.liqo.io_wggatewayservers.yaml @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.9.2 - creationTimestamp: null + controller-gen.kubebuilder.io/version: v0.13.0 name: wggatewayservers.networking.liqo.io spec: group: networking.liqo.io @@ -8973,9 +8972,7 @@ spec: format: int32 type: integer protocol: - allOf: - - default: TCP - - default: TCP + default: TCP description: Protocol specifies the protocol of the endpoint. enum: - TCP diff --git a/deployments/liqo/crds/networking.liqo.io_wggatewayservertemplates.yaml b/deployments/liqo/crds/networking.liqo.io_wggatewayservertemplates.yaml index 28fef0b42c..b4f4994898 100644 --- a/deployments/liqo/crds/networking.liqo.io_wggatewayservertemplates.yaml +++ b/deployments/liqo/crds/networking.liqo.io_wggatewayservertemplates.yaml @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.9.2 - creationTimestamp: null + controller-gen.kubebuilder.io/version: v0.13.0 name: wggatewayservertemplates.networking.liqo.io spec: group: networking.liqo.io diff --git a/deployments/liqo/crds/offloading.liqo.io_namespaceoffloadings.yaml b/deployments/liqo/crds/offloading.liqo.io_namespaceoffloadings.yaml index 2ef225f89e..c9cd8975ea 100644 --- a/deployments/liqo/crds/offloading.liqo.io_namespaceoffloadings.yaml +++ b/deployments/liqo/crds/offloading.liqo.io_namespaceoffloadings.yaml @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.9.2 - creationTimestamp: null + controller-gen.kubebuilder.io/version: v0.13.0 name: namespaceoffloadings.offloading.liqo.io spec: group: offloading.liqo.io diff --git a/deployments/liqo/crds/sharing.liqo.io_resourceoffers.yaml b/deployments/liqo/crds/sharing.liqo.io_resourceoffers.yaml index f7d2b5ed41..dae78c74e4 100644 --- a/deployments/liqo/crds/sharing.liqo.io_resourceoffers.yaml +++ b/deployments/liqo/crds/sharing.liqo.io_resourceoffers.yaml @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.9.2 - creationTimestamp: null + controller-gen.kubebuilder.io/version: v0.13.0 name: resourceoffers.sharing.liqo.io spec: group: sharing.liqo.io diff --git a/deployments/liqo/crds/virtualkubelet.liqo.io_namespacemaps.yaml b/deployments/liqo/crds/virtualkubelet.liqo.io_namespacemaps.yaml index 75e5e9993b..b662046e6c 100644 --- a/deployments/liqo/crds/virtualkubelet.liqo.io_namespacemaps.yaml +++ b/deployments/liqo/crds/virtualkubelet.liqo.io_namespacemaps.yaml @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.9.2 - creationTimestamp: null + controller-gen.kubebuilder.io/version: v0.13.0 name: namespacemaps.virtualkubelet.liqo.io spec: group: virtualkubelet.liqo.io diff --git a/deployments/liqo/crds/virtualkubelet.liqo.io_shadowendpointslices.yaml b/deployments/liqo/crds/virtualkubelet.liqo.io_shadowendpointslices.yaml index bca6ae6d53..999ea4c229 100644 --- a/deployments/liqo/crds/virtualkubelet.liqo.io_shadowendpointslices.yaml +++ b/deployments/liqo/crds/virtualkubelet.liqo.io_shadowendpointslices.yaml @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.9.2 - creationTimestamp: null + controller-gen.kubebuilder.io/version: v0.13.0 name: shadowendpointslices.virtualkubelet.liqo.io spec: group: virtualkubelet.liqo.io diff --git a/deployments/liqo/crds/virtualkubelet.liqo.io_shadowpods.yaml b/deployments/liqo/crds/virtualkubelet.liqo.io_shadowpods.yaml index d3385d8b41..38e20ef13a 100644 --- a/deployments/liqo/crds/virtualkubelet.liqo.io_shadowpods.yaml +++ b/deployments/liqo/crds/virtualkubelet.liqo.io_shadowpods.yaml @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.9.2 - creationTimestamp: null + controller-gen.kubebuilder.io/version: v0.13.0 name: shadowpods.virtualkubelet.liqo.io spec: group: virtualkubelet.liqo.io diff --git a/deployments/liqo/crds/virtualkubelet.liqo.io_virtualnodes.yaml b/deployments/liqo/crds/virtualkubelet.liqo.io_virtualnodes.yaml index 0877602f70..10d3eeda0a 100644 --- a/deployments/liqo/crds/virtualkubelet.liqo.io_virtualnodes.yaml +++ b/deployments/liqo/crds/virtualkubelet.liqo.io_virtualnodes.yaml @@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.9.2 - creationTimestamp: null + controller-gen.kubebuilder.io/version: v0.13.0 name: virtualnodes.virtualkubelet.liqo.io spec: group: virtualkubelet.liqo.io diff --git a/deployments/liqo/files/liqo-network-manager-ClusterRole.yaml b/deployments/liqo/files/liqo-network-manager-ClusterRole.yaml index 8fb45b2f1e..174008704f 100644 --- a/deployments/liqo/files/liqo-network-manager-ClusterRole.yaml +++ b/deployments/liqo/files/liqo-network-manager-ClusterRole.yaml @@ -84,3 +84,12 @@ rules: - patch - update - watch +- apiGroups: + - networking.liqo.io + resources: + - configuration + verbs: + - get + - list + - update + - watch diff --git a/pkg/liqo-controller-manager/ip-controller/ip_controller.go b/pkg/liqo-controller-manager/ip-controller/ip_controller.go index 9dae9dc1ec..93259c33f5 100644 --- a/pkg/liqo-controller-manager/ip-controller/ip_controller.go +++ b/pkg/liqo-controller-manager/ip-controller/ip_controller.go @@ -16,7 +16,6 @@ package ipctrl import ( "context" - "slices" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" @@ -29,6 +28,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/reconcile" + "slices" ipamv1alpha1 "github.com/liqotech/liqo/apis/ipam/v1alpha1" "github.com/liqotech/liqo/apis/virtualkubelet/v1alpha1" diff --git a/pkg/liqonet/configuration-controller/configuration-controller.go b/pkg/liqonet/configuration-controller/configuration-controller.go new file mode 100644 index 0000000000..3601c1d6bb --- /dev/null +++ b/pkg/liqonet/configuration-controller/configuration-controller.go @@ -0,0 +1,71 @@ +// Copyright 2019-2023 The Liqo Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package configurationcontroller + +import ( + "context" + "fmt" + + apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/client-go/tools/record" + "k8s.io/klog/v2" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" + + networkingv1alpha1 "github.com/liqotech/liqo/apis/networking/v1alpha1" +) + +// ConfigurationReconciler manage Configuration lifecycle. +type ConfigurationReconciler struct { + client.Client + Scheme *runtime.Scheme + EventsRecorder record.EventRecorder +} + +// NewConfigurationReconciler returns a new ConfigurationReconciler. +func NewConfigurationReconciler(cl client.Client, s *runtime.Scheme, er record.EventRecorder) *ConfigurationReconciler { + return &ConfigurationReconciler{ + Client: cl, + Scheme: s, + EventsRecorder: er, + } +} + +// cluster-role +// +kubebuilder:rbac:groups=networking.liqo.io,resources=configuration,verbs=get;list;watch;update + +// Reconcile manage NamespaceMaps associated with the virtual-node. +func (r *ConfigurationReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { + configuration := &networkingv1alpha1.Configuration{} + if err := r.Get(ctx, req.NamespacedName, configuration); err != nil { + if apierrors.IsNotFound(err) { + klog.Infof("There is no a configuration called '%s' in '%s'", req.Name, req.Namespace) + return ctrl.Result{}, nil + } + return ctrl.Result{}, fmt.Errorf(" %w --> Unable to get the configuration '%s'", err, req.Name) + } + + klog.Info("Reconciling configuration") + klog.Infof("Configuration: %s", configuration) + + return ctrl.Result{}, nil +} + +// SetupWithManager register the ConfigurationReconciler to the manager. +func (r *ConfigurationReconciler) SetupWithManager(mgr ctrl.Manager) error { + return ctrl.NewControllerManagedBy(mgr). + For(&networkingv1alpha1.Configuration{}).Complete(r) +} diff --git a/pkg/liqonet/configuration-controller/doc.go b/pkg/liqonet/configuration-controller/doc.go new file mode 100644 index 0000000000..86a51f96a2 --- /dev/null +++ b/pkg/liqonet/configuration-controller/doc.go @@ -0,0 +1,15 @@ +// Copyright 2019-2023 The Liqo Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package configurationcontroller