diff --git a/cmd/crd-replicator/main.go b/cmd/crd-replicator/main.go index 69fd3ed0f7..b18aa12b7e 100644 --- a/cmd/crd-replicator/main.go +++ b/cmd/crd-replicator/main.go @@ -65,7 +65,6 @@ func main() { mgr, err := ctrl.NewManager(cfg, ctrl.Options{ MapperProvider: mapper.LiqoMapperProvider(scheme), Scheme: scheme, - Port: 9443, LeaderElection: false, }) if err != nil { diff --git a/cmd/discovery/main.go b/cmd/discovery/main.go index 34838fe1cf..1f8e6f2886 100644 --- a/cmd/discovery/main.go +++ b/cmd/discovery/main.go @@ -23,8 +23,10 @@ import ( clientgoscheme "k8s.io/client-go/kubernetes/scheme" "k8s.io/klog/v2" ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/cache" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/log" + "sigs.k8s.io/controller-runtime/pkg/metrics/server" discoveryv1alpha1 "github.com/liqotech/liqo/apis/discovery/v1alpha1" nettypes "github.com/liqotech/liqo/apis/net/v1alpha1" @@ -96,10 +98,16 @@ func main() { // Create an accessory manager restricted to the given namespace only, to avoid introducing // performance overhead and requiring excessively wide permissions when not necessary. auxmgr, err := ctrl.NewManager(config, ctrl.Options{ - MapperProvider: mapper.LiqoMapperProvider(scheme), - Scheme: scheme, - Namespace: *namespace, - MetricsBindAddress: "0", // Disable the metrics of the auxiliary manager to prevent conflicts. + MapperProvider: mapper.LiqoMapperProvider(scheme), + Scheme: scheme, + Metrics: server.Options{ + BindAddress: "0", // Disable the metrics of the auxiliary manager to prevent conflicts. + }, + Cache: cache.Options{ + DefaultNamespaces: map[string]cache.Config{ + *namespace: {}, + }, + }, }) if err != nil { klog.Errorf("Unable to create auxiliary (namespaced) manager: %w", err) diff --git a/cmd/liqo-controller-manager/main.go b/cmd/liqo-controller-manager/main.go index b5705a2b51..31bf9d341b 100644 --- a/cmd/liqo-controller-manager/main.go +++ b/cmd/liqo-controller-manager/main.go @@ -44,6 +44,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/healthz" "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/manager" + "sigs.k8s.io/controller-runtime/pkg/metrics/server" "sigs.k8s.io/controller-runtime/pkg/webhook" "sigs.k8s.io/sig-storage-lib-external-provisioner/v7/controller" @@ -230,16 +231,22 @@ func main() { // Create the main manager. // This manager caches only the pods that are offloaded from a remote cluster and are scheduled on this. mgr, err := ctrl.NewManager(config, ctrl.Options{ - MapperProvider: mapper.LiqoMapperProvider(scheme), - Scheme: scheme, - MetricsBindAddress: *metricsAddr, + MapperProvider: mapper.LiqoMapperProvider(scheme), + Scheme: scheme, + Metrics: server.Options{ + BindAddress: *metricsAddr, + }, HealthProbeBindAddress: *probeAddr, LeaderElection: *leaderElection, LeaderElectionID: "66cf253f.ctrlmgr.liqo.io", LeaderElectionNamespace: *liqoNamespace, LeaderElectionReleaseOnCancel: true, LeaderElectionResourceLock: resourcelock.LeasesResourceLock, - Port: int(*webhookPort), + WebhookServer: &webhook.DefaultServer{ + Options: webhook.Options{ + Port: int(*webhookPort), + }, + }, NewCache: func(config *rest.Config, opts cache.Options) (cache.Cache, error) { opts.ByObject = map[client.Object]cache.ByObject{ &corev1.Pod{}: { @@ -261,9 +268,9 @@ func main() { // Create an accessory manager that cache only local offloaded pods. // This manager caches only the pods that are offloaded and scheduled on a remote cluster. auxmgrLocalPods, err := ctrl.NewManager(config, ctrl.Options{ - MapperProvider: mapper.LiqoMapperProvider(scheme), - Scheme: scheme, - MetricsBindAddress: "0", // Disable the metrics of the auxiliary manager to prevent conflicts. + MapperProvider: mapper.LiqoMapperProvider(scheme), + Scheme: scheme, + Metrics: server.Options{BindAddress: "0"}, // Disable the metrics of the auxiliary manager to prevent conflicts. NewCache: func(config *rest.Config, opts cache.Options) (cache.Cache, error) { opts.ByObject = map[client.Object]cache.ByObject{ &corev1.Pod{}: { @@ -287,9 +294,9 @@ func main() { // Create an accessory manager that cache only local offloaded pods. // This manager caches only virtual kubelet pods. auxmgrVirtualKubeletPods, err := ctrl.NewManager(config, ctrl.Options{ - MapperProvider: mapper.LiqoMapperProvider(scheme), - Scheme: scheme, - MetricsBindAddress: "0", // Disable the metrics of the auxiliary manager to prevent conflicts. + MapperProvider: mapper.LiqoMapperProvider(scheme), + Scheme: scheme, + Metrics: server.Options{BindAddress: "0"}, // Disable the metrics of the auxiliary manager to prevent conflicts. NewCache: func(config *rest.Config, opts cache.Options) (cache.Cache, error) { opts.ByObject = map[client.Object]cache.ByObject{ &corev1.Pod{}: { diff --git a/cmd/liqonet/gateway-operator.go b/cmd/liqonet/gateway-operator.go index 9f9d6478e7..0589631a84 100644 --- a/cmd/liqonet/gateway-operator.go +++ b/cmd/liqonet/gateway-operator.go @@ -34,6 +34,7 @@ import ( ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/cache" "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/metrics/server" tunneloperator "github.com/liqotech/liqo/internal/liqonet/tunnel-operator" liqoconst "github.com/liqotech/liqo/pkg/consts" @@ -117,9 +118,11 @@ func runGatewayOperator(commonFlags *liqonetCommonFlags, gatewayFlags *gatewayOp config := restcfg.SetRateLimiter(ctrl.GetConfigOrDie()) main, err := ctrl.NewManager(config, ctrl.Options{ - MapperProvider: mapper.LiqoMapperProvider(scheme), - Scheme: scheme, - MetricsBindAddress: metricsAddr, + MapperProvider: mapper.LiqoMapperProvider(scheme), + Scheme: scheme, + Metrics: server.Options{ + BindAddress: metricsAddr, + }, LeaderElection: enableLeaderElection, LeaderElectionID: liqoconst.GatewayLeaderElectionID, LeaderElectionNamespace: podNamespace, @@ -149,9 +152,9 @@ func runGatewayOperator(commonFlags *liqonetCommonFlags, gatewayFlags *gatewayOp // Create an accessory manager that cache only pods managed by a ShadowPod (i.e., remote offloaded pods). // This manager caches only the pods that are offloaded from a remote cluster and are scheduled on this. auxmgrOffloadedPods, err := ctrl.NewManager(config, ctrl.Options{ - MapperProvider: mapper.LiqoMapperProvider(scheme), - Scheme: scheme, - MetricsBindAddress: "0", // Disable the metrics of the auxiliary manager to prevent conflicts. + MapperProvider: mapper.LiqoMapperProvider(scheme), + Scheme: scheme, + Metrics: server.Options{BindAddress: "0"}, // Disable the metrics of the auxiliary manager to prevent conflicts. NewCache: func(config *rest.Config, opts cache.Options) (cache.Cache, error) { opts.ByObject = map[client.Object]cache.ByObject{ &corev1.Pod{}: { diff --git a/cmd/liqonet/network-manager.go b/cmd/liqonet/network-manager.go index 2883152346..2161f732b5 100644 --- a/cmd/liqonet/network-manager.go +++ b/cmd/liqonet/network-manager.go @@ -26,6 +26,7 @@ import ( ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/cache" "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/metrics/server" "github.com/liqotech/liqo/internal/liqonet/network-manager/netcfgcreator" "github.com/liqotech/liqo/internal/liqonet/network-manager/tunnelendpointcreator" @@ -62,9 +63,11 @@ func runNetworkManager(commonFlags *liqonetCommonFlags, managerFlags *networkMan } mgr, err := ctrl.NewManager(restcfg.SetRateLimiter(ctrl.GetConfigOrDie()), ctrl.Options{ - MapperProvider: mapper.LiqoMapperProvider(scheme), - Scheme: scheme, - MetricsBindAddress: commonFlags.metricsAddr, + MapperProvider: mapper.LiqoMapperProvider(scheme), + Scheme: scheme, + Metrics: server.Options{ + BindAddress: commonFlags.metricsAddr, + }, NewCache: func(config *rest.Config, opts cache.Options) (cache.Cache, error) { opts.ByObject = map[client.Object]cache.ByObject{ &corev1.Secret{}: { diff --git a/cmd/liqonet/route-operator.go b/cmd/liqonet/route-operator.go index e768a6a607..51f3d81e34 100644 --- a/cmd/liqonet/route-operator.go +++ b/cmd/liqonet/route-operator.go @@ -30,6 +30,7 @@ import ( ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/cache" "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/metrics/server" routeoperator "github.com/liqotech/liqo/internal/liqonet/route-operator" liqoconst "github.com/liqotech/liqo/pkg/consts" @@ -104,9 +105,11 @@ func runRouteOperator(commonFlags *liqonetCommonFlags, routeFlags *routeOperator smcLabelSelector := labels.NewSelector().Add(*smcLabelRequirement) mainMgr, err := ctrl.NewManager(restcfg.SetRateLimiter(ctrl.GetConfigOrDie()), ctrl.Options{ - MapperProvider: mapper.LiqoMapperProvider(scheme), - Scheme: scheme, - MetricsBindAddress: commonFlags.metricsAddr, + MapperProvider: mapper.LiqoMapperProvider(scheme), + Scheme: scheme, + Metrics: server.Options{ + BindAddress: commonFlags.metricsAddr, + }, NewCache: func(config *rest.Config, opts cache.Options) (cache.Cache, error) { opts.ByObject = map[client.Object]cache.ByObject{ &corev1.Pod{}: { @@ -129,17 +132,18 @@ func runRouteOperator(commonFlags *liqonetCommonFlags, routeFlags *routeOperator // This manager is used by the overlay operator and it is limited to the pods running // on the same namespace as the operator. overlayMgr, err := ctrl.NewManager(mainMgr.GetConfig(), ctrl.Options{ - MapperProvider: mapper.LiqoMapperProvider(scheme), - Scheme: scheme, - MetricsBindAddress: ":0", - Namespace: podNamespace, - NewCache: func(config *rest.Config, opts cache.Options) (cache.Cache, error) { - opts.ByObject = map[client.Object]cache.ByObject{ + MapperProvider: mapper.LiqoMapperProvider(scheme), + Scheme: scheme, + Metrics: server.Options{BindAddress: "0"}, // Disable the metrics of the auxiliary manager to prevent conflicts. + Cache: cache.Options{ + DefaultNamespaces: map[string]cache.Config{ + podNamespace: {}, + }, + ByObject: map[client.Object]cache.ByObject{ &corev1.Pod{}: { Label: ovcLabelSelector, }, - } - return cache.New(config, opts) + }, }, }) if err != nil { diff --git a/go.mod b/go.mod index ee193791d5..2aec3cf336 100644 --- a/go.mod +++ b/go.mod @@ -59,7 +59,7 @@ require ( k8s.io/metrics v0.28.2 k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 sigs.k8s.io/aws-iam-authenticator v0.6.12 - sigs.k8s.io/controller-runtime v0.15.1 + sigs.k8s.io/controller-runtime v0.16.2 sigs.k8s.io/sig-storage-lib-external-provisioner/v7 v7.0.1 ) @@ -239,13 +239,12 @@ require ( go.opentelemetry.io/otel/metric v1.16.0 // indirect go.opentelemetry.io/otel/trace v1.16.0 // indirect go.starlark.net v0.0.0-20230525235612-a134d8f9ddca // indirect - go.uber.org/atomic v1.10.0 // indirect go.uber.org/multierr v1.11.0 // indirect - go.uber.org/zap v1.24.0 // indirect - golang.org/x/crypto v0.14.0 // indirect - golang.org/x/net v0.17.0 // indirect + go.uber.org/zap v1.25.0 // indirect + golang.org/x/crypto v0.13.0 // indirect + golang.org/x/net v0.15.0 // indirect golang.org/x/oauth2 v0.11.0 // indirect - golang.org/x/term v0.13.0 // indirect + golang.org/x/term v0.12.0 // indirect golang.org/x/time v0.3.0 // indirect golang.org/x/tools v0.13.0 // indirect golang.zx2c4.com/wireguard v0.0.0-20220904105730-b51010ba13f0 // indirect diff --git a/go.sum b/go.sum index 98c5cf9c88..d597cf5a17 100644 --- a/go.sum +++ b/go.sum @@ -863,14 +863,12 @@ go.opentelemetry.io/otel/trace v1.16.0/go.mod h1:Yt9vYq1SdNz3xdjZZK7wcXv1qv2pwLk go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.starlark.net v0.0.0-20230525235612-a134d8f9ddca h1:VdD38733bfYv5tUZwEIskMM93VanwNIi5bIKnDrJdEY= go.starlark.net v0.0.0-20230525235612-a134d8f9ddca/go.mod h1:jxU+3+j+71eXOW14274+SmmuW82qJzl6iZSeqEtTGds= -go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= -go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A= go.uber.org/goleak v1.2.1/go.mod h1:qlT2yGI9QafXHhZZLxlSuNsMw3FFLxBr+tBRlmO1xH4= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= -go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= +go.uber.org/zap v1.25.0 h1:4Hvk6GtkucQ790dqmj7l1eEnRdKm3k3ZUrUMS2d5+5c= +go.uber.org/zap v1.25.0/go.mod h1:JIAUzQIH94IC4fOJQm7gMmBJP5k7wQfdcnYdPoEXJYk= go4.org/netipx v0.0.0-20220925034521-797b0c90d8ab h1:+yW1yrZ09EYNu1spCUOHBBNRbrLnfmutwyhbhCv3b6Q= go4.org/netipx v0.0.0-20220925034521-797b0c90d8ab/go.mod h1:tgPU4N2u9RByaTN3NC2p9xOzyFpte4jYwsIIRF7XlSc= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= @@ -893,8 +891,8 @@ golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4 golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= -golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= +golang.org/x/crypto v0.13.0 h1:mvySKfSWJ+UKUii46M40LOvyWfN0s2U+46/jDd0e6Ck= +golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -974,8 +972,8 @@ golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= -golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= +golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8= +golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1069,8 +1067,8 @@ golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= -golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek= -golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= +golang.org/x/term v0.12.0 h1:/ZfYdc3zq+q02Rv9vGqTeSItdzZTSNDmfTi0mBAuidU= +golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1311,8 +1309,8 @@ rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= sigs.k8s.io/aws-iam-authenticator v0.6.12 h1:XlW7djx+FqvyIysdBN60AIKBvHMr+MWVT87U0cG+Qlk= sigs.k8s.io/aws-iam-authenticator v0.6.12/go.mod h1:uh/d/yhtzJXBdevntKgTKRaabgD2T/JI/YdV+9IaycE= -sigs.k8s.io/controller-runtime v0.15.1 h1:9UvgKD4ZJGcj24vefUFgZFP3xej/3igL9BsOUTb/+4c= -sigs.k8s.io/controller-runtime v0.15.1/go.mod h1:7ngYvp1MLT+9GeZ+6lH3LOlcHkp/+tzA/fmHa4iq9kk= +sigs.k8s.io/controller-runtime v0.16.2 h1:mwXAVuEk3EQf478PQwQ48zGOXvW27UJc8NHktQVuIPU= +sigs.k8s.io/controller-runtime v0.16.2/go.mod h1:vpMu3LpI5sYWtujJOa2uPK61nB5rbwlN7BAB8aSLvGU= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= sigs.k8s.io/kustomize/api v0.13.5-0.20230601165947-6ce0bf390ce3 h1:XX3Ajgzov2RKUdc5jW3t5jwY7Bo7dcRm+tFxT+NfgY0= diff --git a/internal/liqonet/route-operator/overlayOperator_test.go b/internal/liqonet/route-operator/overlayOperator_test.go index 36bf1a6422..c65c338469 100644 --- a/internal/liqonet/route-operator/overlayOperator_test.go +++ b/internal/liqonet/route-operator/overlayOperator_test.go @@ -32,6 +32,7 @@ import ( clientgoscheme "k8s.io/client-go/kubernetes/scheme" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/envtest" + "sigs.k8s.io/controller-runtime/pkg/metrics/server" liqoerrors "github.com/liqotech/liqo/pkg/liqonet/errors" "github.com/liqotech/liqo/pkg/liqonet/overlay" @@ -400,8 +401,8 @@ func setupOverlayTestEnv() error { return err } mgr, err := ctrl.NewManager(config, ctrl.Options{ - Scheme: overlayScheme, - MetricsBindAddress: "0", + Scheme: overlayScheme, + Metrics: server.Options{BindAddress: "0"}, // this avoids port binding collision }) go func() { if err = mgr.Start(context.Background()); err != nil { diff --git a/internal/liqonet/tunnel-operator/tunnel_operator_suite_test.go b/internal/liqonet/tunnel-operator/tunnel_operator_suite_test.go index 43e7109cdf..0b4d8dfa2b 100644 --- a/internal/liqonet/tunnel-operator/tunnel_operator_suite_test.go +++ b/internal/liqonet/tunnel-operator/tunnel_operator_suite_test.go @@ -29,6 +29,7 @@ import ( controllerruntime "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/envtest" + "sigs.k8s.io/controller-runtime/pkg/metrics/server" "sigs.k8s.io/controller-runtime/pkg/reconcile" "github.com/liqotech/liqo/apis/discovery/v1alpha1" @@ -125,8 +126,8 @@ var _ = BeforeSuite(func() { config, err := envTest.Start() Expect(err).ShouldNot(HaveOccurred()) mgr, err := controllerruntime.NewManager(config, controllerruntime.Options{ - Scheme: scheme.Scheme, - MetricsBindAddress: "0", + Scheme: scheme.Scheme, + Metrics: server.Options{BindAddress: "0"}, // this avoids port binding collision }) Expect(err).ShouldNot(HaveOccurred()) controller, err = NewNatMappingController(mgr.GetClient(), &readyClustersMutex, readyClusters, iptNetns) diff --git a/pkg/liqo-controller-manager/resource-request-controller/suite_test.go b/pkg/liqo-controller-manager/resource-request-controller/suite_test.go index a9d8fb8ffc..c79c40f0e3 100644 --- a/pkg/liqo-controller-manager/resource-request-controller/suite_test.go +++ b/pkg/liqo-controller-manager/resource-request-controller/suite_test.go @@ -31,6 +31,7 @@ import ( ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/envtest" + "sigs.k8s.io/controller-runtime/pkg/metrics/server" discoveryv1alpha1 "github.com/liqotech/liqo/apis/discovery/v1alpha1" sharingv1alpha1 "github.com/liqotech/liqo/apis/sharing/v1alpha1" @@ -79,8 +80,8 @@ func createCluster() { By("Starting a new manager") k8sManager, err := ctrl.NewManager(cfg, ctrl.Options{ - Scheme: scheme.Scheme, - MetricsBindAddress: "0", // this avoids port binding collision + Scheme: scheme.Scheme, + Metrics: server.Options{BindAddress: "0"}, // this avoids port binding collision }) Expect(err).ToNot(HaveOccurred()) // Disabling panic on failure. diff --git a/pkg/liqo-controller-manager/virtualnode-controller/suite_test.go b/pkg/liqo-controller-manager/virtualnode-controller/suite_test.go index 921eb653a5..caa8fad0a8 100644 --- a/pkg/liqo-controller-manager/virtualnode-controller/suite_test.go +++ b/pkg/liqo-controller-manager/virtualnode-controller/suite_test.go @@ -31,6 +31,7 @@ import ( ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/envtest" + "sigs.k8s.io/controller-runtime/pkg/metrics/server" discoveryv1alpha1 "github.com/liqotech/liqo/apis/discovery/v1alpha1" mapsv1alpha1 "github.com/liqotech/liqo/apis/virtualkubelet/v1alpha1" @@ -114,8 +115,8 @@ var _ = BeforeSuite(func() { // +kubebuilder:scaffold:scheme k8sManager, err := ctrl.NewManager(cfg, ctrl.Options{ - Scheme: scheme.Scheme, - MetricsBindAddress: "0", // this avoids port binding collision + Scheme: scheme.Scheme, + Metrics: server.Options{BindAddress: "0"}, // this avoids port binding collision }) Expect(err).ToNot(HaveOccurred()) diff --git a/pkg/utils/testutil/cluster.go b/pkg/utils/testutil/cluster.go index cc18606509..c912119455 100644 --- a/pkg/utils/testutil/cluster.go +++ b/pkg/utils/testutil/cluster.go @@ -23,6 +23,7 @@ import ( ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/envtest" "sigs.k8s.io/controller-runtime/pkg/manager" + "sigs.k8s.io/controller-runtime/pkg/metrics/server" discoveryv1alpha1 "github.com/liqotech/liqo/apis/discovery/v1alpha1" netv1alpha1 "github.com/liqotech/liqo/apis/net/v1alpha1" @@ -75,8 +76,8 @@ func NewTestCluster(crdPath []string) (Cluster, manager.Manager, error) { utilruntime.Must(virtualkubeletv1alpha1.AddToScheme(scheme.Scheme)) mgr, err := ctrl.NewManager(cluster.cfg, ctrl.Options{ - Scheme: scheme.Scheme, - MetricsBindAddress: "0", // this avoids port binding collision + Scheme: scheme.Scheme, + Metrics: server.Options{BindAddress: "0"}, // this avoids port binding collision }) if err != nil { klog.Error(err) diff --git a/test/integration/integration_suite_test.go b/test/integration/integration_suite_test.go index 2491a79872..7ac7150ad9 100644 --- a/test/integration/integration_suite_test.go +++ b/test/integration/integration_suite_test.go @@ -31,6 +31,7 @@ import ( controllerruntime "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/envtest" + "sigs.k8s.io/controller-runtime/pkg/metrics/server" discoveryv1alpha1 "github.com/liqotech/liqo/apis/discovery/v1alpha1" netv1alpha1 "github.com/liqotech/liqo/apis/net/v1alpha1" @@ -148,8 +149,8 @@ func initNatMappingController() error { return err } mgr, err := controllerruntime.NewManager(config, controllerruntime.Options{ - Scheme: scheme.Scheme, - MetricsBindAddress: "0", + Scheme: scheme.Scheme, + Metrics: server.Options{BindAddress: "0"}, // this avoids port binding collision }) if err != nil { return err