Skip to content

Commit

Permalink
Configuration controller
Browse files Browse the repository at this point in the history
  • Loading branch information
cheina97 committed Sep 19, 2023
1 parent 3598f8e commit 7c8193a
Show file tree
Hide file tree
Showing 37 changed files with 135 additions and 61 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion apis/discovery/v1alpha1/zz_generated.deepcopy.go

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

1 change: 0 additions & 1 deletion apis/ipam/v1alpha1/zz_generated.deepcopy.go

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

4 changes: 2 additions & 2 deletions apis/net/v1alpha1/zz_generated.deepcopy.go

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

1 change: 0 additions & 1 deletion apis/networking/v1alpha1/zz_generated.deepcopy.go

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

4 changes: 2 additions & 2 deletions apis/offloading/v1alpha1/zz_generated.deepcopy.go

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

1 change: 0 additions & 1 deletion apis/sharing/v1alpha1/zz_generated.deepcopy.go

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

1 change: 0 additions & 1 deletion apis/virtualkubelet/v1alpha1/zz_generated.deepcopy.go

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

8 changes: 8 additions & 0 deletions cmd/liqonet/network-manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions deployments/liqo/crds/discovery.liqo.io_foreignclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions deployments/liqo/crds/ipam.liqo.io_ips.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions deployments/liqo/crds/ipam.liqo.io_networks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions deployments/liqo/crds/net.liqo.io_ipamstorages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions deployments/liqo/crds/net.liqo.io_natmappings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions deployments/liqo/crds/net.liqo.io_networkconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions deployments/liqo/crds/net.liqo.io_tunnelendpoints.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions deployments/liqo/crds/networking.liqo.io_configurations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions deployments/liqo/crds/networking.liqo.io_connections.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions deployments/liqo/crds/networking.liqo.io_gatewayclients.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions deployments/liqo/crds/networking.liqo.io_gatewayservers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions deployments/liqo/crds/networking.liqo.io_publickeys.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions deployments/liqo/crds/sharing.liqo.io_resourceoffers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions deployments/liqo/crds/virtualkubelet.liqo.io_shadowpods.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions deployments/liqo/files/liqo-network-manager-ClusterRole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,12 @@ rules:
- patch
- update
- watch
- apiGroups:
- networking.liqo.io
resources:
- configuration
verbs:
- get
- list
- update
- watch
2 changes: 1 addition & 1 deletion pkg/liqo-controller-manager/ip-controller/ip_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package ipctrl

import (
"context"
"slices"

apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/labels"
Expand All @@ -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"
Expand Down
Loading

0 comments on commit 7c8193a

Please sign in to comment.