diff --git a/go.mod b/go.mod index 9f3ec9f470f..92b562bb37c 100644 --- a/go.mod +++ b/go.mod @@ -34,7 +34,6 @@ require ( github.com/onsi/gomega v1.31.0 github.com/opencontainers/image-spec v1.1.0 github.com/pkg/errors v0.9.1 - github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.71.0 github.com/prometheus/client_golang v1.19.0 github.com/replicatedhq/troubleshoot v0.57.0 github.com/rogpeppe/go-internal v1.12.0 diff --git a/go.sum b/go.sum index cd2c62d84e3..7de2e547ae1 100644 --- a/go.sum +++ b/go.sum @@ -694,8 +694,6 @@ github.com/poy/onpar v1.1.2 h1:QaNrNiZx0+Nar5dLgTVp5mXkyoVFIbepjyEoGSnhbAY= github.com/poy/onpar v1.1.2/go.mod h1:6X8FLNoxyr9kkmnlqpK6LSoiOtrO6MICtWwEuWkLjzg= github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g= github.com/prashantv/gostub v1.1.0/go.mod h1:A5zLQHz7ieHGG7is6LLXLz7I8+3LZzsrV0P1IAHhP5U= -github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.71.0 h1:et+XkusxWLz+XNqZiyMom9tv9ACvNAUyLXti2LTiV7o= -github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.71.0/go.mod h1:3RiUkFmR9kmPZi9r/8a5jw0a9yg+LMmr7qa0wjqvSiI= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v0.9.2/go.mod h1:OsXs2jCmiKlQ1lTBmv21f2mNfw4xf/QclQDMrYNZzcM= github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= diff --git a/pkg/controller/builder/builder_daemon_set.go b/pkg/controller/builder/builder_daemon_set.go deleted file mode 100644 index d6713627c34..00000000000 --- a/pkg/controller/builder/builder_daemon_set.go +++ /dev/null @@ -1,80 +0,0 @@ -/* -Copyright (C) 2022-2024 ApeCloud Co., Ltd - -This file is part of KubeBlocks project - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see . -*/ - -package builder - -import ( - appsv1 "k8s.io/api/apps/v1" - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -type DaemonSetBuilder struct { - BaseBuilder[appsv1.DaemonSet, *appsv1.DaemonSet, DaemonSetBuilder] -} - -func NewDaemonSetBuilder(namespace, name string) *DaemonSetBuilder { - builder := &DaemonSetBuilder{} - builder.init(namespace, name, &appsv1.DaemonSet{}, builder) - return builder -} - -func (builder *DaemonSetBuilder) SetSelector(selector *metav1.LabelSelector) *DaemonSetBuilder { - builder.get().Spec.Selector = selector - return builder -} - -func (builder *DaemonSetBuilder) SetTemplate(template corev1.PodTemplateSpec) *DaemonSetBuilder { - builder.get().Spec.Template = template - return builder -} - -func (builder *DaemonSetBuilder) SetUpdateStrategy(strategy appsv1.DaemonSetUpdateStrategy) *DaemonSetBuilder { - builder.get().Spec.UpdateStrategy = strategy - return builder -} - -func (builder *DaemonSetBuilder) AddLabelsInMap(labels map[string]string) *DaemonSetBuilder { - l := builder.object.GetLabels() - if l == nil { - l = make(map[string]string) - } - for k, v := range labels { - l[k] = v - } - builder.object.SetLabels(l) - return builder.concreteBuilder -} - -func (builder *DaemonSetBuilder) AddMatchLabelsInMap(labels map[string]string) *DaemonSetBuilder { - selector := builder.get().Spec.Selector - if selector == nil { - selector = &metav1.LabelSelector{} - builder.get().Spec.Selector = selector - } - matchLabels := builder.get().Spec.Selector.MatchLabels - if matchLabels == nil { - matchLabels = make(map[string]string, len(labels)) - } - for k, v := range labels { - matchLabels[k] = v - } - builder.get().Spec.Selector.MatchLabels = matchLabels - return builder -} diff --git a/pkg/controller/builder/builder_daemon_set_test.go b/pkg/controller/builder/builder_daemon_set_test.go deleted file mode 100644 index 9daa67cd149..00000000000 --- a/pkg/controller/builder/builder_daemon_set_test.go +++ /dev/null @@ -1,102 +0,0 @@ -/* -Copyright (C) 2022-2024 ApeCloud Co., Ltd - -This file is part of KubeBlocks project - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see . -*/ - -package builder - -import ( - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - - appv1 "k8s.io/api/apps/v1" - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/intstr" - - cfgutil "github.com/apecloud/kubeblocks/pkg/configuration/util" - "github.com/apecloud/kubeblocks/pkg/constant" -) - -var _ = Describe("daemon-set builder", func() { - It("should work well", func() { - const ( - name = "foo" - ns = "default" - ) - - commonLabels := map[string]string{ - constant.AppManagedByLabelKey: constant.AppName, - constant.AppNameLabelKey: "apecloudoteld", - constant.AppInstanceLabelKey: "apecloudoteld", - } - - labelSelector := &metav1.LabelSelector{ - MatchLabels: commonLabels, - } - - podTemplate := corev1.PodTemplateSpec{ - ObjectMeta: metav1.ObjectMeta{ - Labels: commonLabels, - }, - Spec: NewPodBuilder("", ""). - AddServiceAccount("oteld-controller"). - AddContainer(corev1.Container{}). - AddVolumes(corev1.Volume{ - Name: "oteldlog", - VolumeSource: corev1.VolumeSource{ - HostPath: &corev1.HostPathVolumeSource{ - Path: "/var/log/oteld", - Type: cfgutil.ToPointer(corev1.HostPathDirectoryOrCreate), - }}, - }). - AddVolumes(corev1.Volume{ - Name: "root", - VolumeSource: corev1.VolumeSource{ - HostPath: &corev1.HostPathVolumeSource{Path: "/"}}, - }). - SetSecurityContext(corev1.PodSecurityContext{ - RunAsUser: cfgutil.ToPointer(int64(0)), - RunAsGroup: cfgutil.ToPointer(int64(0)), - FSGroup: cfgutil.ToPointer(int64(65534)), - RunAsNonRoot: cfgutil.ToPointer(false), - }). - GetObject().Spec, - } - - daemonset := NewDaemonSetBuilder(ns, name). - SetTemplate(podTemplate). - AddLabelsInMap(commonLabels). - AddMatchLabelsInMap(commonLabels). - SetSelector(labelSelector). - SetUpdateStrategy(appv1.DaemonSetUpdateStrategy{ - Type: appv1.RollingUpdateDaemonSetStrategyType, - RollingUpdate: &appv1.RollingUpdateDaemonSet{ - MaxUnavailable: cfgutil.ToPointer(intstr.FromInt32(10)), - }}). - GetObject() - - Expect(daemonset.Name).Should(Equal(name)) - Expect(daemonset.Namespace).Should(Equal(ns)) - Expect(daemonset.Spec.Template).Should(BeEquivalentTo(podTemplate)) - Expect(daemonset.Spec.Selector.MatchLabels).Should(BeEquivalentTo(commonLabels)) - Expect(daemonset.Labels).Should(BeEquivalentTo(commonLabels)) - Expect(daemonset.Spec.UpdateStrategy.Type).Should(BeEquivalentTo(appv1.RollingUpdateDaemonSetStrategyType)) - Expect(daemonset.Spec.UpdateStrategy.RollingUpdate).ShouldNot(BeNil()) - Expect(daemonset.Spec.UpdateStrategy.RollingUpdate.MaxUnavailable.String()).Should(BeEquivalentTo("10")) - }) -}) diff --git a/pkg/controller/builder/builder_deployment.go b/pkg/controller/builder/builder_deployment.go deleted file mode 100644 index a84654832e8..00000000000 --- a/pkg/controller/builder/builder_deployment.go +++ /dev/null @@ -1,75 +0,0 @@ -/* -Copyright (C) 2022-2024 ApeCloud Co., Ltd - -This file is part of KubeBlocks project - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see . -*/ - -package builder - -import ( - appsv1 "k8s.io/api/apps/v1" - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -type DeploymentBuilder struct { - BaseBuilder[appsv1.Deployment, *appsv1.Deployment, DeploymentBuilder] -} - -func NewDeploymentBuilder(namespace, name string) *DeploymentBuilder { - builder := &DeploymentBuilder{} - builder.init(namespace, name, &appsv1.Deployment{}, builder) - return builder -} - -func (builder *DeploymentBuilder) SetSelector(selector *metav1.LabelSelector) *DeploymentBuilder { - builder.get().Spec.Selector = selector - return builder -} - -func (builder *DeploymentBuilder) SetTemplate(template corev1.PodTemplateSpec) *DeploymentBuilder { - builder.get().Spec.Template = template - return builder -} - -func (builder *DeploymentBuilder) AddLabelsInMap(labels map[string]string) *DeploymentBuilder { - l := builder.object.GetLabels() - if l == nil { - l = make(map[string]string) - } - for k, v := range labels { - l[k] = v - } - builder.object.SetLabels(l) - return builder.concreteBuilder -} - -func (builder *DeploymentBuilder) AddMatchLabelsInMap(labels map[string]string) *DeploymentBuilder { - selector := builder.get().Spec.Selector - if selector == nil { - selector = &metav1.LabelSelector{} - builder.get().Spec.Selector = selector - } - matchLabels := builder.get().Spec.Selector.MatchLabels - if matchLabels == nil { - matchLabels = make(map[string]string, len(labels)) - } - for k, v := range labels { - matchLabels[k] = v - } - builder.get().Spec.Selector.MatchLabels = matchLabels - return builder -} diff --git a/pkg/controller/builder/builder_deployment_test.go b/pkg/controller/builder/builder_deployment_test.go deleted file mode 100644 index 45761271f21..00000000000 --- a/pkg/controller/builder/builder_deployment_test.go +++ /dev/null @@ -1,92 +0,0 @@ -/* -Copyright (C) 2022-2024 ApeCloud Co., Ltd - -This file is part of KubeBlocks project - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see . -*/ - -package builder - -import ( - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - - cfgutil "github.com/apecloud/kubeblocks/pkg/configuration/util" - "github.com/apecloud/kubeblocks/pkg/constant" -) - -var _ = Describe("deployment builder", func() { - It("should work well", func() { - const ( - name = "foo" - ns = "default" - ) - - commonLabels := map[string]string{ - constant.AppManagedByLabelKey: constant.AppName, - constant.AppNameLabelKey: "apecloudoteld", - constant.AppInstanceLabelKey: "apecloudoteld", - } - - labelSelector := &metav1.LabelSelector{ - MatchLabels: commonLabels, - } - - podTemplate := corev1.PodTemplateSpec{ - ObjectMeta: metav1.ObjectMeta{ - Labels: commonLabels, - }, - Spec: NewPodBuilder("", ""). - AddServiceAccount("oteld-controller"). - AddContainer(corev1.Container{}). - AddVolumes(corev1.Volume{ - Name: "oteldlog", - VolumeSource: corev1.VolumeSource{ - HostPath: &corev1.HostPathVolumeSource{ - Path: "/var/log/oteld", - Type: cfgutil.ToPointer(corev1.HostPathDirectoryOrCreate), - }}, - }). - AddVolumes(corev1.Volume{ - Name: "root", - VolumeSource: corev1.VolumeSource{ - HostPath: &corev1.HostPathVolumeSource{Path: "/"}}, - }). - SetSecurityContext(corev1.PodSecurityContext{ - RunAsUser: cfgutil.ToPointer(int64(0)), - RunAsGroup: cfgutil.ToPointer(int64(0)), - FSGroup: cfgutil.ToPointer(int64(65534)), - RunAsNonRoot: cfgutil.ToPointer(false), - }). - GetObject().Spec, - } - - deployment := NewDeploymentBuilder(ns, name). - SetTemplate(podTemplate). - AddLabelsInMap(commonLabels). - AddMatchLabelsInMap(commonLabels). - SetSelector(labelSelector). - GetObject() - - Expect(deployment.Name).Should(BeEquivalentTo(name)) - Expect(deployment.Namespace).Should(BeEquivalentTo(ns)) - Expect(deployment.Spec.Template).Should(BeEquivalentTo(podTemplate)) - Expect(deployment.Spec.Selector.MatchLabels).Should(BeEquivalentTo(commonLabels)) - Expect(deployment.Labels).Should(BeEquivalentTo(commonLabels)) - }) -}) diff --git a/pkg/controller/builder/builder_monitor_service.go b/pkg/controller/builder/builder_monitor_service.go deleted file mode 100644 index d025e77a7a9..00000000000 --- a/pkg/controller/builder/builder_monitor_service.go +++ /dev/null @@ -1,60 +0,0 @@ -/* -Copyright (C) 2022-2024 ApeCloud Co., Ltd - -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 builder - -import ( - monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" - - "github.com/apecloud/kubeblocks/pkg/common" -) - -type MonitorServiceBuilder struct { - BaseBuilder[monitoringv1.ServiceMonitor, *monitoringv1.ServiceMonitor, MonitorServiceBuilder] -} - -func NewMonitorServiceBuilder(namespace, name string) *MonitorServiceBuilder { - builder := &MonitorServiceBuilder{} - builder.init(namespace, name, &monitoringv1.ServiceMonitor{}, builder) - return builder -} - -func (builder *MonitorServiceBuilder) SetMonitorServiceSpec(spec monitoringv1.ServiceMonitorSpec) *MonitorServiceBuilder { - builder.get().Spec = spec - return builder -} - -func (builder *MonitorServiceBuilder) SetDefaultEndpoint(exporter *common.Exporter) *MonitorServiceBuilder { - if exporter == nil { - return builder - } - - if len(builder.get().Spec.Endpoints) != 0 { - return builder - } - - endpoint := monitoringv1.Endpoint{ - Port: exporter.ScrapePort, - // TODO: deprecated: use `port` instead. - // Compatible with previous versions of kb, the old addon supports int type port. - TargetPort: exporter.TargetPort, - Path: common.FromScrapePath(exporter.Exporter), - Scheme: common.FromScheme(exporter.Exporter), - } - - builder.get().Spec.Endpoints = []monitoringv1.Endpoint{endpoint} - return builder -} diff --git a/pkg/controller/builder/builder_monitor_service_test.go b/pkg/controller/builder/builder_monitor_service_test.go deleted file mode 100644 index eecf097588d..00000000000 --- a/pkg/controller/builder/builder_monitor_service_test.go +++ /dev/null @@ -1,56 +0,0 @@ -/* -Copyright (C) 2022-2024 ApeCloud Co., Ltd - -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 builder - -import ( - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - - monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" - - appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1" - "github.com/apecloud/kubeblocks/pkg/common" -) - -var _ = Describe("monitor_service builder", func() { - It("should work well", func() { - const ( - name = "monitor_test" - ns = "default" - ) - - exporter := appsv1.Exporter{ - ScrapePath: "metrics", - ScrapePort: "http-metrics", - ScrapeScheme: appsv1.HTTPSProtocol, - } - - ncs := NewMonitorServiceBuilder(ns, name). - SetMonitorServiceSpec(monitoringv1.ServiceMonitorSpec{}). - SetDefaultEndpoint(&common.Exporter{ - Exporter: exporter, - }). - GetObject() - - Expect(ncs.Name).Should(Equal(name)) - Expect(ncs.Namespace).Should(Equal(ns)) - Expect(len(ncs.Spec.Endpoints)).Should(Equal(1)) - Expect(ncs.Spec.Endpoints[0].Port).Should(Equal("http-metrics")) - Expect(ncs.Spec.Endpoints[0].Scheme).Should(Equal("https")) - Expect(ncs.Spec.Endpoints[0].Path).Should(Equal("metrics")) - }) -}) diff --git a/pkg/controller/builder/builder_stateful_set.go b/pkg/controller/builder/builder_stateful_set.go deleted file mode 100644 index 08ebb7fbff0..00000000000 --- a/pkg/controller/builder/builder_stateful_set.go +++ /dev/null @@ -1,115 +0,0 @@ -/* -Copyright (C) 2022-2024 ApeCloud Co., Ltd - -This file is part of KubeBlocks project - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see . -*/ - -package builder - -import ( - apps "k8s.io/api/apps/v1" - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -type StatefulSetBuilder struct { - BaseBuilder[apps.StatefulSet, *apps.StatefulSet, StatefulSetBuilder] -} - -func NewStatefulSetBuilder(namespace, name string) *StatefulSetBuilder { - builder := &StatefulSetBuilder{} - builder.init(namespace, name, &apps.StatefulSet{}, builder) - return builder -} - -func (builder *StatefulSetBuilder) AddMatchLabel(key, value string) *StatefulSetBuilder { - labels := make(map[string]string, 1) - labels[key] = value - return builder.AddMatchLabelsInMap(labels) -} - -func (builder *StatefulSetBuilder) AddMatchLabels(keyValues ...string) *StatefulSetBuilder { - return builder.AddMatchLabelsInMap(WithMap(keyValues...)) -} - -func (builder *StatefulSetBuilder) AddMatchLabelsInMap(labels map[string]string) *StatefulSetBuilder { - selector := builder.get().Spec.Selector - if selector == nil { - selector = &metav1.LabelSelector{} - builder.get().Spec.Selector = selector - } - matchLabels := builder.get().Spec.Selector.MatchLabels - if matchLabels == nil { - matchLabels = make(map[string]string, len(labels)) - } - for k, v := range labels { - matchLabels[k] = v - } - builder.get().Spec.Selector.MatchLabels = matchLabels - return builder -} - -func (builder *StatefulSetBuilder) SetSelector(selector *metav1.LabelSelector) *StatefulSetBuilder { - builder.get().Spec.Selector = selector - return builder -} - -func (builder *StatefulSetBuilder) SetServiceName(serviceName string) *StatefulSetBuilder { - builder.get().Spec.ServiceName = serviceName - return builder -} - -func (builder *StatefulSetBuilder) SetReplicas(replicas int32) *StatefulSetBuilder { - builder.get().Spec.Replicas = &replicas - return builder -} - -func (builder *StatefulSetBuilder) SetMinReadySeconds(minReadySeconds int32) *StatefulSetBuilder { - builder.get().Spec.MinReadySeconds = minReadySeconds - return builder -} - -func (builder *StatefulSetBuilder) SetPodManagementPolicy(policy apps.PodManagementPolicyType) *StatefulSetBuilder { - builder.get().Spec.PodManagementPolicy = policy - return builder -} - -func (builder *StatefulSetBuilder) SetTemplate(template corev1.PodTemplateSpec) *StatefulSetBuilder { - builder.get().Spec.Template = template - return builder -} - -func (builder *StatefulSetBuilder) AddVolumeClaimTemplates(templates ...corev1.PersistentVolumeClaim) *StatefulSetBuilder { - templateList := builder.get().Spec.VolumeClaimTemplates - templateList = append(templateList, templates...) - builder.get().Spec.VolumeClaimTemplates = templateList - return builder -} - -func (builder *StatefulSetBuilder) SetVolumeClaimTemplates(templates ...corev1.PersistentVolumeClaim) *StatefulSetBuilder { - builder.get().Spec.VolumeClaimTemplates = templates - return builder -} - -func (builder *StatefulSetBuilder) SetUpdateStrategy(strategy apps.StatefulSetUpdateStrategy) *StatefulSetBuilder { - builder.get().Spec.UpdateStrategy = strategy - return builder -} - -func (builder *StatefulSetBuilder) SetUpdateStrategyType(strategyType apps.StatefulSetUpdateStrategyType) *StatefulSetBuilder { - builder.get().Spec.UpdateStrategy.Type = strategyType - return builder -} diff --git a/pkg/controller/builder/builder_stateful_set_test.go b/pkg/controller/builder/builder_stateful_set_test.go deleted file mode 100644 index 103944cfe14..00000000000 --- a/pkg/controller/builder/builder_stateful_set_test.go +++ /dev/null @@ -1,148 +0,0 @@ -/* -Copyright (C) 2022-2024 ApeCloud Co., Ltd - -This file is part of KubeBlocks project - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see . -*/ - -package builder - -import ( - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - "k8s.io/apimachinery/pkg/util/intstr" - - apps "k8s.io/api/apps/v1" - corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/api/resource" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -var _ = Describe("stateful_set builder", func() { - It("should work well", func() { - const ( - name = "foo" - ns = "default" - selectorKey1, selectorValue1 = "foo-1", "bar-1" - selectorKey2, selectorValue2 = "foo-2", "bar-2" - selectorKey3, selectorValue3 = "foo-3", "bar-3" - selectorKey4, selectorValue4 = "foo-4", "bar-4" - port = int32(12345) - serviceName = "foo" - replicas = int32(5) - minReadySeconds = int32(37) - policy = apps.OrderedReadyPodManagement - ) - selectors := map[string]string{selectorKey4: selectorValue4} - pod := NewPodBuilder(ns, "foo"). - AddContainer(corev1.Container{ - Name: "foo", - Image: "bar", - Ports: []corev1.ContainerPort{ - { - Name: "foo", - Protocol: corev1.ProtocolTCP, - ContainerPort: port, - }, - }, - }).GetObject() - template := corev1.PodTemplateSpec{ - ObjectMeta: pod.ObjectMeta, - Spec: pod.Spec, - } - vcs := []corev1.PersistentVolumeClaim{ - { - ObjectMeta: metav1.ObjectMeta{ - Name: "foo-1", - Namespace: ns, - }, - Spec: corev1.PersistentVolumeClaimSpec{ - VolumeName: "foo-1", - Resources: corev1.VolumeResourceRequirements{ - Requests: corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse("500m"), - }, - }, - }, - }, - } - vc := corev1.PersistentVolumeClaim{ - ObjectMeta: metav1.ObjectMeta{ - Name: "foo-2", - Namespace: ns, - }, - Spec: corev1.PersistentVolumeClaimSpec{ - VolumeName: "foo-2", - Resources: corev1.VolumeResourceRequirements{ - Requests: corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse("600m"), - }, - }, - }, - } - partition, maxUnavailable := int32(3), intstr.FromInt(2) - strategy := apps.StatefulSetUpdateStrategy{ - Type: apps.RollingUpdateStatefulSetStrategyType, - RollingUpdate: &apps.RollingUpdateStatefulSetStrategy{ - Partition: &partition, - MaxUnavailable: &maxUnavailable, - }, - } - strategyType := apps.OnDeleteStatefulSetStrategyType - sts := NewStatefulSetBuilder(ns, name). - AddMatchLabel(selectorKey1, selectorValue1). - AddMatchLabels(selectorKey2, selectorValue2, selectorKey3, selectorValue3). - AddMatchLabelsInMap(selectors). - SetServiceName(serviceName). - SetReplicas(replicas). - SetMinReadySeconds(minReadySeconds). - SetPodManagementPolicy(policy). - SetTemplate(template). - SetVolumeClaimTemplates(vcs...). - AddVolumeClaimTemplates(vc). - SetUpdateStrategy(strategy). - SetUpdateStrategyType(strategyType). - GetObject() - - Expect(sts.Name).Should(Equal(name)) - Expect(sts.Namespace).Should(Equal(ns)) - Expect(sts.Spec.Selector).ShouldNot(BeNil()) - Expect(sts.Spec.Selector.MatchLabels).Should(HaveLen(4)) - Expect(sts.Spec.Selector.MatchLabels[selectorKey1]).Should(Equal(selectorValue1)) - Expect(sts.Spec.Selector.MatchLabels[selectorKey2]).Should(Equal(selectorValue2)) - Expect(sts.Spec.Selector.MatchLabels[selectorKey3]).Should(Equal(selectorValue3)) - Expect(sts.Spec.Selector.MatchLabels[selectorKey4]).Should(Equal(selectorValue4)) - Expect(sts.Spec.ServiceName).Should(Equal(serviceName)) - Expect(sts.Spec.Replicas).ShouldNot(BeNil()) - Expect(*sts.Spec.Replicas).Should(Equal(replicas)) - Expect(sts.Spec.PodManagementPolicy).Should(Equal(policy)) - Expect(sts.Spec.Template).Should(Equal(template)) - Expect(sts.Spec.VolumeClaimTemplates).Should(HaveLen(2)) - Expect(sts.Spec.VolumeClaimTemplates[0]).Should(Equal(vcs[0])) - Expect(sts.Spec.VolumeClaimTemplates[1]).Should(Equal(vc)) - Expect(sts.Spec.UpdateStrategy.Type).Should(Equal(strategyType)) - Expect(sts.Spec.UpdateStrategy.RollingUpdate).ShouldNot(BeNil()) - Expect(sts.Spec.UpdateStrategy.RollingUpdate.Partition).ShouldNot(BeNil()) - Expect(*sts.Spec.UpdateStrategy.RollingUpdate.Partition).Should(Equal(partition)) - Expect(sts.Spec.UpdateStrategy.RollingUpdate.MaxUnavailable).ShouldNot(BeNil()) - Expect(sts.Spec.UpdateStrategy.RollingUpdate.MaxUnavailable).ShouldNot(Equal(maxUnavailable)) - - labelSelector := &metav1.LabelSelector{ - MatchLabels: selectors, - } - sts = NewStatefulSetBuilder(ns, name).SetSelector(labelSelector).GetObject() - Expect(sts.Spec.Selector).Should(Equal(labelSelector)) - }) -}) diff --git a/pkg/controller/builder/builder_volume_snapshot_class.go b/pkg/controller/builder/builder_volume_snapshot_class.go deleted file mode 100644 index 19bbfb7a102..00000000000 --- a/pkg/controller/builder/builder_volume_snapshot_class.go +++ /dev/null @@ -1,44 +0,0 @@ -/* -Copyright (C) 2022-2024 ApeCloud Co., Ltd - -This file is part of KubeBlocks project - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see . -*/ - -package builder - -import ( - snapshotv1 "github.com/kubernetes-csi/external-snapshotter/client/v6/apis/volumesnapshot/v1" -) - -type VolumeSnapshotClassBuilder struct { - BaseBuilder[snapshotv1.VolumeSnapshotClass, *snapshotv1.VolumeSnapshotClass, VolumeSnapshotClassBuilder] -} - -func NewVolumeSnapshotClassBuilder(namespace, name string) *VolumeSnapshotClassBuilder { - builder := &VolumeSnapshotClassBuilder{} - builder.init(namespace, name, &snapshotv1.VolumeSnapshotClass{}, builder) - return builder -} - -func (builder *VolumeSnapshotClassBuilder) SetDriver(driver string) *VolumeSnapshotClassBuilder { - builder.get().Driver = driver - return builder -} - -func (builder *VolumeSnapshotClassBuilder) SetDeletionPolicy(policy snapshotv1.DeletionPolicy) *VolumeSnapshotClassBuilder { - builder.get().DeletionPolicy = policy - return builder -} diff --git a/pkg/controller/builder/builder_volume_snapshot_class_test.go b/pkg/controller/builder/builder_volume_snapshot_class_test.go deleted file mode 100644 index 4bbab5673f2..00000000000 --- a/pkg/controller/builder/builder_volume_snapshot_class_test.go +++ /dev/null @@ -1,48 +0,0 @@ -/* -Copyright (C) 2022-2024 ApeCloud Co., Ltd - -This file is part of KubeBlocks project - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see . -*/ - -package builder - -import ( - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - - snapshotv1 "github.com/kubernetes-csi/external-snapshotter/client/v6/apis/volumesnapshot/v1" -) - -var _ = Describe("volume snapshot class builder", func() { - It("should work well", func() { - const ( - name = "foo" - ns = "default" - ) - - driver := "openebs-snapshot" - policy := snapshotv1.VolumeSnapshotContentRetain - vsc := NewVolumeSnapshotClassBuilder(ns, name). - SetDriver(driver). - SetDeletionPolicy(policy). - GetObject() - - Expect(vsc.Name).Should(Equal(name)) - Expect(vsc.Namespace).Should(Equal(ns)) - Expect(vsc.Driver).Should(Equal(driver)) - Expect(vsc.DeletionPolicy).Should(Equal(policy)) - }) -}) diff --git a/pkg/controller/factory/builder.go b/pkg/controller/factory/builder.go index fa640487418..785315fbf1d 100644 --- a/pkg/controller/factory/builder.go +++ b/pkg/controller/factory/builder.go @@ -24,7 +24,6 @@ import ( "path/filepath" "strconv" - snapshotv1 "github.com/kubernetes-csi/external-snapshotter/client/v6/apis/volumesnapshot/v1" corev1 "k8s.io/api/core/v1" rbacv1 "k8s.io/api/rbac/v1" "k8s.io/apimachinery/pkg/types" @@ -378,14 +377,6 @@ func setToolsScriptsPath(container *corev1.Container, meta cfgcm.ConfigSpecMeta) }) } -func BuildVolumeSnapshotClass(name string, driver string) *snapshotv1.VolumeSnapshotClass { - return builder.NewVolumeSnapshotClassBuilder("", name). - AddLabels(constant.AppManagedByLabelKey, constant.AppName). - SetDriver(driver). - SetDeletionPolicy(snapshotv1.VolumeSnapshotContentDelete). - GetObject() -} - func BuildServiceAccount(cluster *appsv1.Cluster, saName string) *corev1.ServiceAccount { // TODO(component): compName wellKnownLabels := constant.GetKBWellKnownLabels(cluster.Spec.ClusterDef, cluster.Name, "") diff --git a/pkg/controller/factory/builder_test.go b/pkg/controller/factory/builder_test.go index cc95637b667..2eb38ad3aac 100644 --- a/pkg/controller/factory/builder_test.go +++ b/pkg/controller/factory/builder_test.go @@ -228,15 +228,6 @@ var _ = Describe("builder", func() { Expect(*configmap.SecurityContext.RunAsUser).Should(BeEquivalentTo(int64(0))) }) - It("builds volume snapshot class correctly", func() { - className := "vsc-test" - driverName := "csi-driver-test" - obj := BuildVolumeSnapshotClass(className, driverName) - Expect(obj).ShouldNot(BeNil()) - Expect(obj.Name).Should(Equal(className)) - Expect(obj.Driver).Should(Equal(driverName)) - }) - It("builds cfg manager tools correctly", func() { _, cluster, _ := newClusterObjs(nil) cfgManagerParams := &cfgcm.CfgManagerBuildParams{ diff --git a/pkg/controller/handler/handler_builder_test.go b/pkg/controller/handler/handler_builder_test.go index 76b34e72160..1c9bd60a041 100644 --- a/pkg/controller/handler/handler_builder_test.go +++ b/pkg/controller/handler/handler_builder_test.go @@ -29,6 +29,7 @@ import ( "github.com/golang/mock/gomock" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/util/workqueue" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/event" @@ -53,17 +54,19 @@ var _ = Describe("handler builder test.", func() { eventName := podName + ".123456" labels := map[string]string{ constant.AppManagedByLabelKey: constant.AppName, - constant.AppNameLabelKey: clusterName + "def", - constant.AppComponentLabelKey: componentName + "def", constant.AppInstanceLabelKey: clusterName, constant.KBAppComponentLabelKey: componentName, } its := builder.NewInstanceSetBuilder(namespace, name). AddLabelsInMap(labels). GetObject() - sts := builder.NewStatefulSetBuilder(namespace, stsName). - AddLabelsInMap(labels). - GetObject() + sts := &appsv1.StatefulSet{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: namespace, + Name: stsName, + Labels: labels, + }, + } pod := builder.NewPodBuilder(namespace, podName). SetOwnerReferences("apps/v1", "StatefulSet", sts). GetObject() diff --git a/pkg/controller/kubebuilderx/plan_builder_test.go b/pkg/controller/kubebuilderx/plan_builder_test.go index 114610cc4cd..439cd51956f 100644 --- a/pkg/controller/kubebuilderx/plan_builder_test.go +++ b/pkg/controller/kubebuilderx/plan_builder_test.go @@ -28,7 +28,6 @@ import ( "github.com/golang/mock/gomock" "golang.org/x/exp/slices" - apps "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" "sigs.k8s.io/controller-runtime/pkg/client" @@ -78,30 +77,6 @@ var _ = Describe("plan builder test", func() { Expect(planBuilder.defaultWalkFunc(v)).Should(Succeed()) }) - It("should update sts object", func() { - stsOrig := builder.NewStatefulSetBuilder(namespace, name).SetReplicas(3).GetObject() - sts := stsOrig.DeepCopy() - replicas := int32(5) - sts.Spec.Replicas = &replicas - v := &model.ObjectVertex{ - OriObj: stsOrig, - Obj: sts, - Action: model.ActionUpdatePtr(), - } - k8sMock.EXPECT(). - Update(gomock.Any(), gomock.Any(), gomock.Any()). - DoAndReturn(func(_ context.Context, obj *apps.StatefulSet, _ ...client.UpdateOption) error { - Expect(obj).ShouldNot(BeNil()) - Expect(obj.Namespace).Should(Equal(sts.Namespace)) - Expect(obj.Name).Should(Equal(sts.Name)) - Expect(obj.Spec.Replicas).Should(Equal(sts.Spec.Replicas)) - Expect(obj.Spec.Template).Should(Equal(sts.Spec.Template)) - Expect(obj.Spec.UpdateStrategy).Should(Equal(sts.Spec.UpdateStrategy)) - return nil - }).Times(1) - Expect(planBuilder.defaultWalkFunc(v)).Should(Succeed()) - }) - It("should update svc object", func() { svcOrig := builder.NewServiceBuilder(namespace, name).SetType(corev1.ServiceTypeLoadBalancer).GetObject() svc := svcOrig.DeepCopy() diff --git a/pkg/controller/kubebuilderx/utils_test.go b/pkg/controller/kubebuilderx/utils_test.go index 16650e16928..757ead0e9f0 100644 --- a/pkg/controller/kubebuilderx/utils_test.go +++ b/pkg/controller/kubebuilderx/utils_test.go @@ -26,12 +26,12 @@ import ( . "github.com/onsi/gomega" "github.com/golang/mock/gomock" - appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" + workloads "github.com/apecloud/kubeblocks/apis/workloads/v1" "github.com/apecloud/kubeblocks/pkg/controller/builder" "github.com/apecloud/kubeblocks/pkg/controller/model" testutil "github.com/apecloud/kubeblocks/pkg/testutil/k8s" @@ -48,7 +48,7 @@ var _ = Describe("utils test", func() { controller, k8sMock := testutil.SetupK8sMock() defer controller.Finish() - root := builder.NewStatefulSetBuilder(namespace, name).GetObject() + root := builder.NewInstanceSetBuilder(namespace, name).GetObject() obj0 := builder.NewPodBuilder(namespace, name+"-0").GetObject() obj1 := builder.NewPodBuilder(namespace, name+"-1").GetObject() obj2 := builder.NewPodBuilder(namespace, name+"-2").GetObject() @@ -57,8 +57,8 @@ var _ = Describe("utils test", func() { } k8sMock.EXPECT(). - Get(gomock.Any(), gomock.Any(), &appsv1.StatefulSet{}, gomock.Any()). - DoAndReturn(func(_ context.Context, objKey client.ObjectKey, obj *appsv1.StatefulSet, _ ...client.GetOption) error { + Get(gomock.Any(), gomock.Any(), &workloads.InstanceSet{}, gomock.Any()). + DoAndReturn(func(_ context.Context, objKey client.ObjectKey, obj *workloads.InstanceSet, _ ...client.GetOption) error { *obj = *root return nil }).Times(1) @@ -71,7 +71,7 @@ var _ = Describe("utils test", func() { }).Times(1) req := ctrl.Request{NamespacedName: client.ObjectKeyFromObject(root)} ml := client.MatchingLabels{"foo": "bar"} - tree, err := ReadObjectTree[*appsv1.StatefulSet](context.Background(), k8sMock, req, ml, &corev1.PodList{}) + tree, err := ReadObjectTree[*workloads.InstanceSet](context.Background(), k8sMock, req, ml, &corev1.PodList{}) Expect(err).Should(BeNil()) Expect(tree.GetRoot()).ShouldNot(BeNil()) Expect(tree.GetRoot()).Should(Equal(root)) diff --git a/pkg/controller/model/graph_client_test.go b/pkg/controller/model/graph_client_test.go index 9798af5d25c..e3094f02ccd 100644 --- a/pkg/controller/model/graph_client_test.go +++ b/pkg/controller/model/graph_client_test.go @@ -29,6 +29,7 @@ import ( corev1 "k8s.io/api/core/v1" "sigs.k8s.io/controller-runtime/pkg/client" + workloads "github.com/apecloud/kubeblocks/apis/workloads/v1" "github.com/apecloud/kubeblocks/pkg/controller/builder" "github.com/apecloud/kubeblocks/pkg/controller/graph" ) @@ -44,7 +45,7 @@ var _ = Describe("graph client test.", func() { graphCli := NewGraphClient(nil) dag := graph.NewDAG() dagExpected := graph.NewDAG() - root := builder.NewStatefulSetBuilder(namespace, name).GetObject() + root := builder.NewInstanceSetBuilder(namespace, name).GetObject() By("init root vertex") graphCli.Root(dag, root.DeepCopy(), root, ActionStatusPtr()) @@ -115,7 +116,7 @@ var _ = Describe("graph client test.", func() { Expect(graphCli.FindAll(dag, &appsv1.Deployment{})).Should(HaveLen(0)) By("find objects different with the given type") - newPodList := graphCli.FindAll(dag, &appsv1.StatefulSet{}, &HaveDifferentTypeWithOption{}) + newPodList := graphCli.FindAll(dag, &workloads.InstanceSet{}, &HaveDifferentTypeWithOption{}) Expect(newPodList).Should(HaveLen(3)) // should have same result as podList for _, object := range podList { @@ -153,7 +154,7 @@ var _ = Describe("graph client test.", func() { Expect(dag.Equals(dagExpected, DefaultLess)).Should(BeTrue()) By("post create root vertex") - root := builder.NewStatefulSetBuilder(namespace, name).GetObject() + root := builder.NewInstanceSetBuilder(namespace, name).GetObject() graphCli.Root(dag, root.DeepCopy(), root, ActionStatusPtr()) rootVertex := &ObjectVertex{Obj: root, OriObj: root, Action: ActionStatusPtr()} dagExpected.AddVertex(rootVertex) diff --git a/pkg/controller/model/suite_test.go b/pkg/controller/model/suite_test.go index d32e22d3b93..9e2daaf40d5 100644 --- a/pkg/controller/model/suite_test.go +++ b/pkg/controller/model/suite_test.go @@ -24,6 +24,8 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" + + workloadsv1 "github.com/apecloud/kubeblocks/apis/workloads/v1" ) // These tests use Ginkgo (BDD-style Go testing framework). Refer to @@ -39,6 +41,8 @@ func TestAPIs(t *testing.T) { } var _ = BeforeSuite(func() { + AddScheme(workloadsv1.AddToScheme) + go func() { defer GinkgoRecover() }() diff --git a/pkg/controller/model/transform_types_test.go b/pkg/controller/model/transform_types_test.go index d521ffc3684..f79892303e8 100644 --- a/pkg/controller/model/transform_types_test.go +++ b/pkg/controller/model/transform_types_test.go @@ -34,11 +34,11 @@ var _ = Describe("transform types test", func() { Context("FindX function", func() { It("should work well", func() { - root := builder.NewStatefulSetBuilder(namespace, name).GetObject() + root := builder.NewInstanceSetBuilder(namespace, name).GetObject() vertex := &ObjectVertex{Obj: root} - Expect(vertex.String()).Should(Equal("{obj:*v1.StatefulSet, name: bar, action: nil}")) + Expect(vertex.String()).Should(Equal("{obj:*v1.InstanceSet, name: bar, action: nil}")) vertex.Action = ActionCreatePtr() - Expect(vertex.String()).Should(Equal("{obj:*v1.StatefulSet, name: bar, action: CREATE}")) + Expect(vertex.String()).Should(Equal("{obj:*v1.InstanceSet, name: bar, action: CREATE}")) }) }) }) diff --git a/pkg/controller/model/transform_utils_test.go b/pkg/controller/model/transform_utils_test.go index 15d264f64b9..22b804374b4 100644 --- a/pkg/controller/model/transform_utils_test.go +++ b/pkg/controller/model/transform_utils_test.go @@ -52,7 +52,7 @@ var _ = Describe("transform utils test", func() { Expect(err).ShouldNot(BeNil()) Expect(err.Error()).Should(ContainSubstring("root vertex not found")) - root := builder.NewStatefulSetBuilder(namespace, name).GetObject() + root := builder.NewInstanceSetBuilder(namespace, name).GetObject() obj0 := builder.NewPodBuilder(namespace, name+"-0").GetObject() obj1 := builder.NewPodBuilder(namespace, name+"-1").GetObject() obj2 := builder.NewPodBuilder(namespace, name+"-2").GetObject() @@ -69,10 +69,10 @@ var _ = Describe("transform utils test", func() { Context("IsOwnerOf function", func() { It("should work well", func() { - ownerAPIVersion := "apps/v1" - ownerKind := "StatefulSet" + ownerAPIVersion := "workloads.kubeblocks.io/v1" + ownerKind := "InstanceSet" objectName := name + "-0" - owner := builder.NewStatefulSetBuilder(namespace, name).GetObject() + owner := builder.NewInstanceSetBuilder(namespace, name).GetObject() object := builder.NewPodBuilder(namespace, objectName). SetOwnerReferences(ownerAPIVersion, ownerKind, owner). GetObject() @@ -124,7 +124,7 @@ var _ = Describe("transform utils test", func() { controller, k8sMock := testutil.SetupK8sMock() defer controller.Finish() - root := builder.NewStatefulSetBuilder(namespace, name).GetObject() + root := builder.NewInstanceSetBuilder(namespace, name).GetObject() obj0 := builder.NewPodBuilder(namespace, name+"-0").GetObject() obj1 := builder.NewPodBuilder(namespace, name+"-1").GetObject() obj2 := builder.NewPodBuilder(namespace, name+"-2").GetObject()