diff --git a/api/v1beta2/mysqlcluster_webhook_test.go b/api/v1beta2/mysqlcluster_webhook_test.go index 7ef0d21f3..4b2b70f4d 100644 --- a/api/v1beta2/mysqlcluster_webhook_test.go +++ b/api/v1beta2/mysqlcluster_webhook_test.go @@ -35,10 +35,8 @@ func makeMySQLCluster() *mocov1beta2.MySQLCluster { }, Spec: mocov1beta2.PersistentVolumeClaimSpecApplyConfiguration(*corev1ac.PersistentVolumeClaimSpec(). WithStorageClassName("default"). - WithResources(corev1ac.ResourceRequirements(). - WithRequests(corev1.ResourceList{ - corev1.ResourceStorage: resource.MustParse("1Gi"), - })), + WithResources( + corev1ac.VolumeResourceRequirements().WithRequests(corev1.ResourceList{corev1.ResourceStorage: resource.MustParse("1Gi")})), ), }, }, diff --git a/api/v1beta2/webhook_suite_test.go b/api/v1beta2/webhook_suite_test.go index 68091cf0f..e0b328c89 100644 --- a/api/v1beta2/webhook_suite_test.go +++ b/api/v1beta2/webhook_suite_test.go @@ -24,6 +24,8 @@ import ( "sigs.k8s.io/controller-runtime/pkg/envtest" logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/log/zap" + metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server" + "sigs.k8s.io/controller-runtime/pkg/webhook" ) // These tests use Ginkgo (BDD-style Go testing framework). Refer to @@ -80,11 +82,15 @@ var _ = BeforeSuite(func() { webhookInstallOptions := &testEnv.CRDInstallOptions.WebhookOptions mgr, err := ctrl.NewManager(cfg, ctrl.Options{ Scheme: scheme, - Host: webhookInstallOptions.LocalServingHost, - Port: webhookInstallOptions.LocalServingPort, - CertDir: webhookInstallOptions.LocalServingCertDir, + WebhookServer: webhook.NewServer(webhook.Options{ + Host: webhookInstallOptions.LocalServingHost, + Port: webhookInstallOptions.LocalServingPort, + CertDir: webhookInstallOptions.LocalServingCertDir, + }), LeaderElection: false, - MetricsBindAddress: "0", + Metrics: metricsserver.Options{ + BindAddress: "0", + }, }) Expect(err).NotTo(HaveOccurred()) diff --git a/clustering/manager_test.go b/clustering/manager_test.go index 57c12f8f2..a6cc08c00 100644 --- a/clustering/manager_test.go +++ b/clustering/manager_test.go @@ -21,6 +21,7 @@ import ( ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/manager" + metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server" ) func testSetupResources(ctx context.Context, replicas int32, sourceSecret string) { @@ -127,7 +128,9 @@ var _ = Describe("manager", func() { mgr, err = ctrl.NewManager(cfg, ctrl.Options{ Scheme: scheme, LeaderElection: false, - MetricsBindAddress: "0", + Metrics: metricsserver.Options{ + BindAddress: "0", + }, }) Expect(err).NotTo(HaveOccurred()) diff --git a/cmd/moco-controller/cmd/run.go b/cmd/moco-controller/cmd/run.go index 7e645b8d4..1beec6dd7 100644 --- a/cmd/moco-controller/cmd/run.go +++ b/cmd/moco-controller/cmd/run.go @@ -20,6 +20,8 @@ import ( "sigs.k8s.io/controller-runtime/pkg/healthz" "sigs.k8s.io/controller-runtime/pkg/log/zap" k8smetrics "sigs.k8s.io/controller-runtime/pkg/metrics" + metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server" + "sigs.k8s.io/controller-runtime/pkg/webhook" // +kubebuilder:scaffold:imports ) @@ -68,15 +70,20 @@ func subMain(ns, addr string, port int) error { mgr, err := ctrl.NewManager(restCfg, ctrl.Options{ Scheme: scheme, - MetricsBindAddress: config.metricsAddr, + Metrics: metricsserver.Options{ + BindAddress: config.metricsAddr, + }, HealthProbeBindAddress: config.probeAddr, PprofBindAddress: config.pprofAddr, LeaderElection: true, LeaderElectionID: config.leaderElectionID, LeaderElectionNamespace: ns, - Host: addr, - Port: port, - CertDir: config.certDir, + WebhookServer: webhook.NewServer(webhook.Options{ + Host: addr, + Port: port, + CertDir: config.certDir, + }), + }) if err != nil { setupLog.Error(err, "unable to start manager") diff --git a/controllers/mysqlcluster_controller_test.go b/controllers/mysqlcluster_controller_test.go index d8a418fd3..d77a38b73 100644 --- a/controllers/mysqlcluster_controller_test.go +++ b/controllers/mysqlcluster_controller_test.go @@ -51,9 +51,13 @@ func testNewMySQLCluster(ns string) *mocov1beta2.MySQLCluster { { ObjectMeta: mocov1beta2.ObjectMeta{Name: "mysql-data"}, Spec: mocov1beta2.PersistentVolumeClaimSpecApplyConfiguration(*corev1ac.PersistentVolumeClaimSpec(). - WithStorageClassName("hoge").WithResources(corev1ac.ResourceRequirements(). - WithRequests(corev1.ResourceList{corev1.ResourceStorage: *resource.NewQuantity(1<<30, resource.BinarySI)}), - )), + WithStorageClassName("hoge"). + WithResources( + corev1ac.VolumeResourceRequirements().WithRequests( + corev1.ResourceList{corev1.ResourceStorage: *resource.NewQuantity(1<<30, resource.BinarySI)}, + ), + ), + ), }, } return cluster diff --git a/controllers/pod_watcher_test.go b/controllers/pod_watcher_test.go index d0dcdcade..5bd09bea2 100644 --- a/controllers/pod_watcher_test.go +++ b/controllers/pod_watcher_test.go @@ -14,6 +14,7 @@ import ( "k8s.io/utils/ptr" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" + metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server" ) func testNewSts(ns string) *appsv1.StatefulSet { @@ -64,7 +65,9 @@ var _ = Describe("PodWatcher", func() { mgr, err := ctrl.NewManager(cfg, ctrl.Options{ Scheme: scheme, LeaderElection: false, - MetricsBindAddress: "0", + Metrics: metricsserver.Options{ + BindAddress: "0", + }, }) Expect(err).ToNot(HaveOccurred()) diff --git a/controllers/pvc_test.go b/controllers/pvc_test.go index 48b1e780c..fb14dbac4 100644 --- a/controllers/pvc_test.go +++ b/controllers/pvc_test.go @@ -263,7 +263,7 @@ func TestNeedResizePVC(t *testing.T) { }, Spec: corev1.PersistentVolumeClaimSpec{ StorageClassName: ptr.To[string]("default"), - Resources: corev1.ResourceRequirements{ + Resources: corev1.VolumeResourceRequirements{ Requests: corev1.ResourceList{corev1.ResourceStorage: resource.MustParse("1Gi")}, }, }, @@ -282,7 +282,7 @@ func TestNeedResizePVC(t *testing.T) { pvc := mocov1beta2.PersistentVolumeClaim{ ObjectMeta: mocov1beta2.ObjectMeta{Name: "new-data"}, Spec: mocov1beta2.PersistentVolumeClaimSpecApplyConfiguration(*corev1ac.PersistentVolumeClaimSpec(). - WithStorageClassName("default").WithResources(corev1ac.ResourceRequirements(). + WithStorageClassName("default").WithResources(corev1ac.VolumeResourceRequirements(). WithRequests(corev1.ResourceList{corev1.ResourceStorage: resource.MustParse("1Gi")}), )), } @@ -299,7 +299,7 @@ func TestNeedResizePVC(t *testing.T) { pvc := mocov1beta2.PersistentVolumeClaim{ ObjectMeta: mocov1beta2.ObjectMeta{Name: "new-data"}, Spec: mocov1beta2.PersistentVolumeClaimSpecApplyConfiguration(*corev1ac.PersistentVolumeClaimSpec(). - WithStorageClassName("default").WithResources(corev1ac.ResourceRequirements(). + WithStorageClassName("default").WithResources(corev1ac.VolumeResourceRequirements(). WithRequests(corev1.ResourceList{corev1.ResourceStorage: resource.MustParse("1Gi")}), )), } @@ -314,7 +314,7 @@ func TestNeedResizePVC(t *testing.T) { }, Spec: corev1.PersistentVolumeClaimSpec{ StorageClassName: ptr.To[string]("default"), - Resources: corev1.ResourceRequirements{ + Resources: corev1.VolumeResourceRequirements{ Requests: corev1.ResourceList{corev1.ResourceStorage: resource.MustParse("2Gi")}, }, }, @@ -374,7 +374,7 @@ func newMySQLClusterWithVolumeSize(size resource.Quantity) *mocov1beta2.MySQLClu { ObjectMeta: mocov1beta2.ObjectMeta{Name: "mysql-data"}, Spec: mocov1beta2.PersistentVolumeClaimSpecApplyConfiguration(*corev1ac.PersistentVolumeClaimSpec(). - WithStorageClassName("default").WithResources(corev1ac.ResourceRequirements(). + WithStorageClassName("default").WithResources(corev1ac.VolumeResourceRequirements(). WithRequests(corev1.ResourceList{corev1.ResourceStorage: size}), )), }, @@ -406,7 +406,7 @@ func newStatefulSetWithVolumeSize(size resource.Quantity) *appsv1.StatefulSet { }, Spec: corev1.PersistentVolumeClaimSpec{ StorageClassName: ptr.To[string]("default"), - Resources: corev1.ResourceRequirements{ + Resources: corev1.VolumeResourceRequirements{ Requests: corev1.ResourceList{corev1.ResourceStorage: size}, }, }, diff --git a/go.mod b/go.mod index 73a5d64b7..502133918 100644 --- a/go.mod +++ b/go.mod @@ -29,10 +29,10 @@ require ( google.golang.org/protobuf v1.34.1 k8s.io/api v0.30.1 k8s.io/apimachinery v0.30.1 - k8s.io/cli-runtime v0.30.1 + k8s.io/cli-runtime v0.28.10 k8s.io/client-go v0.30.1 k8s.io/klog/v2 v2.120.1 - k8s.io/kubectl v0.30.1 + k8s.io/kubectl v0.28.10 k8s.io/utils v0.0.0-20240502163921-fe8a2dddb1d0 sigs.k8s.io/controller-runtime v0.18.2 ) diff --git a/go.sum b/go.sum index ee88defe8..2fd74e3f6 100644 --- a/go.sum +++ b/go.sum @@ -440,8 +440,8 @@ k8s.io/apiextensions-apiserver v0.30.0 h1:jcZFKMqnICJfRxTgnC4E+Hpcq8UEhT8B2lhBcQ k8s.io/apiextensions-apiserver v0.30.0/go.mod h1:N9ogQFGcrbWqAY9p2mUAL5mGxsLqwgtUce127VtRX5Y= k8s.io/apimachinery v0.30.1 h1:ZQStsEfo4n65yAdlGTfP/uSHMQSoYzU/oeEbkmF7P2U= k8s.io/apimachinery v0.30.1/go.mod h1:iexa2somDaxdnj7bha06bhb43Zpa6eWH8N8dbqVjTUc= -k8s.io/cli-runtime v0.30.1 h1:kSBBpfrJGS6lllc24KeniI9JN7ckOOJKnmFYH1RpTOw= -k8s.io/cli-runtime v0.30.1/go.mod h1:zhHgbqI4J00pxb6gM3gJPVf2ysDjhQmQtnTxnMScab8= +k8s.io/cli-runtime v0.28.10 h1:H+x/4DA3FoOcDXmExdf5Dx4eUPfSV4qzxVmBFtK534U= +k8s.io/cli-runtime v0.28.10/go.mod h1:vXWKeqv5sH6k/vDwHAjmcgJCcXq/OGyFUwifmN4M0xE= k8s.io/client-go v0.30.1 h1:uC/Ir6A3R46wdkgCV3vbLyNOYyCJ8oZnjtJGKfytl/Q= k8s.io/client-go v0.30.1/go.mod h1:wrAqLNs2trwiCH/wxxmT/x3hKVH9PuV0GGW0oDoHVqc= k8s.io/component-base v0.30.1 h1:bvAtlPh1UrdaZL20D9+sWxsJljMi0QZ3Lmw+kmZAaxQ= @@ -450,8 +450,8 @@ k8s.io/klog/v2 v2.120.1 h1:QXU6cPEOIslTGvZaXvFWiP9VKyeet3sawzTOvdXb4Vw= k8s.io/klog/v2 v2.120.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 h1:BZqlfIlq5YbRMFko6/PM7FjZpUb45WallggurYhKGag= k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340/go.mod h1:yD4MZYeKMBwQKVht279WycxKyM84kkAx2DPrTXaeb98= -k8s.io/kubectl v0.30.1 h1:sHFIRI3oP0FFZmBAVEE8ErjnTyXDPkBcvO88mH9RjuY= -k8s.io/kubectl v0.30.1/go.mod h1:7j+L0Cc38RYEcx+WH3y44jRBe1Q1jxdGPKkX0h4iDq0= +k8s.io/kubectl v0.28.10 h1:ljlWrQVqKZspYESo4u570s3/BbnhiJ2z5LspzIKRSDM= +k8s.io/kubectl v0.28.10/go.mod h1:A1imFpT+xfaRkf+jN1yGHkAnq7hukF74i2ny/iXjbHc= k8s.io/utils v0.0.0-20240502163921-fe8a2dddb1d0 h1:jgGTlFYnhF1PM1Ax/lAlxUPE+KfCIXHaathvJg1C3ak= k8s.io/utils v0.0.0-20240502163921-fe8a2dddb1d0/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/controller-runtime v0.18.2 h1:RqVW6Kpeaji67CY5nPEfRz6ZfFMk0lWQlNrLqlNpx+Q=