From 49be5b6af1cc5c61f7f5b7f1a34f8185a72f2084 Mon Sep 17 00:00:00 2001 From: Leon Date: Fri, 2 Aug 2024 14:20:47 +0800 Subject: [PATCH] chore: remove cluster version crd (#7026) --- .../v1alpha1/backuppolicytemplate_types.go | 3 +- apis/apps/v1alpha1/cluster_types_test.go | 1 - apis/apps/v1alpha1/clusterversion_types.go | 243 -- .../v1alpha1/clusterversion_types_test.go | 153 - apis/apps/v1alpha1/configconstraint_types.go | 2 +- apis/apps/v1alpha1/opsrequest_conditions.go | 2 +- apis/apps/v1alpha1/opsrequest_validation.go | 7 +- apis/apps/v1alpha1/type.go | 3 +- apis/apps/v1alpha1/zz_generated.deepcopy.go | 198 - apis/apps/v1beta1/configconstraint_types.go | 2 +- cmd/manager/main.go | 9 - ...s.kubeblocks.io_backuppolicytemplates.yaml | 6 +- .../apps.kubeblocks.io_clusterversions.yaml | 3279 ----------------- .../apps.kubeblocks.io_configconstraints.yaml | 4 +- config/crd/kustomization.yaml | 3 - .../cainjection_in_apps_clusterversions.yaml | 7 - .../webhook_in_apps_clusterversions.yaml | 16 - .../rbac/apps_clusterversion_editor_role.yaml | 24 - .../rbac/apps_clusterversion_viewer_role.yaml | 20 - config/rbac/role.yaml | 26 - .../ops/mysql_clusterversion_upgrade.yaml | 12 - controllers/apps/cluster_controller_test.go | 129 +- controllers/apps/cluster_plan_builder.go | 1 - controllers/apps/cluster_plan_builder_test.go | 12 +- .../apps/clusterdefinition_controller.go | 13 +- .../apps/clusterdefinition_controller_test.go | 59 +- controllers/apps/clusterversion_controller.go | 229 -- .../apps/clusterversion_controller_test.go | 83 - controllers/apps/component_controller_test.go | 68 +- .../apps/component_plan_builder_test.go | 2 +- controllers/apps/component_utils_test.go | 13 +- controllers/apps/configuration/config_util.go | 14 +- .../apps/configuration/config_util_test.go | 83 - .../configconstraint_controller.go | 5 +- .../configconstraint_controller_test.go | 13 +- .../apps/configuration/configuration_test.go | 13 +- controllers/apps/const.go | 1 - controllers/apps/operations/backup_test.go | 5 +- controllers/apps/operations/custom_test.go | 5 +- .../apps/operations/datascript_test.go | 7 +- controllers/apps/operations/expose_test.go | 7 +- .../operations/horizontal_scaling_test.go | 16 +- .../apps/operations/ops_progress_util_test.go | 7 +- controllers/apps/operations/ops_util_test.go | 14 +- .../apps/operations/rebuild_instance_test.go | 8 +- .../apps/operations/reconfigure_test.go | 5 +- controllers/apps/operations/restart_test.go | 5 +- controllers/apps/operations/restore_test.go | 5 +- controllers/apps/operations/start_test.go | 5 +- controllers/apps/operations/stop_test.go | 5 +- controllers/apps/operations/suite_test.go | 8 +- .../apps/operations/switchover_test.go | 21 +- .../apps/operations/switchover_util_test.go | 26 +- controllers/apps/operations/upgrade.go | 55 +- controllers/apps/operations/upgrade_test.go | 67 +- .../apps/operations/util/common_util_test.go | 3 +- .../apps/operations/vertical_scaling_test.go | 9 +- .../apps/operations/volume_expansion_test.go | 7 +- .../apps/opsrequest_controller_test.go | 28 +- .../apps/servicedescriptor_controller_test.go | 4 +- controllers/apps/suite_test.go | 7 - .../transformer_cluster_api_normalization.go | 2 +- .../apps/transformer_cluster_backup_policy.go | 9 - .../transformer_cluster_component_test.go | 2 +- .../apps/transformer_cluster_deletion_test.go | 2 +- .../transformer_cluster_halt_recovering.go | 11 - .../transformer_cluster_load_resources.go | 30 - controllers/apps/transformer_cluster_meta.go | 6 +- .../apps/transformer_component_rbac_test.go | 2 +- .../apps/transformer_component_tls_test.go | 13 +- .../extensions/addon_controller_test.go | 12 +- controllers/k8score/event_controller_test.go | 4 +- deploy/helm/config/rbac/role.yaml | 26 - ...s.kubeblocks.io_backuppolicytemplates.yaml | 6 +- .../apps.kubeblocks.io_clusterversions.yaml | 3279 ----------------- .../apps.kubeblocks.io_configconstraints.yaml | 4 +- .../admission/webhookconfiguration.yaml | 24 - .../rbac/apps_clusterversion_editor_role.yaml | 26 - .../rbac/apps_clusterversion_viewer_role.yaml | 22 - docs/developer_docs/api-reference/cluster.md | 436 +-- .../typed/apps/v1alpha1/apps_client.go | 5 - .../typed/apps/v1alpha1/clusterversion.go | 184 - .../apps/v1alpha1/fake/fake_apps_client.go | 4 - .../apps/v1alpha1/fake/fake_clusterversion.go | 132 - .../apps/v1alpha1/generated_expansion.go | 2 - .../apps/v1alpha1/clusterversion.go | 89 - .../apps/v1alpha1/interface.go | 7 - .../informers/externalversions/generic.go | 2 - .../listers/apps/v1alpha1/clusterversion.go | 68 - .../apps/v1alpha1/expansion_generated.go | 4 - pkg/configuration/core/configtemplate_util.go | 57 +- .../core/configtemplate_util_test.go | 238 +- pkg/configuration/core/type.go | 1 - pkg/constant/annotations.go | 1 - pkg/constant/config.go | 2 +- pkg/constant/labels.go | 1 - .../component/action_post_provision_test.go | 22 +- .../component/action_pre_terminate_test.go | 22 +- pkg/controller/component/action_utils_test.go | 22 +- pkg/controller/component/component.go | 40 +- pkg/controller/component/component_test.go | 57 +- .../component/definition_convertor.go | 40 +- .../component/definition_convertor_test.go | 88 +- .../component/fieldref_util_test.go | 5 +- .../service_descriptor_utils_test.go | 25 +- .../component/service_reference_test.go | 13 +- .../component/synthesize_component.go | 114 +- .../configuration/configuration_test.go | 33 +- .../configuration/envfrom_utils_test.go | 19 +- pkg/controller/configuration/operator.go | 2 - pkg/controller/configuration/operator_test.go | 8 +- pkg/controller/configuration/pipeline_test.go | 7 +- .../configuration/resource_wrapper.go | 18 - .../configuration/resource_wrapper_test.go | 21 +- .../configuration/template_wrapper_test.go | 6 +- .../configuration/tool_image_builder_test.go | 6 +- pkg/controller/factory/builder_test.go | 45 +- pkg/controller/job/job_utils_test.go | 23 +- pkg/controller/plan/prepare_test.go | 28 +- pkg/controller/plan/restore_test.go | 28 +- .../scheduling/scheduling_utils_test.go | 3 +- pkg/controllerutil/cluster_utils_test.go | 15 +- pkg/controllerutil/sharding_utils_test.go | 15 +- pkg/generics/type.go | 2 - .../apps/backuppolicytemplate_factory.go | 18 +- pkg/testutil/apps/cluster_factory.go | 3 +- .../apps/cluster_instance_set_test_util.go | 19 +- pkg/testutil/apps/cluster_util.go | 14 +- pkg/testutil/apps/clusterversion_factory.go | 106 - pkg/testutil/apps/common_util.go | 13 +- pkg/testutil/apps/constant.go | 3 - pkg/testutil/dataprotection/backup_utils.go | 3 +- test/e2e/testdata/config/postgresql_cv.yaml | 23 - 133 files changed, 425 insertions(+), 10304 deletions(-) delete mode 100644 apis/apps/v1alpha1/clusterversion_types.go delete mode 100644 apis/apps/v1alpha1/clusterversion_types_test.go delete mode 100644 config/crd/bases/apps.kubeblocks.io_clusterversions.yaml delete mode 100644 config/crd/patches/cainjection_in_apps_clusterversions.yaml delete mode 100644 config/crd/patches/webhook_in_apps_clusterversions.yaml delete mode 100644 config/rbac/apps_clusterversion_editor_role.yaml delete mode 100644 config/rbac/apps_clusterversion_viewer_role.yaml delete mode 100644 config/samples/ops/mysql_clusterversion_upgrade.yaml delete mode 100644 controllers/apps/clusterversion_controller.go delete mode 100644 controllers/apps/clusterversion_controller_test.go delete mode 100644 deploy/helm/crds/apps.kubeblocks.io_clusterversions.yaml delete mode 100644 deploy/helm/templates/rbac/apps_clusterversion_editor_role.yaml delete mode 100644 deploy/helm/templates/rbac/apps_clusterversion_viewer_role.yaml delete mode 100644 pkg/client/clientset/versioned/typed/apps/v1alpha1/clusterversion.go delete mode 100644 pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_clusterversion.go delete mode 100644 pkg/client/informers/externalversions/apps/v1alpha1/clusterversion.go delete mode 100644 pkg/client/listers/apps/v1alpha1/clusterversion.go delete mode 100644 pkg/testutil/apps/clusterversion_factory.go delete mode 100644 test/e2e/testdata/config/postgresql_cv.yaml diff --git a/apis/apps/v1alpha1/backuppolicytemplate_types.go b/apis/apps/v1alpha1/backuppolicytemplate_types.go index c35ddb3d63c..acd19f3f105 100644 --- a/apis/apps/v1alpha1/backuppolicytemplate_types.go +++ b/apis/apps/v1alpha1/backuppolicytemplate_types.go @@ -149,8 +149,7 @@ type ValueFrom struct { } type ValueMapping struct { - // Represents an array of names of ClusterVersion or ComponentDefinition that can be mapped to - // the appropriate version of the backup tool image. + // Represents an array of names of ComponentDefinition that can be mapped to the appropriate version of the backup tool image. // // This mapping allows different versions of component images to correspond to specific versions of backup tool images. // diff --git a/apis/apps/v1alpha1/cluster_types_test.go b/apis/apps/v1alpha1/cluster_types_test.go index 06a8f791566..701772ba09d 100644 --- a/apis/apps/v1alpha1/cluster_types_test.go +++ b/apis/apps/v1alpha1/cluster_types_test.go @@ -217,7 +217,6 @@ kind: Cluster metadata: name: wesql spec: - clusterVersionRef: cluster-version-consensus clusterDefinitionRef: cluster-definition-consensus componentSpecs: - name: wesql-test diff --git a/apis/apps/v1alpha1/clusterversion_types.go b/apis/apps/v1alpha1/clusterversion_types.go deleted file mode 100644 index 29379fc9191..00000000000 --- a/apis/apps/v1alpha1/clusterversion_types.go +++ /dev/null @@ -1,243 +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 v1alpha1 - -import ( - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// ClusterVersionSpec defines the desired state of ClusterVersion. -// -// Deprecated since v0.9. -// This struct is maintained for backward compatibility and its use is discouraged. -type ClusterVersionSpec struct { - // Specifies a reference to the ClusterDefinition. - // - // +kubebuilder:validation:Required - // +kubebuilder:validation:Pattern:=`^[a-z0-9]([a-z0-9\.\-]*[a-z0-9])?$` - ClusterDefinitionRef string `json:"clusterDefinitionRef"` - - // Contains a list of versioning contexts for the components' containers. - // - // +kubebuilder:validation:Required - // +kubebuilder:validation:MinItems=1 - // +patchMergeKey=componentDefRef - // +patchStrategy=merge,retainKeys - // +listType=map - // +listMapKey=componentDefRef - ComponentVersions []ClusterComponentVersion `json:"componentVersions" patchStrategy:"merge,retainKeys" patchMergeKey:"componentDefRef"` -} - -// ClusterVersionStatus defines the observed state of ClusterVersion. -// -// Deprecated since v0.9. -// This struct is maintained for backward compatibility and its use is discouraged. -type ClusterVersionStatus struct { - // The current phase of the ClusterVersion. - // - // +optional - Phase Phase `json:"phase,omitempty"` - - // Provides additional information about the current phase. - // - // +optional - Message string `json:"message,omitempty"` - - // The generation number that has been observed by the controller. - // - // +optional - ObservedGeneration int64 `json:"observedGeneration,omitempty"` - - // The generation number of the ClusterDefinition that is currently being referenced. - // - // +optional - ClusterDefGeneration int64 `json:"clusterDefGeneration,omitempty"` -} - -func (r ClusterVersionStatus) GetTerminalPhases() []Phase { - return []Phase{AvailablePhase} -} - -// ClusterComponentVersion is an application version component spec. -// -// Deprecated since v0.9. -// This struct is maintained for backward compatibility and its use is discouraged. -type ClusterComponentVersion struct { - // Specifies a reference to one of the cluster component definition names in the ClusterDefinition API (spec.componentDefs.name). - // - // +kubebuilder:validation:Required - // +kubebuilder:validation:MaxLength=63 - // +kubebuilder:validation:Pattern:=`^[a-z0-9]([a-z0-9\.\-]*[a-z0-9])?$` - ComponentDefRef string `json:"componentDefRef"` - - // Defines a configuration extension mechanism to handle configuration differences between versions. - // The configTemplateRefs field, in conjunction with the configTemplateRefs in the ClusterDefinition, determines - // the final configuration file. - // - // +patchMergeKey=name - // +patchStrategy=merge,retainKeys - // +listType=map - // +listMapKey=name - // +optional - ConfigSpecs []ComponentConfigSpec `json:"configSpecs,omitempty" patchStrategy:"merge,retainKeys" patchMergeKey:"name"` - - // Defines the image for the component to connect to databases or engines. - // This overrides the `image` and `env` attributes defined in clusterDefinition.spec.componentDefs.systemAccountSpec.cmdExecutorConfig. - // To clear default environment settings, set systemAccountSpec.cmdExecutorConfig.env to an empty list. - // - // +optional - SystemAccountSpec *SystemAccountShortSpec `json:"systemAccountSpec,omitempty"` - - // Defines the context for container images for component versions. - // This value replaces the values in clusterDefinition.spec.componentDefs.podSpec.[initContainers | containers]. - VersionsCtx VersionsContext `json:"versionsContext"` - - // Defines the images for the component to perform a switchover. - // This overrides the image and env attributes defined in clusterDefinition.spec.componentDefs.SwitchoverSpec.CommandExecutorEnvItem. - // - // +optional - SwitchoverSpec *SwitchoverShortSpec `json:"switchoverSpec,omitempty"` -} - -// SystemAccountShortSpec represents a condensed version of the SystemAccountSpec. -// -// Deprecated since v0.9. -// This struct is maintained for backward compatibility and its use is discouraged. -type SystemAccountShortSpec struct { - // Configures the method for obtaining the client SDK and executing statements. - // - // +kubebuilder:validation:Required - CmdExecutorConfig *CommandExecutorEnvItem `json:"cmdExecutorConfig"` -} - -// SwitchoverShortSpec represents a condensed version of the SwitchoverSpec. -// -// Deprecated since v0.9. -// This struct is maintained for backward compatibility and its use is discouraged. -type SwitchoverShortSpec struct { - // Represents the configuration for the command executor. - // - // +kubebuilder:validation:Required - CmdExecutorConfig *CommandExecutorEnvItem `json:"cmdExecutorConfig"` -} - -// VersionsContext is deprecated since v0.9. -// This struct is maintained for backward compatibility and its use is discouraged. -type VersionsContext struct { - // Provides override values for ClusterDefinition.spec.componentDefs.podSpec.initContainers. - // Typically used in scenarios such as updating application container images. - // - // +kubebuilder:pruning:PreserveUnknownFields - // +patchMergeKey=name - // +patchStrategy=merge - // +listType=map - // +listMapKey=name - // +optional - InitContainers []corev1.Container `json:"initContainers,omitempty"` - - // Provides override values for ClusterDefinition.spec.componentDefs.podSpec.containers. - // Typically used in scenarios such as updating application container images. - // - // +kubebuilder:pruning:PreserveUnknownFields - // +patchMergeKey=name - // +patchStrategy=merge - // +listType=map - // +listMapKey=name - // +optional - Containers []corev1.Container `json:"containers,omitempty"` -} - -// +genclient -// +genclient:nonNamespaced -// +k8s:openapi-gen=true -// +kubebuilder:object:root=true -// +kubebuilder:subresource:status -// +kubebuilder:resource:categories={kubeblocks},scope=Cluster,shortName=cv -// +kubebuilder:printcolumn:name="CLUSTER-DEFINITION",type="string",JSONPath=".spec.clusterDefinitionRef",description="ClusterDefinition referenced by cluster." -// +kubebuilder:printcolumn:name="STATUS",type="string",JSONPath=".status.phase",description="status phase" -// +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp" -// +kubebuilder:deprecatedversion:warning="The ClusterVersion CRD has been deprecated since 0.9.0" - -// ClusterVersion is the Schema for the ClusterVersions API. -// -// Deprecated: ClusterVersion has been replaced by ComponentVersion since v0.9. -// This struct is maintained for backward compatibility and its use is discouraged. -type ClusterVersion struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec ClusterVersionSpec `json:"spec,omitempty"` - Status ClusterVersionStatus `json:"status,omitempty"` -} - -// +kubebuilder:object:root=true - -// ClusterVersionList contains a list of ClusterVersion. -type ClusterVersionList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []ClusterVersion `json:"items"` -} - -func init() { - SchemeBuilder.Register(&ClusterVersion{}, &ClusterVersionList{}) -} - -// GetDefNameMappingComponents returns ComponentDefRef name mapping ClusterComponentVersion. -func (r ClusterVersionSpec) GetDefNameMappingComponents() map[string]*ClusterComponentVersion { - m := map[string]*ClusterComponentVersion{} - for i, c := range r.ComponentVersions { - m[c.ComponentDefRef] = &r.ComponentVersions[i] - } - return m -} - -// GetInconsistentComponentsInfo get clusterVersion invalid component name and no containers component compared with clusterDefinitionDef -func (r *ClusterVersion) GetInconsistentComponentsInfo(clusterDef *ClusterDefinition) ([]string, []string) { - - var ( - // clusterDefinition components to map. the value of map represents whether there is a default containers - componentMap = map[string]bool{} - notFoundComponentDefNames = make([]string, 0) - noContainersComponent = make([]string, 0) - ) - - for _, v := range clusterDef.Spec.ComponentDefs { - if v.PodSpec == nil || v.PodSpec.Containers == nil || len(v.PodSpec.Containers) == 0 { - componentMap[v.Name] = false - } else { - componentMap[v.Name] = true - } - } - // get not found component name in clusterDefinition - for _, v := range r.Spec.ComponentVersions { - if _, ok := componentMap[v.ComponentDefRef]; !ok { - notFoundComponentDefNames = append(notFoundComponentDefNames, v.ComponentDefRef) - } else if (len(v.VersionsCtx.Containers) > 0) || - (len(v.VersionsCtx.InitContainers) > 0) { - componentMap[v.ComponentDefRef] = true - } - } - // get no containers components in clusterDefinition and clusterVersion - for k, v := range componentMap { - if !v { - noContainersComponent = append(noContainersComponent, k) - } - } - return notFoundComponentDefNames, noContainersComponent -} diff --git a/apis/apps/v1alpha1/clusterversion_types_test.go b/apis/apps/v1alpha1/clusterversion_types_test.go deleted file mode 100644 index a3d820ce67b..00000000000 --- a/apis/apps/v1alpha1/clusterversion_types_test.go +++ /dev/null @@ -1,153 +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 v1alpha1 - -import ( - "testing" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - - "k8s.io/apimachinery/pkg/util/yaml" -) - -func TestGetInconsistentComponentsInfoWithoutResult(t *testing.T) { - g := NewGomegaWithT(t) - - // init ClusterVersion - clusterVersion := &ClusterVersion{} - clusterVersionYaml := ` -apiVersion: apps.kubeblocks.io/v1alpha1 -kind: ClusterVersion -metadata: - name: clusterversion-1 -spec: - clusterDefinitionRef: cluster-definition-1 - componentVersions: - - componentDefRef: component1 - versionsContext: - containers: - - name: container1.a - - name: container1.b - - componentDefRef: component2 - versionsContext: - containers: - - name: container2 - - componentDefRef: component3 - versionsContext: - containers: -` - g.Expect(yaml.Unmarshal([]byte(clusterVersionYaml), clusterVersion)).To(Succeed()) - - // init clusterDef - clusterDef := &ClusterDefinition{} - clusterDefYaml := ` -apiVersion: apps.kubeblocks.io/v1alpha1 -kind: ClusterDefinition -metadata: - name: cluster-definition-1 -spec: - componentDefs: - - name: component1 - podSpec: - containers: - - name: container1.c - - name: component2 - podSpec: - containers: - - name: component3 - podSpec: - containers: - - name: container3 -` - g.Expect(yaml.Unmarshal([]byte(clusterDefYaml), clusterDef)).To(Succeed()) - - notFoundComponentDefNames, noContainersComponents := clusterVersion.GetInconsistentComponentsInfo(clusterDef) - g.Expect(len(notFoundComponentDefNames)).To(Equal(0)) - g.Expect(len(noContainersComponents)).To(Equal(0)) -} - -func TestGetInconsistentComponentsInfoWithResults(t *testing.T) { - g := NewGomegaWithT(t) - - // init clusterVersion - clusterVersion := &ClusterVersion{} - clusterVersionYaml := ` -apiVersion: apps.kubeblocks.io/v1alpha1 -kind: ClusterVersion -metadata: - name: clusterversion-2 -spec: - clusterDefinitionRef: cluster-definition-2 - componentVersions: - - componentDefRef: component1 - versionsContext: - containers: - - name: container1 - - componentDefRef: component2 - versionsContext: - containers: - - componentDefRef: component3 - versionsContext: - containers: - - name: container3 -` - g.Expect(yaml.Unmarshal([]byte(clusterVersionYaml), clusterVersion)).To(Succeed()) - - // init clusterDef - clusterDef := &ClusterDefinition{} - clusterDefYaml := ` -apiVersion: apps.kubeblocks.io/v1alpha1 -kind: ClusterDefinition -metadata: - name: cluster-definition-2 -spec: - componentDefs: - - name: component1 - podSpec: - containers: - - name: container1 - - name: component2 - podSpec: -` - g.Expect(yaml.Unmarshal([]byte(clusterDefYaml), clusterDef)).To(Succeed()) - - notFoundComponentDefNames, noContainersComponents := clusterVersion.GetInconsistentComponentsInfo(clusterDef) - g.Expect(len(notFoundComponentDefNames)).To(Equal(1)) - g.Expect(notFoundComponentDefNames[0]).To(Equal("component3")) - g.Expect(len(noContainersComponents)).To(Equal(1)) - g.Expect(noContainersComponents[0]).To(Equal("component2")) -} - -var _ = Describe("", func() { - - It("test GetTerminalPhases", func() { - r := ClusterVersionStatus{} - Expect(r.GetTerminalPhases()).Should(ContainElement(AvailablePhase)) - }) - - It("test GetDefNameMappingComponents", func() { - r := ClusterVersionSpec{} - compDefRef := "test-comp-def" - r.ComponentVersions = []ClusterComponentVersion{ - { - ComponentDefRef: compDefRef, - }, - } - Expect(r.GetDefNameMappingComponents()[compDefRef]).ShouldNot(BeNil()) - }) -}) diff --git a/apis/apps/v1alpha1/configconstraint_types.go b/apis/apps/v1alpha1/configconstraint_types.go index fc7bf1683ca..beba03a03e1 100644 --- a/apis/apps/v1alpha1/configconstraint_types.go +++ b/apis/apps/v1alpha1/configconstraint_types.go @@ -177,7 +177,7 @@ type ConfigConstraintSpec struct { type ConfigConstraintStatus struct { // Specifies the status of the configuration template. - // When set to CCAvailablePhase, the ConfigConstraint can be referenced by ClusterDefinition or ClusterVersion. + // When set to CCAvailablePhase, the ConfigConstraint can be referenced by ClusterDefinition. // // +optional Phase appsv1beta1.ConfigConstraintPhase `json:"phase,omitempty"` diff --git a/apis/apps/v1alpha1/opsrequest_conditions.go b/apis/apps/v1alpha1/opsrequest_conditions.go index 5003479aeac..8de6aafec0a 100644 --- a/apis/apps/v1alpha1/opsrequest_conditions.go +++ b/apis/apps/v1alpha1/opsrequest_conditions.go @@ -258,7 +258,7 @@ func NewExposingCondition(ops *OpsRequest) *metav1.Condition { } } -// NewUpgradingCondition creates a condition that the OpsRequest starts to upgrade the cluster version +// NewUpgradingCondition creates a condition that the OpsRequest starts to upgrade the version func NewUpgradingCondition(ops *OpsRequest) *metav1.Condition { return &metav1.Condition{ Type: ConditionTypeVersionUpgrading, diff --git a/apis/apps/v1alpha1/opsrequest_validation.go b/apis/apps/v1alpha1/opsrequest_validation.go index 46978a1634a..d1d6d9e6de9 100644 --- a/apis/apps/v1alpha1/opsrequest_validation.go +++ b/apis/apps/v1alpha1/opsrequest_validation.go @@ -197,16 +197,13 @@ func (r *OpsRequest) validateRestart(cluster *Cluster) error { } // validateUpgrade validates spec.clusterOps.upgrade -func (r *OpsRequest) validateUpgrade(ctx context.Context, - k8sClient client.Client, - cluster *Cluster) error { +func (r *OpsRequest) validateUpgrade(ctx context.Context, k8sClient client.Client, cluster *Cluster) error { upgrade := r.Spec.Upgrade if upgrade == nil { return notEmptyError("spec.upgrade") } if upgrade.ClusterVersionRef != nil && *upgrade.ClusterVersionRef != "" { - // TODO: remove this deprecated api after v0.9 - return k8sClient.Get(ctx, types.NamespacedName{Name: *upgrade.ClusterVersionRef}, &ClusterVersion{}) + return fmt.Errorf("not supported") } if len(r.Spec.Upgrade.Components) == 0 { return notEmptyError("spec.upgrade.components") diff --git a/apis/apps/v1alpha1/type.go b/apis/apps/v1alpha1/type.go index 92679dc6d10..69a8589ce94 100644 --- a/apis/apps/v1alpha1/type.go +++ b/apis/apps/v1alpha1/type.go @@ -26,7 +26,6 @@ import ( const ( APIVersion = "apps.kubeblocks.io/v1alpha1" - ClusterVersionKind = "ClusterVersion" ClusterDefinitionKind = "ClusterDefinition" ClusterKind = "Cluster" ComponentKind = "Component" @@ -307,7 +306,7 @@ const ( ConditionTypeSwitchoverPrefix = "Switchover-" // ConditionTypeSwitchoverPrefix component status condition of switchover ) -// Phase represents the current status of the ClusterDefinition and ClusterVersion CR. +// Phase represents the current status of the ClusterDefinition CR. // // +enum // +kubebuilder:validation:Enum={Available,Unavailable} diff --git a/apis/apps/v1alpha1/zz_generated.deepcopy.go b/apis/apps/v1alpha1/zz_generated.deepcopy.go index abc2bf91c37..d44c760e027 100644 --- a/apis/apps/v1alpha1/zz_generated.deepcopy.go +++ b/apis/apps/v1alpha1/zz_generated.deepcopy.go @@ -740,39 +740,6 @@ func (in *ClusterComponentStatus) DeepCopy() *ClusterComponentStatus { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ClusterComponentVersion) DeepCopyInto(out *ClusterComponentVersion) { - *out = *in - if in.ConfigSpecs != nil { - in, out := &in.ConfigSpecs, &out.ConfigSpecs - *out = make([]ComponentConfigSpec, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.SystemAccountSpec != nil { - in, out := &in.SystemAccountSpec, &out.SystemAccountSpec - *out = new(SystemAccountShortSpec) - (*in).DeepCopyInto(*out) - } - in.VersionsCtx.DeepCopyInto(&out.VersionsCtx) - if in.SwitchoverSpec != nil { - in, out := &in.SwitchoverSpec, &out.SwitchoverSpec - *out = new(SwitchoverShortSpec) - (*in).DeepCopyInto(*out) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterComponentVersion. -func (in *ClusterComponentVersion) DeepCopy() *ClusterComponentVersion { - if in == nil { - return nil - } - out := new(ClusterComponentVersion) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterComponentVolumeClaimTemplate) DeepCopyInto(out *ClusterComponentVolumeClaimTemplate) { *out = *in @@ -1284,102 +1251,6 @@ func (in *ClusterTopologyOrders) DeepCopy() *ClusterTopologyOrders { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ClusterVersion) DeepCopyInto(out *ClusterVersion) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - out.Status = in.Status -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterVersion. -func (in *ClusterVersion) DeepCopy() *ClusterVersion { - if in == nil { - return nil - } - out := new(ClusterVersion) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ClusterVersion) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ClusterVersionList) DeepCopyInto(out *ClusterVersionList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]ClusterVersion, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterVersionList. -func (in *ClusterVersionList) DeepCopy() *ClusterVersionList { - if in == nil { - return nil - } - out := new(ClusterVersionList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ClusterVersionList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ClusterVersionSpec) DeepCopyInto(out *ClusterVersionSpec) { - *out = *in - if in.ComponentVersions != nil { - in, out := &in.ComponentVersions, &out.ComponentVersions - *out = make([]ClusterComponentVersion, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterVersionSpec. -func (in *ClusterVersionSpec) DeepCopy() *ClusterVersionSpec { - if in == nil { - return nil - } - out := new(ClusterVersionSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ClusterVersionStatus) DeepCopyInto(out *ClusterVersionStatus) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterVersionStatus. -func (in *ClusterVersionStatus) DeepCopy() *ClusterVersionStatus { - if in == nil { - return nil - } - out := new(ClusterVersionStatus) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *CmdExecutorConfig) DeepCopyInto(out *CmdExecutorConfig) { *out = *in @@ -5870,26 +5741,6 @@ func (in *SwitchoverAction) DeepCopy() *SwitchoverAction { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *SwitchoverShortSpec) DeepCopyInto(out *SwitchoverShortSpec) { - *out = *in - if in.CmdExecutorConfig != nil { - in, out := &in.CmdExecutorConfig, &out.CmdExecutorConfig - *out = new(CommandExecutorEnvItem) - (*in).DeepCopyInto(*out) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SwitchoverShortSpec. -func (in *SwitchoverShortSpec) DeepCopy() *SwitchoverShortSpec { - if in == nil { - return nil - } - out := new(SwitchoverShortSpec) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *SwitchoverSpec) DeepCopyInto(out *SwitchoverSpec) { *out = *in @@ -5952,26 +5803,6 @@ func (in *SystemAccountConfig) DeepCopy() *SystemAccountConfig { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *SystemAccountShortSpec) DeepCopyInto(out *SystemAccountShortSpec) { - *out = *in - if in.CmdExecutorConfig != nil { - in, out := &in.CmdExecutorConfig, &out.CmdExecutorConfig - *out = new(CommandExecutorEnvItem) - (*in).DeepCopyInto(*out) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SystemAccountShortSpec. -func (in *SystemAccountShortSpec) DeepCopy() *SystemAccountShortSpec { - if in == nil { - return nil - } - out := new(SystemAccountShortSpec) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *SystemAccountSpec) DeepCopyInto(out *SystemAccountSpec) { *out = *in @@ -6288,35 +6119,6 @@ func (in *VarSource) DeepCopy() *VarSource { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *VersionsContext) DeepCopyInto(out *VersionsContext) { - *out = *in - if in.InitContainers != nil { - in, out := &in.InitContainers, &out.InitContainers - *out = make([]v1.Container, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.Containers != nil { - in, out := &in.Containers, &out.Containers - *out = make([]v1.Container, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VersionsContext. -func (in *VersionsContext) DeepCopy() *VersionsContext { - if in == nil { - return nil - } - out := new(VersionsContext) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *VerticalScaling) DeepCopyInto(out *VerticalScaling) { *out = *in diff --git a/apis/apps/v1beta1/configconstraint_types.go b/apis/apps/v1beta1/configconstraint_types.go index e353424a2c2..feb69b3f913 100644 --- a/apis/apps/v1beta1/configconstraint_types.go +++ b/apis/apps/v1beta1/configconstraint_types.go @@ -138,7 +138,7 @@ type ConfigConstraintSpec struct { type ConfigConstraintStatus struct { // Specifies the status of the configuration template. - // When set to CCAvailablePhase, the ConfigConstraint can be referenced by ClusterDefinition or ClusterVersion. + // When set to CCAvailablePhase, the ConfigConstraint can be referenced by ClusterDefinition. // // +optional Phase ConfigConstraintPhase `json:"phase,omitempty"` diff --git a/cmd/manager/main.go b/cmd/manager/main.go index c9dc5026394..c7f0a003954 100644 --- a/cmd/manager/main.go +++ b/cmd/manager/main.go @@ -392,15 +392,6 @@ func main() { os.Exit(1) } - if err = (&appscontrollers.ClusterVersionReconciler{ - Client: mgr.GetClient(), - Scheme: mgr.GetScheme(), - Recorder: mgr.GetEventRecorderFor("cluster-version-controller"), - }).SetupWithManager(mgr); err != nil { - setupLog.Error(err, "unable to create controller", "controller", "ClusterVersion") - os.Exit(1) - } - if err = (&appscontrollers.ComponentReconciler{ Client: client, Scheme: mgr.GetScheme(), diff --git a/config/crd/bases/apps.kubeblocks.io_backuppolicytemplates.yaml b/config/crd/bases/apps.kubeblocks.io_backuppolicytemplates.yaml index 5b572f21616..4f0ae6e1b58 100644 --- a/config/crd/bases/apps.kubeblocks.io_backuppolicytemplates.yaml +++ b/config/crd/bases/apps.kubeblocks.io_backuppolicytemplates.yaml @@ -231,8 +231,7 @@ spec: type: string names: description: |- - Represents an array of names of ClusterVersion or ComponentDefinition that can be mapped to - the appropriate version of the backup tool image. + Represents an array of names of ComponentDefinition that can be mapped to the appropriate version of the backup tool image. This mapping allows different versions of component images to correspond to specific versions of backup tool images. @@ -255,8 +254,7 @@ spec: type: string names: description: |- - Represents an array of names of ClusterVersion or ComponentDefinition that can be mapped to - the appropriate version of the backup tool image. + Represents an array of names of ComponentDefinition that can be mapped to the appropriate version of the backup tool image. This mapping allows different versions of component images to correspond to specific versions of backup tool images. diff --git a/config/crd/bases/apps.kubeblocks.io_clusterversions.yaml b/config/crd/bases/apps.kubeblocks.io_clusterversions.yaml deleted file mode 100644 index 9b85a09b815..00000000000 --- a/config/crd/bases/apps.kubeblocks.io_clusterversions.yaml +++ /dev/null @@ -1,3279 +0,0 @@ -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.14.0 - labels: - app.kubernetes.io/name: kubeblocks - name: clusterversions.apps.kubeblocks.io -spec: - group: apps.kubeblocks.io - names: - categories: - - kubeblocks - kind: ClusterVersion - listKind: ClusterVersionList - plural: clusterversions - shortNames: - - cv - singular: clusterversion - scope: Cluster - versions: - - additionalPrinterColumns: - - description: ClusterDefinition referenced by cluster. - jsonPath: .spec.clusterDefinitionRef - name: CLUSTER-DEFINITION - type: string - - description: status phase - jsonPath: .status.phase - name: STATUS - type: string - - jsonPath: .metadata.creationTimestamp - name: AGE - type: date - deprecated: true - deprecationWarning: The ClusterVersion CRD has been deprecated since 0.9.0 - name: v1alpha1 - schema: - openAPIV3Schema: - description: |- - ClusterVersion is the Schema for the ClusterVersions API. - - - Deprecated: ClusterVersion has been replaced by ComponentVersion since v0.9. - This struct is maintained for backward compatibility and its use is discouraged. - properties: - apiVersion: - description: |- - APIVersion defines the versioned schema of this representation of an object. - Servers should convert recognized schemas to the latest internal value, and - may reject unrecognized values. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources - type: string - kind: - description: |- - Kind is a string value representing the REST resource this object represents. - Servers may infer this from the endpoint the client submits requests to. - Cannot be updated. - In CamelCase. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds - type: string - metadata: - type: object - spec: - description: |- - ClusterVersionSpec defines the desired state of ClusterVersion. - - - Deprecated since v0.9. - This struct is maintained for backward compatibility and its use is discouraged. - properties: - clusterDefinitionRef: - description: Specifies a reference to the ClusterDefinition. - pattern: ^[a-z0-9]([a-z0-9\.\-]*[a-z0-9])?$ - type: string - componentVersions: - description: Contains a list of versioning contexts for the components' - containers. - items: - description: |- - ClusterComponentVersion is an application version component spec. - - - Deprecated since v0.9. - This struct is maintained for backward compatibility and its use is discouraged. - properties: - componentDefRef: - description: Specifies a reference to one of the cluster component - definition names in the ClusterDefinition API (spec.componentDefs.name). - maxLength: 63 - pattern: ^[a-z0-9]([a-z0-9\.\-]*[a-z0-9])?$ - type: string - configSpecs: - description: |- - Defines a configuration extension mechanism to handle configuration differences between versions. - The configTemplateRefs field, in conjunction with the configTemplateRefs in the ClusterDefinition, determines - the final configuration file. - items: - properties: - asEnvFrom: - description: |- - Specifies the containers to inject the ConfigMap parameters as environment variables. - - - This is useful when application images accept parameters through environment variables and - generate the final configuration file in the startup script based on these variables. - - - This field allows users to specify a list of container names, and KubeBlocks will inject the environment - variables converted from the ConfigMap into these designated containers. This provides a flexible way to - pass the configuration items from the ConfigMap to the container without modifying the image. - - - Deprecated: `asEnvFrom` has been deprecated since 0.9.0 and will be removed in 0.10.0. - Use `injectEnvTo` instead. - items: - type: string - type: array - x-kubernetes-list-type: set - constraintRef: - description: Specifies the name of the referenced configuration - constraints object. - maxLength: 63 - pattern: ^[a-z0-9]([a-z0-9\.\-]*[a-z0-9])?$ - type: string - defaultMode: - description: |- - The operator attempts to set default file permissions for scripts (0555) and configurations (0444). - However, certain database engines may require different file permissions. - You can specify the desired file permissions here. - - - Must be specified as an octal value between 0000 and 0777 (inclusive), - or as a decimal value between 0 and 511 (inclusive). - YAML supports both octal and decimal values for file permissions. - - - Please note that this setting only affects the permissions of the files themselves. - Directories within the specified path are not impacted by this setting. - It's important to be aware that this setting might conflict with other options - that influence the file mode, such as fsGroup. - In such cases, the resulting file mode may have additional bits set. - Refers to documents of k8s.ConfigMapVolumeSource.defaultMode for more information. - format: int32 - type: integer - injectEnvTo: - description: |- - Specifies the containers to inject the ConfigMap parameters as environment variables. - - - This is useful when application images accept parameters through environment variables and - generate the final configuration file in the startup script based on these variables. - - - This field allows users to specify a list of container names, and KubeBlocks will inject the environment - variables converted from the ConfigMap into these designated containers. This provides a flexible way to - pass the configuration items from the ConfigMap to the container without modifying the image. - items: - type: string - type: array - x-kubernetes-list-type: set - keys: - description: |- - Specifies the configuration files within the ConfigMap that support dynamic updates. - - - A configuration template (provided in the form of a ConfigMap) may contain templates for multiple - configuration files. - Each configuration file corresponds to a key in the ConfigMap. - Some of these configuration files may support dynamic modification and reloading without requiring - a pod restart. - - - If empty or omitted, all configuration files in the ConfigMap are assumed to support dynamic updates, - and ConfigConstraint applies to all keys. - items: - type: string - type: array - x-kubernetes-list-type: set - legacyRenderedConfigSpec: - description: |- - Specifies the secondary rendered config spec for pod-specific customization. - - - The template is rendered inside the pod (by the "config-manager" sidecar container) and merged with the main - template's render result to generate the final configuration file. - - - This field is intended to handle scenarios where different pods within the same Component have - varying configurations. It allows for pod-specific customization of the configuration. - - - Note: This field will be deprecated in future versions, and the functionality will be moved to - `cluster.spec.componentSpecs[*].instances[*]`. - properties: - namespace: - default: default - description: |- - Specifies the namespace of the referenced configuration template ConfigMap object. - An empty namespace is equivalent to the "default" namespace. - maxLength: 63 - pattern: ^[a-z0-9]([a-z0-9\-]*[a-z0-9])?$ - type: string - policy: - default: none - description: Defines the strategy for merging externally - imported templates into component templates. - enum: - - patch - - replace - - none - type: string - templateRef: - description: Specifies the name of the referenced - configuration template ConfigMap object. - maxLength: 63 - pattern: ^[a-z0-9]([a-z0-9\.\-]*[a-z0-9])?$ - type: string - required: - - templateRef - type: object - name: - description: Specifies the name of the configuration template. - maxLength: 63 - pattern: ^[a-z0-9]([a-z0-9\.\-]*[a-z0-9])?$ - type: string - namespace: - default: default - description: |- - Specifies the namespace of the referenced configuration template ConfigMap object. - An empty namespace is equivalent to the "default" namespace. - maxLength: 63 - pattern: ^[a-z0-9]([a-z0-9\-]*[a-z0-9])?$ - type: string - reRenderResourceTypes: - description: |- - Specifies whether the configuration needs to be re-rendered after v-scale or h-scale operations to reflect changes. - - - In some scenarios, the configuration may need to be updated to reflect the changes in resource allocation - or cluster topology. Examples: - - - - Redis: adjust maxmemory after v-scale operation. - - MySQL: increase max connections after v-scale operation. - - Zookeeper: update zoo.cfg with new node addresses after h-scale operation. - items: - description: RerenderResourceType defines the resource - requirements for a component. - enum: - - vscale - - hscale - - tls - type: string - type: array - x-kubernetes-list-type: set - templateRef: - description: Specifies the name of the referenced configuration - template ConfigMap object. - maxLength: 63 - pattern: ^[a-z0-9]([a-z0-9\.\-]*[a-z0-9])?$ - type: string - volumeName: - description: |- - Refers to the volume name of PodTemplate. The configuration file produced through the configuration - template will be mounted to the corresponding volume. Must be a DNS_LABEL name. - The volume name must be defined in podSpec.containers[*].volumeMounts. - maxLength: 63 - pattern: ^[a-z]([a-z0-9\-]*[a-z0-9])?$ - type: string - required: - - name - - volumeName - type: object - type: array - x-kubernetes-list-map-keys: - - name - x-kubernetes-list-type: map - switchoverSpec: - description: |- - Defines the images for the component to perform a switchover. - This overrides the image and env attributes defined in clusterDefinition.spec.componentDefs.SwitchoverSpec.CommandExecutorEnvItem. - properties: - cmdExecutorConfig: - description: Represents the configuration for the command - executor. - properties: - env: - description: A list of environment variables that will - be injected into the command execution context. - items: - description: EnvVar represents an environment variable - present in a Container. - properties: - name: - description: Name of the environment variable. - Must be a C_IDENTIFIER. - type: string - value: - description: |- - Variable references $(VAR_NAME) are expanded - using the previously defined environment variables in the container and - any service environment variables. If a variable cannot be resolved, - the reference in the input string will be unchanged. Double $$ are reduced - to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. - "$$(VAR_NAME)" will produce the string literal "$(VAR_NAME)". - Escaped references will never be expanded, regardless of whether the variable - exists or not. - Defaults to "". - type: string - valueFrom: - description: Source for the environment variable's - value. Cannot be used if value is not empty. - properties: - configMapKeyRef: - description: Selects a key of a ConfigMap. - properties: - key: - description: The key to select. - type: string - name: - description: |- - Name of the referent. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid? - type: string - optional: - description: Specify whether the ConfigMap - or its key must be defined - type: boolean - required: - - key - type: object - x-kubernetes-map-type: atomic - fieldRef: - description: |- - Selects a field of the pod: supports metadata.name, metadata.namespace, `metadata.labels['']`, `metadata.annotations['']`, - spec.nodeName, spec.serviceAccountName, status.hostIP, status.podIP, status.podIPs. - properties: - apiVersion: - description: Version of the schema the - FieldPath is written in terms of, defaults - to "v1". - type: string - fieldPath: - description: Path of the field to select - in the specified API version. - type: string - required: - - fieldPath - type: object - x-kubernetes-map-type: atomic - resourceFieldRef: - description: |- - Selects a resource of the container: only resources limits and requests - (limits.cpu, limits.memory, limits.ephemeral-storage, requests.cpu, requests.memory and requests.ephemeral-storage) are currently supported. - properties: - containerName: - description: 'Container name: required - for volumes, optional for env vars' - type: string - divisor: - anyOf: - - type: integer - - type: string - description: Specifies the output format - of the exposed resources, defaults to - "1" - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - resource: - description: 'Required: resource to select' - type: string - required: - - resource - type: object - x-kubernetes-map-type: atomic - secretKeyRef: - description: Selects a key of a secret in - the pod's namespace - properties: - key: - description: The key of the secret to - select from. Must be a valid secret - key. - type: string - name: - description: |- - Name of the referent. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid? - type: string - optional: - description: Specify whether the Secret - or its key must be defined - type: boolean - required: - - key - type: object - x-kubernetes-map-type: atomic - type: object - required: - - name - type: object - type: array - x-kubernetes-preserve-unknown-fields: true - image: - description: Specifies the image used to execute the - command. - type: string - required: - - image - type: object - required: - - cmdExecutorConfig - type: object - systemAccountSpec: - description: |- - Defines the image for the component to connect to databases or engines. - This overrides the `image` and `env` attributes defined in clusterDefinition.spec.componentDefs.systemAccountSpec.cmdExecutorConfig. - To clear default environment settings, set systemAccountSpec.cmdExecutorConfig.env to an empty list. - properties: - cmdExecutorConfig: - description: Configures the method for obtaining the client - SDK and executing statements. - properties: - env: - description: A list of environment variables that will - be injected into the command execution context. - items: - description: EnvVar represents an environment variable - present in a Container. - properties: - name: - description: Name of the environment variable. - Must be a C_IDENTIFIER. - type: string - value: - description: |- - Variable references $(VAR_NAME) are expanded - using the previously defined environment variables in the container and - any service environment variables. If a variable cannot be resolved, - the reference in the input string will be unchanged. Double $$ are reduced - to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. - "$$(VAR_NAME)" will produce the string literal "$(VAR_NAME)". - Escaped references will never be expanded, regardless of whether the variable - exists or not. - Defaults to "". - type: string - valueFrom: - description: Source for the environment variable's - value. Cannot be used if value is not empty. - properties: - configMapKeyRef: - description: Selects a key of a ConfigMap. - properties: - key: - description: The key to select. - type: string - name: - description: |- - Name of the referent. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid? - type: string - optional: - description: Specify whether the ConfigMap - or its key must be defined - type: boolean - required: - - key - type: object - x-kubernetes-map-type: atomic - fieldRef: - description: |- - Selects a field of the pod: supports metadata.name, metadata.namespace, `metadata.labels['']`, `metadata.annotations['']`, - spec.nodeName, spec.serviceAccountName, status.hostIP, status.podIP, status.podIPs. - properties: - apiVersion: - description: Version of the schema the - FieldPath is written in terms of, defaults - to "v1". - type: string - fieldPath: - description: Path of the field to select - in the specified API version. - type: string - required: - - fieldPath - type: object - x-kubernetes-map-type: atomic - resourceFieldRef: - description: |- - Selects a resource of the container: only resources limits and requests - (limits.cpu, limits.memory, limits.ephemeral-storage, requests.cpu, requests.memory and requests.ephemeral-storage) are currently supported. - properties: - containerName: - description: 'Container name: required - for volumes, optional for env vars' - type: string - divisor: - anyOf: - - type: integer - - type: string - description: Specifies the output format - of the exposed resources, defaults to - "1" - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - resource: - description: 'Required: resource to select' - type: string - required: - - resource - type: object - x-kubernetes-map-type: atomic - secretKeyRef: - description: Selects a key of a secret in - the pod's namespace - properties: - key: - description: The key of the secret to - select from. Must be a valid secret - key. - type: string - name: - description: |- - Name of the referent. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid? - type: string - optional: - description: Specify whether the Secret - or its key must be defined - type: boolean - required: - - key - type: object - x-kubernetes-map-type: atomic - type: object - required: - - name - type: object - type: array - x-kubernetes-preserve-unknown-fields: true - image: - description: Specifies the image used to execute the - command. - type: string - required: - - image - type: object - required: - - cmdExecutorConfig - type: object - versionsContext: - description: |- - Defines the context for container images for component versions. - This value replaces the values in clusterDefinition.spec.componentDefs.podSpec.[initContainers | containers]. - properties: - containers: - description: |- - Provides override values for ClusterDefinition.spec.componentDefs.podSpec.containers. - Typically used in scenarios such as updating application container images. - items: - description: A single application container that you want - to run within a pod. - properties: - args: - description: |- - Arguments to the entrypoint. - The container image's CMD is used if this is not provided. - Variable references $(VAR_NAME) are expanded using the container's environment. If a variable - cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced - to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will - produce the string literal "$(VAR_NAME)". Escaped references will never be expanded, regardless - of whether the variable exists or not. Cannot be updated. - More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell - items: - type: string - type: array - command: - description: |- - Entrypoint array. Not executed within a shell. - The container image's ENTRYPOINT is used if this is not provided. - Variable references $(VAR_NAME) are expanded using the container's environment. If a variable - cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced - to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will - produce the string literal "$(VAR_NAME)". Escaped references will never be expanded, regardless - of whether the variable exists or not. Cannot be updated. - More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell - items: - type: string - type: array - env: - description: |- - List of environment variables to set in the container. - Cannot be updated. - items: - description: EnvVar represents an environment variable - present in a Container. - properties: - name: - description: Name of the environment variable. - Must be a C_IDENTIFIER. - type: string - value: - description: |- - Variable references $(VAR_NAME) are expanded - using the previously defined environment variables in the container and - any service environment variables. If a variable cannot be resolved, - the reference in the input string will be unchanged. Double $$ are reduced - to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. - "$$(VAR_NAME)" will produce the string literal "$(VAR_NAME)". - Escaped references will never be expanded, regardless of whether the variable - exists or not. - Defaults to "". - type: string - valueFrom: - description: Source for the environment variable's - value. Cannot be used if value is not empty. - properties: - configMapKeyRef: - description: Selects a key of a ConfigMap. - properties: - key: - description: The key to select. - type: string - name: - description: |- - Name of the referent. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid? - type: string - optional: - description: Specify whether the ConfigMap - or its key must be defined - type: boolean - required: - - key - type: object - x-kubernetes-map-type: atomic - fieldRef: - description: |- - Selects a field of the pod: supports metadata.name, metadata.namespace, `metadata.labels['']`, `metadata.annotations['']`, - spec.nodeName, spec.serviceAccountName, status.hostIP, status.podIP, status.podIPs. - properties: - apiVersion: - description: Version of the schema the - FieldPath is written in terms of, - defaults to "v1". - type: string - fieldPath: - description: Path of the field to select - in the specified API version. - type: string - required: - - fieldPath - type: object - x-kubernetes-map-type: atomic - resourceFieldRef: - description: |- - Selects a resource of the container: only resources limits and requests - (limits.cpu, limits.memory, limits.ephemeral-storage, requests.cpu, requests.memory and requests.ephemeral-storage) are currently supported. - properties: - containerName: - description: 'Container name: required - for volumes, optional for env vars' - type: string - divisor: - anyOf: - - type: integer - - type: string - description: Specifies the output format - of the exposed resources, defaults - to "1" - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - resource: - description: 'Required: resource to - select' - type: string - required: - - resource - type: object - x-kubernetes-map-type: atomic - secretKeyRef: - description: Selects a key of a secret in - the pod's namespace - properties: - key: - description: The key of the secret to - select from. Must be a valid secret - key. - type: string - name: - description: |- - Name of the referent. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid? - type: string - optional: - description: Specify whether the Secret - or its key must be defined - type: boolean - required: - - key - type: object - x-kubernetes-map-type: atomic - type: object - required: - - name - type: object - type: array - envFrom: - description: |- - List of sources to populate environment variables in the container. - The keys defined within a source must be a C_IDENTIFIER. All invalid keys - will be reported as an event when the container is starting. When a key exists in multiple - sources, the value associated with the last source will take precedence. - Values defined by an Env with a duplicate key will take precedence. - Cannot be updated. - items: - description: EnvFromSource represents the source - of a set of ConfigMaps - properties: - configMapRef: - description: The ConfigMap to select from - properties: - name: - description: |- - Name of the referent. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid? - type: string - optional: - description: Specify whether the ConfigMap - must be defined - type: boolean - type: object - x-kubernetes-map-type: atomic - prefix: - description: An optional identifier to prepend - to each key in the ConfigMap. Must be a C_IDENTIFIER. - type: string - secretRef: - description: The Secret to select from - properties: - name: - description: |- - Name of the referent. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid? - type: string - optional: - description: Specify whether the Secret - must be defined - type: boolean - type: object - x-kubernetes-map-type: atomic - type: object - type: array - image: - description: |- - Container image name. - More info: https://kubernetes.io/docs/concepts/containers/images - This field is optional to allow higher level config management to default or override - container images in workload controllers like Deployments and StatefulSets. - type: string - imagePullPolicy: - description: |- - Image pull policy. - One of Always, Never, IfNotPresent. - Defaults to Always if :latest tag is specified, or IfNotPresent otherwise. - Cannot be updated. - More info: https://kubernetes.io/docs/concepts/containers/images#updating-images - type: string - lifecycle: - description: |- - Actions that the management system should take in response to container lifecycle events. - Cannot be updated. - properties: - postStart: - description: |- - PostStart is called immediately after a container is created. If the handler fails, - the container is terminated and restarted according to its restart policy. - Other management of the container blocks until the hook completes. - More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks - properties: - exec: - description: Exec specifies the action to - take. - properties: - command: - description: |- - Command is the command line to execute inside the container, the working directory for the - command is root ('/') in the container's filesystem. The command is simply exec'd, it is - not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use - a shell, you need to explicitly call out to that shell. - Exit status of 0 is treated as live/healthy and non-zero is unhealthy. - items: - type: string - type: array - type: object - httpGet: - description: HTTPGet specifies the http request - to perform. - properties: - host: - description: |- - Host name to connect to, defaults to the pod IP. You probably want to set - "Host" in httpHeaders instead. - type: string - httpHeaders: - description: Custom headers to set in - the request. HTTP allows repeated headers. - items: - description: HTTPHeader describes a - custom header to be used in HTTP probes - properties: - name: - description: |- - The header field name. - This will be canonicalized upon output, so case-variant names will be understood as the same header. - type: string - value: - description: The header field value - type: string - required: - - name - - value - type: object - type: array - path: - description: Path to access on the HTTP - server. - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Name or number of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - scheme: - description: |- - Scheme to use for connecting to the host. - Defaults to HTTP. - type: string - required: - - port - type: object - tcpSocket: - description: |- - Deprecated. TCPSocket is NOT supported as a LifecycleHandler and kept - for the backward compatibility. There are no validation of this field and - lifecycle hooks will fail in runtime when tcp handler is specified. - properties: - host: - description: 'Optional: Host name to connect - to, defaults to the pod IP.' - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Number or name of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - required: - - port - type: object - type: object - preStop: - description: |- - PreStop is called immediately before a container is terminated due to an - API request or management event such as liveness/startup probe failure, - preemption, resource contention, etc. The handler is not called if the - container crashes or exits. The Pod's termination grace period countdown begins before the - PreStop hook is executed. Regardless of the outcome of the handler, the - container will eventually terminate within the Pod's termination grace - period (unless delayed by finalizers). Other management of the container blocks until the hook completes - or until the termination grace period is reached. - More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks - properties: - exec: - description: Exec specifies the action to - take. - properties: - command: - description: |- - Command is the command line to execute inside the container, the working directory for the - command is root ('/') in the container's filesystem. The command is simply exec'd, it is - not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use - a shell, you need to explicitly call out to that shell. - Exit status of 0 is treated as live/healthy and non-zero is unhealthy. - items: - type: string - type: array - type: object - httpGet: - description: HTTPGet specifies the http request - to perform. - properties: - host: - description: |- - Host name to connect to, defaults to the pod IP. You probably want to set - "Host" in httpHeaders instead. - type: string - httpHeaders: - description: Custom headers to set in - the request. HTTP allows repeated headers. - items: - description: HTTPHeader describes a - custom header to be used in HTTP probes - properties: - name: - description: |- - The header field name. - This will be canonicalized upon output, so case-variant names will be understood as the same header. - type: string - value: - description: The header field value - type: string - required: - - name - - value - type: object - type: array - path: - description: Path to access on the HTTP - server. - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Name or number of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - scheme: - description: |- - Scheme to use for connecting to the host. - Defaults to HTTP. - type: string - required: - - port - type: object - tcpSocket: - description: |- - Deprecated. TCPSocket is NOT supported as a LifecycleHandler and kept - for the backward compatibility. There are no validation of this field and - lifecycle hooks will fail in runtime when tcp handler is specified. - properties: - host: - description: 'Optional: Host name to connect - to, defaults to the pod IP.' - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Number or name of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - required: - - port - type: object - type: object - type: object - livenessProbe: - description: |- - Periodic probe of container liveness. - Container will be restarted if the probe fails. - Cannot be updated. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - properties: - exec: - description: Exec specifies the action to take. - properties: - command: - description: |- - Command is the command line to execute inside the container, the working directory for the - command is root ('/') in the container's filesystem. The command is simply exec'd, it is - not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use - a shell, you need to explicitly call out to that shell. - Exit status of 0 is treated as live/healthy and non-zero is unhealthy. - items: - type: string - type: array - type: object - failureThreshold: - description: |- - Minimum consecutive failures for the probe to be considered failed after having succeeded. - Defaults to 3. Minimum value is 1. - format: int32 - type: integer - grpc: - description: GRPC specifies an action involving - a GRPC port. - properties: - port: - description: Port number of the gRPC service. - Number must be in the range 1 to 65535. - format: int32 - type: integer - service: - description: |- - Service is the name of the service to place in the gRPC HealthCheckRequest - (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). - - - If this is not specified, the default behavior is defined by gRPC. - type: string - required: - - port - type: object - httpGet: - description: HTTPGet specifies the http request - to perform. - properties: - host: - description: |- - Host name to connect to, defaults to the pod IP. You probably want to set - "Host" in httpHeaders instead. - type: string - httpHeaders: - description: Custom headers to set in the - request. HTTP allows repeated headers. - items: - description: HTTPHeader describes a custom - header to be used in HTTP probes - properties: - name: - description: |- - The header field name. - This will be canonicalized upon output, so case-variant names will be understood as the same header. - type: string - value: - description: The header field value - type: string - required: - - name - - value - type: object - type: array - path: - description: Path to access on the HTTP server. - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Name or number of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - scheme: - description: |- - Scheme to use for connecting to the host. - Defaults to HTTP. - type: string - required: - - port - type: object - initialDelaySeconds: - description: |- - Number of seconds after the container has started before liveness probes are initiated. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - format: int32 - type: integer - periodSeconds: - description: |- - How often (in seconds) to perform the probe. - Default to 10 seconds. Minimum value is 1. - format: int32 - type: integer - successThreshold: - description: |- - Minimum consecutive successes for the probe to be considered successful after having failed. - Defaults to 1. Must be 1 for liveness and startup. Minimum value is 1. - format: int32 - type: integer - tcpSocket: - description: TCPSocket specifies an action involving - a TCP port. - properties: - host: - description: 'Optional: Host name to connect - to, defaults to the pod IP.' - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Number or name of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - required: - - port - type: object - terminationGracePeriodSeconds: - description: |- - Optional duration in seconds the pod needs to terminate gracefully upon probe failure. - The grace period is the duration in seconds after the processes running in the pod are sent - a termination signal and the time when the processes are forcibly halted with a kill signal. - Set this value longer than the expected cleanup time for your process. - If this value is nil, the pod's terminationGracePeriodSeconds will be used. Otherwise, this - value overrides the value provided by the pod spec. - Value must be non-negative integer. The value zero indicates stop immediately via - the kill signal (no opportunity to shut down). - This is a beta field and requires enabling ProbeTerminationGracePeriod feature gate. - Minimum value is 1. spec.terminationGracePeriodSeconds is used if unset. - format: int64 - type: integer - timeoutSeconds: - description: |- - Number of seconds after which the probe times out. - Defaults to 1 second. Minimum value is 1. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - format: int32 - type: integer - type: object - name: - description: |- - Name of the container specified as a DNS_LABEL. - Each container in a pod must have a unique name (DNS_LABEL). - Cannot be updated. - type: string - ports: - description: |- - List of ports to expose from the container. Not specifying a port here - DOES NOT prevent that port from being exposed. Any port which is - listening on the default "0.0.0.0" address inside a container will be - accessible from the network. - Modifying this array with strategic merge patch may corrupt the data. - For more information See https://github.com/kubernetes/kubernetes/issues/108255. - Cannot be updated. - items: - description: ContainerPort represents a network - port in a single container. - properties: - containerPort: - description: |- - Number of port to expose on the pod's IP address. - This must be a valid port number, 0 < x < 65536. - format: int32 - type: integer - hostIP: - description: What host IP to bind the external - port to. - type: string - hostPort: - description: |- - Number of port to expose on the host. - If specified, this must be a valid port number, 0 < x < 65536. - If HostNetwork is specified, this must match ContainerPort. - Most containers do not need this. - format: int32 - type: integer - name: - description: |- - If specified, this must be an IANA_SVC_NAME and unique within the pod. Each - named port in a pod must have a unique name. Name for the port that can be - referred to by services. - type: string - protocol: - default: TCP - description: |- - Protocol for port. Must be UDP, TCP, or SCTP. - Defaults to "TCP". - type: string - required: - - containerPort - type: object - type: array - x-kubernetes-list-map-keys: - - containerPort - - protocol - x-kubernetes-list-type: map - readinessProbe: - description: |- - Periodic probe of container service readiness. - Container will be removed from service endpoints if the probe fails. - Cannot be updated. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - properties: - exec: - description: Exec specifies the action to take. - properties: - command: - description: |- - Command is the command line to execute inside the container, the working directory for the - command is root ('/') in the container's filesystem. The command is simply exec'd, it is - not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use - a shell, you need to explicitly call out to that shell. - Exit status of 0 is treated as live/healthy and non-zero is unhealthy. - items: - type: string - type: array - type: object - failureThreshold: - description: |- - Minimum consecutive failures for the probe to be considered failed after having succeeded. - Defaults to 3. Minimum value is 1. - format: int32 - type: integer - grpc: - description: GRPC specifies an action involving - a GRPC port. - properties: - port: - description: Port number of the gRPC service. - Number must be in the range 1 to 65535. - format: int32 - type: integer - service: - description: |- - Service is the name of the service to place in the gRPC HealthCheckRequest - (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). - - - If this is not specified, the default behavior is defined by gRPC. - type: string - required: - - port - type: object - httpGet: - description: HTTPGet specifies the http request - to perform. - properties: - host: - description: |- - Host name to connect to, defaults to the pod IP. You probably want to set - "Host" in httpHeaders instead. - type: string - httpHeaders: - description: Custom headers to set in the - request. HTTP allows repeated headers. - items: - description: HTTPHeader describes a custom - header to be used in HTTP probes - properties: - name: - description: |- - The header field name. - This will be canonicalized upon output, so case-variant names will be understood as the same header. - type: string - value: - description: The header field value - type: string - required: - - name - - value - type: object - type: array - path: - description: Path to access on the HTTP server. - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Name or number of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - scheme: - description: |- - Scheme to use for connecting to the host. - Defaults to HTTP. - type: string - required: - - port - type: object - initialDelaySeconds: - description: |- - Number of seconds after the container has started before liveness probes are initiated. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - format: int32 - type: integer - periodSeconds: - description: |- - How often (in seconds) to perform the probe. - Default to 10 seconds. Minimum value is 1. - format: int32 - type: integer - successThreshold: - description: |- - Minimum consecutive successes for the probe to be considered successful after having failed. - Defaults to 1. Must be 1 for liveness and startup. Minimum value is 1. - format: int32 - type: integer - tcpSocket: - description: TCPSocket specifies an action involving - a TCP port. - properties: - host: - description: 'Optional: Host name to connect - to, defaults to the pod IP.' - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Number or name of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - required: - - port - type: object - terminationGracePeriodSeconds: - description: |- - Optional duration in seconds the pod needs to terminate gracefully upon probe failure. - The grace period is the duration in seconds after the processes running in the pod are sent - a termination signal and the time when the processes are forcibly halted with a kill signal. - Set this value longer than the expected cleanup time for your process. - If this value is nil, the pod's terminationGracePeriodSeconds will be used. Otherwise, this - value overrides the value provided by the pod spec. - Value must be non-negative integer. The value zero indicates stop immediately via - the kill signal (no opportunity to shut down). - This is a beta field and requires enabling ProbeTerminationGracePeriod feature gate. - Minimum value is 1. spec.terminationGracePeriodSeconds is used if unset. - format: int64 - type: integer - timeoutSeconds: - description: |- - Number of seconds after which the probe times out. - Defaults to 1 second. Minimum value is 1. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - format: int32 - type: integer - type: object - resizePolicy: - description: Resources resize policy for the container. - items: - description: ContainerResizePolicy represents resource - resize policy for the container. - properties: - resourceName: - description: |- - Name of the resource to which this resource resize policy applies. - Supported values: cpu, memory. - type: string - restartPolicy: - description: |- - Restart policy to apply when specified resource is resized. - If not specified, it defaults to NotRequired. - type: string - required: - - resourceName - - restartPolicy - type: object - type: array - x-kubernetes-list-type: atomic - resources: - description: |- - Compute Resources required by this container. - Cannot be updated. - More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ - properties: - claims: - description: |- - Claims lists the names of resources, defined in spec.resourceClaims, - that are used by this container. - - - This is an alpha field and requires enabling the - DynamicResourceAllocation feature gate. - - - This field is immutable. It can only be set for containers. - items: - description: ResourceClaim references one entry - in PodSpec.ResourceClaims. - properties: - name: - description: |- - Name must match the name of one entry in pod.spec.resourceClaims of - the Pod where this field is used. It makes that resource available - inside a container. - type: string - required: - - name - type: object - type: array - x-kubernetes-list-map-keys: - - name - x-kubernetes-list-type: map - limits: - additionalProperties: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - description: |- - Limits describes the maximum amount of compute resources allowed. - More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ - type: object - requests: - additionalProperties: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - description: |- - Requests describes the minimum amount of compute resources required. - If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, - otherwise to an implementation-defined value. Requests cannot exceed Limits. - More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ - type: object - type: object - restartPolicy: - description: |- - RestartPolicy defines the restart behavior of individual containers in a pod. - This field may only be set for init containers, and the only allowed value is "Always". - For non-init containers or when this field is not specified, - the restart behavior is defined by the Pod's restart policy and the container type. - Setting the RestartPolicy as "Always" for the init container will have the following effect: - this init container will be continually restarted on - exit until all regular containers have terminated. Once all regular - containers have completed, all init containers with restartPolicy "Always" - will be shut down. This lifecycle differs from normal init containers and - is often referred to as a "sidecar" container. Although this init - container still starts in the init container sequence, it does not wait - for the container to complete before proceeding to the next init - container. Instead, the next init container starts immediately after this - init container is started, or after any startupProbe has successfully - completed. - type: string - securityContext: - description: |- - SecurityContext defines the security options the container should be run with. - If set, the fields of SecurityContext override the equivalent fields of PodSecurityContext. - More info: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/ - properties: - allowPrivilegeEscalation: - description: |- - AllowPrivilegeEscalation controls whether a process can gain more - privileges than its parent process. This bool directly controls if - the no_new_privs flag will be set on the container process. - AllowPrivilegeEscalation is true always when the container is: - 1) run as Privileged - 2) has CAP_SYS_ADMIN - Note that this field cannot be set when spec.os.name is windows. - type: boolean - capabilities: - description: |- - The capabilities to add/drop when running containers. - Defaults to the default set of capabilities granted by the container runtime. - Note that this field cannot be set when spec.os.name is windows. - properties: - add: - description: Added capabilities - items: - description: Capability represent POSIX - capabilities type - type: string - type: array - drop: - description: Removed capabilities - items: - description: Capability represent POSIX - capabilities type - type: string - type: array - type: object - privileged: - description: |- - Run container in privileged mode. - Processes in privileged containers are essentially equivalent to root on the host. - Defaults to false. - Note that this field cannot be set when spec.os.name is windows. - type: boolean - procMount: - description: |- - procMount denotes the type of proc mount to use for the containers. - The default is DefaultProcMount which uses the container runtime defaults for - readonly paths and masked paths. - This requires the ProcMountType feature flag to be enabled. - Note that this field cannot be set when spec.os.name is windows. - type: string - readOnlyRootFilesystem: - description: |- - Whether this container has a read-only root filesystem. - Default is false. - Note that this field cannot be set when spec.os.name is windows. - type: boolean - runAsGroup: - description: |- - The GID to run the entrypoint of the container process. - Uses runtime default if unset. - May also be set in PodSecurityContext. If set in both SecurityContext and - PodSecurityContext, the value specified in SecurityContext takes precedence. - Note that this field cannot be set when spec.os.name is windows. - format: int64 - type: integer - runAsNonRoot: - description: |- - Indicates that the container must run as a non-root user. - If true, the Kubelet will validate the image at runtime to ensure that it - does not run as UID 0 (root) and fail to start the container if it does. - If unset or false, no such validation will be performed. - May also be set in PodSecurityContext. If set in both SecurityContext and - PodSecurityContext, the value specified in SecurityContext takes precedence. - type: boolean - runAsUser: - description: |- - The UID to run the entrypoint of the container process. - Defaults to user specified in image metadata if unspecified. - May also be set in PodSecurityContext. If set in both SecurityContext and - PodSecurityContext, the value specified in SecurityContext takes precedence. - Note that this field cannot be set when spec.os.name is windows. - format: int64 - type: integer - seLinuxOptions: - description: |- - The SELinux context to be applied to the container. - If unspecified, the container runtime will allocate a random SELinux context for each - container. May also be set in PodSecurityContext. If set in both SecurityContext and - PodSecurityContext, the value specified in SecurityContext takes precedence. - Note that this field cannot be set when spec.os.name is windows. - properties: - level: - description: Level is SELinux level label - that applies to the container. - type: string - role: - description: Role is a SELinux role label - that applies to the container. - type: string - type: - description: Type is a SELinux type label - that applies to the container. - type: string - user: - description: User is a SELinux user label - that applies to the container. - type: string - type: object - seccompProfile: - description: |- - The seccomp options to use by this container. If seccomp options are - provided at both the pod & container level, the container options - override the pod options. - Note that this field cannot be set when spec.os.name is windows. - properties: - localhostProfile: - description: |- - localhostProfile indicates a profile defined in a file on the node should be used. - The profile must be preconfigured on the node to work. - Must be a descending path, relative to the kubelet's configured seccomp profile location. - Must be set if type is "Localhost". Must NOT be set for any other type. - type: string - type: - description: |- - type indicates which kind of seccomp profile will be applied. - Valid options are: - - - Localhost - a profile defined in a file on the node should be used. - RuntimeDefault - the container runtime default profile should be used. - Unconfined - no profile should be applied. - type: string - required: - - type - type: object - windowsOptions: - description: |- - The Windows specific settings applied to all containers. - If unspecified, the options from the PodSecurityContext will be used. - If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence. - Note that this field cannot be set when spec.os.name is linux. - properties: - gmsaCredentialSpec: - description: |- - GMSACredentialSpec is where the GMSA admission webhook - (https://github.com/kubernetes-sigs/windows-gmsa) inlines the contents of the - GMSA credential spec named by the GMSACredentialSpecName field. - type: string - gmsaCredentialSpecName: - description: GMSACredentialSpecName is the - name of the GMSA credential spec to use. - type: string - hostProcess: - description: |- - HostProcess determines if a container should be run as a 'Host Process' container. - All of a Pod's containers must have the same effective HostProcess value - (it is not allowed to have a mix of HostProcess containers and non-HostProcess containers). - In addition, if HostProcess is true then HostNetwork must also be set to true. - type: boolean - runAsUserName: - description: |- - The UserName in Windows to run the entrypoint of the container process. - Defaults to the user specified in image metadata if unspecified. - May also be set in PodSecurityContext. If set in both SecurityContext and - PodSecurityContext, the value specified in SecurityContext takes precedence. - type: string - type: object - type: object - startupProbe: - description: |- - StartupProbe indicates that the Pod has successfully initialized. - If specified, no other probes are executed until this completes successfully. - If this probe fails, the Pod will be restarted, just as if the livenessProbe failed. - This can be used to provide different probe parameters at the beginning of a Pod's lifecycle, - when it might take a long time to load data or warm a cache, than during steady-state operation. - This cannot be updated. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - properties: - exec: - description: Exec specifies the action to take. - properties: - command: - description: |- - Command is the command line to execute inside the container, the working directory for the - command is root ('/') in the container's filesystem. The command is simply exec'd, it is - not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use - a shell, you need to explicitly call out to that shell. - Exit status of 0 is treated as live/healthy and non-zero is unhealthy. - items: - type: string - type: array - type: object - failureThreshold: - description: |- - Minimum consecutive failures for the probe to be considered failed after having succeeded. - Defaults to 3. Minimum value is 1. - format: int32 - type: integer - grpc: - description: GRPC specifies an action involving - a GRPC port. - properties: - port: - description: Port number of the gRPC service. - Number must be in the range 1 to 65535. - format: int32 - type: integer - service: - description: |- - Service is the name of the service to place in the gRPC HealthCheckRequest - (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). - - - If this is not specified, the default behavior is defined by gRPC. - type: string - required: - - port - type: object - httpGet: - description: HTTPGet specifies the http request - to perform. - properties: - host: - description: |- - Host name to connect to, defaults to the pod IP. You probably want to set - "Host" in httpHeaders instead. - type: string - httpHeaders: - description: Custom headers to set in the - request. HTTP allows repeated headers. - items: - description: HTTPHeader describes a custom - header to be used in HTTP probes - properties: - name: - description: |- - The header field name. - This will be canonicalized upon output, so case-variant names will be understood as the same header. - type: string - value: - description: The header field value - type: string - required: - - name - - value - type: object - type: array - path: - description: Path to access on the HTTP server. - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Name or number of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - scheme: - description: |- - Scheme to use for connecting to the host. - Defaults to HTTP. - type: string - required: - - port - type: object - initialDelaySeconds: - description: |- - Number of seconds after the container has started before liveness probes are initiated. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - format: int32 - type: integer - periodSeconds: - description: |- - How often (in seconds) to perform the probe. - Default to 10 seconds. Minimum value is 1. - format: int32 - type: integer - successThreshold: - description: |- - Minimum consecutive successes for the probe to be considered successful after having failed. - Defaults to 1. Must be 1 for liveness and startup. Minimum value is 1. - format: int32 - type: integer - tcpSocket: - description: TCPSocket specifies an action involving - a TCP port. - properties: - host: - description: 'Optional: Host name to connect - to, defaults to the pod IP.' - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Number or name of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - required: - - port - type: object - terminationGracePeriodSeconds: - description: |- - Optional duration in seconds the pod needs to terminate gracefully upon probe failure. - The grace period is the duration in seconds after the processes running in the pod are sent - a termination signal and the time when the processes are forcibly halted with a kill signal. - Set this value longer than the expected cleanup time for your process. - If this value is nil, the pod's terminationGracePeriodSeconds will be used. Otherwise, this - value overrides the value provided by the pod spec. - Value must be non-negative integer. The value zero indicates stop immediately via - the kill signal (no opportunity to shut down). - This is a beta field and requires enabling ProbeTerminationGracePeriod feature gate. - Minimum value is 1. spec.terminationGracePeriodSeconds is used if unset. - format: int64 - type: integer - timeoutSeconds: - description: |- - Number of seconds after which the probe times out. - Defaults to 1 second. Minimum value is 1. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - format: int32 - type: integer - type: object - stdin: - description: |- - Whether this container should allocate a buffer for stdin in the container runtime. If this - is not set, reads from stdin in the container will always result in EOF. - Default is false. - type: boolean - stdinOnce: - description: |- - Whether the container runtime should close the stdin channel after it has been opened by - a single attach. When stdin is true the stdin stream will remain open across multiple attach - sessions. If stdinOnce is set to true, stdin is opened on container start, is empty until the - first client attaches to stdin, and then remains open and accepts data until the client disconnects, - at which time stdin is closed and remains closed until the container is restarted. If this - flag is false, a container processes that reads from stdin will never receive an EOF. - Default is false - type: boolean - terminationMessagePath: - description: |- - Optional: Path at which the file to which the container's termination message - will be written is mounted into the container's filesystem. - Message written is intended to be brief final status, such as an assertion failure message. - Will be truncated by the node if greater than 4096 bytes. The total message length across - all containers will be limited to 12kb. - Defaults to /dev/termination-log. - Cannot be updated. - type: string - terminationMessagePolicy: - description: |- - Indicate how the termination message should be populated. File will use the contents of - terminationMessagePath to populate the container status message on both success and failure. - FallbackToLogsOnError will use the last chunk of container log output if the termination - message file is empty and the container exited with an error. - The log output is limited to 2048 bytes or 80 lines, whichever is smaller. - Defaults to File. - Cannot be updated. - type: string - tty: - description: |- - Whether this container should allocate a TTY for itself, also requires 'stdin' to be true. - Default is false. - type: boolean - volumeDevices: - description: volumeDevices is the list of block devices - to be used by the container. - items: - description: volumeDevice describes a mapping of - a raw block device within a container. - properties: - devicePath: - description: devicePath is the path inside of - the container that the device will be mapped - to. - type: string - name: - description: name must match the name of a persistentVolumeClaim - in the pod - type: string - required: - - devicePath - - name - type: object - type: array - volumeMounts: - description: |- - Pod volumes to mount into the container's filesystem. - Cannot be updated. - items: - description: VolumeMount describes a mounting of - a Volume within a container. - properties: - mountPath: - description: |- - Path within the container at which the volume should be mounted. Must - not contain ':'. - type: string - mountPropagation: - description: |- - mountPropagation determines how mounts are propagated from the host - to container and the other way around. - When not set, MountPropagationNone is used. - This field is beta in 1.10. - type: string - name: - description: This must match the Name of a Volume. - type: string - readOnly: - description: |- - Mounted read-only if true, read-write otherwise (false or unspecified). - Defaults to false. - type: boolean - subPath: - description: |- - Path within the volume from which the container's volume should be mounted. - Defaults to "" (volume's root). - type: string - subPathExpr: - description: |- - Expanded path within the volume from which the container's volume should be mounted. - Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. - Defaults to "" (volume's root). - SubPathExpr and SubPath are mutually exclusive. - type: string - required: - - mountPath - - name - type: object - type: array - workingDir: - description: |- - Container's working directory. - If not specified, the container runtime's default will be used, which - might be configured in the container image. - Cannot be updated. - type: string - required: - - name - type: object - type: array - x-kubernetes-list-map-keys: - - name - x-kubernetes-list-type: map - x-kubernetes-preserve-unknown-fields: true - initContainers: - description: |- - Provides override values for ClusterDefinition.spec.componentDefs.podSpec.initContainers. - Typically used in scenarios such as updating application container images. - items: - description: A single application container that you want - to run within a pod. - properties: - args: - description: |- - Arguments to the entrypoint. - The container image's CMD is used if this is not provided. - Variable references $(VAR_NAME) are expanded using the container's environment. If a variable - cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced - to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will - produce the string literal "$(VAR_NAME)". Escaped references will never be expanded, regardless - of whether the variable exists or not. Cannot be updated. - More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell - items: - type: string - type: array - command: - description: |- - Entrypoint array. Not executed within a shell. - The container image's ENTRYPOINT is used if this is not provided. - Variable references $(VAR_NAME) are expanded using the container's environment. If a variable - cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced - to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will - produce the string literal "$(VAR_NAME)". Escaped references will never be expanded, regardless - of whether the variable exists or not. Cannot be updated. - More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell - items: - type: string - type: array - env: - description: |- - List of environment variables to set in the container. - Cannot be updated. - items: - description: EnvVar represents an environment variable - present in a Container. - properties: - name: - description: Name of the environment variable. - Must be a C_IDENTIFIER. - type: string - value: - description: |- - Variable references $(VAR_NAME) are expanded - using the previously defined environment variables in the container and - any service environment variables. If a variable cannot be resolved, - the reference in the input string will be unchanged. Double $$ are reduced - to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. - "$$(VAR_NAME)" will produce the string literal "$(VAR_NAME)". - Escaped references will never be expanded, regardless of whether the variable - exists or not. - Defaults to "". - type: string - valueFrom: - description: Source for the environment variable's - value. Cannot be used if value is not empty. - properties: - configMapKeyRef: - description: Selects a key of a ConfigMap. - properties: - key: - description: The key to select. - type: string - name: - description: |- - Name of the referent. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid? - type: string - optional: - description: Specify whether the ConfigMap - or its key must be defined - type: boolean - required: - - key - type: object - x-kubernetes-map-type: atomic - fieldRef: - description: |- - Selects a field of the pod: supports metadata.name, metadata.namespace, `metadata.labels['']`, `metadata.annotations['']`, - spec.nodeName, spec.serviceAccountName, status.hostIP, status.podIP, status.podIPs. - properties: - apiVersion: - description: Version of the schema the - FieldPath is written in terms of, - defaults to "v1". - type: string - fieldPath: - description: Path of the field to select - in the specified API version. - type: string - required: - - fieldPath - type: object - x-kubernetes-map-type: atomic - resourceFieldRef: - description: |- - Selects a resource of the container: only resources limits and requests - (limits.cpu, limits.memory, limits.ephemeral-storage, requests.cpu, requests.memory and requests.ephemeral-storage) are currently supported. - properties: - containerName: - description: 'Container name: required - for volumes, optional for env vars' - type: string - divisor: - anyOf: - - type: integer - - type: string - description: Specifies the output format - of the exposed resources, defaults - to "1" - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - resource: - description: 'Required: resource to - select' - type: string - required: - - resource - type: object - x-kubernetes-map-type: atomic - secretKeyRef: - description: Selects a key of a secret in - the pod's namespace - properties: - key: - description: The key of the secret to - select from. Must be a valid secret - key. - type: string - name: - description: |- - Name of the referent. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid? - type: string - optional: - description: Specify whether the Secret - or its key must be defined - type: boolean - required: - - key - type: object - x-kubernetes-map-type: atomic - type: object - required: - - name - type: object - type: array - envFrom: - description: |- - List of sources to populate environment variables in the container. - The keys defined within a source must be a C_IDENTIFIER. All invalid keys - will be reported as an event when the container is starting. When a key exists in multiple - sources, the value associated with the last source will take precedence. - Values defined by an Env with a duplicate key will take precedence. - Cannot be updated. - items: - description: EnvFromSource represents the source - of a set of ConfigMaps - properties: - configMapRef: - description: The ConfigMap to select from - properties: - name: - description: |- - Name of the referent. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid? - type: string - optional: - description: Specify whether the ConfigMap - must be defined - type: boolean - type: object - x-kubernetes-map-type: atomic - prefix: - description: An optional identifier to prepend - to each key in the ConfigMap. Must be a C_IDENTIFIER. - type: string - secretRef: - description: The Secret to select from - properties: - name: - description: |- - Name of the referent. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid? - type: string - optional: - description: Specify whether the Secret - must be defined - type: boolean - type: object - x-kubernetes-map-type: atomic - type: object - type: array - image: - description: |- - Container image name. - More info: https://kubernetes.io/docs/concepts/containers/images - This field is optional to allow higher level config management to default or override - container images in workload controllers like Deployments and StatefulSets. - type: string - imagePullPolicy: - description: |- - Image pull policy. - One of Always, Never, IfNotPresent. - Defaults to Always if :latest tag is specified, or IfNotPresent otherwise. - Cannot be updated. - More info: https://kubernetes.io/docs/concepts/containers/images#updating-images - type: string - lifecycle: - description: |- - Actions that the management system should take in response to container lifecycle events. - Cannot be updated. - properties: - postStart: - description: |- - PostStart is called immediately after a container is created. If the handler fails, - the container is terminated and restarted according to its restart policy. - Other management of the container blocks until the hook completes. - More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks - properties: - exec: - description: Exec specifies the action to - take. - properties: - command: - description: |- - Command is the command line to execute inside the container, the working directory for the - command is root ('/') in the container's filesystem. The command is simply exec'd, it is - not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use - a shell, you need to explicitly call out to that shell. - Exit status of 0 is treated as live/healthy and non-zero is unhealthy. - items: - type: string - type: array - type: object - httpGet: - description: HTTPGet specifies the http request - to perform. - properties: - host: - description: |- - Host name to connect to, defaults to the pod IP. You probably want to set - "Host" in httpHeaders instead. - type: string - httpHeaders: - description: Custom headers to set in - the request. HTTP allows repeated headers. - items: - description: HTTPHeader describes a - custom header to be used in HTTP probes - properties: - name: - description: |- - The header field name. - This will be canonicalized upon output, so case-variant names will be understood as the same header. - type: string - value: - description: The header field value - type: string - required: - - name - - value - type: object - type: array - path: - description: Path to access on the HTTP - server. - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Name or number of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - scheme: - description: |- - Scheme to use for connecting to the host. - Defaults to HTTP. - type: string - required: - - port - type: object - tcpSocket: - description: |- - Deprecated. TCPSocket is NOT supported as a LifecycleHandler and kept - for the backward compatibility. There are no validation of this field and - lifecycle hooks will fail in runtime when tcp handler is specified. - properties: - host: - description: 'Optional: Host name to connect - to, defaults to the pod IP.' - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Number or name of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - required: - - port - type: object - type: object - preStop: - description: |- - PreStop is called immediately before a container is terminated due to an - API request or management event such as liveness/startup probe failure, - preemption, resource contention, etc. The handler is not called if the - container crashes or exits. The Pod's termination grace period countdown begins before the - PreStop hook is executed. Regardless of the outcome of the handler, the - container will eventually terminate within the Pod's termination grace - period (unless delayed by finalizers). Other management of the container blocks until the hook completes - or until the termination grace period is reached. - More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks - properties: - exec: - description: Exec specifies the action to - take. - properties: - command: - description: |- - Command is the command line to execute inside the container, the working directory for the - command is root ('/') in the container's filesystem. The command is simply exec'd, it is - not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use - a shell, you need to explicitly call out to that shell. - Exit status of 0 is treated as live/healthy and non-zero is unhealthy. - items: - type: string - type: array - type: object - httpGet: - description: HTTPGet specifies the http request - to perform. - properties: - host: - description: |- - Host name to connect to, defaults to the pod IP. You probably want to set - "Host" in httpHeaders instead. - type: string - httpHeaders: - description: Custom headers to set in - the request. HTTP allows repeated headers. - items: - description: HTTPHeader describes a - custom header to be used in HTTP probes - properties: - name: - description: |- - The header field name. - This will be canonicalized upon output, so case-variant names will be understood as the same header. - type: string - value: - description: The header field value - type: string - required: - - name - - value - type: object - type: array - path: - description: Path to access on the HTTP - server. - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Name or number of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - scheme: - description: |- - Scheme to use for connecting to the host. - Defaults to HTTP. - type: string - required: - - port - type: object - tcpSocket: - description: |- - Deprecated. TCPSocket is NOT supported as a LifecycleHandler and kept - for the backward compatibility. There are no validation of this field and - lifecycle hooks will fail in runtime when tcp handler is specified. - properties: - host: - description: 'Optional: Host name to connect - to, defaults to the pod IP.' - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Number or name of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - required: - - port - type: object - type: object - type: object - livenessProbe: - description: |- - Periodic probe of container liveness. - Container will be restarted if the probe fails. - Cannot be updated. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - properties: - exec: - description: Exec specifies the action to take. - properties: - command: - description: |- - Command is the command line to execute inside the container, the working directory for the - command is root ('/') in the container's filesystem. The command is simply exec'd, it is - not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use - a shell, you need to explicitly call out to that shell. - Exit status of 0 is treated as live/healthy and non-zero is unhealthy. - items: - type: string - type: array - type: object - failureThreshold: - description: |- - Minimum consecutive failures for the probe to be considered failed after having succeeded. - Defaults to 3. Minimum value is 1. - format: int32 - type: integer - grpc: - description: GRPC specifies an action involving - a GRPC port. - properties: - port: - description: Port number of the gRPC service. - Number must be in the range 1 to 65535. - format: int32 - type: integer - service: - description: |- - Service is the name of the service to place in the gRPC HealthCheckRequest - (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). - - - If this is not specified, the default behavior is defined by gRPC. - type: string - required: - - port - type: object - httpGet: - description: HTTPGet specifies the http request - to perform. - properties: - host: - description: |- - Host name to connect to, defaults to the pod IP. You probably want to set - "Host" in httpHeaders instead. - type: string - httpHeaders: - description: Custom headers to set in the - request. HTTP allows repeated headers. - items: - description: HTTPHeader describes a custom - header to be used in HTTP probes - properties: - name: - description: |- - The header field name. - This will be canonicalized upon output, so case-variant names will be understood as the same header. - type: string - value: - description: The header field value - type: string - required: - - name - - value - type: object - type: array - path: - description: Path to access on the HTTP server. - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Name or number of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - scheme: - description: |- - Scheme to use for connecting to the host. - Defaults to HTTP. - type: string - required: - - port - type: object - initialDelaySeconds: - description: |- - Number of seconds after the container has started before liveness probes are initiated. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - format: int32 - type: integer - periodSeconds: - description: |- - How often (in seconds) to perform the probe. - Default to 10 seconds. Minimum value is 1. - format: int32 - type: integer - successThreshold: - description: |- - Minimum consecutive successes for the probe to be considered successful after having failed. - Defaults to 1. Must be 1 for liveness and startup. Minimum value is 1. - format: int32 - type: integer - tcpSocket: - description: TCPSocket specifies an action involving - a TCP port. - properties: - host: - description: 'Optional: Host name to connect - to, defaults to the pod IP.' - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Number or name of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - required: - - port - type: object - terminationGracePeriodSeconds: - description: |- - Optional duration in seconds the pod needs to terminate gracefully upon probe failure. - The grace period is the duration in seconds after the processes running in the pod are sent - a termination signal and the time when the processes are forcibly halted with a kill signal. - Set this value longer than the expected cleanup time for your process. - If this value is nil, the pod's terminationGracePeriodSeconds will be used. Otherwise, this - value overrides the value provided by the pod spec. - Value must be non-negative integer. The value zero indicates stop immediately via - the kill signal (no opportunity to shut down). - This is a beta field and requires enabling ProbeTerminationGracePeriod feature gate. - Minimum value is 1. spec.terminationGracePeriodSeconds is used if unset. - format: int64 - type: integer - timeoutSeconds: - description: |- - Number of seconds after which the probe times out. - Defaults to 1 second. Minimum value is 1. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - format: int32 - type: integer - type: object - name: - description: |- - Name of the container specified as a DNS_LABEL. - Each container in a pod must have a unique name (DNS_LABEL). - Cannot be updated. - type: string - ports: - description: |- - List of ports to expose from the container. Not specifying a port here - DOES NOT prevent that port from being exposed. Any port which is - listening on the default "0.0.0.0" address inside a container will be - accessible from the network. - Modifying this array with strategic merge patch may corrupt the data. - For more information See https://github.com/kubernetes/kubernetes/issues/108255. - Cannot be updated. - items: - description: ContainerPort represents a network - port in a single container. - properties: - containerPort: - description: |- - Number of port to expose on the pod's IP address. - This must be a valid port number, 0 < x < 65536. - format: int32 - type: integer - hostIP: - description: What host IP to bind the external - port to. - type: string - hostPort: - description: |- - Number of port to expose on the host. - If specified, this must be a valid port number, 0 < x < 65536. - If HostNetwork is specified, this must match ContainerPort. - Most containers do not need this. - format: int32 - type: integer - name: - description: |- - If specified, this must be an IANA_SVC_NAME and unique within the pod. Each - named port in a pod must have a unique name. Name for the port that can be - referred to by services. - type: string - protocol: - default: TCP - description: |- - Protocol for port. Must be UDP, TCP, or SCTP. - Defaults to "TCP". - type: string - required: - - containerPort - type: object - type: array - x-kubernetes-list-map-keys: - - containerPort - - protocol - x-kubernetes-list-type: map - readinessProbe: - description: |- - Periodic probe of container service readiness. - Container will be removed from service endpoints if the probe fails. - Cannot be updated. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - properties: - exec: - description: Exec specifies the action to take. - properties: - command: - description: |- - Command is the command line to execute inside the container, the working directory for the - command is root ('/') in the container's filesystem. The command is simply exec'd, it is - not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use - a shell, you need to explicitly call out to that shell. - Exit status of 0 is treated as live/healthy and non-zero is unhealthy. - items: - type: string - type: array - type: object - failureThreshold: - description: |- - Minimum consecutive failures for the probe to be considered failed after having succeeded. - Defaults to 3. Minimum value is 1. - format: int32 - type: integer - grpc: - description: GRPC specifies an action involving - a GRPC port. - properties: - port: - description: Port number of the gRPC service. - Number must be in the range 1 to 65535. - format: int32 - type: integer - service: - description: |- - Service is the name of the service to place in the gRPC HealthCheckRequest - (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). - - - If this is not specified, the default behavior is defined by gRPC. - type: string - required: - - port - type: object - httpGet: - description: HTTPGet specifies the http request - to perform. - properties: - host: - description: |- - Host name to connect to, defaults to the pod IP. You probably want to set - "Host" in httpHeaders instead. - type: string - httpHeaders: - description: Custom headers to set in the - request. HTTP allows repeated headers. - items: - description: HTTPHeader describes a custom - header to be used in HTTP probes - properties: - name: - description: |- - The header field name. - This will be canonicalized upon output, so case-variant names will be understood as the same header. - type: string - value: - description: The header field value - type: string - required: - - name - - value - type: object - type: array - path: - description: Path to access on the HTTP server. - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Name or number of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - scheme: - description: |- - Scheme to use for connecting to the host. - Defaults to HTTP. - type: string - required: - - port - type: object - initialDelaySeconds: - description: |- - Number of seconds after the container has started before liveness probes are initiated. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - format: int32 - type: integer - periodSeconds: - description: |- - How often (in seconds) to perform the probe. - Default to 10 seconds. Minimum value is 1. - format: int32 - type: integer - successThreshold: - description: |- - Minimum consecutive successes for the probe to be considered successful after having failed. - Defaults to 1. Must be 1 for liveness and startup. Minimum value is 1. - format: int32 - type: integer - tcpSocket: - description: TCPSocket specifies an action involving - a TCP port. - properties: - host: - description: 'Optional: Host name to connect - to, defaults to the pod IP.' - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Number or name of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - required: - - port - type: object - terminationGracePeriodSeconds: - description: |- - Optional duration in seconds the pod needs to terminate gracefully upon probe failure. - The grace period is the duration in seconds after the processes running in the pod are sent - a termination signal and the time when the processes are forcibly halted with a kill signal. - Set this value longer than the expected cleanup time for your process. - If this value is nil, the pod's terminationGracePeriodSeconds will be used. Otherwise, this - value overrides the value provided by the pod spec. - Value must be non-negative integer. The value zero indicates stop immediately via - the kill signal (no opportunity to shut down). - This is a beta field and requires enabling ProbeTerminationGracePeriod feature gate. - Minimum value is 1. spec.terminationGracePeriodSeconds is used if unset. - format: int64 - type: integer - timeoutSeconds: - description: |- - Number of seconds after which the probe times out. - Defaults to 1 second. Minimum value is 1. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - format: int32 - type: integer - type: object - resizePolicy: - description: Resources resize policy for the container. - items: - description: ContainerResizePolicy represents resource - resize policy for the container. - properties: - resourceName: - description: |- - Name of the resource to which this resource resize policy applies. - Supported values: cpu, memory. - type: string - restartPolicy: - description: |- - Restart policy to apply when specified resource is resized. - If not specified, it defaults to NotRequired. - type: string - required: - - resourceName - - restartPolicy - type: object - type: array - x-kubernetes-list-type: atomic - resources: - description: |- - Compute Resources required by this container. - Cannot be updated. - More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ - properties: - claims: - description: |- - Claims lists the names of resources, defined in spec.resourceClaims, - that are used by this container. - - - This is an alpha field and requires enabling the - DynamicResourceAllocation feature gate. - - - This field is immutable. It can only be set for containers. - items: - description: ResourceClaim references one entry - in PodSpec.ResourceClaims. - properties: - name: - description: |- - Name must match the name of one entry in pod.spec.resourceClaims of - the Pod where this field is used. It makes that resource available - inside a container. - type: string - required: - - name - type: object - type: array - x-kubernetes-list-map-keys: - - name - x-kubernetes-list-type: map - limits: - additionalProperties: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - description: |- - Limits describes the maximum amount of compute resources allowed. - More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ - type: object - requests: - additionalProperties: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - description: |- - Requests describes the minimum amount of compute resources required. - If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, - otherwise to an implementation-defined value. Requests cannot exceed Limits. - More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ - type: object - type: object - restartPolicy: - description: |- - RestartPolicy defines the restart behavior of individual containers in a pod. - This field may only be set for init containers, and the only allowed value is "Always". - For non-init containers or when this field is not specified, - the restart behavior is defined by the Pod's restart policy and the container type. - Setting the RestartPolicy as "Always" for the init container will have the following effect: - this init container will be continually restarted on - exit until all regular containers have terminated. Once all regular - containers have completed, all init containers with restartPolicy "Always" - will be shut down. This lifecycle differs from normal init containers and - is often referred to as a "sidecar" container. Although this init - container still starts in the init container sequence, it does not wait - for the container to complete before proceeding to the next init - container. Instead, the next init container starts immediately after this - init container is started, or after any startupProbe has successfully - completed. - type: string - securityContext: - description: |- - SecurityContext defines the security options the container should be run with. - If set, the fields of SecurityContext override the equivalent fields of PodSecurityContext. - More info: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/ - properties: - allowPrivilegeEscalation: - description: |- - AllowPrivilegeEscalation controls whether a process can gain more - privileges than its parent process. This bool directly controls if - the no_new_privs flag will be set on the container process. - AllowPrivilegeEscalation is true always when the container is: - 1) run as Privileged - 2) has CAP_SYS_ADMIN - Note that this field cannot be set when spec.os.name is windows. - type: boolean - capabilities: - description: |- - The capabilities to add/drop when running containers. - Defaults to the default set of capabilities granted by the container runtime. - Note that this field cannot be set when spec.os.name is windows. - properties: - add: - description: Added capabilities - items: - description: Capability represent POSIX - capabilities type - type: string - type: array - drop: - description: Removed capabilities - items: - description: Capability represent POSIX - capabilities type - type: string - type: array - type: object - privileged: - description: |- - Run container in privileged mode. - Processes in privileged containers are essentially equivalent to root on the host. - Defaults to false. - Note that this field cannot be set when spec.os.name is windows. - type: boolean - procMount: - description: |- - procMount denotes the type of proc mount to use for the containers. - The default is DefaultProcMount which uses the container runtime defaults for - readonly paths and masked paths. - This requires the ProcMountType feature flag to be enabled. - Note that this field cannot be set when spec.os.name is windows. - type: string - readOnlyRootFilesystem: - description: |- - Whether this container has a read-only root filesystem. - Default is false. - Note that this field cannot be set when spec.os.name is windows. - type: boolean - runAsGroup: - description: |- - The GID to run the entrypoint of the container process. - Uses runtime default if unset. - May also be set in PodSecurityContext. If set in both SecurityContext and - PodSecurityContext, the value specified in SecurityContext takes precedence. - Note that this field cannot be set when spec.os.name is windows. - format: int64 - type: integer - runAsNonRoot: - description: |- - Indicates that the container must run as a non-root user. - If true, the Kubelet will validate the image at runtime to ensure that it - does not run as UID 0 (root) and fail to start the container if it does. - If unset or false, no such validation will be performed. - May also be set in PodSecurityContext. If set in both SecurityContext and - PodSecurityContext, the value specified in SecurityContext takes precedence. - type: boolean - runAsUser: - description: |- - The UID to run the entrypoint of the container process. - Defaults to user specified in image metadata if unspecified. - May also be set in PodSecurityContext. If set in both SecurityContext and - PodSecurityContext, the value specified in SecurityContext takes precedence. - Note that this field cannot be set when spec.os.name is windows. - format: int64 - type: integer - seLinuxOptions: - description: |- - The SELinux context to be applied to the container. - If unspecified, the container runtime will allocate a random SELinux context for each - container. May also be set in PodSecurityContext. If set in both SecurityContext and - PodSecurityContext, the value specified in SecurityContext takes precedence. - Note that this field cannot be set when spec.os.name is windows. - properties: - level: - description: Level is SELinux level label - that applies to the container. - type: string - role: - description: Role is a SELinux role label - that applies to the container. - type: string - type: - description: Type is a SELinux type label - that applies to the container. - type: string - user: - description: User is a SELinux user label - that applies to the container. - type: string - type: object - seccompProfile: - description: |- - The seccomp options to use by this container. If seccomp options are - provided at both the pod & container level, the container options - override the pod options. - Note that this field cannot be set when spec.os.name is windows. - properties: - localhostProfile: - description: |- - localhostProfile indicates a profile defined in a file on the node should be used. - The profile must be preconfigured on the node to work. - Must be a descending path, relative to the kubelet's configured seccomp profile location. - Must be set if type is "Localhost". Must NOT be set for any other type. - type: string - type: - description: |- - type indicates which kind of seccomp profile will be applied. - Valid options are: - - - Localhost - a profile defined in a file on the node should be used. - RuntimeDefault - the container runtime default profile should be used. - Unconfined - no profile should be applied. - type: string - required: - - type - type: object - windowsOptions: - description: |- - The Windows specific settings applied to all containers. - If unspecified, the options from the PodSecurityContext will be used. - If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence. - Note that this field cannot be set when spec.os.name is linux. - properties: - gmsaCredentialSpec: - description: |- - GMSACredentialSpec is where the GMSA admission webhook - (https://github.com/kubernetes-sigs/windows-gmsa) inlines the contents of the - GMSA credential spec named by the GMSACredentialSpecName field. - type: string - gmsaCredentialSpecName: - description: GMSACredentialSpecName is the - name of the GMSA credential spec to use. - type: string - hostProcess: - description: |- - HostProcess determines if a container should be run as a 'Host Process' container. - All of a Pod's containers must have the same effective HostProcess value - (it is not allowed to have a mix of HostProcess containers and non-HostProcess containers). - In addition, if HostProcess is true then HostNetwork must also be set to true. - type: boolean - runAsUserName: - description: |- - The UserName in Windows to run the entrypoint of the container process. - Defaults to the user specified in image metadata if unspecified. - May also be set in PodSecurityContext. If set in both SecurityContext and - PodSecurityContext, the value specified in SecurityContext takes precedence. - type: string - type: object - type: object - startupProbe: - description: |- - StartupProbe indicates that the Pod has successfully initialized. - If specified, no other probes are executed until this completes successfully. - If this probe fails, the Pod will be restarted, just as if the livenessProbe failed. - This can be used to provide different probe parameters at the beginning of a Pod's lifecycle, - when it might take a long time to load data or warm a cache, than during steady-state operation. - This cannot be updated. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - properties: - exec: - description: Exec specifies the action to take. - properties: - command: - description: |- - Command is the command line to execute inside the container, the working directory for the - command is root ('/') in the container's filesystem. The command is simply exec'd, it is - not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use - a shell, you need to explicitly call out to that shell. - Exit status of 0 is treated as live/healthy and non-zero is unhealthy. - items: - type: string - type: array - type: object - failureThreshold: - description: |- - Minimum consecutive failures for the probe to be considered failed after having succeeded. - Defaults to 3. Minimum value is 1. - format: int32 - type: integer - grpc: - description: GRPC specifies an action involving - a GRPC port. - properties: - port: - description: Port number of the gRPC service. - Number must be in the range 1 to 65535. - format: int32 - type: integer - service: - description: |- - Service is the name of the service to place in the gRPC HealthCheckRequest - (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). - - - If this is not specified, the default behavior is defined by gRPC. - type: string - required: - - port - type: object - httpGet: - description: HTTPGet specifies the http request - to perform. - properties: - host: - description: |- - Host name to connect to, defaults to the pod IP. You probably want to set - "Host" in httpHeaders instead. - type: string - httpHeaders: - description: Custom headers to set in the - request. HTTP allows repeated headers. - items: - description: HTTPHeader describes a custom - header to be used in HTTP probes - properties: - name: - description: |- - The header field name. - This will be canonicalized upon output, so case-variant names will be understood as the same header. - type: string - value: - description: The header field value - type: string - required: - - name - - value - type: object - type: array - path: - description: Path to access on the HTTP server. - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Name or number of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - scheme: - description: |- - Scheme to use for connecting to the host. - Defaults to HTTP. - type: string - required: - - port - type: object - initialDelaySeconds: - description: |- - Number of seconds after the container has started before liveness probes are initiated. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - format: int32 - type: integer - periodSeconds: - description: |- - How often (in seconds) to perform the probe. - Default to 10 seconds. Minimum value is 1. - format: int32 - type: integer - successThreshold: - description: |- - Minimum consecutive successes for the probe to be considered successful after having failed. - Defaults to 1. Must be 1 for liveness and startup. Minimum value is 1. - format: int32 - type: integer - tcpSocket: - description: TCPSocket specifies an action involving - a TCP port. - properties: - host: - description: 'Optional: Host name to connect - to, defaults to the pod IP.' - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Number or name of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - required: - - port - type: object - terminationGracePeriodSeconds: - description: |- - Optional duration in seconds the pod needs to terminate gracefully upon probe failure. - The grace period is the duration in seconds after the processes running in the pod are sent - a termination signal and the time when the processes are forcibly halted with a kill signal. - Set this value longer than the expected cleanup time for your process. - If this value is nil, the pod's terminationGracePeriodSeconds will be used. Otherwise, this - value overrides the value provided by the pod spec. - Value must be non-negative integer. The value zero indicates stop immediately via - the kill signal (no opportunity to shut down). - This is a beta field and requires enabling ProbeTerminationGracePeriod feature gate. - Minimum value is 1. spec.terminationGracePeriodSeconds is used if unset. - format: int64 - type: integer - timeoutSeconds: - description: |- - Number of seconds after which the probe times out. - Defaults to 1 second. Minimum value is 1. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - format: int32 - type: integer - type: object - stdin: - description: |- - Whether this container should allocate a buffer for stdin in the container runtime. If this - is not set, reads from stdin in the container will always result in EOF. - Default is false. - type: boolean - stdinOnce: - description: |- - Whether the container runtime should close the stdin channel after it has been opened by - a single attach. When stdin is true the stdin stream will remain open across multiple attach - sessions. If stdinOnce is set to true, stdin is opened on container start, is empty until the - first client attaches to stdin, and then remains open and accepts data until the client disconnects, - at which time stdin is closed and remains closed until the container is restarted. If this - flag is false, a container processes that reads from stdin will never receive an EOF. - Default is false - type: boolean - terminationMessagePath: - description: |- - Optional: Path at which the file to which the container's termination message - will be written is mounted into the container's filesystem. - Message written is intended to be brief final status, such as an assertion failure message. - Will be truncated by the node if greater than 4096 bytes. The total message length across - all containers will be limited to 12kb. - Defaults to /dev/termination-log. - Cannot be updated. - type: string - terminationMessagePolicy: - description: |- - Indicate how the termination message should be populated. File will use the contents of - terminationMessagePath to populate the container status message on both success and failure. - FallbackToLogsOnError will use the last chunk of container log output if the termination - message file is empty and the container exited with an error. - The log output is limited to 2048 bytes or 80 lines, whichever is smaller. - Defaults to File. - Cannot be updated. - type: string - tty: - description: |- - Whether this container should allocate a TTY for itself, also requires 'stdin' to be true. - Default is false. - type: boolean - volumeDevices: - description: volumeDevices is the list of block devices - to be used by the container. - items: - description: volumeDevice describes a mapping of - a raw block device within a container. - properties: - devicePath: - description: devicePath is the path inside of - the container that the device will be mapped - to. - type: string - name: - description: name must match the name of a persistentVolumeClaim - in the pod - type: string - required: - - devicePath - - name - type: object - type: array - volumeMounts: - description: |- - Pod volumes to mount into the container's filesystem. - Cannot be updated. - items: - description: VolumeMount describes a mounting of - a Volume within a container. - properties: - mountPath: - description: |- - Path within the container at which the volume should be mounted. Must - not contain ':'. - type: string - mountPropagation: - description: |- - mountPropagation determines how mounts are propagated from the host - to container and the other way around. - When not set, MountPropagationNone is used. - This field is beta in 1.10. - type: string - name: - description: This must match the Name of a Volume. - type: string - readOnly: - description: |- - Mounted read-only if true, read-write otherwise (false or unspecified). - Defaults to false. - type: boolean - subPath: - description: |- - Path within the volume from which the container's volume should be mounted. - Defaults to "" (volume's root). - type: string - subPathExpr: - description: |- - Expanded path within the volume from which the container's volume should be mounted. - Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. - Defaults to "" (volume's root). - SubPathExpr and SubPath are mutually exclusive. - type: string - required: - - mountPath - - name - type: object - type: array - workingDir: - description: |- - Container's working directory. - If not specified, the container runtime's default will be used, which - might be configured in the container image. - Cannot be updated. - type: string - required: - - name - type: object - type: array - x-kubernetes-list-map-keys: - - name - x-kubernetes-list-type: map - x-kubernetes-preserve-unknown-fields: true - type: object - required: - - componentDefRef - - versionsContext - type: object - minItems: 1 - type: array - x-kubernetes-list-map-keys: - - componentDefRef - x-kubernetes-list-type: map - required: - - clusterDefinitionRef - - componentVersions - type: object - status: - description: |- - ClusterVersionStatus defines the observed state of ClusterVersion. - - - Deprecated since v0.9. - This struct is maintained for backward compatibility and its use is discouraged. - properties: - clusterDefGeneration: - description: The generation number of the ClusterDefinition that is - currently being referenced. - format: int64 - type: integer - message: - description: Provides additional information about the current phase. - type: string - observedGeneration: - description: The generation number that has been observed by the controller. - format: int64 - type: integer - phase: - description: The current phase of the ClusterVersion. - enum: - - Available - - Unavailable - type: string - type: object - type: object - served: true - storage: true - subresources: - status: {} diff --git a/config/crd/bases/apps.kubeblocks.io_configconstraints.yaml b/config/crd/bases/apps.kubeblocks.io_configconstraints.yaml index 50a118ff6c8..ad8198789bf 100644 --- a/config/crd/bases/apps.kubeblocks.io_configconstraints.yaml +++ b/config/crd/bases/apps.kubeblocks.io_configconstraints.yaml @@ -758,7 +758,7 @@ spec: phase: description: |- Specifies the status of the configuration template. - When set to CCAvailablePhase, the ConfigConstraint can be referenced by ClusterDefinition or ClusterVersion. + When set to CCAvailablePhase, the ConfigConstraint can be referenced by ClusterDefinition. enum: - Available - Unavailable @@ -1418,7 +1418,7 @@ spec: phase: description: |- Specifies the status of the configuration template. - When set to CCAvailablePhase, the ConfigConstraint can be referenced by ClusterDefinition or ClusterVersion. + When set to CCAvailablePhase, the ConfigConstraint can be referenced by ClusterDefinition. enum: - Available - Unavailable diff --git a/config/crd/kustomization.yaml b/config/crd/kustomization.yaml index 1a5378fdb52..6feecab5b32 100644 --- a/config/crd/kustomization.yaml +++ b/config/crd/kustomization.yaml @@ -5,7 +5,6 @@ resources: - bases/apps.kubeblocks.io_backuppolicytemplates.yaml - bases/apps.kubeblocks.io_clusters.yaml - bases/apps.kubeblocks.io_clusterdefinitions.yaml -- bases/apps.kubeblocks.io_clusterversions.yaml - bases/apps.kubeblocks.io_configconstraints.yaml - bases/apps.kubeblocks.io_opsrequests.yaml - bases/dataprotection.kubeblocks.io_actionsets.yaml @@ -32,7 +31,6 @@ patchesStrategicMerge: # patches here are for enabling the conversion webhook for each CRD #- patches/webhook_in_clusters.yaml #- patches/webhook_in_clusterdefinitions.yaml -#- patches/webhook_in_clusterversions.yaml #- patches/webhook_in_backuptools.yaml #- patches/webhook_in_backuppolicies.yaml #- patches/webhook_in_backups.yaml @@ -60,7 +58,6 @@ patchesStrategicMerge: # patches here are for enabling the CA injection for each CRD #- patches/cainjection_in_clusters.yaml #- patches/cainjection_in_clusterdefinitions.yaml -#- patches/cainjection_in_clusterversions.yaml #- patches/cainjection_in_backuptools.yaml #- patches/cainjection_in_backuppolicies.yaml #- patches/cainjection_in_backups.yaml diff --git a/config/crd/patches/cainjection_in_apps_clusterversions.yaml b/config/crd/patches/cainjection_in_apps_clusterversions.yaml deleted file mode 100644 index 15da1d8d9ab..00000000000 --- a/config/crd/patches/cainjection_in_apps_clusterversions.yaml +++ /dev/null @@ -1,7 +0,0 @@ -# The following patch adds a directive for certmanager to inject CA into the CRD -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME) - name: clusterversions.apps.kubeblocks.io diff --git a/config/crd/patches/webhook_in_apps_clusterversions.yaml b/config/crd/patches/webhook_in_apps_clusterversions.yaml deleted file mode 100644 index 4851527b361..00000000000 --- a/config/crd/patches/webhook_in_apps_clusterversions.yaml +++ /dev/null @@ -1,16 +0,0 @@ -# The following patch enables a conversion webhook for the CRD -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - name: clusterversions.apps.kubeblocks.io -spec: - conversion: - strategy: Webhook - webhook: - clientConfig: - service: - namespace: system - name: webhook-service - path: /convert - conversionReviewVersions: - - v1 diff --git a/config/rbac/apps_clusterversion_editor_role.yaml b/config/rbac/apps_clusterversion_editor_role.yaml deleted file mode 100644 index 5e3973b4c02..00000000000 --- a/config/rbac/apps_clusterversion_editor_role.yaml +++ /dev/null @@ -1,24 +0,0 @@ -# permissions for end users to edit clusterversions. -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - name: clusterversion-editor-role -rules: -- apiGroups: - - apps.kubeblocks.io - resources: - - clusterversions - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - apps.kubeblocks.io - resources: - - clusterversions/status - verbs: - - get diff --git a/config/rbac/apps_clusterversion_viewer_role.yaml b/config/rbac/apps_clusterversion_viewer_role.yaml deleted file mode 100644 index c8066a7a4b2..00000000000 --- a/config/rbac/apps_clusterversion_viewer_role.yaml +++ /dev/null @@ -1,20 +0,0 @@ -# permissions for end users to view clusterversions. -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - name: clusterversion-viewer-role -rules: -- apiGroups: - - apps.kubeblocks.io - resources: - - clusterversions - verbs: - - get - - list - - watch -- apiGroups: - - apps.kubeblocks.io - resources: - - clusterversions/status - verbs: - - get diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index 8f6b142af93..aac6ca93aab 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -122,32 +122,6 @@ rules: - get - patch - update -- apiGroups: - - apps.kubeblocks.io - resources: - - clusterversions - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - apps.kubeblocks.io - resources: - - clusterversions/finalizers - verbs: - - update -- apiGroups: - - apps.kubeblocks.io - resources: - - clusterversions/status - verbs: - - get - - patch - - update - apiGroups: - apps.kubeblocks.io resources: diff --git a/config/samples/ops/mysql_clusterversion_upgrade.yaml b/config/samples/ops/mysql_clusterversion_upgrade.yaml deleted file mode 100644 index 1c1fd3c83cf..00000000000 --- a/config/samples/ops/mysql_clusterversion_upgrade.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: apps.kubeblocks.io/v1alpha1 -kind: ClusterVersion -metadata: - name: wesql-8.0.32 -spec: - clusterDefinitionRef: wesql - components: - - type: replicasets - versionsContext: - containers: - - name: mysql - image: docker.io/apecloud/apecloud-mysql-server:latest diff --git a/controllers/apps/cluster_controller_test.go b/controllers/apps/cluster_controller_test.go index 57b4a2d0720..e27356d2c56 100644 --- a/controllers/apps/cluster_controller_test.go +++ b/controllers/apps/cluster_controller_test.go @@ -49,7 +49,6 @@ import ( var _ = Describe("Cluster Controller", func() { const ( clusterDefName = "test-clusterdef" - clusterVersionName = "test-clusterversion" compDefName = "test-compdef" compVersionName = "test-compversion" clusterName = "test-cluster" // this become cluster prefix name if used with testapps.NewClusterFactory().WithRandomName() @@ -62,14 +61,13 @@ var _ = Describe("Cluster Controller", func() { ) var ( - clusterDefObj *appsv1alpha1.ClusterDefinition - clusterVersionObj *appsv1alpha1.ClusterVersion - compDefObj *appsv1alpha1.ComponentDefinition - compVersionObj *appsv1alpha1.ComponentVersion - clusterObj *appsv1alpha1.Cluster - clusterKey types.NamespacedName - allSettings map[string]interface{} - defaultTopology = appsv1alpha1.ClusterTopology{ + clusterDefObj *appsv1alpha1.ClusterDefinition + compDefObj *appsv1alpha1.ComponentDefinition + compVersionObj *appsv1alpha1.ComponentVersion + clusterObj *appsv1alpha1.Cluster + clusterKey types.NamespacedName + allSettings map[string]interface{} + defaultTopology = appsv1alpha1.ClusterTopology{ Name: "default", Default: true, Components: []appsv1alpha1.ClusterTopologyComponent{ @@ -90,7 +88,6 @@ var _ = Describe("Cluster Controller", func() { resetTestContext := func() { clusterDefObj = nil - clusterVersionObj = nil clusterObj = nil resetViperCfg() } @@ -103,7 +100,7 @@ var _ = Describe("Cluster Controller", func() { // create the new objects. By("clean resources") - // delete cluster(and all dependent sub-resources), clusterversion and clusterdef + // delete cluster(and all dependent sub-resources), cluster definition testapps.ClearClusterResourcesWithRemoveFinalizerOption(&testCtx) // delete rest mocked objects @@ -146,13 +143,6 @@ var _ = Describe("Cluster Controller", func() { Create(&testCtx). GetObject() - By("Create a clusterVersion obj") - clusterVersionObj = testapps.NewClusterVersionFactory(clusterVersionName, clusterDefObj.GetName()). - AddComponentVersion(consensusCompDefName). - AddContainerShort("mysql", testapps.ApeCloudMySQLImage). - Create(&testCtx). - GetObject() - By("Create a componentDefinition obj") compDefObj = testapps.NewComponentDefinitionFactory(compDefName). WithRandomName(). @@ -161,7 +151,7 @@ var _ = Describe("Cluster Controller", func() { GetObject() By("Create a bpt obj") - createBackupPolicyTpl(clusterDefObj, compDefObj.Name, clusterVersionName) + createBackupPolicyTpl(clusterDefObj, compDefObj.Name) By("Create a componentVersion obj") compVersionObj = testapps.NewComponentVersionFactory(compVersionName). @@ -200,11 +190,6 @@ var _ = Describe("Cluster Controller", func() { g.Expect(clusterDef.Status.ObservedGeneration).Should(Equal(clusterDef.Generation)) g.Expect(clusterDef.Status.Phase).Should(Equal(appsv1alpha1.AvailablePhase)) })).Should(Succeed()) - Eventually(testapps.CheckObj(&testCtx, client.ObjectKeyFromObject(clusterVersionObj), - func(g Gomega, clusterVersion *appsv1alpha1.ClusterVersion) { - g.Expect(clusterVersion.Status.ObservedGeneration).Should(Equal(clusterVersion.Generation)) - g.Expect(clusterVersion.Status.Phase).Should(Equal(appsv1alpha1.AvailablePhase)) - })).Should(Succeed()) Eventually(testapps.CheckObj(&testCtx, client.ObjectKeyFromObject(compDefObj), func(g Gomega, compDef *appsv1alpha1.ComponentDefinition) { g.Expect(compDef.Status.ObservedGeneration).Should(Equal(compDef.Generation)) @@ -232,8 +217,8 @@ var _ = Describe("Cluster Controller", func() { } } - createClusterObjNoWait := func(clusterDefName, clusterVerName string, processor ...func(*testapps.MockClusterFactory)) { - f := testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, clusterDefName, clusterVerName). + createClusterObjNoWait := func(clusterDefName string, processor ...func(*testapps.MockClusterFactory)) { + f := testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, clusterDefName). WithRandomName() for _, p := range processor { if p != nil { @@ -287,7 +272,7 @@ var _ = Describe("Cluster Controller", func() { createClusterObj := func(compName, compDefName string, processor func(*testapps.MockClusterFactory)) { By("Creating a cluster with new component definition") - createClusterObjNoWait("", "", componentProcessorWrapper(false, compName, compDefName, processor)) + createClusterObjNoWait("", componentProcessorWrapper(false, compName, compDefName, processor)) By("Waiting for the cluster enter Creating phase") Eventually(testapps.GetClusterObservedGeneration(&testCtx, clusterKey)).Should(BeEquivalentTo(1)) @@ -304,7 +289,7 @@ var _ = Describe("Cluster Controller", func() { createClusterObjWithTopology := func(topology, compName string, processor func(*testapps.MockClusterFactory)) { By("Creating a cluster with new component definition") setTopology := func(f *testapps.MockClusterFactory) { f.SetTopology(topology) } - createClusterObjNoWait(clusterDefObj.Name, "", componentProcessorWrapper(false, compName, "", setTopology, processor)) + createClusterObjNoWait(clusterDefObj.Name, componentProcessorWrapper(false, compName, "", setTopology, processor)) By("Waiting for the cluster enter Creating phase") Eventually(testapps.GetClusterObservedGeneration(&testCtx, clusterKey)).Should(BeEquivalentTo(1)) @@ -320,7 +305,7 @@ var _ = Describe("Cluster Controller", func() { createLegacyClusterObj := func(compName, compDefName string, processor func(*testapps.MockClusterFactory)) { By("Creating a cluster") - createClusterObjNoWait(clusterDefObj.Name, clusterVersionObj.Name, componentProcessorWrapper(true, compName, compDefName, processor)) + createClusterObjNoWait(clusterDefObj.Name, componentProcessorWrapper(true, compName, compDefName, processor)) By("Waiting for the cluster enter Creating phase") Eventually(testapps.GetClusterObservedGeneration(&testCtx, clusterKey)).Should(BeEquivalentTo(1)) @@ -336,7 +321,7 @@ var _ = Describe("Cluster Controller", func() { createClusterObjWithSharding := func(compTplName, compDefName string, processor func(*testapps.MockClusterFactory)) { By("Creating a cluster with new component definition") - createClusterObjNoWait("", "", shardingComponentProcessorWrapper(false, compTplName, compDefName, processor)) + createClusterObjNoWait("", shardingComponentProcessorWrapper(false, compTplName, compDefName, processor)) By("Waiting for the cluster enter Creating phase") Eventually(testapps.GetClusterObservedGeneration(&testCtx, clusterKey)).Should(BeEquivalentTo(1)) @@ -366,8 +351,7 @@ var _ = Describe("Cluster Controller", func() { createLegacyClusterObjWithSharding := func(compTplName, compDefName string, processor func(*testapps.MockClusterFactory)) { By("Creating a cluster") - createClusterObjNoWait(clusterDefObj.Name, clusterVersionObj.Name, - shardingComponentProcessorWrapper(true, compTplName, compDefName, processor)) + createClusterObjNoWait(clusterDefObj.Name, shardingComponentProcessorWrapper(true, compTplName, compDefName, processor)) By("Waiting for the cluster enter Creating phase") Eventually(testapps.GetClusterObservedGeneration(&testCtx, clusterKey)).Should(BeEquivalentTo(1)) @@ -384,7 +368,7 @@ var _ = Describe("Cluster Controller", func() { createClusterObjWithMultipleTemplates := func(compName, compDefName string, processor func(*testapps.MockClusterFactory)) { By("Creating a cluster with new component definition") - createClusterObjNoWait("", "", multipleTemplateComponentProcessorWrapper(compName, compDefName, processor)) + createClusterObjNoWait("", multipleTemplateComponentProcessorWrapper(compName, compDefName, processor)) By("Waiting for the cluster enter Creating phase") Eventually(testapps.GetClusterObservedGeneration(&testCtx, clusterKey)).Should(BeEquivalentTo(1)) @@ -408,9 +392,8 @@ var _ = Describe("Cluster Controller", func() { })).Should(Succeed()) } - testClusterWithoutClusterVersion := func(compName, compDefName string) { - By("creating a cluster w/o cluster version") - clusterObj = testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, clusterDefObj.Name, ""). + testCluster := func(compName, compDefName string) { + clusterObj = testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, clusterDefObj.Name). AddComponent(consensusCompName, consensusCompDefName).SetReplicas(3). WithRandomName(). Create(&testCtx). @@ -484,7 +467,7 @@ var _ = Describe("Cluster Controller", func() { testClusterComponentScaleIn := func(compName, compDefName string) { By("creating and checking a cluster with multi component") - clusterObj = testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, clusterDefObj.Name, ""). + clusterObj = testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, clusterDefObj.Name). AddComponent(compName, compDefName).SetReplicas(3). AddComponent(multiConsensusCompName, compDefName).SetReplicas(3). WithRandomName(). @@ -1096,8 +1079,8 @@ var _ = Describe("Cluster Controller", func() { cleanEnv() }) - It("create cluster w/o cluster version", func() { - testClusterWithoutClusterVersion(consensusCompName, consensusCompDefName) + It("create cluster", func() { + testCluster(consensusCompName, consensusCompDefName) }) It("create cluster with legacy component", func() { @@ -1219,8 +1202,7 @@ var _ = Describe("Cluster Controller", func() { It("test cluster conditions when cluster definition non-exist", func() { By("create a cluster with cluster definition non-exist") mockCompDefName := fmt.Sprintf("%s-%s", consensusCompDefName, testCtx.GetRandomStr()) - createClusterObjNoWait(clusterDefObj.Name, clusterVersionObj.Name, - componentProcessorWrapper(true, consensusCompName, mockCompDefName)) + createClusterObjNoWait(clusterDefObj.Name, componentProcessorWrapper(true, consensusCompName, mockCompDefName)) By("check conditions") Eventually(testapps.CheckObj(&testCtx, clusterKey, func(g Gomega, cluster *appsv1alpha1.Cluster) { @@ -1230,53 +1212,6 @@ var _ = Describe("Cluster Controller", func() { g.Expect(condition.Reason).Should(BeEquivalentTo(ReasonPreCheckFailed)) })).Should(Succeed()) }) - - It("test cluster conditions when cluster version unavailable", func() { - By("mock cluster version unavailable") - mockCompDefName := "random-comp-def" - clusterVersionKey := client.ObjectKeyFromObject(clusterVersionObj) - Expect(testapps.GetAndChangeObj(&testCtx, clusterVersionKey, func(clusterVersion *appsv1alpha1.ClusterVersion) { - for i, comp := range clusterVersion.Spec.ComponentVersions { - if comp.ComponentDefRef == consensusCompDefName { - clusterVersion.Spec.ComponentVersions[i].ComponentDefRef = mockCompDefName - break - } - } - })()).ShouldNot(HaveOccurred()) - Eventually(testapps.CheckObj(&testCtx, clusterVersionKey, func(g Gomega, clusterVersion *appsv1alpha1.ClusterVersion) { - g.Expect(clusterVersion.Status.Phase).Should(Equal(appsv1alpha1.UnavailablePhase)) - })).Should(Succeed()) - - By("create a cluster with the unavailable cluster version") - createClusterObjNoWait(clusterDefObj.Name, clusterVersionObj.Name, - componentProcessorWrapper(true, consensusCompName, consensusCompDefName)) - - By("expect the cluster provisioning condition as pre-check failed") - Eventually(testapps.CheckObj(&testCtx, clusterKey, func(g Gomega, cluster *appsv1alpha1.Cluster) { - g.Expect(cluster.Status.ObservedGeneration).Should(BeZero()) - condition := meta.FindStatusCondition(cluster.Status.Conditions, appsv1alpha1.ConditionTypeProvisioningStarted) - g.Expect(condition).ShouldNot(BeNil()) - g.Expect(condition.Reason).Should(BeEquivalentTo(ReasonPreCheckFailed)) - })).Should(Succeed()) - - By("reset cluster version to Available") - Expect(testapps.GetAndChangeObj(&testCtx, clusterVersionKey, func(clusterVersion *appsv1alpha1.ClusterVersion) { - for i, comp := range clusterVersion.Spec.ComponentVersions { - if comp.ComponentDefRef == mockCompDefName { - clusterVersion.Spec.ComponentVersions[i].ComponentDefRef = consensusCompDefName - break - } - } - })()).ShouldNot(HaveOccurred()) - Eventually(testapps.CheckObj(&testCtx, clusterVersionKey, func(g Gomega, clusterVersion *appsv1alpha1.ClusterVersion) { - g.Expect(clusterVersion.Status.Phase).Should(Equal(appsv1alpha1.AvailablePhase)) - })).Should(Succeed()) - - By("expect the cluster phase transit to Creating") - Eventually(testapps.CheckObj(&testCtx, clusterKey, func(g Gomega, cluster *appsv1alpha1.Cluster) { - g.Expect(cluster.Status.Phase).Should(Equal(appsv1alpha1.CreatingClusterPhase)) - })).Should(Succeed()) - }) }) Context("cluster with backup", func() { @@ -1294,8 +1229,7 @@ var _ = Describe("Cluster Controller", func() { createClusterWithBackup := func(backup *appsv1alpha1.ClusterBackup) { By("Creating a cluster") - clusterObj := testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, - clusterDefObj.Name, clusterVersionObj.Name). + clusterObj := testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, clusterDefObj.Name). AddComponent(compName, compDefName).WithRandomName().SetBackup(backup). Create(&testCtx).GetObject() clusterKey = client.ObjectKeyFromObject(clusterObj) @@ -1404,17 +1338,6 @@ var _ = Describe("Cluster Controller", func() { g.Expect(*policy.Spec.BackupRepoName).Should(BeEquivalentTo(backup.RepoName)) } g.Expect(policy.Spec.BackupMethods).ShouldNot(BeEmpty()) - // expect for image tag env in backupMethod - var existImageTagEnv bool - for _, v := range policy.Spec.BackupMethods { - for _, e := range v.Env { - if e.Name == testapps.EnvKeyImageTag && e.Value == testapps.DefaultImageTag { - existImageTagEnv = true - break - } - } - } - g.Expect(existImageTagEnv).Should(BeTrue()) } By("checking backup policy") @@ -1561,7 +1484,7 @@ var _ = Describe("Cluster Controller", func() { }) }) -func createBackupPolicyTpl(clusterDefObj *appsv1alpha1.ClusterDefinition, compDef string, mappingClusterVersions ...string) { +func createBackupPolicyTpl(clusterDefObj *appsv1alpha1.ClusterDefinition, compDef string) { By("create actionSet") fakeActionSet(clusterDefObj.Name) @@ -1573,7 +1496,7 @@ func createBackupPolicyTpl(clusterDefObj *appsv1alpha1.ClusterDefinition, compDe ttl := "7d" for _, v := range clusterDefObj.Spec.ComponentDefs { bpt = bpt.AddBackupPolicy(v.Name). - AddBackupMethod(backupMethodName, false, actionSetName, mappingClusterVersions...). + AddBackupMethod(backupMethodName, false, actionSetName). SetComponentDef(compDef). SetBackupMethodVolumeMounts("data", "/data"). AddBackupMethod(vsBackupMethodName, true, ""). diff --git a/controllers/apps/cluster_plan_builder.go b/controllers/apps/cluster_plan_builder.go index 55398eba871..898743ee14a 100644 --- a/controllers/apps/cluster_plan_builder.go +++ b/controllers/apps/cluster_plan_builder.go @@ -64,7 +64,6 @@ type clusterTransformContext struct { Cluster *appsv1alpha1.Cluster OrigCluster *appsv1alpha1.Cluster ClusterDef *appsv1alpha1.ClusterDefinition - ClusterVer *appsv1alpha1.ClusterVersion ComponentDefs map[string]*appsv1alpha1.ComponentDefinition // ComponentSpecs includes all cluster component specs generated from ComponentSpecs and ShardingSpecs ComponentSpecs []*appsv1alpha1.ClusterComponentSpec diff --git a/controllers/apps/cluster_plan_builder_test.go b/controllers/apps/cluster_plan_builder_test.go index bd1444664c5..6699ff5875e 100644 --- a/controllers/apps/cluster_plan_builder_test.go +++ b/controllers/apps/cluster_plan_builder_test.go @@ -35,9 +35,8 @@ import ( var _ = Describe("cluster plan builder test", func() { const ( - clusterDefName = "test-clusterdef" - clusterVersionName = "test-clusterversion" - clusterName = "test-cluster" // this become cluster prefix name if used with testapps.NewClusterFactory().WithRandomName() + clusterDefName = "test-clusterdef" + clusterName = "test-cluster" // this become cluster prefix name if used with testapps.NewClusterFactory().WithRandomName() ) // Cleanups @@ -48,7 +47,7 @@ var _ = Describe("cluster plan builder test", func() { // create the new objects. By("clean resources") - // delete cluster(and all dependent sub-resources), clusterversion and clusterdef + // delete cluster(and all dependent sub-resources), cluster definition testapps.ClearClusterResourcesWithRemoveFinalizerOption(&testCtx) // delete rest mocked objects @@ -76,8 +75,9 @@ var _ = Describe("cluster plan builder test", func() { Context("test init", func() { It("should init successfully", func() { - clusterObj := testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, - clusterDefName, clusterVersionName).WithRandomName().GetObject() + clusterObj := testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, clusterDefName). + WithRandomName(). + GetObject() Expect(testCtx.Cli.Create(testCtx.Ctx, clusterObj)).Should(Succeed()) clusterKey := client.ObjectKeyFromObject(clusterObj) Eventually(testapps.CheckObjExists(&testCtx, clusterKey, &appsv1alpha1.Cluster{}, true)).Should(Succeed()) diff --git a/controllers/apps/clusterdefinition_controller.go b/controllers/apps/clusterdefinition_controller.go index 13bbfb067e1..40a3f924501 100644 --- a/controllers/apps/clusterdefinition_controller.go +++ b/controllers/apps/clusterdefinition_controller.go @@ -50,8 +50,6 @@ type ClusterDefinitionReconciler struct { Recorder record.EventRecorder } -var clusterDefUpdateHandlers = map[string]func(client client.Client, ctx context.Context, clusterDef *appsv1alpha1.ClusterDefinition) error{} - // Reconcile is part of the main kubernetes reconciliation loop which aims to // move the current state of the cluster closer to the desired state. // @@ -107,10 +105,10 @@ func (r *ClusterDefinitionReconciler) deletionHandler(rctx intctrlutil.RequestCt return func() (*ctrl.Result, error) { recordEvent := func() { r.Recorder.Event(clusterDef, corev1.EventTypeWarning, "ExistsReferencedResources", - "cannot be deleted because of existing referencing Cluster or ClusterVersion") + "cannot be deleted because of existing referencing Cluster") } if res, err := intctrlutil.ValidateReferenceCR(rctx, r.Client, clusterDef, constant.ClusterDefLabelKey, - recordEvent, &appsv1alpha1.ClusterList{}, &appsv1alpha1.ClusterVersionList{}); res != nil || err != nil { + recordEvent, &appsv1alpha1.ClusterList{}); res != nil || err != nil { return res, err } return nil, r.deleteExternalResources(rctx, clusterDef) @@ -171,13 +169,6 @@ func (r *ClusterDefinitionReconciler) reconcile(rctx intctrlutil.RequestCtx, clu res, err1 := intctrlutil.RequeueAfter(time.Second, rctx.Log, err.Error()) return &res, err1 } - - for _, handler := range clusterDefUpdateHandlers { - if err := handler(r.Client, rctx.Ctx, clusterDef); err != nil { - res, err1 := intctrlutil.CheckedRequeueWithError(err, rctx.Log, "") - return &res, err1 - } - } return nil, nil } diff --git a/controllers/apps/clusterdefinition_controller_test.go b/controllers/apps/clusterdefinition_controller_test.go index 9640f541e3a..454f95aa46c 100644 --- a/controllers/apps/clusterdefinition_controller_test.go +++ b/controllers/apps/clusterdefinition_controller_test.go @@ -41,7 +41,6 @@ import ( var _ = Describe("ClusterDefinition Controller", func() { const ( clusterDefName = "test-clusterdef" - clusterVersionName = "test-clusterversion" compDefinitionName = "test-component-definition" statefulCompDefName = "replicasets" @@ -51,8 +50,7 @@ var _ = Describe("ClusterDefinition Controller", func() { ) var ( - clusterDefObj *appsv1alpha1.ClusterDefinition - clusterVersionObj *appsv1alpha1.ClusterVersion + clusterDefObj *appsv1alpha1.ClusterDefinition ) cleanEnv := func() { @@ -67,7 +65,6 @@ var _ = Describe("ClusterDefinition Controller", func() { // resources should be released in following order // non-namespaced - testapps.ClearResourcesWithRemoveFinalizerOption(&testCtx, intctrlutil.ClusterVersionSignature, true, ml) testapps.ClearResourcesWithRemoveFinalizerOption(&testCtx, intctrlutil.ClusterDefinitionSignature, true, ml) testapps.ClearResourcesWithRemoveFinalizerOption(&testCtx, intctrlutil.ComponentDefinitionSignature, true, ml) testapps.ClearResources(&testCtx, intctrlutil.ConfigConstraintSignature, ml) @@ -98,55 +95,6 @@ var _ = Describe("ClusterDefinition Controller", func() { return cm } - Context("with no ConfigSpec", func() { - BeforeEach(func() { - By("Create a clusterDefinition obj") - clusterDefObj = testapps.NewClusterDefFactory(clusterDefName). - AddComponentDef(testapps.StatefulMySQLComponent, statefulCompDefName). - Create(&testCtx).GetObject() - - By("Create a clusterVersion obj") - clusterVersionObj = testapps.NewClusterVersionFactory(clusterVersionName, clusterDefObj.GetName()). - AddComponentVersion(statefulCompDefName).AddContainerShort("mysql", testapps.ApeCloudMySQLImage). - Create(&testCtx).GetObject() - }) - - It("should update status of clusterVersion at the same time when updating clusterDefinition", func() { - By("Check reconciled finalizer and status of ClusterDefinition") - var cdGen int64 - Eventually(testapps.CheckObj(&testCtx, client.ObjectKeyFromObject(clusterDefObj), - func(g Gomega, cd *appsv1alpha1.ClusterDefinition) { - g.Expect(cd.Finalizers).NotTo(BeEmpty()) - g.Expect(cd.Status.ObservedGeneration).To(BeEquivalentTo(1)) - cdGen = cd.Status.ObservedGeneration - })).Should(Succeed()) - - By("Check reconciled finalizer and status of ClusterVersion") - Eventually(testapps.CheckObj(&testCtx, client.ObjectKeyFromObject(clusterVersionObj), - func(g Gomega, cv *appsv1alpha1.ClusterVersion) { - g.Expect(cv.Finalizers).NotTo(BeEmpty()) - g.Expect(cv.Status.ObservedGeneration).To(BeEquivalentTo(1)) - g.Expect(cv.Status.ClusterDefGeneration).To(Equal(cdGen)) - })).Should(Succeed()) - - By("updating clusterDefinition's spec which then update clusterVersion's status") - Eventually(testapps.GetAndChangeObj(&testCtx, client.ObjectKeyFromObject(clusterDefObj), - func(cd *appsv1alpha1.ClusterDefinition) { - cd.Spec.ConnectionCredential["root"] = "password" - })).Should(Succeed()) - - By("Check ClusterVersion.Status as updated") - Eventually(testapps.CheckObj(&testCtx, client.ObjectKeyFromObject(clusterVersionObj), - func(g Gomega, cv *appsv1alpha1.ClusterVersion) { - g.Expect(cv.Status.Phase).To(Equal(appsv1alpha1.AvailablePhase)) - g.Expect(cv.Status.Message).To(Equal("")) - g.Expect(cv.Status.ClusterDefGeneration > cdGen).To(BeTrue()) - })).Should(Succeed()) - - // TODO: update components to break @validateClusterVersion, and transit ClusterVersion.Status.Phase to UnavailablePhase - }) - }) - Context("with ConfigSpec", func() { BeforeEach(func() { By("Create a clusterDefinition obj") @@ -154,11 +102,6 @@ var _ = Describe("ClusterDefinition Controller", func() { AddComponentDef(testapps.StatefulMySQLComponent, statefulCompDefName). AddConfigTemplate(cmName, cmName, cmName, testCtx.DefaultNamespace, configVolumeName). Create(&testCtx).GetObject() - - By("Create a clusterVersion obj") - clusterVersionObj = testapps.NewClusterVersionFactory(clusterVersionName, clusterDefObj.GetName()). - AddComponentVersion(statefulCompDefName).AddContainerShort("mysql", testapps.ApeCloudMySQLImage). - Create(&testCtx).GetObject() }) It("should stop proceeding the status of clusterDefinition if configmap is invalid or doesn't exist", func() { diff --git a/controllers/apps/clusterversion_controller.go b/controllers/apps/clusterversion_controller.go deleted file mode 100644 index 4513a4c69d8..00000000000 --- a/controllers/apps/clusterversion_controller.go +++ /dev/null @@ -1,229 +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 apps - -import ( - "context" - "fmt" - "strings" - "time" - - "golang.org/x/exp/slices" - corev1 "k8s.io/api/core/v1" - apierrors "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/labels" - k8sruntime "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/types" - "k8s.io/client-go/tools/record" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/log" - - appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1" - appsconfig "github.com/apecloud/kubeblocks/controllers/apps/configuration" - "github.com/apecloud/kubeblocks/pkg/constant" - intctrlutil "github.com/apecloud/kubeblocks/pkg/controllerutil" -) - -// +kubebuilder:rbac:groups=apps.kubeblocks.io,resources=clusterversions,verbs=get;list;watch;create;update;patch;delete -// +kubebuilder:rbac:groups=apps.kubeblocks.io,resources=clusterversions/status,verbs=get;update;patch -// +kubebuilder:rbac:groups=apps.kubeblocks.io,resources=clusterversions/finalizers,verbs=update - -// ClusterVersionReconciler reconciles a ClusterVersion object -type ClusterVersionReconciler struct { - client.Client - Scheme *k8sruntime.Scheme - Recorder record.EventRecorder -} - -func init() { - clusterDefUpdateHandlers["clusterVersion"] = clusterVersionUpdateHandler -} - -// Reconcile is part of the main kubernetes reconciliation loop which aims to -// move the current state of the cluster closer to the desired state. -// -// For more details, check Reconcile and its Result here: -// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.14.4/pkg/reconcile -func (r *ClusterVersionReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { - reqCtx := intctrlutil.RequestCtx{ - Ctx: ctx, - Req: req, - Log: log.FromContext(ctx).WithValues("clusterDefinition", req.NamespacedName), - Recorder: r.Recorder, - } - - clusterVersion := &appsv1alpha1.ClusterVersion{} - if err := r.Client.Get(reqCtx.Ctx, reqCtx.Req.NamespacedName, clusterVersion); err != nil { - return intctrlutil.CheckedRequeueWithError(err, reqCtx.Log, "") - } - - res, err := intctrlutil.HandleCRDeletion(reqCtx, r, clusterVersion, clusterVersionFinalizerName, func() (*ctrl.Result, error) { - recordEvent := func() { - r.Recorder.Event(clusterVersion, corev1.EventTypeWarning, constant.ReasonRefCRUnavailable, - "cannot be deleted because of existing referencing Cluster.") - } - if res, err := intctrlutil.ValidateReferenceCR(reqCtx, r.Client, clusterVersion, - constant.ClusterVerLabelKey, recordEvent, &appsv1alpha1.ClusterList{}); res != nil || err != nil { - return res, err - } - return nil, r.deleteExternalResources(reqCtx, clusterVersion) - }) - if res != nil { - return *res, err - } - - if clusterVersion.Status.ObservedGeneration == clusterVersion.Generation && - slices.Contains(clusterVersion.Status.GetTerminalPhases(), clusterVersion.Status.Phase) { - return intctrlutil.Reconciled() - } - - clusterdefinition := &appsv1alpha1.ClusterDefinition{} - if err := r.Client.Get(reqCtx.Ctx, types.NamespacedName{ - Name: clusterVersion.Spec.ClusterDefinitionRef, - }, clusterdefinition); err != nil { - if apierrors.IsNotFound(err) { - if res, patchErr := r.patchClusterDefLabel(reqCtx, clusterVersion); res != nil { - return *res, patchErr - } - if err = r.handleClusterDefNotFound(reqCtx, clusterVersion, err.Error()); err != nil { - return intctrlutil.RequeueWithErrorAndRecordEvent(clusterVersion, r.Recorder, err, reqCtx.Log) - } - return intctrlutil.Reconciled() - } - return intctrlutil.RequeueWithErrorAndRecordEvent(clusterVersion, r.Recorder, err, reqCtx.Log) - } - - patchStatus := func(phase appsv1alpha1.Phase, message string) error { - patch := client.MergeFrom(clusterVersion.DeepCopy()) - clusterVersion.Status.Phase = phase - clusterVersion.Status.Message = message - clusterVersion.Status.ObservedGeneration = clusterVersion.Generation - clusterVersion.Status.ClusterDefGeneration = clusterdefinition.Generation - return r.Client.Status().Patch(ctx, clusterVersion, patch) - } - - if statusMsg := validateClusterVersion(clusterVersion, clusterdefinition); statusMsg != "" { - if err := patchStatus(appsv1alpha1.UnavailablePhase, statusMsg); err != nil { - return intctrlutil.CheckedRequeueWithError(err, reqCtx.Log, "") - } - return intctrlutil.Reconciled() - } - - if err = appsconfig.ReconcileConfigSpecsForReferencedCR(r.Client, reqCtx, clusterVersion); err != nil { - return intctrlutil.RequeueAfter(time.Second, reqCtx.Log, err.Error()) - } - - if res, err = r.patchClusterDefLabel(reqCtx, clusterVersion); res != nil { - return *res, err - } - - if err = patchStatus(appsv1alpha1.AvailablePhase, ""); err != nil { - return intctrlutil.CheckedRequeueWithError(err, reqCtx.Log, "") - } - intctrlutil.RecordCreatedEvent(r.Recorder, clusterVersion) - return intctrlutil.Reconciled() -} - -// SetupWithManager sets up the controller with the Manager. -func (r *ClusterVersionReconciler) SetupWithManager(mgr ctrl.Manager) error { - return intctrlutil.NewNamespacedControllerManagedBy(mgr). - For(&appsv1alpha1.ClusterVersion{}). - Complete(r) -} - -func (r *ClusterVersionReconciler) patchClusterDefLabel(reqCtx intctrlutil.RequestCtx, - clusterVersion *appsv1alpha1.ClusterVersion) (*ctrl.Result, error) { - if v, ok := clusterVersion.ObjectMeta.Labels[constant.ClusterDefLabelKey]; !ok || v != clusterVersion.Spec.ClusterDefinitionRef { - patch := client.MergeFrom(clusterVersion.DeepCopy()) - if clusterVersion.ObjectMeta.Labels == nil { - clusterVersion.ObjectMeta.Labels = map[string]string{} - } - clusterVersion.ObjectMeta.Labels[constant.ClusterDefLabelKey] = clusterVersion.Spec.ClusterDefinitionRef - if err := r.Client.Patch(reqCtx.Ctx, clusterVersion, patch); err != nil { - return intctrlutil.ResultToP(intctrlutil.CheckedRequeueWithError(err, reqCtx.Log, "")) - } - return intctrlutil.ResultToP(intctrlutil.Reconciled()) - } - return nil, nil -} - -// handleClusterDefNotFound handles clusterVersion status when clusterDefinition not found. -func (r *ClusterVersionReconciler) handleClusterDefNotFound(reqCtx intctrlutil.RequestCtx, - clusterVersion *appsv1alpha1.ClusterVersion, message string) error { - if clusterVersion.Status.Message == message { - return nil - } - patch := client.MergeFrom(clusterVersion.DeepCopy()) - clusterVersion.Status.Phase = appsv1alpha1.UnavailablePhase - clusterVersion.Status.Message = message - return r.Client.Status().Patch(reqCtx.Ctx, clusterVersion, patch) -} - -func validateClusterVersion(clusterVersion *appsv1alpha1.ClusterVersion, clusterDef *appsv1alpha1.ClusterDefinition) string { - notFoundComponentDefNames, noContainersComponents := clusterVersion.GetInconsistentComponentsInfo(clusterDef) - var statusMsgs []string - if len(notFoundComponentDefNames) > 0 { - statusMsgs = append(statusMsgs, fmt.Sprintf("spec.componentSpecs[*].componentDefRef %v not found in ClusterDefinition.spec.componentDefs[*].name", notFoundComponentDefNames)) - } else if len(noContainersComponents) > 0 { - statusMsgs = append(statusMsgs, fmt.Sprintf("spec.componentSpecs[*].componentDefRef %v missing spec.componentSpecs[*].containers in ClusterDefinition.spec.componentDefs[*] and ClusterVersion.spec.componentVersions[*]", noContainersComponents)) - } - return strings.Join(statusMsgs, ";") -} - -func (r *ClusterVersionReconciler) deleteExternalResources(reqCtx intctrlutil.RequestCtx, clusterVersion *appsv1alpha1.ClusterVersion) error { - // - // delete any external resources associated with the cronJob - // - // Ensure that delete implementation is idempotent and safe to invoke - // multiple times for same object. - return appsconfig.DeleteConfigMapFinalizer(r.Client, reqCtx, clusterVersion) -} - -func clusterVersionUpdateHandler(cli client.Client, ctx context.Context, clusterDef *appsv1alpha1.ClusterDefinition) error { - labelSelector, err := labels.Parse(constant.ClusterDefLabelKey + "=" + clusterDef.GetName()) - if err != nil { - return err - } - o := &client.ListOptions{LabelSelector: labelSelector} - - list := &appsv1alpha1.ClusterVersionList{} - if err := cli.List(ctx, list, o); err != nil { - return err - } - for _, item := range list.Items { - if item.Status.ClusterDefGeneration != clusterDef.Generation { - patch := client.MergeFrom(item.DeepCopy()) - if statusMsg := validateClusterVersion(&item, clusterDef); statusMsg != "" { - item.Status.Phase = appsv1alpha1.UnavailablePhase - item.Status.Message = statusMsg - } else { - item.Status.Phase = appsv1alpha1.AvailablePhase - item.Status.Message = "" - item.Status.ClusterDefGeneration = clusterDef.Generation - } - if err = cli.Status().Patch(ctx, &item, patch); err != nil { - return err - } - } - } - - return nil -} diff --git a/controllers/apps/clusterversion_controller_test.go b/controllers/apps/clusterversion_controller_test.go deleted file mode 100644 index bb67ade9396..00000000000 --- a/controllers/apps/clusterversion_controller_test.go +++ /dev/null @@ -1,83 +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 apps - -import ( - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - - "sigs.k8s.io/controller-runtime/pkg/client" - - appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1" - testapps "github.com/apecloud/kubeblocks/pkg/testutil/apps" -) - -var _ = Describe("test clusterVersion controller", func() { - - var ( - randomStr = testCtx.GetRandomStr() - clusterVersionName = "mysql-version-" + randomStr - clusterDefName = "mysql-definition-" + randomStr - ) - - const statefulCompDefName = "stateful" - - cleanEnv := func() { - // must wait till resources deleted and no longer existed before the testcases start, - // otherwise if later it needs to create some new resource objects with the same name, - // in race conditions, it will find the existence of old objects, resulting failure to - // create the new objects. - By("clean resources") - - // delete cluster(and all dependent sub-resources), clusterversion and clusterdef - testapps.ClearClusterResources(&testCtx) - } - BeforeEach(cleanEnv) - - AfterEach(cleanEnv) - - Context("test clusterVersion controller", func() { - It("test clusterVersion controller", func() { - By("create a clusterVersion obj") - clusterVersionObj := testapps.NewClusterVersionFactory(clusterVersionName, clusterDefName). - AddComponentVersion(statefulCompDefName).AddContainerShort("mysql", testapps.ApeCloudMySQLImage). - Create(&testCtx).GetObject() - - By("wait for clusterVersion phase is unavailable when clusterDef is not found") - Eventually(testapps.CheckObj(&testCtx, client.ObjectKeyFromObject(clusterVersionObj), - func(g Gomega, tmpCV *appsv1alpha1.ClusterVersion) { - g.Expect(tmpCV.Status.Phase).Should(Equal(appsv1alpha1.UnavailablePhase)) - })).Should(Succeed()) - - By("create a clusterDefinition obj") - testapps.NewClusterDefFactory(clusterDefName). - AddComponentDef(testapps.StatefulMySQLComponent, statefulCompDefName). - Create(&testCtx).GetObject() - - By("wait for clusterVersion phase is available") - Eventually(testapps.CheckObj(&testCtx, - client.ObjectKeyFromObject(clusterVersionObj), - func(g Gomega, tmpCV *appsv1alpha1.ClusterVersion) { - g.Expect(tmpCV.Status.Phase).Should(Equal(appsv1alpha1.AvailablePhase)) - })).Should(Succeed()) - }) - }) - -}) diff --git a/controllers/apps/component_controller_test.go b/controllers/apps/component_controller_test.go index dba8ba3f7f9..1beeb8fc318 100644 --- a/controllers/apps/component_controller_test.go +++ b/controllers/apps/component_controller_test.go @@ -129,13 +129,12 @@ var mockLorryClient4HScale = func(clusterKey types.NamespacedName, compName stri var _ = Describe("Component Controller", func() { const ( - clusterDefName = "test-clusterdef" - clusterVersionName = "test-clusterversion" - compDefName = "test-compdef" - compVerName = "test-compver" - clusterName = "test-cluster" // this become cluster prefix name if used with testapps.NewClusterFactory().WithRandomName() - leader = "leader" - follower = "follower" + clusterDefName = "test-clusterdef" + compDefName = "test-compdef" + compVerName = "test-compver" + clusterName = "test-cluster" // this become cluster prefix name if used with testapps.NewClusterFactory().WithRandomName() + leader = "leader" + follower = "follower" // REVIEW: // - setup componentName and componentDefName as map entry pair statefulCompName = "stateful" @@ -148,15 +147,14 @@ var _ = Describe("Component Controller", func() { ) var ( - clusterDefObj *appsv1alpha1.ClusterDefinition - clusterVersionObj *appsv1alpha1.ClusterVersion - compDefObj *appsv1alpha1.ComponentDefinition - compVerObj *appsv1alpha1.ComponentVersion - clusterObj *appsv1alpha1.Cluster - clusterKey types.NamespacedName - compObj *appsv1alpha1.Component - compKey types.NamespacedName - allSettings map[string]interface{} + clusterDefObj *appsv1alpha1.ClusterDefinition + compDefObj *appsv1alpha1.ComponentDefinition + compVerObj *appsv1alpha1.ComponentVersion + clusterObj *appsv1alpha1.Cluster + clusterKey types.NamespacedName + compObj *appsv1alpha1.Component + compKey types.NamespacedName + allSettings map[string]interface{} ) resetViperCfg := func() { @@ -168,7 +166,6 @@ var _ = Describe("Component Controller", func() { resetTestContext := func() { clusterDefObj = nil - clusterVersionObj = nil clusterObj = nil resetViperCfg() } @@ -181,7 +178,7 @@ var _ = Describe("Component Controller", func() { // create the new objects. By("clean resources") - // delete cluster(and all dependent sub-resources), clusterversion and clusterdef + // delete cluster(and all dependent sub-resources), cluster definition testapps.ClearClusterResourcesWithRemoveFinalizerOption(&testCtx) // delete rest mocked objects @@ -216,7 +213,7 @@ var _ = Describe("Component Controller", func() { } // test function helpers - createAllWorkloadTypesClusterDef := func(noCreateAssociateCV ...bool) { + createAllWorkloadTypesClusterDef := func() { By("Create a clusterDefinition obj") clusterDefObj = testapps.NewClusterDefFactory(clusterDefName). AddComponentDef(testapps.StatefulMySQLComponent, statefulCompDefName). @@ -224,16 +221,6 @@ var _ = Describe("Component Controller", func() { AddComponentDef(testapps.ReplicationRedisComponent, replicationCompDefName). Create(&testCtx).GetObject() - if len(noCreateAssociateCV) > 0 && noCreateAssociateCV[0] { - return - } - By("Create a clusterVersion obj") - clusterVersionObj = testapps.NewClusterVersionFactory(clusterVersionName, clusterDefObj.GetName()). - AddComponentVersion(statefulCompDefName).AddContainerShort("mysql", testapps.ApeCloudMySQLImage). - AddComponentVersion(consensusCompDefName).AddContainerShort("mysql", testapps.ApeCloudMySQLImage). - AddComponentVersion(replicationCompDefName).AddContainerShort("mysql", testapps.ApeCloudMySQLImage). - Create(&testCtx).GetObject() - By("Create a componentDefinition obj") compDefObj = testapps.NewComponentDefinitionFactory(compDefName). WithRandomName(). @@ -267,9 +254,9 @@ var _ = Describe("Component Controller", func() { } } - createClusterObjVx := func(clusterDefName, clusterVerName, compName, compDefName string, v2 bool, + createClusterObjVx := func(clusterDefName, compName, compDefName string, v2 bool, processor func(*testapps.MockClusterFactory), phase *appsv1alpha1.ClusterPhase) { - factory := testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, clusterDefName, clusterVerName). + factory := testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, clusterDefName). WithRandomName() if !v2 { factory.AddComponent(compName, compDefName).SetReplicas(1) @@ -305,17 +292,17 @@ var _ = Describe("Component Controller", func() { createClusterObj := func(compName, compDefName string, processor func(*testapps.MockClusterFactory)) { By("Creating a cluster") - createClusterObjVx(clusterDefObj.Name, clusterVersionObj.Name, compName, compDefName, false, processor, nil) + createClusterObjVx(clusterDefObj.Name, compName, compDefName, false, processor, nil) } createClusterObjV2 := func(compName, compDefName string, processor func(*testapps.MockClusterFactory)) { By("Creating a cluster with new component definition") - createClusterObjVx("", "", compName, compDefName, true, processor, nil) + createClusterObjVx("", compName, compDefName, true, processor, nil) } createClusterObjV2WithPhase := func(compName, compDefName string, processor func(*testapps.MockClusterFactory), phase appsv1alpha1.ClusterPhase) { By("Creating a cluster with new component definition") - createClusterObjVx("", "", compName, compDefName, true, processor, &phase) + createClusterObjVx("", compName, compDefName, true, processor, &phase) } mockCompRunning := func(compName string) { @@ -1747,8 +1734,8 @@ var _ = Describe("Component Controller", func() { testReplicationWorkloadRunning := func(compName, compDefName string) { By("Mock a cluster obj with replication componentDefRef.") pvcSpec := testapps.NewPVCSpec("1Gi") - clusterObj = testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, - clusterDefObj.Name, clusterVersionObj.Name).WithRandomName(). + clusterObj = testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, clusterDefObj.Name). + WithRandomName(). AddComponent(compName, compDefName). SetReplicas(testapps.DefaultReplicationReplicas). AddVolumeClaimTemplate(testapps.DataVolumeName, pvcSpec). @@ -1773,8 +1760,8 @@ var _ = Describe("Component Controller", func() { By("Mock a cluster obj") pvcSpec := testapps.NewPVCSpec("1Gi") - clusterObj = testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, - clusterDefObj.Name, clusterVersionObj.Name).WithRandomName(). + clusterObj = testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, clusterDefObj.Name). + WithRandomName(). AddComponent(compName, compDefName). SetReplicas(replicas).AddVolumeClaimTemplate(testapps.DataVolumeName, pvcSpec). Create(&testCtx).GetObject() @@ -1896,7 +1883,7 @@ var _ = Describe("Component Controller", func() { restoreFromBackup := fmt.Sprintf(`{"%s":{"name":"%s"}}`, compName, backupName) pvcSpec := testapps.NewPVCSpec("1Gi") replicas := 3 - clusterObj = testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, clusterDefObj.Name, clusterVersionObj.Name). + clusterObj = testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, clusterDefObj.Name). WithRandomName(). AddComponent(compName, compDefName). SetReplicas(int32(replicas)). @@ -2241,8 +2228,7 @@ var _ = Describe("Component Controller", func() { Expect(components).ShouldNot(BeEmpty()) By("Creating a cluster") - clusterBuilder := testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, - clusterDefObj.Name, clusterVersionObj.Name) + clusterBuilder := testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, clusterDefObj.Name) compNames := make([]string, 0, len(components)) for compName, compDefName := range components { diff --git a/controllers/apps/component_plan_builder_test.go b/controllers/apps/component_plan_builder_test.go index f20d418287e..bf6539ba7ea 100644 --- a/controllers/apps/component_plan_builder_test.go +++ b/controllers/apps/component_plan_builder_test.go @@ -47,7 +47,7 @@ var _ = Describe("component plan builder test", func() { // create the new objects. By("clean resources") - // delete cluster(and all dependent sub-resources), clusterversion and clusterdef + // delete cluster(and all dependent sub-resources), cluster definition testapps.ClearClusterResourcesWithRemoveFinalizerOption(&testCtx) // delete rest mocked objects diff --git a/controllers/apps/component_utils_test.go b/controllers/apps/component_utils_test.go index c4265608f38..76d1c031b79 100644 --- a/controllers/apps/component_utils_test.go +++ b/controllers/apps/component_utils_test.go @@ -39,10 +39,9 @@ import ( var _ = Describe("Component Utils", func() { var ( - randomStr = testCtx.GetRandomStr() - clusterDefName = "mysql-clusterdef-" + randomStr - clusterVersionName = "mysql-clusterversion-" + randomStr - clusterName = "mysql-" + randomStr + randomStr = testCtx.GetRandomStr() + clusterDefName = "mysql-clusterdef-" + randomStr + clusterName = "mysql-" + randomStr ) const ( @@ -56,7 +55,7 @@ var _ = Describe("Component Utils", func() { // in race conditions, it will find the existence of old objects, resulting failure to // create the new objects. By("clean resources") - // delete cluster(and all dependent sub-resources), clusterversion and clusterdef + // delete cluster(and all dependent sub-resources), cluster definition testapps.ClearClusterResourcesWithRemoveFinalizerOption(&testCtx) // clear rest resources @@ -74,8 +73,8 @@ var _ = Describe("Component Utils", func() { Context("Component test", func() { It("Component test", func() { By(" init cluster, instanceSet, pods") - _, _, cluster := testapps.InitClusterWithHybridComps(&testCtx, clusterDefName, - clusterVersionName, clusterName, statelessCompName, "stateful", consensusCompName) + _, cluster := testapps.InitClusterWithHybridComps(&testCtx, clusterDefName, + clusterName, statelessCompName, "stateful", consensusCompName) its := testapps.MockInstanceSetComponent(&testCtx, clusterName, consensusCompName) _ = testapps.MockInstanceSetPods(&testCtx, its, cluster, consensusCompName) diff --git a/controllers/apps/configuration/config_util.go b/controllers/apps/configuration/config_util.go index 09c5f1dfc31..5361f0f9115 100644 --- a/controllers/apps/configuration/config_util.go +++ b/controllers/apps/configuration/config_util.go @@ -160,7 +160,7 @@ func batchDeleteConfigMapFinalizer(cli client.Client, ctx intctrlutil.RequestCtx labels := client.MatchingLabels{ core.GenerateTPLUniqLabelKeyWithConfig(configSpec.Name): configSpec.TemplateRef, } - if ok, err := validateConfigMapOwners(cli, ctx, labels, validator, &appsv1alpha1.ClusterVersionList{}, &appsv1alpha1.ClusterDefinitionList{}, &appsv1alpha1.ComponentDefinitionList{}); err != nil { + if ok, err := validateConfigMapOwners(cli, ctx, labels, validator, &appsv1alpha1.ClusterDefinitionList{}, &appsv1alpha1.ComponentDefinitionList{}); err != nil { return err } else if !ok { continue @@ -244,8 +244,6 @@ func handleConfigTemplate(object client.Object, handler ConfigTemplateHandler, h switch cr := object.(type) { case *appsv1alpha1.ClusterDefinition: configTemplates, err = getConfigTemplateFromCD(cr, handler2...) - case *appsv1alpha1.ClusterVersion: - configTemplates = getConfigTemplateFromCV(cr) case *appsv1alpha1.ComponentDefinition: configTemplates = getConfigTemplateFromComponentDef(cr) default: @@ -262,16 +260,6 @@ func handleConfigTemplate(object client.Object, handler ConfigTemplateHandler, h } } -func getConfigTemplateFromCV(appVer *appsv1alpha1.ClusterVersion) []appsv1alpha1.ComponentConfigSpec { - configTemplates := make([]appsv1alpha1.ComponentConfigSpec, 0) - for _, component := range appVer.Spec.ComponentVersions { - if len(component.ConfigSpecs) > 0 { - configTemplates = append(configTemplates, component.ConfigSpecs...) - } - } - return configTemplates -} - func getConfigTemplateFromCD(clusterDef *appsv1alpha1.ClusterDefinition, validators ...ComponentValidateHandler) ([]appsv1alpha1.ComponentConfigSpec, error) { configTemplates := make([]appsv1alpha1.ComponentConfigSpec, 0) for _, component := range clusterDef.Spec.ComponentDefs { diff --git a/controllers/apps/configuration/config_util_test.go b/controllers/apps/configuration/config_util_test.go index ecafcfe7883..fb6da10d08c 100644 --- a/controllers/apps/configuration/config_util_test.go +++ b/controllers/apps/configuration/config_util_test.go @@ -38,7 +38,6 @@ import ( var _ = Describe("ConfigWrapper util test", func() { const clusterDefName = "test-clusterdef" - const clusterVersionName = "test-clusterversion" const statefulCompDefName = "replicasets" const configSpecName = "mysql-config-tpl" const configVolumeName = "mysql-config" @@ -58,7 +57,6 @@ var _ = Describe("ConfigWrapper util test", func() { configMapObj *corev1.ConfigMap configConstraintObj *appsv1beta1.ConfigConstraint clusterDefObj *appsv1alpha1.ClusterDefinition - clusterVersionObj *appsv1alpha1.ClusterVersion ) cleanEnv := func() { @@ -74,7 +72,6 @@ var _ = Describe("ConfigWrapper util test", func() { // namespaced testapps.ClearResources(&testCtx, generics.ConfigMapSignature, inNS, ml) // non-namespaced - testapps.ClearResources(&testCtx, generics.ClusterVersionSignature, ml) testapps.ClearResources(&testCtx, generics.ClusterDefinitionSignature, ml) testapps.ClearResources(&testCtx, generics.ConfigConstraintSignature, ml) } @@ -99,11 +96,6 @@ var _ = Describe("ConfigWrapper util test", func() { AddComponentDef(testapps.StatefulMySQLComponent, statefulCompDefName). AddConfigTemplate(configSpecName, configMapObj.Name, configConstraintObj.Name, testCtx.DefaultNamespace, configVolumeName). Create(&testCtx).GetObject() - - By("Create a clusterVersion obj") - clusterVersionObj = testapps.NewClusterVersionFactory(clusterVersionName, clusterDefObj.GetName()). - AddComponentVersion(statefulCompDefName). - Create(&testCtx).GetObject() }) AfterEach(func() { @@ -210,79 +202,4 @@ var _ = Describe("ConfigWrapper util test", func() { Expect(ok).Should(BeTrue()) }) }) - - updateAVTemplates := func() { - var tpls []appsv1alpha1.ComponentConfigSpec - _, err := handleConfigTemplate(clusterDefObj, func(templates []appsv1alpha1.ComponentConfigSpec) (bool, error) { - tpls = templates - return true, nil - }) - Expect(err).Should(Succeed()) - - if len(clusterVersionObj.Spec.ComponentVersions) == 0 { - return - } - - // mock clusterVersionObj config templates - clusterVersionObj.Spec.ComponentVersions[0].ConfigSpecs = tpls - } - - Context("clusterversion CR test", func() { - It("Should success without error", func() { - updateAVTemplates() - availableTPL := configConstraintObj.DeepCopy() - availableTPL.Status.Phase = appsv1beta1.CCAvailablePhase - - k8sMockClient.MockPatchMethod(testutil.WithSucceed()) - k8sMockClient.MockListMethod(testutil.WithSucceed()) - k8sMockClient.MockGetMethod(testutil.WithGetReturned(testutil.WithConstructSequenceResult( - map[client.ObjectKey][]testutil.MockGetReturned{ - client.ObjectKeyFromObject(configMapObj): {{ - Object: nil, - Err: cfgcore.MakeError("failed to get cc object"), - }, { - Object: configMapObj, - Err: nil, - }}, - client.ObjectKeyFromObject(configConstraintObj): {{ - Object: nil, - Err: cfgcore.MakeError("failed to get cc object"), - }, { - Object: configConstraintObj, - Err: nil, - }, { - Object: availableTPL, - Err: nil, - }}, - }, - ), testutil.WithAnyTimes())) - - _, err := checkConfigTemplate(k8sMockClient.Client(), reqCtx, clusterVersionObj) - Expect(err).ShouldNot(Succeed()) - Expect(err.Error()).Should(ContainSubstring("failed to get cc object")) - - _, err = checkConfigTemplate(k8sMockClient.Client(), reqCtx, clusterVersionObj) - Expect(err).ShouldNot(Succeed()) - Expect(err.Error()).Should(ContainSubstring("failed to get cc object")) - - _, err = checkConfigTemplate(k8sMockClient.Client(), reqCtx, clusterVersionObj) - Expect(err).ShouldNot(Succeed()) - Expect(err.Error()).Should(ContainSubstring("status not ready")) - - ok, err := checkConfigTemplate(k8sMockClient.Client(), reqCtx, clusterVersionObj) - Expect(err).Should(Succeed()) - Expect(ok).Should(BeTrue()) - - ok, err = updateLabelsByConfigSpec(k8sMockClient.Client(), reqCtx, clusterVersionObj) - Expect(err).Should(Succeed()) - Expect(ok).Should(BeTrue()) - - _, err = updateLabelsByConfigSpec(k8sMockClient.Client(), reqCtx, clusterVersionObj) - Expect(err).Should(Succeed()) - - err = DeleteConfigMapFinalizer(k8sMockClient.Client(), reqCtx, clusterVersionObj) - Expect(err).Should(Succeed()) - }) - }) - }) diff --git a/controllers/apps/configuration/configconstraint_controller.go b/controllers/apps/configuration/configconstraint_controller.go index 43704d40134..cd6f0a45d1e 100644 --- a/controllers/apps/configuration/configconstraint_controller.go +++ b/controllers/apps/configuration/configconstraint_controller.go @@ -73,7 +73,7 @@ func (r *ConfigConstraintReconciler) Reconcile(ctx context.Context, req ctrl.Req res, err := intctrlutil.HandleCRDeletion(reqCtx, r, configConstraint, constant.ConfigFinalizerName, func() (*ctrl.Result, error) { recordEvent := func() { r.Recorder.Event(configConstraint, corev1.EventTypeWarning, "ExistsReferencedResources", - "cannot be deleted because of existing referencing of ClusterDefinition or ClusterVersion.") + "cannot be deleted because of existing referencing of ClusterDefinition.") } if configConstraint.Status.Phase != appsv1beta1.CCDeletingPhase { err := updateConfigConstraintStatus(r.Client, reqCtx, configConstraint, appsv1beta1.CCDeletingPhase) @@ -85,8 +85,7 @@ func (r *ConfigConstraintReconciler) Reconcile(ctx context.Context, req ctrl.Req } if res, err := intctrlutil.ValidateReferenceCR(reqCtx, r.Client, configConstraint, cfgcore.GenerateConstraintsUniqLabelKeyWithConfig(configConstraint.GetName()), - recordEvent, &appsv1alpha1.ClusterDefinitionList{}, - &appsv1alpha1.ClusterVersionList{}); res != nil || err != nil { + recordEvent, &appsv1alpha1.ClusterDefinitionList{}); res != nil || err != nil { return res, err } return nil, nil diff --git a/controllers/apps/configuration/configconstraint_controller_test.go b/controllers/apps/configuration/configconstraint_controller_test.go index 8082e55a7aa..0d6881f5a3a 100644 --- a/controllers/apps/configuration/configconstraint_controller_test.go +++ b/controllers/apps/configuration/configconstraint_controller_test.go @@ -39,7 +39,6 @@ import ( var _ = Describe("ConfigConstraint Controller", func() { const clusterDefName = "test-clusterdef" - const clusterVersionName = "test-clusterversion" const statefulCompDefName = "replicasets" const configSpecName = "mysql-config-tpl" const configVolumeName = "mysql-config" @@ -51,7 +50,7 @@ var _ = Describe("ConfigConstraint Controller", func() { // create the new objects. By("clean resources") - // delete cluster(and all dependent sub-resources), clusterversion and clusterdef + // delete cluster(and all dependent sub-resources), cluster definition testapps.ClearClusterResources(&testCtx) // delete rest mocked objects @@ -88,13 +87,6 @@ var _ = Describe("ConfigConstraint Controller", func() { cfgcore.GenerateConstraintsUniqLabelKeyWithConfig(constraint.Name), constraint.Name). Create(&testCtx).GetObject() - By("Create a clusterVersion obj") - clusterVersionObj := testapps.NewClusterVersionFactory(clusterVersionName, clusterDefObj.GetName()). - AddComponentVersion(statefulCompDefName). - AddLabels(cfgcore.GenerateTPLUniqLabelKeyWithConfig(configSpecName), configmap.Name, - cfgcore.GenerateConstraintsUniqLabelKeyWithConfig(constraint.Name), constraint.Name). - Create(&testCtx).GetObject() - By("check ConfigConstraint(template) status and finalizer") Eventually(testapps.CheckObj(&testCtx, constraintKey, func(g Gomega, tpl *appsv1beta1.ConfigConstraint) { @@ -115,8 +107,7 @@ var _ = Describe("ConfigConstraint Controller", func() { g.Expect(tpl.Status.Phase).To(BeEquivalentTo(appsv1beta1.CCDeletingPhase)) })).Should(Succeed()) - By("By delete referencing clusterdefinition and clusterversion") - Expect(k8sClient.Delete(testCtx.Ctx, clusterVersionObj)).Should(Succeed()) + By("By delete referencing clusterdefinition") Expect(k8sClient.Delete(testCtx.Ctx, clusterDefObj)).Should(Succeed()) By("check ConfigConstraint should be deleted") diff --git a/controllers/apps/configuration/configuration_test.go b/controllers/apps/configuration/configuration_test.go index eea0170a3ee..ee2ce05709a 100644 --- a/controllers/apps/configuration/configuration_test.go +++ b/controllers/apps/configuration/configuration_test.go @@ -43,7 +43,6 @@ import ( ) const clusterDefName = "test-clusterdef" -const clusterVersionName = "test-clusterversion" const clusterName = "test-cluster" const statefulCompDefName = "replicasets" const statefulCompName = "mysql" @@ -112,16 +111,8 @@ func mockReconcileResource() (*corev1.ConfigMap, *appsv1beta1.ConfigConstraint, core.GenerateConstraintsUniqLabelKeyWithConfig(constraint.Name), constraint.Name). Create(&testCtx).GetObject() - By("Create a clusterVersion obj") - clusterVersionObj := testapps.NewClusterVersionFactory(clusterVersionName, clusterDefObj.GetName()). - AddComponentVersion(statefulCompDefName). - AddLabels(core.GenerateTPLUniqLabelKeyWithConfig(configSpecName), configmap.Name, - core.GenerateConstraintsUniqLabelKeyWithConfig(constraint.Name), constraint.Name). - Create(&testCtx).GetObject() - By("Creating a cluster") - clusterObj := testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, - clusterDefObj.Name, clusterVersionObj.Name). + clusterObj := testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, clusterDefObj.Name). AddComponent(statefulCompName, statefulCompDefName).Create(&testCtx).GetObject() By("Create a component definition obj and mock to available") @@ -191,7 +182,7 @@ func cleanEnv() { // create the new objects. By("clean resources") - // delete cluster(and all dependent sub-resources), clusterversion and clusterdef + // delete cluster(and all dependent sub-resources), cluster definition testapps.ClearClusterResources(&testCtx) // delete rest mocked objects diff --git a/controllers/apps/const.go b/controllers/apps/const.go index ab6c37cb555..b23e75f52ed 100644 --- a/controllers/apps/const.go +++ b/controllers/apps/const.go @@ -22,7 +22,6 @@ package apps const ( // name of our custom finalizer clusterDefinitionFinalizerName = "clusterdefinition.kubeblocks.io/finalizer" - clusterVersionFinalizerName = "clusterversion.kubeblocks.io/finalizer" opsDefinitionFinalizerName = "opsdefinition.kubeblocks.io/finalizer" componentDefinitionFinalizerName = "componentdefinition.kubeblocks.io/finalizer" componentVersionFinalizerName = "componentversion.kubeblocks.io/finalizer" diff --git a/controllers/apps/operations/backup_test.go b/controllers/apps/operations/backup_test.go index ed0134621f6..02326b6378d 100644 --- a/controllers/apps/operations/backup_test.go +++ b/controllers/apps/operations/backup_test.go @@ -36,7 +36,6 @@ var _ = Describe("Backup OpsRequest", func() { var ( randomStr = testCtx.GetRandomStr() clusterDefinitionName = "cluster-definition-for-ops-" + randomStr //nolint:goconst - clusterVersionName = "clusterversion-for-ops-" + randomStr //nolint:goconst clusterName = "cluster-for-ops-" + randomStr //nolint:goconst ) @@ -47,7 +46,7 @@ var _ = Describe("Backup OpsRequest", func() { // create the new objects. By("clean resources") - // delete cluster(and all dependent sub-resources), clusterversion and clusterdef + // delete cluster(and all dependent sub-resources), cluster definition testapps.ClearClusterResources(&testCtx) // delete rest resources @@ -68,7 +67,7 @@ var _ = Describe("Backup OpsRequest", func() { ) BeforeEach(func() { By("init operations resources ") - opsRes, _, _ = initOperationsResources(clusterDefinitionName, clusterVersionName, clusterName) + opsRes, _, _ = initOperationsResources(clusterDefinitionName, clusterName) reqCtx = intctrlutil.RequestCtx{Ctx: testCtx.Ctx} }) diff --git a/controllers/apps/operations/custom_test.go b/controllers/apps/operations/custom_test.go index 37f26325b55..05f11782c3b 100644 --- a/controllers/apps/operations/custom_test.go +++ b/controllers/apps/operations/custom_test.go @@ -38,7 +38,6 @@ var _ = Describe("CustomOps", func() { var ( randomStr = testCtx.GetRandomStr() clusterDefinitionName = "cluster-definition-for-ops-" + randomStr - clusterVersionName = "clusterversion-for-ops-" + randomStr clusterName = "cluster-for-ops-" + randomStr compDefName = "apecloud-mysql" opsResource *OpsResource @@ -55,7 +54,7 @@ var _ = Describe("CustomOps", func() { // create the new objects. By("clean resources") - // delete cluster(and all dependent sub-resources), clusterversion and clusterdef + // delete cluster(and all dependent sub-resources), cluster definition testapps.ClearClusterResources(&testCtx) // delete rest resources @@ -104,7 +103,7 @@ var _ = Describe("CustomOps", func() { Create(&testCtx). GetObject() - cluster = testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, clusterDefinitionName, clusterVersionName). + cluster = testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, clusterDefinitionName). WithRandomName().AddComponentV2(consensusComp, componentDefObj.Name).SetReplicas(1).Create(&testCtx).GetObject() fullCompName := constant.GenerateClusterComponentName(cluster.Name, consensusComp) diff --git a/controllers/apps/operations/datascript_test.go b/controllers/apps/operations/datascript_test.go index 59719ed7097..d9b9452ac8f 100644 --- a/controllers/apps/operations/datascript_test.go +++ b/controllers/apps/operations/datascript_test.go @@ -44,7 +44,6 @@ var _ = Describe("DataScriptOps", func() { var ( randomStr = testCtx.GetRandomStr() clusterDefinitionName = "cluster-definition-for-ops-" + randomStr - clusterVersionName = "clusterversion-for-ops-" + randomStr clusterName = "cluster-for-ops-" + randomStr clusterObj *appsv1alpha1.Cluster @@ -63,7 +62,7 @@ var _ = Describe("DataScriptOps", func() { // create the new objects. By("clean resources") - // delete cluster(and all dependent sub-resources), clusterversion and clusterdef + // delete cluster(and all dependent sub-resources), cluster definition testapps.ClearClusterResources(&testCtx) // delete rest resources @@ -140,8 +139,8 @@ var _ = Describe("DataScriptOps", func() { Context("with Cluster which has MySQL ConsensusSet", func() { BeforeEach(func() { By("mock cluster") - _, _, clusterObj = testapps.InitClusterWithHybridComps(&testCtx, clusterDefinitionName, - clusterVersionName, clusterName, statelessComp, statefulComp, consensusComp) + _, clusterObj = testapps.InitClusterWithHybridComps(&testCtx, clusterDefinitionName, + clusterName, statelessComp, statefulComp, consensusComp) By("init opsResource") opsResource = &OpsResource{ diff --git a/controllers/apps/operations/expose_test.go b/controllers/apps/operations/expose_test.go index bcbeb84ae54..1bec9b64082 100644 --- a/controllers/apps/operations/expose_test.go +++ b/controllers/apps/operations/expose_test.go @@ -38,7 +38,6 @@ var _ = Describe("", func() { var ( randomStr = testCtx.GetRandomStr() clusterDefinitionName = "cluster-definition-for-ops-" + randomStr - clusterVersionName = "clusterversion-for-ops-" + randomStr clusterName = "cluster-for-ops-" + randomStr ) @@ -53,7 +52,7 @@ var _ = Describe("", func() { // create the new objects. By("clean resources") - // delete cluster(and all dependent sub-resources), clusterversion and clusterdef + // delete cluster(and all dependent sub-resources), cluster definition testapps.ClearClusterResources(&testCtx) // delete rest resources @@ -70,7 +69,7 @@ var _ = Describe("", func() { Context("Test OpsRequest", func() { It("Test expose OpsRequest", func() { reqCtx := intctrlutil.RequestCtx{Ctx: testCtx.Ctx} - opsRes, _, clusterObject := initOperationsResources(clusterDefinitionName, clusterVersionName, clusterName) + opsRes, _, clusterObject := initOperationsResources(clusterDefinitionName, clusterName) By("create Expose opsRequest") ops := testapps.NewOpsRequestObj("expose-expose-"+randomStr, testCtx.DefaultNamespace, @@ -108,7 +107,7 @@ var _ = Describe("", func() { It("Test expose OpsRequest with empty ComponentName", func() { reqCtx := intctrlutil.RequestCtx{Ctx: testCtx.Ctx} - opsRes, _, clusterObject := initOperationsResources(clusterDefinitionName, clusterVersionName, clusterName) + opsRes, _, clusterObject := initOperationsResources(clusterDefinitionName, clusterName) By("create Expose opsRequest") ops := testapps.NewOpsRequestObj("expose-expose-"+randomStr, testCtx.DefaultNamespace, diff --git a/controllers/apps/operations/horizontal_scaling_test.go b/controllers/apps/operations/horizontal_scaling_test.go index 57b05ac17d0..1cfe932e67d 100644 --- a/controllers/apps/operations/horizontal_scaling_test.go +++ b/controllers/apps/operations/horizontal_scaling_test.go @@ -25,6 +25,7 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" + corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/sets" @@ -45,7 +46,6 @@ var _ = Describe("HorizontalScaling OpsRequest", func() { var ( randomStr = testCtx.GetRandomStr() clusterDefinitionName = "cluster-definition-for-ops-" + randomStr - clusterVersionName = "clusterversion-for-ops-" + randomStr clusterName = "cluster-for-ops-" + randomStr insTplName = "foo" ) @@ -57,7 +57,7 @@ var _ = Describe("HorizontalScaling OpsRequest", func() { // create the new objects. By("clean resources") - // delete cluster(and all dependent sub-resources), clusterversion and clusterdef + // delete cluster(and all dependent sub-resources), cluster definition testapps.ClearClusterResources(&testCtx) // delete rest resources @@ -85,8 +85,8 @@ var _ = Describe("HorizontalScaling OpsRequest", func() { commonHScaleConsensusCompTest := func(reqCtx intctrlutil.RequestCtx, changeClusterSpec func(cluster *appsv1alpha1.Cluster), horizontalScaling appsv1alpha1.HorizontalScaling) (*OpsResource, []*corev1.Pod) { - By("init operations resources with CLusterDefinition/ClusterVersion/Hybrid components Cluster/consensus Pods") - opsRes, _, _ := initOperationsResources(clusterDefinitionName, clusterVersionName, clusterName) + By("init operations resources with CLusterDefinition/Hybrid components Cluster/consensus Pods") + opsRes, _, _ := initOperationsResources(clusterDefinitionName, clusterName) its := testapps.MockInstanceSetComponent(&testCtx, clusterName, consensusComp) if changeClusterSpec != nil { Expect(testapps.ChangeObj(&testCtx, opsRes.Cluster, func(cluster *appsv1alpha1.Cluster) { @@ -481,8 +481,8 @@ var _ = Describe("HorizontalScaling OpsRequest", func() { } It("test offline the specified pod but it is not online", func() { - By("init operations resources with CLusterDefinition/ClusterVersion/Hybrid components Cluster/consensus Pods") - opsRes, _, _ := initOperationsResources(clusterDefinitionName, clusterVersionName, clusterName) + By("init operations resources with CLusterDefinition/Hybrid components Cluster/consensus Pods") + opsRes, _, _ := initOperationsResources(clusterDefinitionName, clusterName) testapps.MockInstanceSetComponent(&testCtx, clusterName, consensusComp) reqCtx := intctrlutil.RequestCtx{Ctx: ctx} @@ -501,8 +501,8 @@ var _ = Describe("HorizontalScaling OpsRequest", func() { }) It("test run multi horizontalScaling opsRequest with force flag", func() { - By("init operations resources with CLusterDefinition/ClusterVersion/Hybrid components Cluster/consensus Pods") - opsRes, _, _ := initOperationsResources(clusterDefinitionName, clusterVersionName, clusterName) + By("init operations resources with CLusterDefinition/Hybrid components Cluster/consensus Pods") + opsRes, _, _ := initOperationsResources(clusterDefinitionName, clusterName) testapps.MockInstanceSetComponent(&testCtx, clusterName, consensusComp) reqCtx := intctrlutil.RequestCtx{Ctx: ctx} By("create first opsRequest to add 1 replicas with `scaleOut` field and expect replicas to 4") diff --git a/controllers/apps/operations/ops_progress_util_test.go b/controllers/apps/operations/ops_progress_util_test.go index 08a4cf522e4..fb71b78062d 100644 --- a/controllers/apps/operations/ops_progress_util_test.go +++ b/controllers/apps/operations/ops_progress_util_test.go @@ -42,7 +42,6 @@ var _ = Describe("Ops ProgressDetails", func() { var ( randomStr = testCtx.GetRandomStr() clusterDefinitionName = "cluster-definition-for-ops-" + randomStr - clusterVersionName = "clusterversion-for-ops-" + randomStr clusterName = "cluster-for-ops-" + randomStr ) @@ -53,7 +52,7 @@ var _ = Describe("Ops ProgressDetails", func() { // create the new objects. By("clean resources") - // delete cluster(and all dependent sub-resources), clusterversion and clusterdef + // delete cluster(and all dependent sub-resources), cluster definition testapps.ClearClusterResources(&testCtx) // delete rest resources @@ -96,7 +95,7 @@ var _ = Describe("Ops ProgressDetails", func() { It("Test Ops ProgressDetails for rolling update", func() { By("init operations resources ") reqCtx := intctrlutil.RequestCtx{Ctx: testCtx.Ctx} - opsRes, _, _ := initOperationsResources(clusterDefinitionName, clusterVersionName, clusterName) + opsRes, _, _ := initOperationsResources(clusterDefinitionName, clusterName) By("create restart ops and pods of consensus component") opsRes.OpsRequest = createRestartOpsObj(clusterName, "restart-"+randomStr) @@ -115,7 +114,7 @@ var _ = Describe("Ops ProgressDetails", func() { It("Test Ops ProgressDetails with horizontally scaling replicas", func() { By("init operations resources ") reqCtx := intctrlutil.RequestCtx{Ctx: testCtx.Ctx} - opsRes, _, _ := initOperationsResources(clusterDefinitionName, clusterVersionName, clusterName) + opsRes, _, _ := initOperationsResources(clusterDefinitionName, clusterName) its := testapps.MockInstanceSetComponent(&testCtx, clusterName, consensusComp) podList := testapps.MockInstanceSetPods(&testCtx, its, opsRes.Cluster, consensusComp) diff --git a/controllers/apps/operations/ops_util_test.go b/controllers/apps/operations/ops_util_test.go index ee4d1b1ace8..d1bba1cc2dc 100644 --- a/controllers/apps/operations/ops_util_test.go +++ b/controllers/apps/operations/ops_util_test.go @@ -24,6 +24,7 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" + corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/utils/pointer" @@ -43,7 +44,6 @@ var _ = Describe("OpsUtil functions", func() { var ( randomStr = testCtx.GetRandomStr() clusterDefinitionName = "cluster-definition-for-ops-" + randomStr - clusterVersionName = "clusterversion-for-ops-" + randomStr clusterName = "cluster-for-ops-" + randomStr ) @@ -54,7 +54,7 @@ var _ = Describe("OpsUtil functions", func() { // create the new objects. By("clean resources") - // delete cluster(and all dependent sub-resources), clusterversion and clusterdef + // delete cluster(and all dependent sub-resources), cluster definition testapps.ClearClusterResources(&testCtx) // delete rest resources @@ -74,7 +74,7 @@ var _ = Describe("OpsUtil functions", func() { Context("Test ops_util functions", func() { It("Test ops_util functions", func() { By("init operations resources ") - opsRes, _, _ := initOperationsResources(clusterDefinitionName, clusterVersionName, clusterName) + opsRes, _, _ := initOperationsResources(clusterDefinitionName, clusterName) testapps.MockInstanceSetComponent(&testCtx, clusterName, consensusComp) By("Test the functions in ops_util.go") @@ -90,7 +90,7 @@ var _ = Describe("OpsUtil functions", func() { It("Test opsRequest failed cases", func() { By("init operations resources ") - opsRes, _, _ := initOperationsResources(clusterDefinitionName, clusterVersionName, clusterName) + opsRes, _, _ := initOperationsResources(clusterDefinitionName, clusterName) testapps.MockInstanceSetComponent(&testCtx, clusterName, consensusComp) pods := testapps.MockInstanceSetPods(&testCtx, nil, opsRes.Cluster, consensusComp) time.Sleep(time.Second) @@ -141,7 +141,7 @@ var _ = Describe("OpsUtil functions", func() { It("Test opsRequest with disable ha", func() { By("init operations resources ") - opsRes, _, _ := initOperationsResources(clusterDefinitionName, clusterVersionName, clusterName) + opsRes, _, _ := initOperationsResources(clusterDefinitionName, clusterName) By("Test the functions in ops_util.go") ops := testapps.NewOpsRequestObj("restart-ops-"+randomStr, testCtx.DefaultNamespace, @@ -193,7 +193,7 @@ var _ = Describe("OpsUtil functions", func() { It("Test opsRequest Queue functions", func() { By("init operations resources ") reqCtx := intctrlutil.RequestCtx{Ctx: testCtx.Ctx} - opsRes, _, _ := initOperationsResources(clusterDefinitionName, clusterVersionName, clusterName) + opsRes, _, _ := initOperationsResources(clusterDefinitionName, clusterName) runHscaleOps := func(expectPhase appsv1alpha1.OpsPhase) *appsv1alpha1.OpsRequest { ops := createHorizontalScaling(clusterName, appsv1alpha1.HorizontalScaling{ @@ -248,7 +248,7 @@ var _ = Describe("OpsUtil functions", func() { It("Test opsRequest dependency", func() { By("init operations resources ") reqCtx := intctrlutil.RequestCtx{Ctx: testCtx.Ctx} - opsRes, _, _ := initOperationsResources(clusterDefinitionName, clusterVersionName, clusterName) + opsRes, _, _ := initOperationsResources(clusterDefinitionName, clusterName) By("create a first horizontal opsRequest") ops1 := createHorizontalScaling(clusterName, appsv1alpha1.HorizontalScaling{ diff --git a/controllers/apps/operations/rebuild_instance_test.go b/controllers/apps/operations/rebuild_instance_test.go index 503c4099401..3673d3dfa6a 100644 --- a/controllers/apps/operations/rebuild_instance_test.go +++ b/controllers/apps/operations/rebuild_instance_test.go @@ -24,6 +24,7 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" + "golang.org/x/exp/slices" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -46,7 +47,6 @@ var _ = Describe("OpsUtil functions", func() { var ( randomStr = testCtx.GetRandomStr() clusterDefinitionName = "cluster-definition-for-ops-" + randomStr - clusterVersionName = "clusterversion-for-ops-" + randomStr clusterName = "cluster-for-ops-" + randomStr rebuildInstanceCount = 2 ) @@ -58,7 +58,7 @@ var _ = Describe("OpsUtil functions", func() { // create the new objects. By("clean resources") - // delete cluster(and all dependent sub-resources), clusterversion and clusterdef + // delete cluster(and all dependent sub-resources), cluster definition testapps.ClearClusterResources(&testCtx) // delete rest resources @@ -104,7 +104,7 @@ var _ = Describe("OpsUtil functions", func() { } prepareOpsRes := func(backupName string, inPlace bool) *OpsResource { - opsRes, _, _ := initOperationsResources(clusterDefinitionName, clusterVersionName, clusterName) + opsRes, _, _ := initOperationsResources(clusterDefinitionName, clusterName) podList := initInstanceSetPods(ctx, k8sClient, opsRes) // fake to create the source pvc. @@ -377,7 +377,7 @@ var _ = Describe("OpsUtil functions", func() { It("rebuild instance with horizontal scaling", func() { By("init operations resources ") - opsRes, _, _ := initOperationsResources(clusterDefinitionName, clusterVersionName, clusterName) + opsRes, _, _ := initOperationsResources(clusterDefinitionName, clusterName) its := testapps.MockInstanceSetComponent(&testCtx, clusterName, consensusComp) podList := testapps.MockInstanceSetPods(&testCtx, its, opsRes.Cluster, consensusComp) opsRes.OpsRequest = createRebuildInstanceOps("", false, podList[1].Name, podList[2].Name) diff --git a/controllers/apps/operations/reconfigure_test.go b/controllers/apps/operations/reconfigure_test.go index 881a9c5382b..8b80237c18e 100644 --- a/controllers/apps/operations/reconfigure_test.go +++ b/controllers/apps/operations/reconfigure_test.go @@ -47,7 +47,6 @@ var _ = Describe("Reconfigure OpsRequest", func() { var ( randomStr = testCtx.GetRandomStr() clusterDefinitionName = "cluster-definition-for-ops-" + randomStr - clusterVersionName = "clusterversion-for-ops-" + randomStr clusterName = "cluster-for-ops-" + randomStr ) @@ -58,7 +57,7 @@ var _ = Describe("Reconfigure OpsRequest", func() { // create the new objects. By("clean resources") - // delete cluster(and all dependent sub-resources), clusterversion and clusterdef + // delete cluster(and all dependent sub-resources), cluster definition testapps.ClearClusterResources(&testCtx) // delete rest resources @@ -144,7 +143,7 @@ var _ = Describe("Reconfigure OpsRequest", func() { assureMockReconfigureData := func(policyName string) (*OpsResource, *appsv1alpha1.Configuration, *corev1.ConfigMap) { By("init operations resources ") - opsRes, clusterDef, clusterObject := initOperationsResources(clusterDefinitionName, clusterVersionName, clusterName) + opsRes, clusterDef, clusterObject := initOperationsResources(clusterDefinitionName, clusterName) var ( cfgObj *corev1.ConfigMap diff --git a/controllers/apps/operations/restart_test.go b/controllers/apps/operations/restart_test.go index 20b6bd91161..99eb5e6dcc7 100644 --- a/controllers/apps/operations/restart_test.go +++ b/controllers/apps/operations/restart_test.go @@ -36,7 +36,6 @@ var _ = Describe("Restart OpsRequest", func() { var ( randomStr = testCtx.GetRandomStr() clusterDefinitionName = "cluster-definition-for-ops-" + randomStr - clusterVersionName = "clusterversion-for-ops-" + randomStr clusterName = "cluster-for-ops-" + randomStr ) @@ -47,7 +46,7 @@ var _ = Describe("Restart OpsRequest", func() { // create the new objects. By("clean resources") - // delete cluster(and all dependent sub-resources), clusterversion and clusterdef + // delete cluster(and all dependent sub-resources), cluster definition testapps.ClearClusterResources(&testCtx) // delete rest resources @@ -69,7 +68,7 @@ var _ = Describe("Restart OpsRequest", func() { ) BeforeEach(func() { By("init operations resources ") - opsRes, _, cluster = initOperationsResources(clusterDefinitionName, clusterVersionName, clusterName) + opsRes, _, cluster = initOperationsResources(clusterDefinitionName, clusterName) reqCtx = intctrlutil.RequestCtx{Ctx: testCtx.Ctx} }) diff --git a/controllers/apps/operations/restore_test.go b/controllers/apps/operations/restore_test.go index 97b987ccaa6..aead8ad2c31 100644 --- a/controllers/apps/operations/restore_test.go +++ b/controllers/apps/operations/restore_test.go @@ -43,7 +43,6 @@ var _ = Describe("Restore OpsRequest", func() { var ( randomStr = testCtx.GetRandomStr() clusterDefinitionName = "cluster-definition-for-ops-" + randomStr - clusterVersionName = "clusterversion-for-ops-" + randomStr clusterName = "cluster-for-ops-" + randomStr restoreClusterName = "restore-cluster" backupName = "backup-for-ops-" + randomStr @@ -57,7 +56,7 @@ var _ = Describe("Restore OpsRequest", func() { // create the new objects. By("clean resources") - // delete cluster(and all dependent sub-resources), clusterversion and clusterdef + // delete cluster(and all dependent sub-resources), cluster definition testapps.ClearClusterResources(&testCtx) // delete rest resources @@ -80,7 +79,7 @@ var _ = Describe("Restore OpsRequest", func() { ) BeforeEach(func() { By("init operations resources ") - opsRes, _, _ = initOperationsResources(clusterDefinitionName, clusterVersionName, clusterName) + opsRes, _, _ = initOperationsResources(clusterDefinitionName, clusterName) reqCtx = intctrlutil.RequestCtx{Ctx: testCtx.Ctx} By("create Backup") diff --git a/controllers/apps/operations/start_test.go b/controllers/apps/operations/start_test.go index e421a7015e2..09754d4bc9e 100644 --- a/controllers/apps/operations/start_test.go +++ b/controllers/apps/operations/start_test.go @@ -36,7 +36,6 @@ var _ = Describe("Start OpsRequest", func() { var ( randomStr = testCtx.GetRandomStr() clusterDefinitionName = "cluster-definition-for-ops-" + randomStr - clusterVersionName = "clusterversion-for-ops-" + randomStr clusterName = "cluster-for-ops-" + randomStr ) @@ -47,7 +46,7 @@ var _ = Describe("Start OpsRequest", func() { // create the new objects. By("clean resources") - // delete cluster(and all dependent sub-resources), clusterversion and clusterdef + // delete cluster(and all dependent sub-resources), cluster definition testapps.ClearClusterResources(&testCtx) // delete rest resources @@ -66,7 +65,7 @@ var _ = Describe("Start OpsRequest", func() { It("Test start OpsRequest", func() { By("init operations resources ") reqCtx := intctrlutil.RequestCtx{Ctx: ctx} - opsRes, _, _ := initOperationsResources(clusterDefinitionName, clusterVersionName, clusterName) + opsRes, _, _ := initOperationsResources(clusterDefinitionName, clusterName) testapps.MockInstanceSetComponent(&testCtx, clusterName, consensusComp) testapps.MockInstanceSetComponent(&testCtx, clusterName, statelessComp) testapps.MockInstanceSetComponent(&testCtx, clusterName, statefulComp) diff --git a/controllers/apps/operations/stop_test.go b/controllers/apps/operations/stop_test.go index 5b43d075942..494fe371be7 100644 --- a/controllers/apps/operations/stop_test.go +++ b/controllers/apps/operations/stop_test.go @@ -35,7 +35,6 @@ var _ = Describe("Stop OpsRequest", func() { var ( randomStr = testCtx.GetRandomStr() clusterDefinitionName = "cluster-definition-for-ops-" + randomStr - clusterVersionName = "clusterversion-for-ops-" + randomStr clusterName = "cluster-for-ops-" + randomStr ) @@ -46,7 +45,7 @@ var _ = Describe("Stop OpsRequest", func() { // create the new objects. By("clean resources") - // delete cluster(and all dependent sub-resources), clusterversion and clusterdef + // delete cluster(and all dependent sub-resources), cluster definition testapps.ClearClusterResources(&testCtx) // delete rest resources @@ -64,7 +63,7 @@ var _ = Describe("Stop OpsRequest", func() { Context("Test OpsRequest", func() { It("Test stop OpsRequest", func() { reqCtx := intctrlutil.RequestCtx{Ctx: ctx} - opsRes, _, _ := initOperationsResources(clusterDefinitionName, clusterVersionName, clusterName) + opsRes, _, _ := initOperationsResources(clusterDefinitionName, clusterName) testapps.MockInstanceSetComponent(&testCtx, clusterName, consensusComp) testapps.MockInstanceSetComponent(&testCtx, clusterName, statelessComp) testapps.MockInstanceSetComponent(&testCtx, clusterName, statefulComp) diff --git a/controllers/apps/operations/suite_test.go b/controllers/apps/operations/suite_test.go index c9a2716f90c..37e2e881c63 100644 --- a/controllers/apps/operations/suite_test.go +++ b/controllers/apps/operations/suite_test.go @@ -149,11 +149,9 @@ var _ = AfterSuite(func() { }) // initOperationsResources inits the operations resources. -func initOperationsResources(clusterDefinitionName, - clusterVersionName, - clusterName string) (*OpsResource, *appsv1alpha1.ClusterDefinition, *appsv1alpha1.Cluster) { - clusterDef, _, clusterObject := testapps.InitClusterWithHybridComps(&testCtx, clusterDefinitionName, - clusterVersionName, clusterName, statelessComp, statefulComp, consensusComp) +func initOperationsResources(clusterDefinitionName, clusterName string) (*OpsResource, *appsv1alpha1.ClusterDefinition, *appsv1alpha1.Cluster) { + clusterDef, clusterObject := testapps.InitClusterWithHybridComps(&testCtx, clusterDefinitionName, + clusterName, statelessComp, statefulComp, consensusComp) opsRes := &OpsResource{ Cluster: clusterObject, Recorder: k8sManager.GetEventRecorderFor("opsrequest-controller"), diff --git a/controllers/apps/operations/switchover_test.go b/controllers/apps/operations/switchover_test.go index fea740feeff..d6f58963ba8 100644 --- a/controllers/apps/operations/switchover_test.go +++ b/controllers/apps/operations/switchover_test.go @@ -38,16 +38,14 @@ import ( ) var ( - clusterDefObj *appsv1alpha1.ClusterDefinition - clusterVersionObj *appsv1alpha1.ClusterVersion - clusterObj *appsv1alpha1.Cluster + clusterDefObj *appsv1alpha1.ClusterDefinition + clusterObj *appsv1alpha1.Cluster ) var _ = Describe("", func() { var ( - randomStr = testCtx.GetRandomStr() - clusterVersionName = "cluster-version-for-ops-" + randomStr - clusterName = "cluster-for-ops-" + randomStr + randomStr = testCtx.GetRandomStr() + clusterName = "cluster-for-ops-" + randomStr ) defaultRole := func(index int32) string { @@ -80,7 +78,7 @@ var _ = Describe("", func() { // create the new objects. By("clean resources") - // delete cluster(and all dependent sub-resources), clusterversion and clusterdef + // delete cluster(and all dependent sub-resources), cluster definition testapps.ClearClusterResources(&testCtx) // delete rest resources @@ -122,11 +120,6 @@ var _ = Describe("", func() { AddComponentDef(testapps.ConsensusMySQLComponent, consensusComp). AddSwitchoverSpec(switchoverSpec). Create(&testCtx).GetObject() - - By("Create a clusterVersion obj with replication workloadType.") - clusterVersionObj = testapps.NewClusterVersionFactory(clusterVersionName, clusterDefObj.GetName()). - AddComponentVersion(consensusComp).AddContainerShort(testapps.DefaultMySQLContainerName, testapps.ApeCloudMySQLImage). - Create(&testCtx).GetObject() }) It("Test switchover OpsRequest", func() { @@ -135,8 +128,8 @@ var _ = Describe("", func() { Recorder: k8sManager.GetEventRecorderFor("opsrequest-controller"), } By("Creating a cluster with consensus .") - clusterObj = testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, - clusterDefObj.Name, clusterVersionObj.Name).WithRandomName(). + clusterObj = testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, clusterDefObj.Name). + WithRandomName(). AddComponent(consensusComp, consensusComp). SetReplicas(2). Create(&testCtx).GetObject() diff --git a/controllers/apps/operations/switchover_util_test.go b/controllers/apps/operations/switchover_util_test.go index c023f8496db..ee27b520eab 100644 --- a/controllers/apps/operations/switchover_util_test.go +++ b/controllers/apps/operations/switchover_util_test.go @@ -39,15 +39,13 @@ import ( var _ = Describe("Switchover Util", func() { var ( - clusterName = "test-cluster-repl" - clusterDefName = "test-cluster-def-repl" - clusterVersionName = "test-cluster-version-repl" + clusterName = "test-cluster-repl" + clusterDefName = "test-cluster-def-repl" ) var ( - clusterDefObj *appsv1alpha1.ClusterDefinition - clusterVersionObj *appsv1alpha1.ClusterVersion - clusterObj *appsv1alpha1.Cluster + clusterDefObj *appsv1alpha1.ClusterDefinition + clusterObj *appsv1alpha1.Cluster ) defaultRole := func(index int32) string { @@ -64,7 +62,7 @@ var _ = Describe("Switchover Util", func() { // in race conditions, it will find the existence of old objects, resulting failure to // create the new objects. By("clean resources") - // delete cluster(and all dependent sub-resources), clusterversion and clusterdef + // delete cluster(and all dependent sub-resources), cluster definition testapps.ClearClusterResources(&testCtx) // clear rest resources @@ -81,8 +79,8 @@ var _ = Describe("Switchover Util", func() { testNeedDoSwitchover := func() { By("Creating a cluster with replication workloadType.") - clusterObj = testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, - clusterDefObj.Name, clusterVersionObj.Name).WithRandomName(). + clusterObj = testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, clusterDefObj.Name). + WithRandomName(). AddComponent(testapps.DefaultRedisCompSpecName, testapps.DefaultRedisCompDefName). SetReplicas(testapps.DefaultReplicationReplicas). Create(&testCtx).GetObject() @@ -145,8 +143,8 @@ var _ = Describe("Switchover Util", func() { testDoSwitchover := func() { By("Creating a cluster with replication workloadType.") - clusterObj = testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, - clusterDefObj.Name, clusterVersionObj.Name).WithRandomName(). + clusterObj = testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, clusterDefObj.Name). + WithRandomName(). AddComponent(testapps.DefaultRedisCompSpecName, testapps.DefaultRedisCompDefName). SetReplicas(testapps.DefaultReplicationReplicas). Create(&testCtx).GetObject() @@ -231,12 +229,6 @@ var _ = Describe("Switchover Util", func() { AddComponentDef(testapps.ReplicationRedisComponent, testapps.DefaultRedisCompDefName). AddSwitchoverSpec(switchoverSpec). Create(&testCtx).GetObject() - - By("Create a clusterVersion obj with replication workloadType.") - clusterVersionObj = testapps.NewClusterVersionFactory(clusterVersionName, clusterDefObj.GetName()). - AddComponentVersion(testapps.DefaultRedisCompDefName).AddContainerShort(testapps.DefaultRedisContainerName, testapps.DefaultRedisImageName). - Create(&testCtx).GetObject() - }) It("Test needDoSwitchover with different conditions", func() { diff --git a/controllers/apps/operations/upgrade.go b/controllers/apps/operations/upgrade.go index ae4606e069f..ec3a5e51157 100644 --- a/controllers/apps/operations/upgrade.go +++ b/controllers/apps/operations/upgrade.go @@ -20,7 +20,6 @@ along with this program. If not, see . package operations import ( - "context" "fmt" "time" @@ -55,13 +54,11 @@ func (u upgradeOpsHandler) ActionStartedCondition(reqCtx intctrlutil.RequestCtx, return appsv1alpha1.NewHorizontalScalingCondition(opsRes.OpsRequest), nil } -// Action modifies Cluster.spec.clusterVersionRef with opsRequest.spec.upgrade.clusterVersionRef func (u upgradeOpsHandler) Action(reqCtx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) error { var compOpsHelper componentOpsHelper upgradeSpec := opsRes.OpsRequest.Spec.Upgrade if u.existClusterVersion(opsRes.OpsRequest) { - // TODO: remove this deprecated API after v0.9 - opsRes.Cluster.Spec.ClusterVersionRef = *opsRes.OpsRequest.Spec.Upgrade.ClusterVersionRef + return fmt.Errorf("not implemented") } else { compOpsHelper = newComponentOpsHelper(upgradeSpec.Components) if err := compOpsHelper.updateClusterComponentsAndShardings(opsRes.Cluster, func(compSpec *appsv1alpha1.ClusterComponentSpec, obj ComponentOpsInterface) error { @@ -101,17 +98,12 @@ func (u upgradeOpsHandler) Action(reqCtx intctrlutil.RequestCtx, cli client.Clie func (u upgradeOpsHandler) ReconcileAction(reqCtx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) (appsv1alpha1.OpsPhase, time.Duration, error) { upgradeSpec := opsRes.OpsRequest.Spec.Upgrade var ( - compOpsHelper componentOpsHelper - componentDefMap map[string]*appsv1alpha1.ComponentDefinition - componentVersionMap map[string]appsv1alpha1.ClusterComponentVersion - err error + compOpsHelper componentOpsHelper + componentDefMap map[string]*appsv1alpha1.ComponentDefinition + err error ) if u.existClusterVersion(opsRes.OpsRequest) { - // TODO: remove this deprecated API after v0.9 - compOpsHelper = newComponentOpsHelper(u.getCompOpsListForClusterVersion(opsRes)) - if componentVersionMap, err = u.getClusterComponentVersionMap(reqCtx.Ctx, cli, *upgradeSpec.ClusterVersionRef); err != nil { - return opsRes.OpsRequest.Status.Phase, 0, err - } + return appsv1alpha1.OpsFailedPhase, 0, fmt.Errorf("not implemented") } else { compOpsHelper = newComponentOpsHelper(upgradeSpec.Components) if componentDefMap, err = u.getComponentDefMapWithUpdatedImages(reqCtx, cli, opsRes); err != nil { @@ -136,16 +128,7 @@ func (u upgradeOpsHandler) ReconcileAction(reqCtx intctrlutil.RequestCtx, cli cl compOps ComponentOpsInterface, insTemplateName string) bool { if u.existClusterVersion(opsRes.OpsRequest) { - // TODO: remove this deprecated API after v0.9 - compSpec := getComponentSpecOrShardingTemplate(opsRes.Cluster, compOps.GetComponentName()) - if compSpec == nil { - return true - } - compVersion, ok := componentVersionMap[compSpec.ComponentDefRef] - if !ok { - return true - } - return u.podImageApplied(pod, compVersion.VersionsCtx.Containers) + return false } upgradeComponent := compOps.(appsv1alpha1.UpgradeComponent) lastCompConfiguration := opsRes.OpsRequest.Status.LastConfiguration.Components[compOps.GetComponentName()] @@ -171,7 +154,6 @@ func (u upgradeOpsHandler) ReconcileAction(reqCtx intctrlutil.RequestCtx, cli cl // SaveLastConfiguration records last configuration to the OpsRequest.status.lastConfiguration func (u upgradeOpsHandler) SaveLastConfiguration(reqCtx intctrlutil.RequestCtx, cli client.Client, opsRes *OpsResource) error { - opsRes.OpsRequest.Status.LastConfiguration.ClusterVersionRef = opsRes.Cluster.Spec.ClusterVersionRef compOpsHelper := newComponentOpsHelper(opsRes.OpsRequest.Spec.Upgrade.Components) compOpsHelper.saveLastConfigurations(opsRes, func(compSpec appsv1alpha1.ClusterComponentSpec, comOps ComponentOpsInterface) appsv1alpha1.LastComponentConfiguration { return appsv1alpha1.LastComponentConfiguration{ @@ -182,31 +164,6 @@ func (u upgradeOpsHandler) SaveLastConfiguration(reqCtx intctrlutil.RequestCtx, return nil } -// getClusterComponentVersionMap gets the components of ClusterVersion and converts the component list to map. -func (u upgradeOpsHandler) getClusterComponentVersionMap(ctx context.Context, - cli client.Client, clusterVersionName string) (map[string]appsv1alpha1.ClusterComponentVersion, error) { - clusterVersion := &appsv1alpha1.ClusterVersion{} - if err := cli.Get(ctx, client.ObjectKey{Name: clusterVersionName}, clusterVersion); err != nil { - return nil, client.IgnoreNotFound(err) - } - components := map[string]appsv1alpha1.ClusterComponentVersion{} - for _, v := range clusterVersion.Spec.ComponentVersions { - components[v.ComponentDefRef] = v - } - return components, nil -} - -func (u upgradeOpsHandler) getCompOpsListForClusterVersion(opsRes *OpsResource) []appsv1alpha1.ComponentOps { - var compOpsList []appsv1alpha1.ComponentOps - for _, v := range opsRes.Cluster.Spec.ComponentSpecs { - compOpsList = append(compOpsList, appsv1alpha1.ComponentOps{ComponentName: v.Name}) - } - for _, v := range opsRes.Cluster.Spec.ShardingSpecs { - compOpsList = append(compOpsList, appsv1alpha1.ComponentOps{ComponentName: v.Name}) - } - return compOpsList -} - // getComponentDefMapWithUpdatedImages gets the desired componentDefinition map // that is updated with the corresponding images of the ComponentDefinition and service version. func (u upgradeOpsHandler) getComponentDefMapWithUpdatedImages(reqCtx intctrlutil.RequestCtx, diff --git a/controllers/apps/operations/upgrade_test.go b/controllers/apps/operations/upgrade_test.go index 61f3b45a9f3..0e363b95e63 100644 --- a/controllers/apps/operations/upgrade_test.go +++ b/controllers/apps/operations/upgrade_test.go @@ -20,10 +20,9 @@ along with this program. If not, see . package operations import ( - "fmt" - . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" + corev1 "k8s.io/api/core/v1" "k8s.io/utils/pointer" "sigs.k8s.io/controller-runtime/pkg/client" @@ -37,20 +36,17 @@ import ( var _ = Describe("Upgrade OpsRequest", func() { var ( - randomStr = testCtx.GetRandomStr() - clusterDefinitionName = "cluster-definition-for-ops-" + randomStr - clusterVersionName = "clusterversion-for-ops-" + randomStr - clusterName = "cluster-for-ops-" + randomStr - serviceVer0 = testapps.ServiceVersion("v0") - serviceVer1 = testapps.ServiceVersion("v1") - serviceVer2 = testapps.ServiceVersion("v2") - release0 = testapps.ReleaseID("r0") - release1 = testapps.ReleaseID("r1") - release2 = testapps.ReleaseID("r2") - release3 = testapps.ReleaseID("r3") - release4 = testapps.ReleaseID("r4") + randomStr = testCtx.GetRandomStr() + clusterName = "cluster-for-ops-" + randomStr + serviceVer0 = testapps.ServiceVersion("v0") + serviceVer1 = testapps.ServiceVersion("v1") + serviceVer2 = testapps.ServiceVersion("v2") + release0 = testapps.ReleaseID("r0") + release1 = testapps.ReleaseID("r1") + release2 = testapps.ReleaseID("r2") + release3 = testapps.ReleaseID("r3") + release4 = testapps.ReleaseID("r4") ) - const mysqlImageForUpdate = "docker.io/apecloud/apecloud-mysql-server:8.0.30" cleanEnv := func() { // must wait till resources deleted and no longer existed before the testcases start, // otherwise if later it needs to create some new resource objects with the same name, @@ -58,7 +54,7 @@ var _ = Describe("Upgrade OpsRequest", func() { // create the new objects. By("clean resources") - // delete cluster(and all dependent sub-resources), clusterversion and clusterdef + // delete cluster(and all dependent sub-resources), cluster definition testapps.ClearClusterResources(&testCtx) // delete rest resources @@ -187,7 +183,7 @@ var _ = Describe("Upgrade OpsRequest", func() { })).Should(Succeed()) } // create the cluster with no clusterDefinition - clusterObject := testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, "", ""). + clusterObject := testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, ""). AddComponentV2(consensusComp, compDef1.Name). SetServiceVersion(testapps.ServiceVersion("v0")). SetReplicas(int32(3)).Create(&testCtx).GetObject() @@ -239,43 +235,6 @@ var _ = Describe("Upgrade OpsRequest", func() { } Context("Test OpsRequest", func() { - It("Test upgrade OpsRequest with ClusterVersion", func() { - By("init operations resources ") - reqCtx := intctrlutil.RequestCtx{Ctx: ctx} - opsRes, _, clusterObject := initOperationsResources(clusterDefinitionName, clusterVersionName, clusterName) - - By("create Upgrade Ops") - newClusterVersionName := "clusterversion-upgrade-" + randomStr - _ = testapps.NewClusterVersionFactory(newClusterVersionName, clusterDefinitionName). - AddComponentVersion(consensusComp).AddContainerShort(testapps.DefaultMySQLContainerName, mysqlImageForUpdate). - Create(&testCtx).GetObject() - opsRes.OpsRequest = createUpgradeOpsRequest(clusterObject, appsv1alpha1.Upgrade{ClusterVersionRef: &newClusterVersionName}) - - By("mock upgrade OpsRequest phase is Running") - makeUpgradeOpsIsRunning(reqCtx, opsRes) - - By("expect upgrade successfully") - _ = testapps.MockInstanceSetPod(&testCtx, nil, clusterName, statelessComp, fmt.Sprintf(clusterName+"-"+statelessComp+"-0"), "", "") - _ = testapps.MockInstanceSetPods(&testCtx, nil, clusterObject, statefulComp) - pods := testapps.MockInstanceSetPods(&testCtx, nil, clusterObject, consensusComp) - for i := range pods { - pod := pods[i] - Expect(testapps.ChangeObj(&testCtx, pod, func(pod *corev1.Pod) { - pod.Spec.Containers[0].Image = mysqlImageForUpdate - })).Should(Succeed()) - Expect(testapps.ChangeObjStatus(&testCtx, pod, func() { - pod.Status.ContainerStatuses = []corev1.ContainerStatus{ - { - Name: testapps.DefaultMySQLContainerName, - Image: mysqlImageForUpdate, - }, - } - })).Should(Succeed()) - } - // mock component to running - expectOpsSucceed(reqCtx, opsRes, consensusComp, statelessComp, statefulComp) - }) - It("Test upgrade OpsRequest with ComponentDef and no ComponentVersion", func() { By("init operations resources ") compDef1, compDef2, opsRes := initOpsResWithComponentDef(false) diff --git a/controllers/apps/operations/util/common_util_test.go b/controllers/apps/operations/util/common_util_test.go index 4e2cd7e75da..d87c54aa02a 100644 --- a/controllers/apps/operations/util/common_util_test.go +++ b/controllers/apps/operations/util/common_util_test.go @@ -36,7 +36,6 @@ var _ = Describe("OpsRequest Controller", func() { var ( randomStr = testCtx.GetRandomStr() clusterDefinitionName = "cluster-definition-" + randomStr - clusterVersionName = "clusterversion-" + randomStr clusterName = "cluster-" + randomStr consensusCompName = "consensus" ) @@ -61,7 +60,7 @@ var _ = Describe("OpsRequest Controller", func() { Context("Test OpsRequest", func() { It("Should Test all OpsRequest", func() { cluster := testapps.CreateConsensusMysqlCluster(&testCtx, clusterDefinitionName, - clusterVersionName, clusterName, "consensus", consensusCompName) + clusterName, "consensus", consensusCompName) By("init restart OpsRequest") testOpsName := "restart-" + randomStr ops := testapps.NewOpsRequestObj(testOpsName, testCtx.DefaultNamespace, diff --git a/controllers/apps/operations/vertical_scaling_test.go b/controllers/apps/operations/vertical_scaling_test.go index 43a52123f47..becba4bda50 100644 --- a/controllers/apps/operations/vertical_scaling_test.go +++ b/controllers/apps/operations/vertical_scaling_test.go @@ -44,7 +44,6 @@ var _ = Describe("VerticalScaling OpsRequest", func() { var ( randomStr = testCtx.GetRandomStr() clusterDefinitionName = "cluster-definition-for-ops-" + randomStr - clusterVersionName = "clusterversion-for-ops-" + randomStr clusterName = "cluster-for-ops-" + randomStr reqCtx intctrlutil.RequestCtx ) @@ -55,7 +54,7 @@ var _ = Describe("VerticalScaling OpsRequest", func() { // in race conditions, it will find the existence of old objects, resulting failure to // create the new objects. By("clean resources") - // delete cluster(and all dependent sub-resources), clusterversion and clusterdef + // delete cluster(and all dependent sub-resources), cluster definition testapps.ClearClusterResources(&testCtx) // delete rest resources @@ -73,7 +72,7 @@ var _ = Describe("VerticalScaling OpsRequest", func() { testVerticalScaling := func(verticalScaling []appsv1alpha1.VerticalScaling) *OpsResource { By("init operations resources ") - opsRes, _, _ := initOperationsResources(clusterDefinitionName, clusterVersionName, clusterName) + opsRes, _, _ := initOperationsResources(clusterDefinitionName, clusterName) By("create VerticalScaling ops") ops := testapps.NewOpsRequestObj("vertical-scaling-ops-"+randomStr, testCtx.DefaultNamespace, @@ -117,9 +116,9 @@ var _ = Describe("VerticalScaling OpsRequest", func() { }) It("cancel vertical scaling opsRequest", func() { - By("init operations resources with CLusterDefinition/ClusterVersion/Hybrid components Cluster/consensus Pods") + By("init operations resources with CLusterDefinition/Hybrid components Cluster/consensus Pods") reqCtx := intctrlutil.RequestCtx{Ctx: ctx} - opsRes, _, _ := initOperationsResources(clusterDefinitionName, clusterVersionName, clusterName) + opsRes, _, _ := initOperationsResources(clusterDefinitionName, clusterName) podList := initInstanceSetPods(ctx, k8sClient, opsRes) By("create VerticalScaling ops") diff --git a/controllers/apps/operations/volume_expansion_test.go b/controllers/apps/operations/volume_expansion_test.go index 2aead9931e2..7da6f5ce530 100644 --- a/controllers/apps/operations/volume_expansion_test.go +++ b/controllers/apps/operations/volume_expansion_test.go @@ -45,7 +45,6 @@ var _ = Describe("OpsRequest Controller Volume Expansion Handler", func() { // waitDuration = time.Second * 3 randomStr = testCtx.GetRandomStr() clusterDefinitionName = "cluster-definition-for-ops-" + randomStr - clusterVersionName = "clusterversion-for-ops-" + randomStr clusterName = "cluster-for-ops-" + randomStr storageClassName = "csi-hostpath-sc-" + randomStr ) @@ -62,7 +61,7 @@ var _ = Describe("OpsRequest Controller Volume Expansion Handler", func() { // create the new objects. By("clean resources") - // delete cluster(and all dependent sub-resources), clusterversion and clusterdef + // delete cluster(and all dependent sub-resources), cluster definition testapps.ClearClusterResources(&testCtx) // delete rest resources @@ -219,8 +218,8 @@ var _ = Describe("OpsRequest Controller Volume Expansion Handler", func() { Context("Test VolumeExpansion", func() { It("VolumeExpansion should work", func() { reqCtx := intctrlutil.RequestCtx{Ctx: ctx} - _, _, clusterObject := testapps.InitConsensusMysql(&testCtx, clusterDefinitionName, - clusterVersionName, clusterName, "consensus", consensusCompName) + _, clusterObject := testapps.InitConsensusMysql(&testCtx, clusterDefinitionName, + clusterName, "consensus", consensusCompName) // init storageClass sc := testapps.CreateStorageClass(&testCtx, storageClassName, true) Expect(testapps.ChangeObj(&testCtx, sc, func(lsc *storagev1.StorageClass) { diff --git a/controllers/apps/opsrequest_controller_test.go b/controllers/apps/opsrequest_controller_test.go index 522122dab7f..3e49d66a718 100644 --- a/controllers/apps/opsrequest_controller_test.go +++ b/controllers/apps/opsrequest_controller_test.go @@ -53,7 +53,6 @@ import ( var _ = Describe("OpsRequest Controller", func() { const clusterDefName = "test-clusterdef" - const clusterVersionName = "test-clusterversion" const clusterNamePrefix = "test-cluster" const mysqlCompDefName = "mysql" const mysqlCompName = "mysql" @@ -84,7 +83,7 @@ var _ = Describe("OpsRequest Controller", func() { testapps.ClearResourcesWithRemoveFinalizerOption(&testCtx, intctrlutil.OpsRequestSignature, true, inNS, ml) testapps.ClearResourcesWithRemoveFinalizerOption(&testCtx, intctrlutil.VolumeSnapshotSignature, true, inNS) - // delete cluster(and all dependent sub-resources), clusterversion and clusterdef + // delete cluster(and all dependent sub-resources), cluster definition // TODO(review): why finalizers not removed testapps.ClearClusterResourcesWithRemoveFinalizerOption(&testCtx) testapps.ClearResources(&testCtx, intctrlutil.StorageClassSignature, ml) @@ -102,10 +101,9 @@ var _ = Describe("OpsRequest Controller", func() { }) var ( - clusterDefObj *appsv1alpha1.ClusterDefinition - clusterVersionObj *appsv1alpha1.ClusterVersion - clusterObj *appsv1alpha1.Cluster - clusterKey types.NamespacedName + clusterDefObj *appsv1alpha1.ClusterDefinition + clusterObj *appsv1alpha1.Cluster + clusterKey types.NamespacedName ) mockSetClusterStatusPhaseToRunning := func(namespacedName types.NamespacedName) { @@ -139,8 +137,8 @@ var _ = Describe("OpsRequest Controller", func() { const opsName = "mysql-verticalscaling" By("Create a cluster obj") - clusterFactory := testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterNamePrefix, - clusterDefObj.Name, clusterVersionObj.Name).WithRandomName(). + clusterFactory := testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterNamePrefix, clusterDefObj.Name). + WithRandomName(). AddComponent(mysqlCompName, mysqlCompDefName). SetReplicas(1). SetResources(scalingCtx.source) @@ -241,11 +239,6 @@ var _ = Describe("OpsRequest Controller", func() { clusterDefObj = testapps.NewClusterDefFactory(clusterDefName). AddComponentDef(testapps.StatefulMySQLComponent, mysqlCompDefName). Create(&testCtx).GetObject() - - By("Create a clusterVersion obj") - clusterVersionObj = testapps.NewClusterVersionFactory(clusterVersionName, clusterDefObj.GetName()). - AddComponentVersion(mysqlCompDefName).AddContainerShort("mysql", testapps.ApeCloudMySQLImage). - Create(&testCtx).GetObject() }) It("create cluster by resource, vertical scaling by resource", func() { @@ -268,11 +261,6 @@ var _ = Describe("OpsRequest Controller", func() { BackupPolicyTemplateName: backupPolicyTPLName, }).Create(&testCtx).GetObject() - By("Create a clusterVersion obj") - clusterVersionObj = testapps.NewClusterVersionFactory(clusterVersionName, clusterDefObj.GetName()). - AddComponentVersion(mysqlCompDefName).AddContainerShort("mysql", testapps.ApeCloudMySQLImage). - Create(&testCtx).GetObject() - By("Mock lorry client for the default transformer of system accounts provision") mockLorryClientDefault() }) @@ -331,8 +319,8 @@ var _ = Describe("OpsRequest Controller", func() { })()).ShouldNot(HaveOccurred()) } pvcSpec := testapps.NewPVCSpec("1Gi") - clusterObj = testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterNamePrefix, - clusterDefObj.Name, clusterVersionObj.Name).WithRandomName(). + clusterObj = testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterNamePrefix, clusterDefObj.Name). + WithRandomName(). AddComponent(mysqlCompName, mysqlCompDefName). SetReplicas(replicas). AddVolumeClaimTemplate(testapps.DataVolumeName, pvcSpec). diff --git a/controllers/apps/servicedescriptor_controller_test.go b/controllers/apps/servicedescriptor_controller_test.go index 43e1fa5fa11..7603fd10c00 100644 --- a/controllers/apps/servicedescriptor_controller_test.go +++ b/controllers/apps/servicedescriptor_controller_test.go @@ -31,7 +31,7 @@ import ( testapps "github.com/apecloud/kubeblocks/pkg/testutil/apps" ) -var _ = Describe("test clusterVersion controller", func() { +var _ = Describe("test ServiceDescriptor controller", func() { var ( randomStr = testCtx.GetRandomStr() @@ -45,7 +45,7 @@ var _ = Describe("test clusterVersion controller", func() { // create the new objects. By("clean resources") - // delete cluster(and all dependent sub-resources), clusterversion and clusterdef + // delete cluster(and all dependent sub-resources), cluster definition testapps.ClearClusterResources(&testCtx) } BeforeEach(cleanEnv) diff --git a/controllers/apps/suite_test.go b/controllers/apps/suite_test.go index 125d17ea282..2d7b04cca72 100644 --- a/controllers/apps/suite_test.go +++ b/controllers/apps/suite_test.go @@ -194,13 +194,6 @@ var _ = BeforeSuite(func() { }).SetupWithManager(k8sManager) Expect(err).ToNot(HaveOccurred()) - err = (&ClusterVersionReconciler{ - Client: k8sManager.GetClient(), - Scheme: k8sManager.GetScheme(), - Recorder: k8sManager.GetEventRecorderFor("cluster-version-controller"), - }).SetupWithManager(k8sManager) - Expect(err).ToNot(HaveOccurred()) - err = (&ComponentReconciler{ Client: k8sManager.GetClient(), Scheme: k8sManager.GetScheme(), diff --git a/controllers/apps/transformer_cluster_api_normalization.go b/controllers/apps/transformer_cluster_api_normalization.go index 11bc39404db..48c44241471 100644 --- a/controllers/apps/transformer_cluster_api_normalization.go +++ b/controllers/apps/transformer_cluster_api_normalization.go @@ -236,7 +236,7 @@ func (t *ClusterAPINormalizationTransformer) resolveCompDefinitionNServiceVersio func (t *ClusterAPINormalizationTransformer) buildCompDefinition4Legacy(transCtx *clusterTransformContext, compSpec *appsv1alpha1.ClusterComponentSpec) (*appsv1alpha1.ComponentDefinition, error) { - compDef, err := component.BuildComponentDefinition(transCtx.ClusterDef, transCtx.ClusterVer, compSpec) + compDef, err := component.BuildComponentDefinition(transCtx.ClusterDef, compSpec) if err != nil { return nil, err } diff --git a/controllers/apps/transformer_cluster_backup_policy.go b/controllers/apps/transformer_cluster_backup_policy.go index ff741bbf6ab..b708ba1c75c 100644 --- a/controllers/apps/transformer_cluster_backup_policy.go +++ b/controllers/apps/transformer_cluster_backup_policy.go @@ -443,15 +443,6 @@ func (r *clusterBackupPolicyTransformer) syncBackupMethods(backupPolicy *dpv1alp func (r *clusterBackupPolicyTransformer) doEnvMapping(comp *appsv1alpha1.ClusterComponentSpec, envMapping []appsv1alpha1.EnvMappingVar) []corev1.EnvVar { var env []corev1.EnvVar for _, v := range envMapping { - for _, cv := range v.ValueFrom.ClusterVersionRef { - if !slices.Contains(cv.Names, r.Cluster.Spec.ClusterVersionRef) { - continue - } - env = append(env, corev1.EnvVar{ - Name: v.Key, - Value: cv.MappingValue, - }) - } for _, cm := range v.ValueFrom.ComponentDef { if !slices.Contains(cm.Names, comp.ComponentDef) { continue diff --git a/controllers/apps/transformer_cluster_component_test.go b/controllers/apps/transformer_cluster_component_test.go index 03b32dcb57d..2f474599a5b 100644 --- a/controllers/apps/transformer_cluster_component_test.go +++ b/controllers/apps/transformer_cluster_component_test.go @@ -241,7 +241,7 @@ var _ = Describe("cluster component transformer test", func() { } newTransformerNCtx := func(topology string) (graph.Transformer, *clusterTransformContext, *graph.DAG) { - cluster := testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, clusterDefName, ""). + cluster := testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, clusterDefName). WithRandomName(). SetTopology(topology). SetReplicas(1). diff --git a/controllers/apps/transformer_cluster_deletion_test.go b/controllers/apps/transformer_cluster_deletion_test.go index 63252f71927..8c07e29ac3d 100644 --- a/controllers/apps/transformer_cluster_deletion_test.go +++ b/controllers/apps/transformer_cluster_deletion_test.go @@ -66,7 +66,7 @@ var _ = Describe("clusterDeletionTransformer", func() { GetObject() clusterDef.Status.Phase = appsv1alpha1.AvailablePhase - cluster = testapps.NewClusterFactory(testCtx.DefaultNamespace, "test-cluster", clusterDef.Name, ""). + cluster = testapps.NewClusterFactory(testCtx.DefaultNamespace, "test-cluster", clusterDef.Name). SetTopology(clusterDef.Spec.Topologies[0].Name). AddComponentV2("comp1", "compdef1"). AddComponentV2("comp2", "compdef2"). diff --git a/controllers/apps/transformer_cluster_halt_recovering.go b/controllers/apps/transformer_cluster_halt_recovering.go index d4c0b45f3b7..bd1a4df0c54 100644 --- a/controllers/apps/transformer_cluster_halt_recovering.go +++ b/controllers/apps/transformer_cluster_halt_recovering.go @@ -107,17 +107,6 @@ func (t *clusterHaltRecoveryTransformer) Transform(ctx graph.TransformContext, d }) } - // check clusterVersionRef equality but allow clusters.apps.kubeblocks.io/allow-inconsistent-cv=true annotation override - if cluster.Spec.ClusterVersionRef != lc.Spec.ClusterVersionRef && - cluster.Annotations[constant.HaltRecoveryAllowInconsistentCVAnnotKey] != trueVal { - return emitError(metav1.Condition{ - Type: appsv1alpha1.ConditionTypeHaltRecovery, - Reason: "HaltRecoveryFailed", - Message: fmt.Sprintf("not equal to last applied cluster.spec.clusterVersionRef %s; add '%s=true' annotation if void this check", - lc.Spec.ClusterVersionRef, constant.HaltRecoveryAllowInconsistentCVAnnotKey), - }) - } - // check component len equality if l := len(lc.Spec.ComponentSpecs); l != len(cluster.Spec.ComponentSpecs) { return emitError(metav1.Condition{ diff --git a/controllers/apps/transformer_cluster_load_resources.go b/controllers/apps/transformer_cluster_load_resources.go index 2e0a6de7a1f..a3c9ce3a7bf 100644 --- a/controllers/apps/transformer_cluster_load_resources.go +++ b/controllers/apps/transformer_cluster_load_resources.go @@ -54,10 +54,6 @@ func (t *clusterLoadRefResourcesTransformer) Transform(ctx graph.TransformContex return newRequeueError(requeueDuration, err.Error()) } - if err = loadNCheckClusterVersion(transCtx, cluster); err != nil { - return newRequeueError(requeueDuration, err.Error()) - } - if withClusterTopology(cluster) { // check again with cluster definition loaded, // and update topology to cluster spec in case the default topology changed. @@ -126,32 +122,6 @@ func loadNCheckClusterDefinition(transCtx *clusterTransformContext, cluster *app return nil } -func loadNCheckClusterVersion(transCtx *clusterTransformContext, cluster *appsv1alpha1.Cluster) error { - var cv *appsv1alpha1.ClusterVersion - if len(cluster.Spec.ClusterVersionRef) > 0 { - cv = &appsv1alpha1.ClusterVersion{} - key := types.NamespacedName{Name: cluster.Spec.ClusterVersionRef} - if err := transCtx.Client.Get(transCtx.Context, key, cv); err != nil { - return err - } - } - - if cv != nil { - if cv.Generation != cv.Status.ObservedGeneration { - return fmt.Errorf("the referenced ClusterVersion is not up to date: %s", cv.Name) - } - if cv.Status.Phase != appsv1alpha1.AvailablePhase { - return fmt.Errorf("the referenced ClusterVersion is unavailable: %s", cv.Name) - } - } - - if cv == nil { - cv = &appsv1alpha1.ClusterVersion{} - } - transCtx.ClusterVer = cv - return nil -} - func withClusterTopology(cluster *appsv1alpha1.Cluster) bool { return len(cluster.Spec.ClusterDefRef) > 0 && legacyClusterCompCnt(cluster) == 0 && !compatibleUserDefinedInNewAPI(cluster) } diff --git a/controllers/apps/transformer_cluster_meta.go b/controllers/apps/transformer_cluster_meta.go index 992bcf88427..1848b40565e 100644 --- a/controllers/apps/transformer_cluster_meta.go +++ b/controllers/apps/transformer_cluster_meta.go @@ -47,13 +47,11 @@ func (t *clusterAssureMetaTransformer) Transform(ctx graph.TransformContext, dag labels = map[string]string{} } cdLabelName := labels[constant.ClusterDefLabelKey] - cvLabelName := labels[constant.ClusterVerLabelKey] - cdName, cvName := cluster.Spec.ClusterDefRef, cluster.Spec.ClusterVersionRef - if cdLabelName == cdName && cvLabelName == cvName { + cdName := cluster.Spec.ClusterDefRef + if cdLabelName == cdName { return nil } labels[constant.ClusterDefLabelKey] = cdName - labels[constant.ClusterVerLabelKey] = cvName cluster.Labels = labels return nil diff --git a/controllers/apps/transformer_component_rbac_test.go b/controllers/apps/transformer_component_rbac_test.go index 0b26d740b5c..fe461c83c35 100644 --- a/controllers/apps/transformer_component_rbac_test.go +++ b/controllers/apps/transformer_component_rbac_test.go @@ -63,7 +63,7 @@ var _ = Describe("object rbac transformer test.", func() { GetObject() By("Creating a cluster") - cluster = testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, "", ""). + cluster = testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, ""). WithRandomName(). AddComponentV2(compName, compDefName). SetReplicas(1). diff --git a/controllers/apps/transformer_component_tls_test.go b/controllers/apps/transformer_component_tls_test.go index 850e245eec3..a21df0c8cba 100644 --- a/controllers/apps/transformer_component_tls_test.go +++ b/controllers/apps/transformer_component_tls_test.go @@ -46,7 +46,6 @@ import ( var _ = Describe("TLS self-signed cert function", func() { const ( clusterDefName = "test-clusterdef-tls" - clusterVersionName = "test-clusterversion-tls" clusterNamePrefix = "test-cluster" statefulCompDefName = "mysql" statefulCompName = "mysql" @@ -65,7 +64,7 @@ var _ = Describe("TLS self-signed cert function", func() { // create the new objects. By("clean resources") - // delete cluster(and all dependent sub-resources), clusterversion and clusterdef + // delete cluster(and all dependent sub-resources), cluster definition testapps.ClearClusterResourcesWithRemoveFinalizerOption(&testCtx) // delete rest configurations @@ -98,12 +97,6 @@ var _ = Describe("TLS self-signed cert function", func() { AddConfigTemplate(configSpecName, configMapObj.Name, configConstraintObj.Name, testCtx.DefaultNamespace, testapps.ConfVolumeName). AddContainerEnv(mysqlContainerName, corev1.EnvVar{Name: "MYSQL_ALLOW_EMPTY_PASSWORD", Value: "yes"}). CheckedCreate(&testCtx).GetObject() - - By("Create a clusterVersion obj") - testapps.NewClusterVersionFactory(clusterVersionName, clusterDefName). - AddComponentVersion(statefulCompDefName).AddContainerShort(mysqlContainerName, testapps.ApeCloudMySQLImage). - CheckedCreate(&testCtx).GetObject() - }) Context("when issuer is UserProvided", func() { @@ -137,7 +130,7 @@ var _ = Describe("TLS self-signed cert function", func() { }, } By("create cluster obj") - clusterObj := testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterNamePrefix, clusterDefName, clusterVersionName). + clusterObj := testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterNamePrefix, clusterDefName). WithRandomName(). AddComponent(statefulCompName, statefulCompDefName). SetReplicas(3). @@ -155,7 +148,7 @@ var _ = Describe("TLS self-signed cert function", func() { Context("when switch between disabled and enabled", func() { It("should handle tls settings properly", func() { By("create cluster with tls disabled") - clusterObj := testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterNamePrefix, clusterDefName, clusterVersionName). + clusterObj := testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterNamePrefix, clusterDefName). WithRandomName(). AddComponent(statefulCompName, statefulCompDefName). SetReplicas(3). diff --git a/controllers/extensions/addon_controller_test.go b/controllers/extensions/addon_controller_test.go index d8d7c892258..d44b1029c9c 100644 --- a/controllers/extensions/addon_controller_test.go +++ b/controllers/extensions/addon_controller_test.go @@ -53,11 +53,7 @@ import ( var _ = Describe("Addon controller", func() { const ( - clusterDefName = "test-clusterdef" - clusterVersionName = "test-clusterversion" - compDefName = "test-compdef" - compVersionName = "test-compversion" - clusterName = "test-cluster" + clusterName = "test-cluster" ) cleanEnv := func() { // must wait till resources deleted and no longer existed before the testcases start, @@ -843,8 +839,7 @@ var _ = Describe("Addon controller", func() { fakeInstallationCompletedJob(2) By("By creating cluster with addon") - clusterObj := testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, - "test-cd", "test-cv"). + clusterObj := testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, "test-cd"). AddComponent(addon.Name, addon.Name).SetReplicas(1). WithRandomName(). AddLabels(constant.ClusterDefLabelKey, addon.Name). @@ -884,8 +879,7 @@ var _ = Describe("Addon controller", func() { fakeInstallationCompletedJob(2) By("By creating cluster with addon") - clusterObj := testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, - "test-cd", "test-cv"). + clusterObj := testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, "test-cd"). AddComponent(addon.Name, addon.Name).SetReplicas(1). WithRandomName(). AddLabels(constant.ClusterDefLabelKey, addon.Name). diff --git a/controllers/k8score/event_controller_test.go b/controllers/k8score/event_controller_test.go index c9ac185f55a..6020aedaa4d 100644 --- a/controllers/k8score/event_controller_test.go +++ b/controllers/k8score/event_controller_test.go @@ -125,8 +125,8 @@ var _ = Describe("Event Controller", func() { clusterDefObj := testapps.NewClusterDefFactory(clusterDefName). AddComponentDef(testapps.ConsensusMySQLComponent, consensusCompDefName). Create(&testCtx).GetObject() - clusterObj := testapps.NewClusterFactory(testCtx.DefaultNamespace, "", - clusterDefObj.Name, "").WithRandomName(). + clusterObj := testapps.NewClusterFactory(testCtx.DefaultNamespace, "", clusterDefObj.Name). + WithRandomName(). AddComponent(consensusCompName, consensusCompDefName). Create(&testCtx).GetObject() Eventually(testapps.CheckObjExists(&testCtx, client.ObjectKeyFromObject(clusterObj), &appsv1alpha1.Cluster{}, true)).Should(Succeed()) diff --git a/deploy/helm/config/rbac/role.yaml b/deploy/helm/config/rbac/role.yaml index 8f6b142af93..aac6ca93aab 100644 --- a/deploy/helm/config/rbac/role.yaml +++ b/deploy/helm/config/rbac/role.yaml @@ -122,32 +122,6 @@ rules: - get - patch - update -- apiGroups: - - apps.kubeblocks.io - resources: - - clusterversions - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - apps.kubeblocks.io - resources: - - clusterversions/finalizers - verbs: - - update -- apiGroups: - - apps.kubeblocks.io - resources: - - clusterversions/status - verbs: - - get - - patch - - update - apiGroups: - apps.kubeblocks.io resources: diff --git a/deploy/helm/crds/apps.kubeblocks.io_backuppolicytemplates.yaml b/deploy/helm/crds/apps.kubeblocks.io_backuppolicytemplates.yaml index 5b572f21616..4f0ae6e1b58 100644 --- a/deploy/helm/crds/apps.kubeblocks.io_backuppolicytemplates.yaml +++ b/deploy/helm/crds/apps.kubeblocks.io_backuppolicytemplates.yaml @@ -231,8 +231,7 @@ spec: type: string names: description: |- - Represents an array of names of ClusterVersion or ComponentDefinition that can be mapped to - the appropriate version of the backup tool image. + Represents an array of names of ComponentDefinition that can be mapped to the appropriate version of the backup tool image. This mapping allows different versions of component images to correspond to specific versions of backup tool images. @@ -255,8 +254,7 @@ spec: type: string names: description: |- - Represents an array of names of ClusterVersion or ComponentDefinition that can be mapped to - the appropriate version of the backup tool image. + Represents an array of names of ComponentDefinition that can be mapped to the appropriate version of the backup tool image. This mapping allows different versions of component images to correspond to specific versions of backup tool images. diff --git a/deploy/helm/crds/apps.kubeblocks.io_clusterversions.yaml b/deploy/helm/crds/apps.kubeblocks.io_clusterversions.yaml deleted file mode 100644 index 9b85a09b815..00000000000 --- a/deploy/helm/crds/apps.kubeblocks.io_clusterversions.yaml +++ /dev/null @@ -1,3279 +0,0 @@ -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.14.0 - labels: - app.kubernetes.io/name: kubeblocks - name: clusterversions.apps.kubeblocks.io -spec: - group: apps.kubeblocks.io - names: - categories: - - kubeblocks - kind: ClusterVersion - listKind: ClusterVersionList - plural: clusterversions - shortNames: - - cv - singular: clusterversion - scope: Cluster - versions: - - additionalPrinterColumns: - - description: ClusterDefinition referenced by cluster. - jsonPath: .spec.clusterDefinitionRef - name: CLUSTER-DEFINITION - type: string - - description: status phase - jsonPath: .status.phase - name: STATUS - type: string - - jsonPath: .metadata.creationTimestamp - name: AGE - type: date - deprecated: true - deprecationWarning: The ClusterVersion CRD has been deprecated since 0.9.0 - name: v1alpha1 - schema: - openAPIV3Schema: - description: |- - ClusterVersion is the Schema for the ClusterVersions API. - - - Deprecated: ClusterVersion has been replaced by ComponentVersion since v0.9. - This struct is maintained for backward compatibility and its use is discouraged. - properties: - apiVersion: - description: |- - APIVersion defines the versioned schema of this representation of an object. - Servers should convert recognized schemas to the latest internal value, and - may reject unrecognized values. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources - type: string - kind: - description: |- - Kind is a string value representing the REST resource this object represents. - Servers may infer this from the endpoint the client submits requests to. - Cannot be updated. - In CamelCase. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds - type: string - metadata: - type: object - spec: - description: |- - ClusterVersionSpec defines the desired state of ClusterVersion. - - - Deprecated since v0.9. - This struct is maintained for backward compatibility and its use is discouraged. - properties: - clusterDefinitionRef: - description: Specifies a reference to the ClusterDefinition. - pattern: ^[a-z0-9]([a-z0-9\.\-]*[a-z0-9])?$ - type: string - componentVersions: - description: Contains a list of versioning contexts for the components' - containers. - items: - description: |- - ClusterComponentVersion is an application version component spec. - - - Deprecated since v0.9. - This struct is maintained for backward compatibility and its use is discouraged. - properties: - componentDefRef: - description: Specifies a reference to one of the cluster component - definition names in the ClusterDefinition API (spec.componentDefs.name). - maxLength: 63 - pattern: ^[a-z0-9]([a-z0-9\.\-]*[a-z0-9])?$ - type: string - configSpecs: - description: |- - Defines a configuration extension mechanism to handle configuration differences between versions. - The configTemplateRefs field, in conjunction with the configTemplateRefs in the ClusterDefinition, determines - the final configuration file. - items: - properties: - asEnvFrom: - description: |- - Specifies the containers to inject the ConfigMap parameters as environment variables. - - - This is useful when application images accept parameters through environment variables and - generate the final configuration file in the startup script based on these variables. - - - This field allows users to specify a list of container names, and KubeBlocks will inject the environment - variables converted from the ConfigMap into these designated containers. This provides a flexible way to - pass the configuration items from the ConfigMap to the container without modifying the image. - - - Deprecated: `asEnvFrom` has been deprecated since 0.9.0 and will be removed in 0.10.0. - Use `injectEnvTo` instead. - items: - type: string - type: array - x-kubernetes-list-type: set - constraintRef: - description: Specifies the name of the referenced configuration - constraints object. - maxLength: 63 - pattern: ^[a-z0-9]([a-z0-9\.\-]*[a-z0-9])?$ - type: string - defaultMode: - description: |- - The operator attempts to set default file permissions for scripts (0555) and configurations (0444). - However, certain database engines may require different file permissions. - You can specify the desired file permissions here. - - - Must be specified as an octal value between 0000 and 0777 (inclusive), - or as a decimal value between 0 and 511 (inclusive). - YAML supports both octal and decimal values for file permissions. - - - Please note that this setting only affects the permissions of the files themselves. - Directories within the specified path are not impacted by this setting. - It's important to be aware that this setting might conflict with other options - that influence the file mode, such as fsGroup. - In such cases, the resulting file mode may have additional bits set. - Refers to documents of k8s.ConfigMapVolumeSource.defaultMode for more information. - format: int32 - type: integer - injectEnvTo: - description: |- - Specifies the containers to inject the ConfigMap parameters as environment variables. - - - This is useful when application images accept parameters through environment variables and - generate the final configuration file in the startup script based on these variables. - - - This field allows users to specify a list of container names, and KubeBlocks will inject the environment - variables converted from the ConfigMap into these designated containers. This provides a flexible way to - pass the configuration items from the ConfigMap to the container without modifying the image. - items: - type: string - type: array - x-kubernetes-list-type: set - keys: - description: |- - Specifies the configuration files within the ConfigMap that support dynamic updates. - - - A configuration template (provided in the form of a ConfigMap) may contain templates for multiple - configuration files. - Each configuration file corresponds to a key in the ConfigMap. - Some of these configuration files may support dynamic modification and reloading without requiring - a pod restart. - - - If empty or omitted, all configuration files in the ConfigMap are assumed to support dynamic updates, - and ConfigConstraint applies to all keys. - items: - type: string - type: array - x-kubernetes-list-type: set - legacyRenderedConfigSpec: - description: |- - Specifies the secondary rendered config spec for pod-specific customization. - - - The template is rendered inside the pod (by the "config-manager" sidecar container) and merged with the main - template's render result to generate the final configuration file. - - - This field is intended to handle scenarios where different pods within the same Component have - varying configurations. It allows for pod-specific customization of the configuration. - - - Note: This field will be deprecated in future versions, and the functionality will be moved to - `cluster.spec.componentSpecs[*].instances[*]`. - properties: - namespace: - default: default - description: |- - Specifies the namespace of the referenced configuration template ConfigMap object. - An empty namespace is equivalent to the "default" namespace. - maxLength: 63 - pattern: ^[a-z0-9]([a-z0-9\-]*[a-z0-9])?$ - type: string - policy: - default: none - description: Defines the strategy for merging externally - imported templates into component templates. - enum: - - patch - - replace - - none - type: string - templateRef: - description: Specifies the name of the referenced - configuration template ConfigMap object. - maxLength: 63 - pattern: ^[a-z0-9]([a-z0-9\.\-]*[a-z0-9])?$ - type: string - required: - - templateRef - type: object - name: - description: Specifies the name of the configuration template. - maxLength: 63 - pattern: ^[a-z0-9]([a-z0-9\.\-]*[a-z0-9])?$ - type: string - namespace: - default: default - description: |- - Specifies the namespace of the referenced configuration template ConfigMap object. - An empty namespace is equivalent to the "default" namespace. - maxLength: 63 - pattern: ^[a-z0-9]([a-z0-9\-]*[a-z0-9])?$ - type: string - reRenderResourceTypes: - description: |- - Specifies whether the configuration needs to be re-rendered after v-scale or h-scale operations to reflect changes. - - - In some scenarios, the configuration may need to be updated to reflect the changes in resource allocation - or cluster topology. Examples: - - - - Redis: adjust maxmemory after v-scale operation. - - MySQL: increase max connections after v-scale operation. - - Zookeeper: update zoo.cfg with new node addresses after h-scale operation. - items: - description: RerenderResourceType defines the resource - requirements for a component. - enum: - - vscale - - hscale - - tls - type: string - type: array - x-kubernetes-list-type: set - templateRef: - description: Specifies the name of the referenced configuration - template ConfigMap object. - maxLength: 63 - pattern: ^[a-z0-9]([a-z0-9\.\-]*[a-z0-9])?$ - type: string - volumeName: - description: |- - Refers to the volume name of PodTemplate. The configuration file produced through the configuration - template will be mounted to the corresponding volume. Must be a DNS_LABEL name. - The volume name must be defined in podSpec.containers[*].volumeMounts. - maxLength: 63 - pattern: ^[a-z]([a-z0-9\-]*[a-z0-9])?$ - type: string - required: - - name - - volumeName - type: object - type: array - x-kubernetes-list-map-keys: - - name - x-kubernetes-list-type: map - switchoverSpec: - description: |- - Defines the images for the component to perform a switchover. - This overrides the image and env attributes defined in clusterDefinition.spec.componentDefs.SwitchoverSpec.CommandExecutorEnvItem. - properties: - cmdExecutorConfig: - description: Represents the configuration for the command - executor. - properties: - env: - description: A list of environment variables that will - be injected into the command execution context. - items: - description: EnvVar represents an environment variable - present in a Container. - properties: - name: - description: Name of the environment variable. - Must be a C_IDENTIFIER. - type: string - value: - description: |- - Variable references $(VAR_NAME) are expanded - using the previously defined environment variables in the container and - any service environment variables. If a variable cannot be resolved, - the reference in the input string will be unchanged. Double $$ are reduced - to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. - "$$(VAR_NAME)" will produce the string literal "$(VAR_NAME)". - Escaped references will never be expanded, regardless of whether the variable - exists or not. - Defaults to "". - type: string - valueFrom: - description: Source for the environment variable's - value. Cannot be used if value is not empty. - properties: - configMapKeyRef: - description: Selects a key of a ConfigMap. - properties: - key: - description: The key to select. - type: string - name: - description: |- - Name of the referent. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid? - type: string - optional: - description: Specify whether the ConfigMap - or its key must be defined - type: boolean - required: - - key - type: object - x-kubernetes-map-type: atomic - fieldRef: - description: |- - Selects a field of the pod: supports metadata.name, metadata.namespace, `metadata.labels['']`, `metadata.annotations['']`, - spec.nodeName, spec.serviceAccountName, status.hostIP, status.podIP, status.podIPs. - properties: - apiVersion: - description: Version of the schema the - FieldPath is written in terms of, defaults - to "v1". - type: string - fieldPath: - description: Path of the field to select - in the specified API version. - type: string - required: - - fieldPath - type: object - x-kubernetes-map-type: atomic - resourceFieldRef: - description: |- - Selects a resource of the container: only resources limits and requests - (limits.cpu, limits.memory, limits.ephemeral-storage, requests.cpu, requests.memory and requests.ephemeral-storage) are currently supported. - properties: - containerName: - description: 'Container name: required - for volumes, optional for env vars' - type: string - divisor: - anyOf: - - type: integer - - type: string - description: Specifies the output format - of the exposed resources, defaults to - "1" - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - resource: - description: 'Required: resource to select' - type: string - required: - - resource - type: object - x-kubernetes-map-type: atomic - secretKeyRef: - description: Selects a key of a secret in - the pod's namespace - properties: - key: - description: The key of the secret to - select from. Must be a valid secret - key. - type: string - name: - description: |- - Name of the referent. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid? - type: string - optional: - description: Specify whether the Secret - or its key must be defined - type: boolean - required: - - key - type: object - x-kubernetes-map-type: atomic - type: object - required: - - name - type: object - type: array - x-kubernetes-preserve-unknown-fields: true - image: - description: Specifies the image used to execute the - command. - type: string - required: - - image - type: object - required: - - cmdExecutorConfig - type: object - systemAccountSpec: - description: |- - Defines the image for the component to connect to databases or engines. - This overrides the `image` and `env` attributes defined in clusterDefinition.spec.componentDefs.systemAccountSpec.cmdExecutorConfig. - To clear default environment settings, set systemAccountSpec.cmdExecutorConfig.env to an empty list. - properties: - cmdExecutorConfig: - description: Configures the method for obtaining the client - SDK and executing statements. - properties: - env: - description: A list of environment variables that will - be injected into the command execution context. - items: - description: EnvVar represents an environment variable - present in a Container. - properties: - name: - description: Name of the environment variable. - Must be a C_IDENTIFIER. - type: string - value: - description: |- - Variable references $(VAR_NAME) are expanded - using the previously defined environment variables in the container and - any service environment variables. If a variable cannot be resolved, - the reference in the input string will be unchanged. Double $$ are reduced - to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. - "$$(VAR_NAME)" will produce the string literal "$(VAR_NAME)". - Escaped references will never be expanded, regardless of whether the variable - exists or not. - Defaults to "". - type: string - valueFrom: - description: Source for the environment variable's - value. Cannot be used if value is not empty. - properties: - configMapKeyRef: - description: Selects a key of a ConfigMap. - properties: - key: - description: The key to select. - type: string - name: - description: |- - Name of the referent. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid? - type: string - optional: - description: Specify whether the ConfigMap - or its key must be defined - type: boolean - required: - - key - type: object - x-kubernetes-map-type: atomic - fieldRef: - description: |- - Selects a field of the pod: supports metadata.name, metadata.namespace, `metadata.labels['']`, `metadata.annotations['']`, - spec.nodeName, spec.serviceAccountName, status.hostIP, status.podIP, status.podIPs. - properties: - apiVersion: - description: Version of the schema the - FieldPath is written in terms of, defaults - to "v1". - type: string - fieldPath: - description: Path of the field to select - in the specified API version. - type: string - required: - - fieldPath - type: object - x-kubernetes-map-type: atomic - resourceFieldRef: - description: |- - Selects a resource of the container: only resources limits and requests - (limits.cpu, limits.memory, limits.ephemeral-storage, requests.cpu, requests.memory and requests.ephemeral-storage) are currently supported. - properties: - containerName: - description: 'Container name: required - for volumes, optional for env vars' - type: string - divisor: - anyOf: - - type: integer - - type: string - description: Specifies the output format - of the exposed resources, defaults to - "1" - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - resource: - description: 'Required: resource to select' - type: string - required: - - resource - type: object - x-kubernetes-map-type: atomic - secretKeyRef: - description: Selects a key of a secret in - the pod's namespace - properties: - key: - description: The key of the secret to - select from. Must be a valid secret - key. - type: string - name: - description: |- - Name of the referent. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid? - type: string - optional: - description: Specify whether the Secret - or its key must be defined - type: boolean - required: - - key - type: object - x-kubernetes-map-type: atomic - type: object - required: - - name - type: object - type: array - x-kubernetes-preserve-unknown-fields: true - image: - description: Specifies the image used to execute the - command. - type: string - required: - - image - type: object - required: - - cmdExecutorConfig - type: object - versionsContext: - description: |- - Defines the context for container images for component versions. - This value replaces the values in clusterDefinition.spec.componentDefs.podSpec.[initContainers | containers]. - properties: - containers: - description: |- - Provides override values for ClusterDefinition.spec.componentDefs.podSpec.containers. - Typically used in scenarios such as updating application container images. - items: - description: A single application container that you want - to run within a pod. - properties: - args: - description: |- - Arguments to the entrypoint. - The container image's CMD is used if this is not provided. - Variable references $(VAR_NAME) are expanded using the container's environment. If a variable - cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced - to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will - produce the string literal "$(VAR_NAME)". Escaped references will never be expanded, regardless - of whether the variable exists or not. Cannot be updated. - More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell - items: - type: string - type: array - command: - description: |- - Entrypoint array. Not executed within a shell. - The container image's ENTRYPOINT is used if this is not provided. - Variable references $(VAR_NAME) are expanded using the container's environment. If a variable - cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced - to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will - produce the string literal "$(VAR_NAME)". Escaped references will never be expanded, regardless - of whether the variable exists or not. Cannot be updated. - More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell - items: - type: string - type: array - env: - description: |- - List of environment variables to set in the container. - Cannot be updated. - items: - description: EnvVar represents an environment variable - present in a Container. - properties: - name: - description: Name of the environment variable. - Must be a C_IDENTIFIER. - type: string - value: - description: |- - Variable references $(VAR_NAME) are expanded - using the previously defined environment variables in the container and - any service environment variables. If a variable cannot be resolved, - the reference in the input string will be unchanged. Double $$ are reduced - to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. - "$$(VAR_NAME)" will produce the string literal "$(VAR_NAME)". - Escaped references will never be expanded, regardless of whether the variable - exists or not. - Defaults to "". - type: string - valueFrom: - description: Source for the environment variable's - value. Cannot be used if value is not empty. - properties: - configMapKeyRef: - description: Selects a key of a ConfigMap. - properties: - key: - description: The key to select. - type: string - name: - description: |- - Name of the referent. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid? - type: string - optional: - description: Specify whether the ConfigMap - or its key must be defined - type: boolean - required: - - key - type: object - x-kubernetes-map-type: atomic - fieldRef: - description: |- - Selects a field of the pod: supports metadata.name, metadata.namespace, `metadata.labels['']`, `metadata.annotations['']`, - spec.nodeName, spec.serviceAccountName, status.hostIP, status.podIP, status.podIPs. - properties: - apiVersion: - description: Version of the schema the - FieldPath is written in terms of, - defaults to "v1". - type: string - fieldPath: - description: Path of the field to select - in the specified API version. - type: string - required: - - fieldPath - type: object - x-kubernetes-map-type: atomic - resourceFieldRef: - description: |- - Selects a resource of the container: only resources limits and requests - (limits.cpu, limits.memory, limits.ephemeral-storage, requests.cpu, requests.memory and requests.ephemeral-storage) are currently supported. - properties: - containerName: - description: 'Container name: required - for volumes, optional for env vars' - type: string - divisor: - anyOf: - - type: integer - - type: string - description: Specifies the output format - of the exposed resources, defaults - to "1" - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - resource: - description: 'Required: resource to - select' - type: string - required: - - resource - type: object - x-kubernetes-map-type: atomic - secretKeyRef: - description: Selects a key of a secret in - the pod's namespace - properties: - key: - description: The key of the secret to - select from. Must be a valid secret - key. - type: string - name: - description: |- - Name of the referent. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid? - type: string - optional: - description: Specify whether the Secret - or its key must be defined - type: boolean - required: - - key - type: object - x-kubernetes-map-type: atomic - type: object - required: - - name - type: object - type: array - envFrom: - description: |- - List of sources to populate environment variables in the container. - The keys defined within a source must be a C_IDENTIFIER. All invalid keys - will be reported as an event when the container is starting. When a key exists in multiple - sources, the value associated with the last source will take precedence. - Values defined by an Env with a duplicate key will take precedence. - Cannot be updated. - items: - description: EnvFromSource represents the source - of a set of ConfigMaps - properties: - configMapRef: - description: The ConfigMap to select from - properties: - name: - description: |- - Name of the referent. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid? - type: string - optional: - description: Specify whether the ConfigMap - must be defined - type: boolean - type: object - x-kubernetes-map-type: atomic - prefix: - description: An optional identifier to prepend - to each key in the ConfigMap. Must be a C_IDENTIFIER. - type: string - secretRef: - description: The Secret to select from - properties: - name: - description: |- - Name of the referent. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid? - type: string - optional: - description: Specify whether the Secret - must be defined - type: boolean - type: object - x-kubernetes-map-type: atomic - type: object - type: array - image: - description: |- - Container image name. - More info: https://kubernetes.io/docs/concepts/containers/images - This field is optional to allow higher level config management to default or override - container images in workload controllers like Deployments and StatefulSets. - type: string - imagePullPolicy: - description: |- - Image pull policy. - One of Always, Never, IfNotPresent. - Defaults to Always if :latest tag is specified, or IfNotPresent otherwise. - Cannot be updated. - More info: https://kubernetes.io/docs/concepts/containers/images#updating-images - type: string - lifecycle: - description: |- - Actions that the management system should take in response to container lifecycle events. - Cannot be updated. - properties: - postStart: - description: |- - PostStart is called immediately after a container is created. If the handler fails, - the container is terminated and restarted according to its restart policy. - Other management of the container blocks until the hook completes. - More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks - properties: - exec: - description: Exec specifies the action to - take. - properties: - command: - description: |- - Command is the command line to execute inside the container, the working directory for the - command is root ('/') in the container's filesystem. The command is simply exec'd, it is - not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use - a shell, you need to explicitly call out to that shell. - Exit status of 0 is treated as live/healthy and non-zero is unhealthy. - items: - type: string - type: array - type: object - httpGet: - description: HTTPGet specifies the http request - to perform. - properties: - host: - description: |- - Host name to connect to, defaults to the pod IP. You probably want to set - "Host" in httpHeaders instead. - type: string - httpHeaders: - description: Custom headers to set in - the request. HTTP allows repeated headers. - items: - description: HTTPHeader describes a - custom header to be used in HTTP probes - properties: - name: - description: |- - The header field name. - This will be canonicalized upon output, so case-variant names will be understood as the same header. - type: string - value: - description: The header field value - type: string - required: - - name - - value - type: object - type: array - path: - description: Path to access on the HTTP - server. - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Name or number of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - scheme: - description: |- - Scheme to use for connecting to the host. - Defaults to HTTP. - type: string - required: - - port - type: object - tcpSocket: - description: |- - Deprecated. TCPSocket is NOT supported as a LifecycleHandler and kept - for the backward compatibility. There are no validation of this field and - lifecycle hooks will fail in runtime when tcp handler is specified. - properties: - host: - description: 'Optional: Host name to connect - to, defaults to the pod IP.' - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Number or name of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - required: - - port - type: object - type: object - preStop: - description: |- - PreStop is called immediately before a container is terminated due to an - API request or management event such as liveness/startup probe failure, - preemption, resource contention, etc. The handler is not called if the - container crashes or exits. The Pod's termination grace period countdown begins before the - PreStop hook is executed. Regardless of the outcome of the handler, the - container will eventually terminate within the Pod's termination grace - period (unless delayed by finalizers). Other management of the container blocks until the hook completes - or until the termination grace period is reached. - More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks - properties: - exec: - description: Exec specifies the action to - take. - properties: - command: - description: |- - Command is the command line to execute inside the container, the working directory for the - command is root ('/') in the container's filesystem. The command is simply exec'd, it is - not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use - a shell, you need to explicitly call out to that shell. - Exit status of 0 is treated as live/healthy and non-zero is unhealthy. - items: - type: string - type: array - type: object - httpGet: - description: HTTPGet specifies the http request - to perform. - properties: - host: - description: |- - Host name to connect to, defaults to the pod IP. You probably want to set - "Host" in httpHeaders instead. - type: string - httpHeaders: - description: Custom headers to set in - the request. HTTP allows repeated headers. - items: - description: HTTPHeader describes a - custom header to be used in HTTP probes - properties: - name: - description: |- - The header field name. - This will be canonicalized upon output, so case-variant names will be understood as the same header. - type: string - value: - description: The header field value - type: string - required: - - name - - value - type: object - type: array - path: - description: Path to access on the HTTP - server. - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Name or number of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - scheme: - description: |- - Scheme to use for connecting to the host. - Defaults to HTTP. - type: string - required: - - port - type: object - tcpSocket: - description: |- - Deprecated. TCPSocket is NOT supported as a LifecycleHandler and kept - for the backward compatibility. There are no validation of this field and - lifecycle hooks will fail in runtime when tcp handler is specified. - properties: - host: - description: 'Optional: Host name to connect - to, defaults to the pod IP.' - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Number or name of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - required: - - port - type: object - type: object - type: object - livenessProbe: - description: |- - Periodic probe of container liveness. - Container will be restarted if the probe fails. - Cannot be updated. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - properties: - exec: - description: Exec specifies the action to take. - properties: - command: - description: |- - Command is the command line to execute inside the container, the working directory for the - command is root ('/') in the container's filesystem. The command is simply exec'd, it is - not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use - a shell, you need to explicitly call out to that shell. - Exit status of 0 is treated as live/healthy and non-zero is unhealthy. - items: - type: string - type: array - type: object - failureThreshold: - description: |- - Minimum consecutive failures for the probe to be considered failed after having succeeded. - Defaults to 3. Minimum value is 1. - format: int32 - type: integer - grpc: - description: GRPC specifies an action involving - a GRPC port. - properties: - port: - description: Port number of the gRPC service. - Number must be in the range 1 to 65535. - format: int32 - type: integer - service: - description: |- - Service is the name of the service to place in the gRPC HealthCheckRequest - (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). - - - If this is not specified, the default behavior is defined by gRPC. - type: string - required: - - port - type: object - httpGet: - description: HTTPGet specifies the http request - to perform. - properties: - host: - description: |- - Host name to connect to, defaults to the pod IP. You probably want to set - "Host" in httpHeaders instead. - type: string - httpHeaders: - description: Custom headers to set in the - request. HTTP allows repeated headers. - items: - description: HTTPHeader describes a custom - header to be used in HTTP probes - properties: - name: - description: |- - The header field name. - This will be canonicalized upon output, so case-variant names will be understood as the same header. - type: string - value: - description: The header field value - type: string - required: - - name - - value - type: object - type: array - path: - description: Path to access on the HTTP server. - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Name or number of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - scheme: - description: |- - Scheme to use for connecting to the host. - Defaults to HTTP. - type: string - required: - - port - type: object - initialDelaySeconds: - description: |- - Number of seconds after the container has started before liveness probes are initiated. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - format: int32 - type: integer - periodSeconds: - description: |- - How often (in seconds) to perform the probe. - Default to 10 seconds. Minimum value is 1. - format: int32 - type: integer - successThreshold: - description: |- - Minimum consecutive successes for the probe to be considered successful after having failed. - Defaults to 1. Must be 1 for liveness and startup. Minimum value is 1. - format: int32 - type: integer - tcpSocket: - description: TCPSocket specifies an action involving - a TCP port. - properties: - host: - description: 'Optional: Host name to connect - to, defaults to the pod IP.' - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Number or name of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - required: - - port - type: object - terminationGracePeriodSeconds: - description: |- - Optional duration in seconds the pod needs to terminate gracefully upon probe failure. - The grace period is the duration in seconds after the processes running in the pod are sent - a termination signal and the time when the processes are forcibly halted with a kill signal. - Set this value longer than the expected cleanup time for your process. - If this value is nil, the pod's terminationGracePeriodSeconds will be used. Otherwise, this - value overrides the value provided by the pod spec. - Value must be non-negative integer. The value zero indicates stop immediately via - the kill signal (no opportunity to shut down). - This is a beta field and requires enabling ProbeTerminationGracePeriod feature gate. - Minimum value is 1. spec.terminationGracePeriodSeconds is used if unset. - format: int64 - type: integer - timeoutSeconds: - description: |- - Number of seconds after which the probe times out. - Defaults to 1 second. Minimum value is 1. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - format: int32 - type: integer - type: object - name: - description: |- - Name of the container specified as a DNS_LABEL. - Each container in a pod must have a unique name (DNS_LABEL). - Cannot be updated. - type: string - ports: - description: |- - List of ports to expose from the container. Not specifying a port here - DOES NOT prevent that port from being exposed. Any port which is - listening on the default "0.0.0.0" address inside a container will be - accessible from the network. - Modifying this array with strategic merge patch may corrupt the data. - For more information See https://github.com/kubernetes/kubernetes/issues/108255. - Cannot be updated. - items: - description: ContainerPort represents a network - port in a single container. - properties: - containerPort: - description: |- - Number of port to expose on the pod's IP address. - This must be a valid port number, 0 < x < 65536. - format: int32 - type: integer - hostIP: - description: What host IP to bind the external - port to. - type: string - hostPort: - description: |- - Number of port to expose on the host. - If specified, this must be a valid port number, 0 < x < 65536. - If HostNetwork is specified, this must match ContainerPort. - Most containers do not need this. - format: int32 - type: integer - name: - description: |- - If specified, this must be an IANA_SVC_NAME and unique within the pod. Each - named port in a pod must have a unique name. Name for the port that can be - referred to by services. - type: string - protocol: - default: TCP - description: |- - Protocol for port. Must be UDP, TCP, or SCTP. - Defaults to "TCP". - type: string - required: - - containerPort - type: object - type: array - x-kubernetes-list-map-keys: - - containerPort - - protocol - x-kubernetes-list-type: map - readinessProbe: - description: |- - Periodic probe of container service readiness. - Container will be removed from service endpoints if the probe fails. - Cannot be updated. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - properties: - exec: - description: Exec specifies the action to take. - properties: - command: - description: |- - Command is the command line to execute inside the container, the working directory for the - command is root ('/') in the container's filesystem. The command is simply exec'd, it is - not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use - a shell, you need to explicitly call out to that shell. - Exit status of 0 is treated as live/healthy and non-zero is unhealthy. - items: - type: string - type: array - type: object - failureThreshold: - description: |- - Minimum consecutive failures for the probe to be considered failed after having succeeded. - Defaults to 3. Minimum value is 1. - format: int32 - type: integer - grpc: - description: GRPC specifies an action involving - a GRPC port. - properties: - port: - description: Port number of the gRPC service. - Number must be in the range 1 to 65535. - format: int32 - type: integer - service: - description: |- - Service is the name of the service to place in the gRPC HealthCheckRequest - (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). - - - If this is not specified, the default behavior is defined by gRPC. - type: string - required: - - port - type: object - httpGet: - description: HTTPGet specifies the http request - to perform. - properties: - host: - description: |- - Host name to connect to, defaults to the pod IP. You probably want to set - "Host" in httpHeaders instead. - type: string - httpHeaders: - description: Custom headers to set in the - request. HTTP allows repeated headers. - items: - description: HTTPHeader describes a custom - header to be used in HTTP probes - properties: - name: - description: |- - The header field name. - This will be canonicalized upon output, so case-variant names will be understood as the same header. - type: string - value: - description: The header field value - type: string - required: - - name - - value - type: object - type: array - path: - description: Path to access on the HTTP server. - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Name or number of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - scheme: - description: |- - Scheme to use for connecting to the host. - Defaults to HTTP. - type: string - required: - - port - type: object - initialDelaySeconds: - description: |- - Number of seconds after the container has started before liveness probes are initiated. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - format: int32 - type: integer - periodSeconds: - description: |- - How often (in seconds) to perform the probe. - Default to 10 seconds. Minimum value is 1. - format: int32 - type: integer - successThreshold: - description: |- - Minimum consecutive successes for the probe to be considered successful after having failed. - Defaults to 1. Must be 1 for liveness and startup. Minimum value is 1. - format: int32 - type: integer - tcpSocket: - description: TCPSocket specifies an action involving - a TCP port. - properties: - host: - description: 'Optional: Host name to connect - to, defaults to the pod IP.' - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Number or name of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - required: - - port - type: object - terminationGracePeriodSeconds: - description: |- - Optional duration in seconds the pod needs to terminate gracefully upon probe failure. - The grace period is the duration in seconds after the processes running in the pod are sent - a termination signal and the time when the processes are forcibly halted with a kill signal. - Set this value longer than the expected cleanup time for your process. - If this value is nil, the pod's terminationGracePeriodSeconds will be used. Otherwise, this - value overrides the value provided by the pod spec. - Value must be non-negative integer. The value zero indicates stop immediately via - the kill signal (no opportunity to shut down). - This is a beta field and requires enabling ProbeTerminationGracePeriod feature gate. - Minimum value is 1. spec.terminationGracePeriodSeconds is used if unset. - format: int64 - type: integer - timeoutSeconds: - description: |- - Number of seconds after which the probe times out. - Defaults to 1 second. Minimum value is 1. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - format: int32 - type: integer - type: object - resizePolicy: - description: Resources resize policy for the container. - items: - description: ContainerResizePolicy represents resource - resize policy for the container. - properties: - resourceName: - description: |- - Name of the resource to which this resource resize policy applies. - Supported values: cpu, memory. - type: string - restartPolicy: - description: |- - Restart policy to apply when specified resource is resized. - If not specified, it defaults to NotRequired. - type: string - required: - - resourceName - - restartPolicy - type: object - type: array - x-kubernetes-list-type: atomic - resources: - description: |- - Compute Resources required by this container. - Cannot be updated. - More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ - properties: - claims: - description: |- - Claims lists the names of resources, defined in spec.resourceClaims, - that are used by this container. - - - This is an alpha field and requires enabling the - DynamicResourceAllocation feature gate. - - - This field is immutable. It can only be set for containers. - items: - description: ResourceClaim references one entry - in PodSpec.ResourceClaims. - properties: - name: - description: |- - Name must match the name of one entry in pod.spec.resourceClaims of - the Pod where this field is used. It makes that resource available - inside a container. - type: string - required: - - name - type: object - type: array - x-kubernetes-list-map-keys: - - name - x-kubernetes-list-type: map - limits: - additionalProperties: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - description: |- - Limits describes the maximum amount of compute resources allowed. - More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ - type: object - requests: - additionalProperties: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - description: |- - Requests describes the minimum amount of compute resources required. - If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, - otherwise to an implementation-defined value. Requests cannot exceed Limits. - More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ - type: object - type: object - restartPolicy: - description: |- - RestartPolicy defines the restart behavior of individual containers in a pod. - This field may only be set for init containers, and the only allowed value is "Always". - For non-init containers or when this field is not specified, - the restart behavior is defined by the Pod's restart policy and the container type. - Setting the RestartPolicy as "Always" for the init container will have the following effect: - this init container will be continually restarted on - exit until all regular containers have terminated. Once all regular - containers have completed, all init containers with restartPolicy "Always" - will be shut down. This lifecycle differs from normal init containers and - is often referred to as a "sidecar" container. Although this init - container still starts in the init container sequence, it does not wait - for the container to complete before proceeding to the next init - container. Instead, the next init container starts immediately after this - init container is started, or after any startupProbe has successfully - completed. - type: string - securityContext: - description: |- - SecurityContext defines the security options the container should be run with. - If set, the fields of SecurityContext override the equivalent fields of PodSecurityContext. - More info: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/ - properties: - allowPrivilegeEscalation: - description: |- - AllowPrivilegeEscalation controls whether a process can gain more - privileges than its parent process. This bool directly controls if - the no_new_privs flag will be set on the container process. - AllowPrivilegeEscalation is true always when the container is: - 1) run as Privileged - 2) has CAP_SYS_ADMIN - Note that this field cannot be set when spec.os.name is windows. - type: boolean - capabilities: - description: |- - The capabilities to add/drop when running containers. - Defaults to the default set of capabilities granted by the container runtime. - Note that this field cannot be set when spec.os.name is windows. - properties: - add: - description: Added capabilities - items: - description: Capability represent POSIX - capabilities type - type: string - type: array - drop: - description: Removed capabilities - items: - description: Capability represent POSIX - capabilities type - type: string - type: array - type: object - privileged: - description: |- - Run container in privileged mode. - Processes in privileged containers are essentially equivalent to root on the host. - Defaults to false. - Note that this field cannot be set when spec.os.name is windows. - type: boolean - procMount: - description: |- - procMount denotes the type of proc mount to use for the containers. - The default is DefaultProcMount which uses the container runtime defaults for - readonly paths and masked paths. - This requires the ProcMountType feature flag to be enabled. - Note that this field cannot be set when spec.os.name is windows. - type: string - readOnlyRootFilesystem: - description: |- - Whether this container has a read-only root filesystem. - Default is false. - Note that this field cannot be set when spec.os.name is windows. - type: boolean - runAsGroup: - description: |- - The GID to run the entrypoint of the container process. - Uses runtime default if unset. - May also be set in PodSecurityContext. If set in both SecurityContext and - PodSecurityContext, the value specified in SecurityContext takes precedence. - Note that this field cannot be set when spec.os.name is windows. - format: int64 - type: integer - runAsNonRoot: - description: |- - Indicates that the container must run as a non-root user. - If true, the Kubelet will validate the image at runtime to ensure that it - does not run as UID 0 (root) and fail to start the container if it does. - If unset or false, no such validation will be performed. - May also be set in PodSecurityContext. If set in both SecurityContext and - PodSecurityContext, the value specified in SecurityContext takes precedence. - type: boolean - runAsUser: - description: |- - The UID to run the entrypoint of the container process. - Defaults to user specified in image metadata if unspecified. - May also be set in PodSecurityContext. If set in both SecurityContext and - PodSecurityContext, the value specified in SecurityContext takes precedence. - Note that this field cannot be set when spec.os.name is windows. - format: int64 - type: integer - seLinuxOptions: - description: |- - The SELinux context to be applied to the container. - If unspecified, the container runtime will allocate a random SELinux context for each - container. May also be set in PodSecurityContext. If set in both SecurityContext and - PodSecurityContext, the value specified in SecurityContext takes precedence. - Note that this field cannot be set when spec.os.name is windows. - properties: - level: - description: Level is SELinux level label - that applies to the container. - type: string - role: - description: Role is a SELinux role label - that applies to the container. - type: string - type: - description: Type is a SELinux type label - that applies to the container. - type: string - user: - description: User is a SELinux user label - that applies to the container. - type: string - type: object - seccompProfile: - description: |- - The seccomp options to use by this container. If seccomp options are - provided at both the pod & container level, the container options - override the pod options. - Note that this field cannot be set when spec.os.name is windows. - properties: - localhostProfile: - description: |- - localhostProfile indicates a profile defined in a file on the node should be used. - The profile must be preconfigured on the node to work. - Must be a descending path, relative to the kubelet's configured seccomp profile location. - Must be set if type is "Localhost". Must NOT be set for any other type. - type: string - type: - description: |- - type indicates which kind of seccomp profile will be applied. - Valid options are: - - - Localhost - a profile defined in a file on the node should be used. - RuntimeDefault - the container runtime default profile should be used. - Unconfined - no profile should be applied. - type: string - required: - - type - type: object - windowsOptions: - description: |- - The Windows specific settings applied to all containers. - If unspecified, the options from the PodSecurityContext will be used. - If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence. - Note that this field cannot be set when spec.os.name is linux. - properties: - gmsaCredentialSpec: - description: |- - GMSACredentialSpec is where the GMSA admission webhook - (https://github.com/kubernetes-sigs/windows-gmsa) inlines the contents of the - GMSA credential spec named by the GMSACredentialSpecName field. - type: string - gmsaCredentialSpecName: - description: GMSACredentialSpecName is the - name of the GMSA credential spec to use. - type: string - hostProcess: - description: |- - HostProcess determines if a container should be run as a 'Host Process' container. - All of a Pod's containers must have the same effective HostProcess value - (it is not allowed to have a mix of HostProcess containers and non-HostProcess containers). - In addition, if HostProcess is true then HostNetwork must also be set to true. - type: boolean - runAsUserName: - description: |- - The UserName in Windows to run the entrypoint of the container process. - Defaults to the user specified in image metadata if unspecified. - May also be set in PodSecurityContext. If set in both SecurityContext and - PodSecurityContext, the value specified in SecurityContext takes precedence. - type: string - type: object - type: object - startupProbe: - description: |- - StartupProbe indicates that the Pod has successfully initialized. - If specified, no other probes are executed until this completes successfully. - If this probe fails, the Pod will be restarted, just as if the livenessProbe failed. - This can be used to provide different probe parameters at the beginning of a Pod's lifecycle, - when it might take a long time to load data or warm a cache, than during steady-state operation. - This cannot be updated. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - properties: - exec: - description: Exec specifies the action to take. - properties: - command: - description: |- - Command is the command line to execute inside the container, the working directory for the - command is root ('/') in the container's filesystem. The command is simply exec'd, it is - not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use - a shell, you need to explicitly call out to that shell. - Exit status of 0 is treated as live/healthy and non-zero is unhealthy. - items: - type: string - type: array - type: object - failureThreshold: - description: |- - Minimum consecutive failures for the probe to be considered failed after having succeeded. - Defaults to 3. Minimum value is 1. - format: int32 - type: integer - grpc: - description: GRPC specifies an action involving - a GRPC port. - properties: - port: - description: Port number of the gRPC service. - Number must be in the range 1 to 65535. - format: int32 - type: integer - service: - description: |- - Service is the name of the service to place in the gRPC HealthCheckRequest - (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). - - - If this is not specified, the default behavior is defined by gRPC. - type: string - required: - - port - type: object - httpGet: - description: HTTPGet specifies the http request - to perform. - properties: - host: - description: |- - Host name to connect to, defaults to the pod IP. You probably want to set - "Host" in httpHeaders instead. - type: string - httpHeaders: - description: Custom headers to set in the - request. HTTP allows repeated headers. - items: - description: HTTPHeader describes a custom - header to be used in HTTP probes - properties: - name: - description: |- - The header field name. - This will be canonicalized upon output, so case-variant names will be understood as the same header. - type: string - value: - description: The header field value - type: string - required: - - name - - value - type: object - type: array - path: - description: Path to access on the HTTP server. - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Name or number of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - scheme: - description: |- - Scheme to use for connecting to the host. - Defaults to HTTP. - type: string - required: - - port - type: object - initialDelaySeconds: - description: |- - Number of seconds after the container has started before liveness probes are initiated. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - format: int32 - type: integer - periodSeconds: - description: |- - How often (in seconds) to perform the probe. - Default to 10 seconds. Minimum value is 1. - format: int32 - type: integer - successThreshold: - description: |- - Minimum consecutive successes for the probe to be considered successful after having failed. - Defaults to 1. Must be 1 for liveness and startup. Minimum value is 1. - format: int32 - type: integer - tcpSocket: - description: TCPSocket specifies an action involving - a TCP port. - properties: - host: - description: 'Optional: Host name to connect - to, defaults to the pod IP.' - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Number or name of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - required: - - port - type: object - terminationGracePeriodSeconds: - description: |- - Optional duration in seconds the pod needs to terminate gracefully upon probe failure. - The grace period is the duration in seconds after the processes running in the pod are sent - a termination signal and the time when the processes are forcibly halted with a kill signal. - Set this value longer than the expected cleanup time for your process. - If this value is nil, the pod's terminationGracePeriodSeconds will be used. Otherwise, this - value overrides the value provided by the pod spec. - Value must be non-negative integer. The value zero indicates stop immediately via - the kill signal (no opportunity to shut down). - This is a beta field and requires enabling ProbeTerminationGracePeriod feature gate. - Minimum value is 1. spec.terminationGracePeriodSeconds is used if unset. - format: int64 - type: integer - timeoutSeconds: - description: |- - Number of seconds after which the probe times out. - Defaults to 1 second. Minimum value is 1. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - format: int32 - type: integer - type: object - stdin: - description: |- - Whether this container should allocate a buffer for stdin in the container runtime. If this - is not set, reads from stdin in the container will always result in EOF. - Default is false. - type: boolean - stdinOnce: - description: |- - Whether the container runtime should close the stdin channel after it has been opened by - a single attach. When stdin is true the stdin stream will remain open across multiple attach - sessions. If stdinOnce is set to true, stdin is opened on container start, is empty until the - first client attaches to stdin, and then remains open and accepts data until the client disconnects, - at which time stdin is closed and remains closed until the container is restarted. If this - flag is false, a container processes that reads from stdin will never receive an EOF. - Default is false - type: boolean - terminationMessagePath: - description: |- - Optional: Path at which the file to which the container's termination message - will be written is mounted into the container's filesystem. - Message written is intended to be brief final status, such as an assertion failure message. - Will be truncated by the node if greater than 4096 bytes. The total message length across - all containers will be limited to 12kb. - Defaults to /dev/termination-log. - Cannot be updated. - type: string - terminationMessagePolicy: - description: |- - Indicate how the termination message should be populated. File will use the contents of - terminationMessagePath to populate the container status message on both success and failure. - FallbackToLogsOnError will use the last chunk of container log output if the termination - message file is empty and the container exited with an error. - The log output is limited to 2048 bytes or 80 lines, whichever is smaller. - Defaults to File. - Cannot be updated. - type: string - tty: - description: |- - Whether this container should allocate a TTY for itself, also requires 'stdin' to be true. - Default is false. - type: boolean - volumeDevices: - description: volumeDevices is the list of block devices - to be used by the container. - items: - description: volumeDevice describes a mapping of - a raw block device within a container. - properties: - devicePath: - description: devicePath is the path inside of - the container that the device will be mapped - to. - type: string - name: - description: name must match the name of a persistentVolumeClaim - in the pod - type: string - required: - - devicePath - - name - type: object - type: array - volumeMounts: - description: |- - Pod volumes to mount into the container's filesystem. - Cannot be updated. - items: - description: VolumeMount describes a mounting of - a Volume within a container. - properties: - mountPath: - description: |- - Path within the container at which the volume should be mounted. Must - not contain ':'. - type: string - mountPropagation: - description: |- - mountPropagation determines how mounts are propagated from the host - to container and the other way around. - When not set, MountPropagationNone is used. - This field is beta in 1.10. - type: string - name: - description: This must match the Name of a Volume. - type: string - readOnly: - description: |- - Mounted read-only if true, read-write otherwise (false or unspecified). - Defaults to false. - type: boolean - subPath: - description: |- - Path within the volume from which the container's volume should be mounted. - Defaults to "" (volume's root). - type: string - subPathExpr: - description: |- - Expanded path within the volume from which the container's volume should be mounted. - Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. - Defaults to "" (volume's root). - SubPathExpr and SubPath are mutually exclusive. - type: string - required: - - mountPath - - name - type: object - type: array - workingDir: - description: |- - Container's working directory. - If not specified, the container runtime's default will be used, which - might be configured in the container image. - Cannot be updated. - type: string - required: - - name - type: object - type: array - x-kubernetes-list-map-keys: - - name - x-kubernetes-list-type: map - x-kubernetes-preserve-unknown-fields: true - initContainers: - description: |- - Provides override values for ClusterDefinition.spec.componentDefs.podSpec.initContainers. - Typically used in scenarios such as updating application container images. - items: - description: A single application container that you want - to run within a pod. - properties: - args: - description: |- - Arguments to the entrypoint. - The container image's CMD is used if this is not provided. - Variable references $(VAR_NAME) are expanded using the container's environment. If a variable - cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced - to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will - produce the string literal "$(VAR_NAME)". Escaped references will never be expanded, regardless - of whether the variable exists or not. Cannot be updated. - More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell - items: - type: string - type: array - command: - description: |- - Entrypoint array. Not executed within a shell. - The container image's ENTRYPOINT is used if this is not provided. - Variable references $(VAR_NAME) are expanded using the container's environment. If a variable - cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced - to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will - produce the string literal "$(VAR_NAME)". Escaped references will never be expanded, regardless - of whether the variable exists or not. Cannot be updated. - More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell - items: - type: string - type: array - env: - description: |- - List of environment variables to set in the container. - Cannot be updated. - items: - description: EnvVar represents an environment variable - present in a Container. - properties: - name: - description: Name of the environment variable. - Must be a C_IDENTIFIER. - type: string - value: - description: |- - Variable references $(VAR_NAME) are expanded - using the previously defined environment variables in the container and - any service environment variables. If a variable cannot be resolved, - the reference in the input string will be unchanged. Double $$ are reduced - to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. - "$$(VAR_NAME)" will produce the string literal "$(VAR_NAME)". - Escaped references will never be expanded, regardless of whether the variable - exists or not. - Defaults to "". - type: string - valueFrom: - description: Source for the environment variable's - value. Cannot be used if value is not empty. - properties: - configMapKeyRef: - description: Selects a key of a ConfigMap. - properties: - key: - description: The key to select. - type: string - name: - description: |- - Name of the referent. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid? - type: string - optional: - description: Specify whether the ConfigMap - or its key must be defined - type: boolean - required: - - key - type: object - x-kubernetes-map-type: atomic - fieldRef: - description: |- - Selects a field of the pod: supports metadata.name, metadata.namespace, `metadata.labels['']`, `metadata.annotations['']`, - spec.nodeName, spec.serviceAccountName, status.hostIP, status.podIP, status.podIPs. - properties: - apiVersion: - description: Version of the schema the - FieldPath is written in terms of, - defaults to "v1". - type: string - fieldPath: - description: Path of the field to select - in the specified API version. - type: string - required: - - fieldPath - type: object - x-kubernetes-map-type: atomic - resourceFieldRef: - description: |- - Selects a resource of the container: only resources limits and requests - (limits.cpu, limits.memory, limits.ephemeral-storage, requests.cpu, requests.memory and requests.ephemeral-storage) are currently supported. - properties: - containerName: - description: 'Container name: required - for volumes, optional for env vars' - type: string - divisor: - anyOf: - - type: integer - - type: string - description: Specifies the output format - of the exposed resources, defaults - to "1" - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - resource: - description: 'Required: resource to - select' - type: string - required: - - resource - type: object - x-kubernetes-map-type: atomic - secretKeyRef: - description: Selects a key of a secret in - the pod's namespace - properties: - key: - description: The key of the secret to - select from. Must be a valid secret - key. - type: string - name: - description: |- - Name of the referent. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid? - type: string - optional: - description: Specify whether the Secret - or its key must be defined - type: boolean - required: - - key - type: object - x-kubernetes-map-type: atomic - type: object - required: - - name - type: object - type: array - envFrom: - description: |- - List of sources to populate environment variables in the container. - The keys defined within a source must be a C_IDENTIFIER. All invalid keys - will be reported as an event when the container is starting. When a key exists in multiple - sources, the value associated with the last source will take precedence. - Values defined by an Env with a duplicate key will take precedence. - Cannot be updated. - items: - description: EnvFromSource represents the source - of a set of ConfigMaps - properties: - configMapRef: - description: The ConfigMap to select from - properties: - name: - description: |- - Name of the referent. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid? - type: string - optional: - description: Specify whether the ConfigMap - must be defined - type: boolean - type: object - x-kubernetes-map-type: atomic - prefix: - description: An optional identifier to prepend - to each key in the ConfigMap. Must be a C_IDENTIFIER. - type: string - secretRef: - description: The Secret to select from - properties: - name: - description: |- - Name of the referent. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid? - type: string - optional: - description: Specify whether the Secret - must be defined - type: boolean - type: object - x-kubernetes-map-type: atomic - type: object - type: array - image: - description: |- - Container image name. - More info: https://kubernetes.io/docs/concepts/containers/images - This field is optional to allow higher level config management to default or override - container images in workload controllers like Deployments and StatefulSets. - type: string - imagePullPolicy: - description: |- - Image pull policy. - One of Always, Never, IfNotPresent. - Defaults to Always if :latest tag is specified, or IfNotPresent otherwise. - Cannot be updated. - More info: https://kubernetes.io/docs/concepts/containers/images#updating-images - type: string - lifecycle: - description: |- - Actions that the management system should take in response to container lifecycle events. - Cannot be updated. - properties: - postStart: - description: |- - PostStart is called immediately after a container is created. If the handler fails, - the container is terminated and restarted according to its restart policy. - Other management of the container blocks until the hook completes. - More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks - properties: - exec: - description: Exec specifies the action to - take. - properties: - command: - description: |- - Command is the command line to execute inside the container, the working directory for the - command is root ('/') in the container's filesystem. The command is simply exec'd, it is - not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use - a shell, you need to explicitly call out to that shell. - Exit status of 0 is treated as live/healthy and non-zero is unhealthy. - items: - type: string - type: array - type: object - httpGet: - description: HTTPGet specifies the http request - to perform. - properties: - host: - description: |- - Host name to connect to, defaults to the pod IP. You probably want to set - "Host" in httpHeaders instead. - type: string - httpHeaders: - description: Custom headers to set in - the request. HTTP allows repeated headers. - items: - description: HTTPHeader describes a - custom header to be used in HTTP probes - properties: - name: - description: |- - The header field name. - This will be canonicalized upon output, so case-variant names will be understood as the same header. - type: string - value: - description: The header field value - type: string - required: - - name - - value - type: object - type: array - path: - description: Path to access on the HTTP - server. - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Name or number of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - scheme: - description: |- - Scheme to use for connecting to the host. - Defaults to HTTP. - type: string - required: - - port - type: object - tcpSocket: - description: |- - Deprecated. TCPSocket is NOT supported as a LifecycleHandler and kept - for the backward compatibility. There are no validation of this field and - lifecycle hooks will fail in runtime when tcp handler is specified. - properties: - host: - description: 'Optional: Host name to connect - to, defaults to the pod IP.' - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Number or name of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - required: - - port - type: object - type: object - preStop: - description: |- - PreStop is called immediately before a container is terminated due to an - API request or management event such as liveness/startup probe failure, - preemption, resource contention, etc. The handler is not called if the - container crashes or exits. The Pod's termination grace period countdown begins before the - PreStop hook is executed. Regardless of the outcome of the handler, the - container will eventually terminate within the Pod's termination grace - period (unless delayed by finalizers). Other management of the container blocks until the hook completes - or until the termination grace period is reached. - More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks - properties: - exec: - description: Exec specifies the action to - take. - properties: - command: - description: |- - Command is the command line to execute inside the container, the working directory for the - command is root ('/') in the container's filesystem. The command is simply exec'd, it is - not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use - a shell, you need to explicitly call out to that shell. - Exit status of 0 is treated as live/healthy and non-zero is unhealthy. - items: - type: string - type: array - type: object - httpGet: - description: HTTPGet specifies the http request - to perform. - properties: - host: - description: |- - Host name to connect to, defaults to the pod IP. You probably want to set - "Host" in httpHeaders instead. - type: string - httpHeaders: - description: Custom headers to set in - the request. HTTP allows repeated headers. - items: - description: HTTPHeader describes a - custom header to be used in HTTP probes - properties: - name: - description: |- - The header field name. - This will be canonicalized upon output, so case-variant names will be understood as the same header. - type: string - value: - description: The header field value - type: string - required: - - name - - value - type: object - type: array - path: - description: Path to access on the HTTP - server. - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Name or number of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - scheme: - description: |- - Scheme to use for connecting to the host. - Defaults to HTTP. - type: string - required: - - port - type: object - tcpSocket: - description: |- - Deprecated. TCPSocket is NOT supported as a LifecycleHandler and kept - for the backward compatibility. There are no validation of this field and - lifecycle hooks will fail in runtime when tcp handler is specified. - properties: - host: - description: 'Optional: Host name to connect - to, defaults to the pod IP.' - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Number or name of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - required: - - port - type: object - type: object - type: object - livenessProbe: - description: |- - Periodic probe of container liveness. - Container will be restarted if the probe fails. - Cannot be updated. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - properties: - exec: - description: Exec specifies the action to take. - properties: - command: - description: |- - Command is the command line to execute inside the container, the working directory for the - command is root ('/') in the container's filesystem. The command is simply exec'd, it is - not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use - a shell, you need to explicitly call out to that shell. - Exit status of 0 is treated as live/healthy and non-zero is unhealthy. - items: - type: string - type: array - type: object - failureThreshold: - description: |- - Minimum consecutive failures for the probe to be considered failed after having succeeded. - Defaults to 3. Minimum value is 1. - format: int32 - type: integer - grpc: - description: GRPC specifies an action involving - a GRPC port. - properties: - port: - description: Port number of the gRPC service. - Number must be in the range 1 to 65535. - format: int32 - type: integer - service: - description: |- - Service is the name of the service to place in the gRPC HealthCheckRequest - (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). - - - If this is not specified, the default behavior is defined by gRPC. - type: string - required: - - port - type: object - httpGet: - description: HTTPGet specifies the http request - to perform. - properties: - host: - description: |- - Host name to connect to, defaults to the pod IP. You probably want to set - "Host" in httpHeaders instead. - type: string - httpHeaders: - description: Custom headers to set in the - request. HTTP allows repeated headers. - items: - description: HTTPHeader describes a custom - header to be used in HTTP probes - properties: - name: - description: |- - The header field name. - This will be canonicalized upon output, so case-variant names will be understood as the same header. - type: string - value: - description: The header field value - type: string - required: - - name - - value - type: object - type: array - path: - description: Path to access on the HTTP server. - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Name or number of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - scheme: - description: |- - Scheme to use for connecting to the host. - Defaults to HTTP. - type: string - required: - - port - type: object - initialDelaySeconds: - description: |- - Number of seconds after the container has started before liveness probes are initiated. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - format: int32 - type: integer - periodSeconds: - description: |- - How often (in seconds) to perform the probe. - Default to 10 seconds. Minimum value is 1. - format: int32 - type: integer - successThreshold: - description: |- - Minimum consecutive successes for the probe to be considered successful after having failed. - Defaults to 1. Must be 1 for liveness and startup. Minimum value is 1. - format: int32 - type: integer - tcpSocket: - description: TCPSocket specifies an action involving - a TCP port. - properties: - host: - description: 'Optional: Host name to connect - to, defaults to the pod IP.' - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Number or name of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - required: - - port - type: object - terminationGracePeriodSeconds: - description: |- - Optional duration in seconds the pod needs to terminate gracefully upon probe failure. - The grace period is the duration in seconds after the processes running in the pod are sent - a termination signal and the time when the processes are forcibly halted with a kill signal. - Set this value longer than the expected cleanup time for your process. - If this value is nil, the pod's terminationGracePeriodSeconds will be used. Otherwise, this - value overrides the value provided by the pod spec. - Value must be non-negative integer. The value zero indicates stop immediately via - the kill signal (no opportunity to shut down). - This is a beta field and requires enabling ProbeTerminationGracePeriod feature gate. - Minimum value is 1. spec.terminationGracePeriodSeconds is used if unset. - format: int64 - type: integer - timeoutSeconds: - description: |- - Number of seconds after which the probe times out. - Defaults to 1 second. Minimum value is 1. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - format: int32 - type: integer - type: object - name: - description: |- - Name of the container specified as a DNS_LABEL. - Each container in a pod must have a unique name (DNS_LABEL). - Cannot be updated. - type: string - ports: - description: |- - List of ports to expose from the container. Not specifying a port here - DOES NOT prevent that port from being exposed. Any port which is - listening on the default "0.0.0.0" address inside a container will be - accessible from the network. - Modifying this array with strategic merge patch may corrupt the data. - For more information See https://github.com/kubernetes/kubernetes/issues/108255. - Cannot be updated. - items: - description: ContainerPort represents a network - port in a single container. - properties: - containerPort: - description: |- - Number of port to expose on the pod's IP address. - This must be a valid port number, 0 < x < 65536. - format: int32 - type: integer - hostIP: - description: What host IP to bind the external - port to. - type: string - hostPort: - description: |- - Number of port to expose on the host. - If specified, this must be a valid port number, 0 < x < 65536. - If HostNetwork is specified, this must match ContainerPort. - Most containers do not need this. - format: int32 - type: integer - name: - description: |- - If specified, this must be an IANA_SVC_NAME and unique within the pod. Each - named port in a pod must have a unique name. Name for the port that can be - referred to by services. - type: string - protocol: - default: TCP - description: |- - Protocol for port. Must be UDP, TCP, or SCTP. - Defaults to "TCP". - type: string - required: - - containerPort - type: object - type: array - x-kubernetes-list-map-keys: - - containerPort - - protocol - x-kubernetes-list-type: map - readinessProbe: - description: |- - Periodic probe of container service readiness. - Container will be removed from service endpoints if the probe fails. - Cannot be updated. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - properties: - exec: - description: Exec specifies the action to take. - properties: - command: - description: |- - Command is the command line to execute inside the container, the working directory for the - command is root ('/') in the container's filesystem. The command is simply exec'd, it is - not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use - a shell, you need to explicitly call out to that shell. - Exit status of 0 is treated as live/healthy and non-zero is unhealthy. - items: - type: string - type: array - type: object - failureThreshold: - description: |- - Minimum consecutive failures for the probe to be considered failed after having succeeded. - Defaults to 3. Minimum value is 1. - format: int32 - type: integer - grpc: - description: GRPC specifies an action involving - a GRPC port. - properties: - port: - description: Port number of the gRPC service. - Number must be in the range 1 to 65535. - format: int32 - type: integer - service: - description: |- - Service is the name of the service to place in the gRPC HealthCheckRequest - (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). - - - If this is not specified, the default behavior is defined by gRPC. - type: string - required: - - port - type: object - httpGet: - description: HTTPGet specifies the http request - to perform. - properties: - host: - description: |- - Host name to connect to, defaults to the pod IP. You probably want to set - "Host" in httpHeaders instead. - type: string - httpHeaders: - description: Custom headers to set in the - request. HTTP allows repeated headers. - items: - description: HTTPHeader describes a custom - header to be used in HTTP probes - properties: - name: - description: |- - The header field name. - This will be canonicalized upon output, so case-variant names will be understood as the same header. - type: string - value: - description: The header field value - type: string - required: - - name - - value - type: object - type: array - path: - description: Path to access on the HTTP server. - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Name or number of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - scheme: - description: |- - Scheme to use for connecting to the host. - Defaults to HTTP. - type: string - required: - - port - type: object - initialDelaySeconds: - description: |- - Number of seconds after the container has started before liveness probes are initiated. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - format: int32 - type: integer - periodSeconds: - description: |- - How often (in seconds) to perform the probe. - Default to 10 seconds. Minimum value is 1. - format: int32 - type: integer - successThreshold: - description: |- - Minimum consecutive successes for the probe to be considered successful after having failed. - Defaults to 1. Must be 1 for liveness and startup. Minimum value is 1. - format: int32 - type: integer - tcpSocket: - description: TCPSocket specifies an action involving - a TCP port. - properties: - host: - description: 'Optional: Host name to connect - to, defaults to the pod IP.' - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Number or name of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - required: - - port - type: object - terminationGracePeriodSeconds: - description: |- - Optional duration in seconds the pod needs to terminate gracefully upon probe failure. - The grace period is the duration in seconds after the processes running in the pod are sent - a termination signal and the time when the processes are forcibly halted with a kill signal. - Set this value longer than the expected cleanup time for your process. - If this value is nil, the pod's terminationGracePeriodSeconds will be used. Otherwise, this - value overrides the value provided by the pod spec. - Value must be non-negative integer. The value zero indicates stop immediately via - the kill signal (no opportunity to shut down). - This is a beta field and requires enabling ProbeTerminationGracePeriod feature gate. - Minimum value is 1. spec.terminationGracePeriodSeconds is used if unset. - format: int64 - type: integer - timeoutSeconds: - description: |- - Number of seconds after which the probe times out. - Defaults to 1 second. Minimum value is 1. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - format: int32 - type: integer - type: object - resizePolicy: - description: Resources resize policy for the container. - items: - description: ContainerResizePolicy represents resource - resize policy for the container. - properties: - resourceName: - description: |- - Name of the resource to which this resource resize policy applies. - Supported values: cpu, memory. - type: string - restartPolicy: - description: |- - Restart policy to apply when specified resource is resized. - If not specified, it defaults to NotRequired. - type: string - required: - - resourceName - - restartPolicy - type: object - type: array - x-kubernetes-list-type: atomic - resources: - description: |- - Compute Resources required by this container. - Cannot be updated. - More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ - properties: - claims: - description: |- - Claims lists the names of resources, defined in spec.resourceClaims, - that are used by this container. - - - This is an alpha field and requires enabling the - DynamicResourceAllocation feature gate. - - - This field is immutable. It can only be set for containers. - items: - description: ResourceClaim references one entry - in PodSpec.ResourceClaims. - properties: - name: - description: |- - Name must match the name of one entry in pod.spec.resourceClaims of - the Pod where this field is used. It makes that resource available - inside a container. - type: string - required: - - name - type: object - type: array - x-kubernetes-list-map-keys: - - name - x-kubernetes-list-type: map - limits: - additionalProperties: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - description: |- - Limits describes the maximum amount of compute resources allowed. - More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ - type: object - requests: - additionalProperties: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - description: |- - Requests describes the minimum amount of compute resources required. - If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, - otherwise to an implementation-defined value. Requests cannot exceed Limits. - More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ - type: object - type: object - restartPolicy: - description: |- - RestartPolicy defines the restart behavior of individual containers in a pod. - This field may only be set for init containers, and the only allowed value is "Always". - For non-init containers or when this field is not specified, - the restart behavior is defined by the Pod's restart policy and the container type. - Setting the RestartPolicy as "Always" for the init container will have the following effect: - this init container will be continually restarted on - exit until all regular containers have terminated. Once all regular - containers have completed, all init containers with restartPolicy "Always" - will be shut down. This lifecycle differs from normal init containers and - is often referred to as a "sidecar" container. Although this init - container still starts in the init container sequence, it does not wait - for the container to complete before proceeding to the next init - container. Instead, the next init container starts immediately after this - init container is started, or after any startupProbe has successfully - completed. - type: string - securityContext: - description: |- - SecurityContext defines the security options the container should be run with. - If set, the fields of SecurityContext override the equivalent fields of PodSecurityContext. - More info: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/ - properties: - allowPrivilegeEscalation: - description: |- - AllowPrivilegeEscalation controls whether a process can gain more - privileges than its parent process. This bool directly controls if - the no_new_privs flag will be set on the container process. - AllowPrivilegeEscalation is true always when the container is: - 1) run as Privileged - 2) has CAP_SYS_ADMIN - Note that this field cannot be set when spec.os.name is windows. - type: boolean - capabilities: - description: |- - The capabilities to add/drop when running containers. - Defaults to the default set of capabilities granted by the container runtime. - Note that this field cannot be set when spec.os.name is windows. - properties: - add: - description: Added capabilities - items: - description: Capability represent POSIX - capabilities type - type: string - type: array - drop: - description: Removed capabilities - items: - description: Capability represent POSIX - capabilities type - type: string - type: array - type: object - privileged: - description: |- - Run container in privileged mode. - Processes in privileged containers are essentially equivalent to root on the host. - Defaults to false. - Note that this field cannot be set when spec.os.name is windows. - type: boolean - procMount: - description: |- - procMount denotes the type of proc mount to use for the containers. - The default is DefaultProcMount which uses the container runtime defaults for - readonly paths and masked paths. - This requires the ProcMountType feature flag to be enabled. - Note that this field cannot be set when spec.os.name is windows. - type: string - readOnlyRootFilesystem: - description: |- - Whether this container has a read-only root filesystem. - Default is false. - Note that this field cannot be set when spec.os.name is windows. - type: boolean - runAsGroup: - description: |- - The GID to run the entrypoint of the container process. - Uses runtime default if unset. - May also be set in PodSecurityContext. If set in both SecurityContext and - PodSecurityContext, the value specified in SecurityContext takes precedence. - Note that this field cannot be set when spec.os.name is windows. - format: int64 - type: integer - runAsNonRoot: - description: |- - Indicates that the container must run as a non-root user. - If true, the Kubelet will validate the image at runtime to ensure that it - does not run as UID 0 (root) and fail to start the container if it does. - If unset or false, no such validation will be performed. - May also be set in PodSecurityContext. If set in both SecurityContext and - PodSecurityContext, the value specified in SecurityContext takes precedence. - type: boolean - runAsUser: - description: |- - The UID to run the entrypoint of the container process. - Defaults to user specified in image metadata if unspecified. - May also be set in PodSecurityContext. If set in both SecurityContext and - PodSecurityContext, the value specified in SecurityContext takes precedence. - Note that this field cannot be set when spec.os.name is windows. - format: int64 - type: integer - seLinuxOptions: - description: |- - The SELinux context to be applied to the container. - If unspecified, the container runtime will allocate a random SELinux context for each - container. May also be set in PodSecurityContext. If set in both SecurityContext and - PodSecurityContext, the value specified in SecurityContext takes precedence. - Note that this field cannot be set when spec.os.name is windows. - properties: - level: - description: Level is SELinux level label - that applies to the container. - type: string - role: - description: Role is a SELinux role label - that applies to the container. - type: string - type: - description: Type is a SELinux type label - that applies to the container. - type: string - user: - description: User is a SELinux user label - that applies to the container. - type: string - type: object - seccompProfile: - description: |- - The seccomp options to use by this container. If seccomp options are - provided at both the pod & container level, the container options - override the pod options. - Note that this field cannot be set when spec.os.name is windows. - properties: - localhostProfile: - description: |- - localhostProfile indicates a profile defined in a file on the node should be used. - The profile must be preconfigured on the node to work. - Must be a descending path, relative to the kubelet's configured seccomp profile location. - Must be set if type is "Localhost". Must NOT be set for any other type. - type: string - type: - description: |- - type indicates which kind of seccomp profile will be applied. - Valid options are: - - - Localhost - a profile defined in a file on the node should be used. - RuntimeDefault - the container runtime default profile should be used. - Unconfined - no profile should be applied. - type: string - required: - - type - type: object - windowsOptions: - description: |- - The Windows specific settings applied to all containers. - If unspecified, the options from the PodSecurityContext will be used. - If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence. - Note that this field cannot be set when spec.os.name is linux. - properties: - gmsaCredentialSpec: - description: |- - GMSACredentialSpec is where the GMSA admission webhook - (https://github.com/kubernetes-sigs/windows-gmsa) inlines the contents of the - GMSA credential spec named by the GMSACredentialSpecName field. - type: string - gmsaCredentialSpecName: - description: GMSACredentialSpecName is the - name of the GMSA credential spec to use. - type: string - hostProcess: - description: |- - HostProcess determines if a container should be run as a 'Host Process' container. - All of a Pod's containers must have the same effective HostProcess value - (it is not allowed to have a mix of HostProcess containers and non-HostProcess containers). - In addition, if HostProcess is true then HostNetwork must also be set to true. - type: boolean - runAsUserName: - description: |- - The UserName in Windows to run the entrypoint of the container process. - Defaults to the user specified in image metadata if unspecified. - May also be set in PodSecurityContext. If set in both SecurityContext and - PodSecurityContext, the value specified in SecurityContext takes precedence. - type: string - type: object - type: object - startupProbe: - description: |- - StartupProbe indicates that the Pod has successfully initialized. - If specified, no other probes are executed until this completes successfully. - If this probe fails, the Pod will be restarted, just as if the livenessProbe failed. - This can be used to provide different probe parameters at the beginning of a Pod's lifecycle, - when it might take a long time to load data or warm a cache, than during steady-state operation. - This cannot be updated. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - properties: - exec: - description: Exec specifies the action to take. - properties: - command: - description: |- - Command is the command line to execute inside the container, the working directory for the - command is root ('/') in the container's filesystem. The command is simply exec'd, it is - not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use - a shell, you need to explicitly call out to that shell. - Exit status of 0 is treated as live/healthy and non-zero is unhealthy. - items: - type: string - type: array - type: object - failureThreshold: - description: |- - Minimum consecutive failures for the probe to be considered failed after having succeeded. - Defaults to 3. Minimum value is 1. - format: int32 - type: integer - grpc: - description: GRPC specifies an action involving - a GRPC port. - properties: - port: - description: Port number of the gRPC service. - Number must be in the range 1 to 65535. - format: int32 - type: integer - service: - description: |- - Service is the name of the service to place in the gRPC HealthCheckRequest - (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). - - - If this is not specified, the default behavior is defined by gRPC. - type: string - required: - - port - type: object - httpGet: - description: HTTPGet specifies the http request - to perform. - properties: - host: - description: |- - Host name to connect to, defaults to the pod IP. You probably want to set - "Host" in httpHeaders instead. - type: string - httpHeaders: - description: Custom headers to set in the - request. HTTP allows repeated headers. - items: - description: HTTPHeader describes a custom - header to be used in HTTP probes - properties: - name: - description: |- - The header field name. - This will be canonicalized upon output, so case-variant names will be understood as the same header. - type: string - value: - description: The header field value - type: string - required: - - name - - value - type: object - type: array - path: - description: Path to access on the HTTP server. - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Name or number of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - scheme: - description: |- - Scheme to use for connecting to the host. - Defaults to HTTP. - type: string - required: - - port - type: object - initialDelaySeconds: - description: |- - Number of seconds after the container has started before liveness probes are initiated. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - format: int32 - type: integer - periodSeconds: - description: |- - How often (in seconds) to perform the probe. - Default to 10 seconds. Minimum value is 1. - format: int32 - type: integer - successThreshold: - description: |- - Minimum consecutive successes for the probe to be considered successful after having failed. - Defaults to 1. Must be 1 for liveness and startup. Minimum value is 1. - format: int32 - type: integer - tcpSocket: - description: TCPSocket specifies an action involving - a TCP port. - properties: - host: - description: 'Optional: Host name to connect - to, defaults to the pod IP.' - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Number or name of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - required: - - port - type: object - terminationGracePeriodSeconds: - description: |- - Optional duration in seconds the pod needs to terminate gracefully upon probe failure. - The grace period is the duration in seconds after the processes running in the pod are sent - a termination signal and the time when the processes are forcibly halted with a kill signal. - Set this value longer than the expected cleanup time for your process. - If this value is nil, the pod's terminationGracePeriodSeconds will be used. Otherwise, this - value overrides the value provided by the pod spec. - Value must be non-negative integer. The value zero indicates stop immediately via - the kill signal (no opportunity to shut down). - This is a beta field and requires enabling ProbeTerminationGracePeriod feature gate. - Minimum value is 1. spec.terminationGracePeriodSeconds is used if unset. - format: int64 - type: integer - timeoutSeconds: - description: |- - Number of seconds after which the probe times out. - Defaults to 1 second. Minimum value is 1. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - format: int32 - type: integer - type: object - stdin: - description: |- - Whether this container should allocate a buffer for stdin in the container runtime. If this - is not set, reads from stdin in the container will always result in EOF. - Default is false. - type: boolean - stdinOnce: - description: |- - Whether the container runtime should close the stdin channel after it has been opened by - a single attach. When stdin is true the stdin stream will remain open across multiple attach - sessions. If stdinOnce is set to true, stdin is opened on container start, is empty until the - first client attaches to stdin, and then remains open and accepts data until the client disconnects, - at which time stdin is closed and remains closed until the container is restarted. If this - flag is false, a container processes that reads from stdin will never receive an EOF. - Default is false - type: boolean - terminationMessagePath: - description: |- - Optional: Path at which the file to which the container's termination message - will be written is mounted into the container's filesystem. - Message written is intended to be brief final status, such as an assertion failure message. - Will be truncated by the node if greater than 4096 bytes. The total message length across - all containers will be limited to 12kb. - Defaults to /dev/termination-log. - Cannot be updated. - type: string - terminationMessagePolicy: - description: |- - Indicate how the termination message should be populated. File will use the contents of - terminationMessagePath to populate the container status message on both success and failure. - FallbackToLogsOnError will use the last chunk of container log output if the termination - message file is empty and the container exited with an error. - The log output is limited to 2048 bytes or 80 lines, whichever is smaller. - Defaults to File. - Cannot be updated. - type: string - tty: - description: |- - Whether this container should allocate a TTY for itself, also requires 'stdin' to be true. - Default is false. - type: boolean - volumeDevices: - description: volumeDevices is the list of block devices - to be used by the container. - items: - description: volumeDevice describes a mapping of - a raw block device within a container. - properties: - devicePath: - description: devicePath is the path inside of - the container that the device will be mapped - to. - type: string - name: - description: name must match the name of a persistentVolumeClaim - in the pod - type: string - required: - - devicePath - - name - type: object - type: array - volumeMounts: - description: |- - Pod volumes to mount into the container's filesystem. - Cannot be updated. - items: - description: VolumeMount describes a mounting of - a Volume within a container. - properties: - mountPath: - description: |- - Path within the container at which the volume should be mounted. Must - not contain ':'. - type: string - mountPropagation: - description: |- - mountPropagation determines how mounts are propagated from the host - to container and the other way around. - When not set, MountPropagationNone is used. - This field is beta in 1.10. - type: string - name: - description: This must match the Name of a Volume. - type: string - readOnly: - description: |- - Mounted read-only if true, read-write otherwise (false or unspecified). - Defaults to false. - type: boolean - subPath: - description: |- - Path within the volume from which the container's volume should be mounted. - Defaults to "" (volume's root). - type: string - subPathExpr: - description: |- - Expanded path within the volume from which the container's volume should be mounted. - Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. - Defaults to "" (volume's root). - SubPathExpr and SubPath are mutually exclusive. - type: string - required: - - mountPath - - name - type: object - type: array - workingDir: - description: |- - Container's working directory. - If not specified, the container runtime's default will be used, which - might be configured in the container image. - Cannot be updated. - type: string - required: - - name - type: object - type: array - x-kubernetes-list-map-keys: - - name - x-kubernetes-list-type: map - x-kubernetes-preserve-unknown-fields: true - type: object - required: - - componentDefRef - - versionsContext - type: object - minItems: 1 - type: array - x-kubernetes-list-map-keys: - - componentDefRef - x-kubernetes-list-type: map - required: - - clusterDefinitionRef - - componentVersions - type: object - status: - description: |- - ClusterVersionStatus defines the observed state of ClusterVersion. - - - Deprecated since v0.9. - This struct is maintained for backward compatibility and its use is discouraged. - properties: - clusterDefGeneration: - description: The generation number of the ClusterDefinition that is - currently being referenced. - format: int64 - type: integer - message: - description: Provides additional information about the current phase. - type: string - observedGeneration: - description: The generation number that has been observed by the controller. - format: int64 - type: integer - phase: - description: The current phase of the ClusterVersion. - enum: - - Available - - Unavailable - type: string - type: object - type: object - served: true - storage: true - subresources: - status: {} diff --git a/deploy/helm/crds/apps.kubeblocks.io_configconstraints.yaml b/deploy/helm/crds/apps.kubeblocks.io_configconstraints.yaml index 50a118ff6c8..ad8198789bf 100644 --- a/deploy/helm/crds/apps.kubeblocks.io_configconstraints.yaml +++ b/deploy/helm/crds/apps.kubeblocks.io_configconstraints.yaml @@ -758,7 +758,7 @@ spec: phase: description: |- Specifies the status of the configuration template. - When set to CCAvailablePhase, the ConfigConstraint can be referenced by ClusterDefinition or ClusterVersion. + When set to CCAvailablePhase, the ConfigConstraint can be referenced by ClusterDefinition. enum: - Available - Unavailable @@ -1418,7 +1418,7 @@ spec: phase: description: |- Specifies the status of the configuration template. - When set to CCAvailablePhase, the ConfigConstraint can be referenced by ClusterDefinition or ClusterVersion. + When set to CCAvailablePhase, the ConfigConstraint can be referenced by ClusterDefinition. enum: - Available - Unavailable diff --git a/deploy/helm/templates/admission/webhookconfiguration.yaml b/deploy/helm/templates/admission/webhookconfiguration.yaml index bddc16a0630..f91c9c5ad76 100644 --- a/deploy/helm/templates/admission/webhookconfiguration.yaml +++ b/deploy/helm/templates/admission/webhookconfiguration.yaml @@ -123,30 +123,6 @@ metadata: labels: {{- include "kubeblocks.labels" . | nindent 4 }} webhooks: -- admissionReviewVersions: - - v1 - clientConfig: - service: - name: {{ include "kubeblocks.svcName" . }} - namespace: {{ .Release.Namespace }} - path: /validate-apps-kubeblocks-io-v1alpha1-clusterversion - port: {{ .Values.service.port }} - {{- if .Values.admissionWebhooks.createSelfSignedCert }} - caBundle: {{ $ca.Cert | b64enc }} - {{- end }} - failurePolicy: Fail - name: vclusterversion.kb.io - rules: - - apiGroups: - - apps.kubeblocks.io - apiVersions: - - v1alpha1 - operations: - - CREATE - - UPDATE - resources: - - clusterversions - sideEffects: None - admissionReviewVersions: - v1 clientConfig: diff --git a/deploy/helm/templates/rbac/apps_clusterversion_editor_role.yaml b/deploy/helm/templates/rbac/apps_clusterversion_editor_role.yaml deleted file mode 100644 index fb50b1c6a56..00000000000 --- a/deploy/helm/templates/rbac/apps_clusterversion_editor_role.yaml +++ /dev/null @@ -1,26 +0,0 @@ -# permissions for end users to edit clusterversions. -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - name: {{ include "kubeblocks.fullname" . }}-clusterversion-editor-role - labels: - {{- include "kubeblocks.labels" . | nindent 4 }} -rules: -- apiGroups: - - apps.kubeblocks.io - resources: - - clusterversions - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - apps.kubeblocks.io - resources: - - clusterversions/status - verbs: - - get diff --git a/deploy/helm/templates/rbac/apps_clusterversion_viewer_role.yaml b/deploy/helm/templates/rbac/apps_clusterversion_viewer_role.yaml deleted file mode 100644 index 6cee39f7c48..00000000000 --- a/deploy/helm/templates/rbac/apps_clusterversion_viewer_role.yaml +++ /dev/null @@ -1,22 +0,0 @@ -# permissions for end users to view clusterversions. -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - name: {{ include "kubeblocks.fullname" . }}-clusterversion-viewer-role - labels: - {{- include "kubeblocks.labels" . | nindent 4 }} -rules: -- apiGroups: - - apps.kubeblocks.io - resources: - - clusterversions - verbs: - - get - - list - - watch -- apiGroups: - - apps.kubeblocks.io - resources: - - clusterversions/status - verbs: - - get diff --git a/docs/developer_docs/api-reference/cluster.md b/docs/developer_docs/api-reference/cluster.md index e9a1dbb8130..fd5677d7f38 100644 --- a/docs/developer_docs/api-reference/cluster.md +++ b/docs/developer_docs/api-reference/cluster.md @@ -27,8 +27,6 @@ Resource Types:
  • ClusterDefinition
  • -ClusterVersion -
  • Component
  • ComponentDefinition @@ -593,104 +591,6 @@ ClusterDefinitionStatus -

    ClusterVersion -

    -
    -

    ClusterVersion is the Schema for the ClusterVersions API.

    -

    Deprecated: ClusterVersion has been replaced by ComponentVersion since v0.9. -This struct is maintained for backward compatibility and its use is discouraged.

    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    FieldDescription
    -apiVersion
    -string
    -apps.kubeblocks.io/v1alpha1 -
    -kind
    -string -
    ClusterVersion
    -metadata
    - - -Kubernetes meta/v1.ObjectMeta - - -
    -Refer to the Kubernetes API documentation for the fields of the -metadata field. -
    -spec
    - - -ClusterVersionSpec - - -
    -
    -
    - - - - - - - - - -
    -clusterDefinitionRef
    - -string - -
    -

    Specifies a reference to the ClusterDefinition.

    -
    -componentVersions
    - - -[]ClusterComponentVersion - - -
    -

    Contains a list of versioning contexts for the components’ containers.

    -
    -
    -status
    - - -ClusterVersionStatus - - -
    -

    Component

    @@ -5248,98 +5148,6 @@ This is the readiness time of the last Component Pod.

    -

    ClusterComponentVersion -

    -

    -(Appears on:ClusterVersionSpec) -

    -
    -

    ClusterComponentVersion is an application version component spec.

    -

    Deprecated since v0.9. -This struct is maintained for backward compatibility and its use is discouraged.

    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    FieldDescription
    -componentDefRef
    - -string - -
    -

    Specifies a reference to one of the cluster component definition names in the ClusterDefinition API (spec.componentDefs.name).

    -
    -configSpecs
    - - -[]ComponentConfigSpec - - -
    -(Optional) -

    Defines a configuration extension mechanism to handle configuration differences between versions. -The configTemplateRefs field, in conjunction with the configTemplateRefs in the ClusterDefinition, determines -the final configuration file.

    -
    -systemAccountSpec
    - - -SystemAccountShortSpec - - -
    -(Optional) -

    Defines the image for the component to connect to databases or engines. -This overrides the image and env attributes defined in clusterDefinition.spec.componentDefs.systemAccountSpec.cmdExecutorConfig. -To clear default environment settings, set systemAccountSpec.cmdExecutorConfig.env to an empty list.

    -
    -versionsContext
    - - -VersionsContext - - -
    -

    Defines the context for container images for component versions. -This value replaces the values in clusterDefinition.spec.componentDefs.podSpec.[initContainers | containers].

    -
    -switchoverSpec
    - - -SwitchoverShortSpec - - -
    -(Optional) -

    Defines the images for the component to perform a switchover. -This overrides the image and env attributes defined in clusterDefinition.spec.componentDefs.SwitchoverSpec.CommandExecutorEnvItem.

    -

    ClusterComponentVolumeClaimTemplate

    @@ -6759,120 +6567,6 @@ separated by commas.

    -

    ClusterVersionSpec -

    -

    -(Appears on:ClusterVersion) -

    -
    -

    ClusterVersionSpec defines the desired state of ClusterVersion.

    -

    Deprecated since v0.9. -This struct is maintained for backward compatibility and its use is discouraged.

    -
    - - - - - - - - - - - - - - - - - -
    FieldDescription
    -clusterDefinitionRef
    - -string - -
    -

    Specifies a reference to the ClusterDefinition.

    -
    -componentVersions
    - - -[]ClusterComponentVersion - - -
    -

    Contains a list of versioning contexts for the components’ containers.

    -
    -

    ClusterVersionStatus -

    -

    -(Appears on:ClusterVersion) -

    -
    -

    ClusterVersionStatus defines the observed state of ClusterVersion.

    -

    Deprecated since v0.9. -This struct is maintained for backward compatibility and its use is discouraged.

    -
    - - - - - - - - - - - - - - - - - - - - - - - - - -
    FieldDescription
    -phase
    - - -Phase - - -
    -(Optional) -

    The current phase of the ClusterVersion.

    -
    -message
    - -string - -
    -(Optional) -

    Provides additional information about the current phase.

    -
    -observedGeneration
    - -int64 - -
    -(Optional) -

    The generation number that has been observed by the controller.

    -
    -clusterDefGeneration
    - -int64 - -
    -(Optional) -

    The generation number of the ClusterDefinition that is currently being referenced.

    -

    CmdExecutorConfig

    @@ -6925,7 +6619,7 @@ CommandExecutorItem

    CommandExecutorEnvItem

    -(Appears on:CmdExecutorConfig, SwitchoverShortSpec, SystemAccountShortSpec) +(Appears on:CmdExecutorConfig)

    CommandExecutorEnvItem is deprecated since v0.8.

    @@ -7078,7 +6772,7 @@ MatchExpressions

    ComponentConfigSpec

    -(Appears on:ClusterComponentDefinition, ClusterComponentVersion, ComponentDefinitionSpec, ConfigurationItemDetail) +(Appears on:ClusterComponentDefinition, ComponentDefinitionSpec, ConfigurationItemDetail)

    @@ -10122,7 +9816,7 @@ ConfigConstraintPhase (Optional)

    Specifies the status of the configuration template. -When set to CCAvailablePhase, the ConfigConstraint can be referenced by ClusterDefinition or ClusterVersion.

    +When set to CCAvailablePhase, the ConfigConstraint can be referenced by ClusterDefinition.

    @@ -15259,10 +14953,10 @@ Kubernetes core/v1.PersistentVolumeMode

    Phase (string alias)

    -(Appears on:ClusterDefinitionStatus, ClusterVersionStatus, ComponentDefinitionStatus, ComponentVersionStatus, OpsDefinitionStatus, ServiceDescriptorStatus) +(Appears on:ClusterDefinitionStatus, ComponentDefinitionStatus, ComponentVersionStatus, OpsDefinitionStatus, ServiceDescriptorStatus)

    -

    Phase represents the current status of the ClusterDefinition and ClusterVersion CR.

    +

    Phase represents the current status of the ClusterDefinition CR.

    @@ -19725,39 +19419,6 @@ When defined, the scripts defined in scriptSpecs can be referenced within the Sw
    -

    SwitchoverShortSpec -

    -

    -(Appears on:ClusterComponentVersion) -

    -
    -

    SwitchoverShortSpec represents a condensed version of the SwitchoverSpec.

    -

    Deprecated since v0.9. -This struct is maintained for backward compatibility and its use is discouraged.

    -
    - - - - - - - - - - - - - -
    FieldDescription
    -cmdExecutorConfig
    - - -CommandExecutorEnvItem - - -
    -

    Represents the configuration for the command executor.

    -

    SwitchoverSpec

    @@ -19934,39 +19595,6 @@ ProvisionPolicy -

    SystemAccountShortSpec -

    -

    -(Appears on:ClusterComponentVersion) -

    -
    -

    SystemAccountShortSpec represents a condensed version of the SystemAccountSpec.

    -

    Deprecated since v0.9. -This struct is maintained for backward compatibility and its use is discouraged.

    -
    - - - - - - - - - - - - - -
    FieldDescription
    -cmdExecutorConfig
    - - -CommandExecutorEnvItem - - -
    -

    Configures the method for obtaining the client SDK and executing statements.

    -

    SystemAccountSpec

    @@ -20711,8 +20339,7 @@ use the latest available version in ComponentVersion.

    -

    Represents an array of names of ClusterVersion or ComponentDefinition that can be mapped to -the appropriate version of the backup tool image.

    +

    Represents an array of names of ComponentDefinition that can be mapped to the appropriate version of the backup tool image.

    This mapping allows different versions of component images to correspond to specific versions of backup tool images.

    @@ -20853,55 +20480,6 @@ ComponentVarSelector -

    VersionsContext -

    -

    -(Appears on:ClusterComponentVersion) -

    -
    -

    VersionsContext is deprecated since v0.9. -This struct is maintained for backward compatibility and its use is discouraged.

    -
    - - - - - - - - - - - - - - - - - -
    FieldDescription
    -initContainers
    - - -[]Kubernetes core/v1.Container - - -
    -(Optional) -

    Provides override values for ClusterDefinition.spec.componentDefs.podSpec.initContainers. -Typically used in scenarios such as updating application container images.

    -
    -containers
    - - -[]Kubernetes core/v1.Container - - -
    -(Optional) -

    Provides override values for ClusterDefinition.spec.componentDefs.podSpec.containers. -Typically used in scenarios such as updating application container images.

    -

    VerticalScaling

    @@ -21738,7 +21316,7 @@ ConfigConstraintPhase (Optional)

    Specifies the status of the configuration template. -When set to CCAvailablePhase, the ConfigConstraint can be referenced by ClusterDefinition or ClusterVersion.

    +When set to CCAvailablePhase, the ConfigConstraint can be referenced by ClusterDefinition.

    diff --git a/pkg/client/clientset/versioned/typed/apps/v1alpha1/apps_client.go b/pkg/client/clientset/versioned/typed/apps/v1alpha1/apps_client.go index 0515c6b576f..4baf1af6aad 100644 --- a/pkg/client/clientset/versioned/typed/apps/v1alpha1/apps_client.go +++ b/pkg/client/clientset/versioned/typed/apps/v1alpha1/apps_client.go @@ -31,7 +31,6 @@ type AppsV1alpha1Interface interface { BackupPolicyTemplatesGetter ClustersGetter ClusterDefinitionsGetter - ClusterVersionsGetter ComponentsGetter ComponentDefinitionsGetter ComponentVersionsGetter @@ -58,10 +57,6 @@ func (c *AppsV1alpha1Client) ClusterDefinitions() ClusterDefinitionInterface { return newClusterDefinitions(c) } -func (c *AppsV1alpha1Client) ClusterVersions() ClusterVersionInterface { - return newClusterVersions(c) -} - func (c *AppsV1alpha1Client) Components(namespace string) ComponentInterface { return newComponents(c, namespace) } diff --git a/pkg/client/clientset/versioned/typed/apps/v1alpha1/clusterversion.go b/pkg/client/clientset/versioned/typed/apps/v1alpha1/clusterversion.go deleted file mode 100644 index 8965b99ba11..00000000000 --- a/pkg/client/clientset/versioned/typed/apps/v1alpha1/clusterversion.go +++ /dev/null @@ -1,184 +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. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - "context" - "time" - - v1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1" - scheme "github.com/apecloud/kubeblocks/pkg/client/clientset/versioned/scheme" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" -) - -// ClusterVersionsGetter has a method to return a ClusterVersionInterface. -// A group's client should implement this interface. -type ClusterVersionsGetter interface { - ClusterVersions() ClusterVersionInterface -} - -// ClusterVersionInterface has methods to work with ClusterVersion resources. -type ClusterVersionInterface interface { - Create(ctx context.Context, clusterVersion *v1alpha1.ClusterVersion, opts v1.CreateOptions) (*v1alpha1.ClusterVersion, error) - Update(ctx context.Context, clusterVersion *v1alpha1.ClusterVersion, opts v1.UpdateOptions) (*v1alpha1.ClusterVersion, error) - UpdateStatus(ctx context.Context, clusterVersion *v1alpha1.ClusterVersion, opts v1.UpdateOptions) (*v1alpha1.ClusterVersion, error) - Delete(ctx context.Context, name string, opts v1.DeleteOptions) error - DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error - Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.ClusterVersion, error) - List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.ClusterVersionList, error) - Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) - Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ClusterVersion, err error) - ClusterVersionExpansion -} - -// clusterVersions implements ClusterVersionInterface -type clusterVersions struct { - client rest.Interface -} - -// newClusterVersions returns a ClusterVersions -func newClusterVersions(c *AppsV1alpha1Client) *clusterVersions { - return &clusterVersions{ - client: c.RESTClient(), - } -} - -// Get takes name of the clusterVersion, and returns the corresponding clusterVersion object, and an error if there is any. -func (c *clusterVersions) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.ClusterVersion, err error) { - result = &v1alpha1.ClusterVersion{} - err = c.client.Get(). - Resource("clusterversions"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of ClusterVersions that match those selectors. -func (c *clusterVersions) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ClusterVersionList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1alpha1.ClusterVersionList{} - err = c.client.Get(). - Resource("clusterversions"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested clusterVersions. -func (c *clusterVersions) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - opts.Watch = true - return c.client.Get(). - Resource("clusterversions"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a clusterVersion and creates it. Returns the server's representation of the clusterVersion, and an error, if there is any. -func (c *clusterVersions) Create(ctx context.Context, clusterVersion *v1alpha1.ClusterVersion, opts v1.CreateOptions) (result *v1alpha1.ClusterVersion, err error) { - result = &v1alpha1.ClusterVersion{} - err = c.client.Post(). - Resource("clusterversions"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(clusterVersion). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a clusterVersion and updates it. Returns the server's representation of the clusterVersion, and an error, if there is any. -func (c *clusterVersions) Update(ctx context.Context, clusterVersion *v1alpha1.ClusterVersion, opts v1.UpdateOptions) (result *v1alpha1.ClusterVersion, err error) { - result = &v1alpha1.ClusterVersion{} - err = c.client.Put(). - Resource("clusterversions"). - Name(clusterVersion.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(clusterVersion). - Do(ctx). - Into(result) - return -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *clusterVersions) UpdateStatus(ctx context.Context, clusterVersion *v1alpha1.ClusterVersion, opts v1.UpdateOptions) (result *v1alpha1.ClusterVersion, err error) { - result = &v1alpha1.ClusterVersion{} - err = c.client.Put(). - Resource("clusterversions"). - Name(clusterVersion.Name). - SubResource("status"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(clusterVersion). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the clusterVersion and deletes it. Returns an error if one occurs. -func (c *clusterVersions) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Resource("clusterversions"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *clusterVersions) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - var timeout time.Duration - if listOpts.TimeoutSeconds != nil { - timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second - } - return c.client.Delete(). - Resource("clusterversions"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched clusterVersion. -func (c *clusterVersions) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ClusterVersion, err error) { - result = &v1alpha1.ClusterVersion{} - err = c.client.Patch(pt). - Resource("clusterversions"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_apps_client.go b/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_apps_client.go index e346ebf0785..6b9372e765a 100644 --- a/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_apps_client.go +++ b/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_apps_client.go @@ -40,10 +40,6 @@ func (c *FakeAppsV1alpha1) ClusterDefinitions() v1alpha1.ClusterDefinitionInterf return &FakeClusterDefinitions{c} } -func (c *FakeAppsV1alpha1) ClusterVersions() v1alpha1.ClusterVersionInterface { - return &FakeClusterVersions{c} -} - func (c *FakeAppsV1alpha1) Components(namespace string) v1alpha1.ComponentInterface { return &FakeComponents{c, namespace} } diff --git a/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_clusterversion.go b/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_clusterversion.go deleted file mode 100644 index ab13d9c0175..00000000000 --- a/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_clusterversion.go +++ /dev/null @@ -1,132 +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. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package fake - -import ( - "context" - - v1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - labels "k8s.io/apimachinery/pkg/labels" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - testing "k8s.io/client-go/testing" -) - -// FakeClusterVersions implements ClusterVersionInterface -type FakeClusterVersions struct { - Fake *FakeAppsV1alpha1 -} - -var clusterversionsResource = v1alpha1.SchemeGroupVersion.WithResource("clusterversions") - -var clusterversionsKind = v1alpha1.SchemeGroupVersion.WithKind("ClusterVersion") - -// Get takes name of the clusterVersion, and returns the corresponding clusterVersion object, and an error if there is any. -func (c *FakeClusterVersions) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.ClusterVersion, err error) { - obj, err := c.Fake. - Invokes(testing.NewRootGetAction(clusterversionsResource, name), &v1alpha1.ClusterVersion{}) - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.ClusterVersion), err -} - -// List takes label and field selectors, and returns the list of ClusterVersions that match those selectors. -func (c *FakeClusterVersions) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ClusterVersionList, err error) { - obj, err := c.Fake. - Invokes(testing.NewRootListAction(clusterversionsResource, clusterversionsKind, opts), &v1alpha1.ClusterVersionList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &v1alpha1.ClusterVersionList{ListMeta: obj.(*v1alpha1.ClusterVersionList).ListMeta} - for _, item := range obj.(*v1alpha1.ClusterVersionList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -// Watch returns a watch.Interface that watches the requested clusterVersions. -func (c *FakeClusterVersions) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { - return c.Fake. - InvokesWatch(testing.NewRootWatchAction(clusterversionsResource, opts)) -} - -// Create takes the representation of a clusterVersion and creates it. Returns the server's representation of the clusterVersion, and an error, if there is any. -func (c *FakeClusterVersions) Create(ctx context.Context, clusterVersion *v1alpha1.ClusterVersion, opts v1.CreateOptions) (result *v1alpha1.ClusterVersion, err error) { - obj, err := c.Fake. - Invokes(testing.NewRootCreateAction(clusterversionsResource, clusterVersion), &v1alpha1.ClusterVersion{}) - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.ClusterVersion), err -} - -// Update takes the representation of a clusterVersion and updates it. Returns the server's representation of the clusterVersion, and an error, if there is any. -func (c *FakeClusterVersions) Update(ctx context.Context, clusterVersion *v1alpha1.ClusterVersion, opts v1.UpdateOptions) (result *v1alpha1.ClusterVersion, err error) { - obj, err := c.Fake. - Invokes(testing.NewRootUpdateAction(clusterversionsResource, clusterVersion), &v1alpha1.ClusterVersion{}) - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.ClusterVersion), err -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeClusterVersions) UpdateStatus(ctx context.Context, clusterVersion *v1alpha1.ClusterVersion, opts v1.UpdateOptions) (*v1alpha1.ClusterVersion, error) { - obj, err := c.Fake. - Invokes(testing.NewRootUpdateSubresourceAction(clusterversionsResource, "status", clusterVersion), &v1alpha1.ClusterVersion{}) - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.ClusterVersion), err -} - -// Delete takes name of the clusterVersion and deletes it. Returns an error if one occurs. -func (c *FakeClusterVersions) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - _, err := c.Fake. - Invokes(testing.NewRootDeleteActionWithOptions(clusterversionsResource, name, opts), &v1alpha1.ClusterVersion{}) - return err -} - -// DeleteCollection deletes a collection of objects. -func (c *FakeClusterVersions) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewRootDeleteCollectionAction(clusterversionsResource, listOpts) - - _, err := c.Fake.Invokes(action, &v1alpha1.ClusterVersionList{}) - return err -} - -// Patch applies the patch and returns the patched clusterVersion. -func (c *FakeClusterVersions) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ClusterVersion, err error) { - obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceAction(clusterversionsResource, name, pt, data, subresources...), &v1alpha1.ClusterVersion{}) - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.ClusterVersion), err -} diff --git a/pkg/client/clientset/versioned/typed/apps/v1alpha1/generated_expansion.go b/pkg/client/clientset/versioned/typed/apps/v1alpha1/generated_expansion.go index 885da06ef98..0f8d6ecbd66 100644 --- a/pkg/client/clientset/versioned/typed/apps/v1alpha1/generated_expansion.go +++ b/pkg/client/clientset/versioned/typed/apps/v1alpha1/generated_expansion.go @@ -24,8 +24,6 @@ type ClusterExpansion interface{} type ClusterDefinitionExpansion interface{} -type ClusterVersionExpansion interface{} - type ComponentExpansion interface{} type ComponentDefinitionExpansion interface{} diff --git a/pkg/client/informers/externalversions/apps/v1alpha1/clusterversion.go b/pkg/client/informers/externalversions/apps/v1alpha1/clusterversion.go deleted file mode 100644 index 376af543094..00000000000 --- a/pkg/client/informers/externalversions/apps/v1alpha1/clusterversion.go +++ /dev/null @@ -1,89 +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. -*/ - -// Code generated by informer-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - "context" - time "time" - - appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1" - versioned "github.com/apecloud/kubeblocks/pkg/client/clientset/versioned" - internalinterfaces "github.com/apecloud/kubeblocks/pkg/client/informers/externalversions/internalinterfaces" - v1alpha1 "github.com/apecloud/kubeblocks/pkg/client/listers/apps/v1alpha1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime "k8s.io/apimachinery/pkg/runtime" - watch "k8s.io/apimachinery/pkg/watch" - cache "k8s.io/client-go/tools/cache" -) - -// ClusterVersionInformer provides access to a shared informer and lister for -// ClusterVersions. -type ClusterVersionInformer interface { - Informer() cache.SharedIndexInformer - Lister() v1alpha1.ClusterVersionLister -} - -type clusterVersionInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc -} - -// NewClusterVersionInformer constructs a new informer for ClusterVersion type. -// Always prefer using an informer factory to get a shared informer instead of getting an independent -// one. This reduces memory footprint and number of connections to the server. -func NewClusterVersionInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { - return NewFilteredClusterVersionInformer(client, resyncPeriod, indexers, nil) -} - -// NewFilteredClusterVersionInformer constructs a new informer for ClusterVersion type. -// Always prefer using an informer factory to get a shared informer instead of getting an independent -// one. This reduces memory footprint and number of connections to the server. -func NewFilteredClusterVersionInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { - return cache.NewSharedIndexInformer( - &cache.ListWatch{ - ListFunc: func(options v1.ListOptions) (runtime.Object, error) { - if tweakListOptions != nil { - tweakListOptions(&options) - } - return client.AppsV1alpha1().ClusterVersions().List(context.TODO(), options) - }, - WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { - if tweakListOptions != nil { - tweakListOptions(&options) - } - return client.AppsV1alpha1().ClusterVersions().Watch(context.TODO(), options) - }, - }, - &appsv1alpha1.ClusterVersion{}, - resyncPeriod, - indexers, - ) -} - -func (f *clusterVersionInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { - return NewFilteredClusterVersionInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) -} - -func (f *clusterVersionInformer) Informer() cache.SharedIndexInformer { - return f.factory.InformerFor(&appsv1alpha1.ClusterVersion{}, f.defaultInformer) -} - -func (f *clusterVersionInformer) Lister() v1alpha1.ClusterVersionLister { - return v1alpha1.NewClusterVersionLister(f.Informer().GetIndexer()) -} diff --git a/pkg/client/informers/externalversions/apps/v1alpha1/interface.go b/pkg/client/informers/externalversions/apps/v1alpha1/interface.go index 1680292398e..8d937199cec 100644 --- a/pkg/client/informers/externalversions/apps/v1alpha1/interface.go +++ b/pkg/client/informers/externalversions/apps/v1alpha1/interface.go @@ -30,8 +30,6 @@ type Interface interface { Clusters() ClusterInformer // ClusterDefinitions returns a ClusterDefinitionInformer. ClusterDefinitions() ClusterDefinitionInformer - // ClusterVersions returns a ClusterVersionInformer. - ClusterVersions() ClusterVersionInformer // Components returns a ComponentInformer. Components() ComponentInformer // ComponentDefinitions returns a ComponentDefinitionInformer. @@ -74,11 +72,6 @@ func (v *version) ClusterDefinitions() ClusterDefinitionInformer { return &clusterDefinitionInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// ClusterVersions returns a ClusterVersionInformer. -func (v *version) ClusterVersions() ClusterVersionInformer { - return &clusterVersionInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} -} - // Components returns a ComponentInformer. func (v *version) Components() ComponentInformer { return &componentInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} diff --git a/pkg/client/informers/externalversions/generic.go b/pkg/client/informers/externalversions/generic.go index dedb7e21556..1d66d96e47e 100644 --- a/pkg/client/informers/externalversions/generic.go +++ b/pkg/client/informers/externalversions/generic.go @@ -64,8 +64,6 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource return &genericInformer{resource: resource.GroupResource(), informer: f.Apps().V1alpha1().Clusters().Informer()}, nil case v1alpha1.SchemeGroupVersion.WithResource("clusterdefinitions"): return &genericInformer{resource: resource.GroupResource(), informer: f.Apps().V1alpha1().ClusterDefinitions().Informer()}, nil - case v1alpha1.SchemeGroupVersion.WithResource("clusterversions"): - return &genericInformer{resource: resource.GroupResource(), informer: f.Apps().V1alpha1().ClusterVersions().Informer()}, nil case v1alpha1.SchemeGroupVersion.WithResource("components"): return &genericInformer{resource: resource.GroupResource(), informer: f.Apps().V1alpha1().Components().Informer()}, nil case v1alpha1.SchemeGroupVersion.WithResource("componentdefinitions"): diff --git a/pkg/client/listers/apps/v1alpha1/clusterversion.go b/pkg/client/listers/apps/v1alpha1/clusterversion.go deleted file mode 100644 index 59761daae40..00000000000 --- a/pkg/client/listers/apps/v1alpha1/clusterversion.go +++ /dev/null @@ -1,68 +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. -*/ - -// Code generated by lister-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - v1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1" - "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/client-go/tools/cache" -) - -// ClusterVersionLister helps list ClusterVersions. -// All objects returned here must be treated as read-only. -type ClusterVersionLister interface { - // List lists all ClusterVersions in the indexer. - // Objects returned here must be treated as read-only. - List(selector labels.Selector) (ret []*v1alpha1.ClusterVersion, err error) - // Get retrieves the ClusterVersion from the index for a given name. - // Objects returned here must be treated as read-only. - Get(name string) (*v1alpha1.ClusterVersion, error) - ClusterVersionListerExpansion -} - -// clusterVersionLister implements the ClusterVersionLister interface. -type clusterVersionLister struct { - indexer cache.Indexer -} - -// NewClusterVersionLister returns a new ClusterVersionLister. -func NewClusterVersionLister(indexer cache.Indexer) ClusterVersionLister { - return &clusterVersionLister{indexer: indexer} -} - -// List lists all ClusterVersions in the indexer. -func (s *clusterVersionLister) List(selector labels.Selector) (ret []*v1alpha1.ClusterVersion, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.ClusterVersion)) - }) - return ret, err -} - -// Get retrieves the ClusterVersion from the index for a given name. -func (s *clusterVersionLister) Get(name string) (*v1alpha1.ClusterVersion, error) { - obj, exists, err := s.indexer.GetByKey(name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1alpha1.Resource("clusterversion"), name) - } - return obj.(*v1alpha1.ClusterVersion), nil -} diff --git a/pkg/client/listers/apps/v1alpha1/expansion_generated.go b/pkg/client/listers/apps/v1alpha1/expansion_generated.go index 0f577dba1c3..277b9e9cc69 100644 --- a/pkg/client/listers/apps/v1alpha1/expansion_generated.go +++ b/pkg/client/listers/apps/v1alpha1/expansion_generated.go @@ -34,10 +34,6 @@ type ClusterNamespaceListerExpansion interface{} // ClusterDefinitionLister. type ClusterDefinitionListerExpansion interface{} -// ClusterVersionListerExpansion allows custom methods to be added to -// ClusterVersionLister. -type ClusterVersionListerExpansion interface{} - // ComponentListerExpansion allows custom methods to be added to // ComponentLister. type ComponentListerExpansion interface{} diff --git a/pkg/configuration/core/configtemplate_util.go b/pkg/configuration/core/configtemplate_util.go index 13301dfeba7..080eaa3bcec 100644 --- a/pkg/configuration/core/configtemplate_util.go +++ b/pkg/configuration/core/configtemplate_util.go @@ -21,11 +21,10 @@ package core import ( appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1" - "github.com/apecloud/kubeblocks/pkg/common" ) type ComponentsType interface { - appsv1alpha1.ClusterComponentVersion | appsv1alpha1.ClusterComponentDefinition | appsv1alpha1.ClusterComponentSpec + appsv1alpha1.ClusterComponentDefinition | appsv1alpha1.ClusterComponentSpec } type filterFn[T ComponentsType] func(o T) bool @@ -43,7 +42,6 @@ func filter[T ComponentsType](components []T, f filterFn[T]) *T { func GetConfigTemplatesFromComponent( cComponents []appsv1alpha1.ClusterComponentSpec, dComponents []appsv1alpha1.ClusterComponentDefinition, - aComponents []appsv1alpha1.ClusterComponentVersion, componentName string) ([]appsv1alpha1.ComponentConfigSpec, error) { findCompTypeByName := func(comName string) *appsv1alpha1.ClusterComponentSpec { return filter(cComponents, func(o appsv1alpha1.ClusterComponentSpec) bool { @@ -55,63 +53,14 @@ func GetConfigTemplatesFromComponent( if cCom == nil { return nil, MakeError("failed to find component[%s]", componentName) } - aCom := filter(aComponents, func(o appsv1alpha1.ClusterComponentVersion) bool { - return o.ComponentDefRef == cCom.ComponentDefRef - }) dCom := filter(dComponents, func(o appsv1alpha1.ClusterComponentDefinition) bool { return o.Name == cCom.ComponentDefRef }) - var ( - cvConfigSpecs []appsv1alpha1.ComponentConfigSpec - cdConfigSpecs []appsv1alpha1.ComponentConfigSpec - ) - - if aCom != nil { - cvConfigSpecs = aCom.ConfigSpecs - } if dCom != nil { - cdConfigSpecs = dCom.ConfigSpecs - } - - return MergeConfigTemplates(cvConfigSpecs, cdConfigSpecs), nil -} - -// MergeConfigTemplates merges ClusterVersion.ComponentDefs[*].ConfigTemplateRefs and ClusterDefinition.ComponentDefs[*].ConfigTemplateRefs -func MergeConfigTemplates(cvConfigSpecs []appsv1alpha1.ComponentConfigSpec, - cdConfigSpecs []appsv1alpha1.ComponentConfigSpec) []appsv1alpha1.ComponentConfigSpec { - if len(cvConfigSpecs) == 0 { - return cdConfigSpecs - } - - if len(cdConfigSpecs) == 0 { - return cvConfigSpecs + return dCom.ConfigSpecs, nil } - - mergedCfgTpl := make([]appsv1alpha1.ComponentConfigSpec, 0, common.SafeAddInt(len(cvConfigSpecs), len(cdConfigSpecs))) - mergedTplMap := make(map[string]struct{}, cap(mergedCfgTpl)) - - for _, configSpec := range cvConfigSpecs { - tplName := configSpec.Name - if _, ok := (mergedTplMap)[tplName]; ok { - // It's been checked in validation webhook - continue - } - mergedCfgTpl = append(mergedCfgTpl, configSpec) - mergedTplMap[tplName] = struct{}{} - } - - for _, configSpec := range cdConfigSpecs { - // ClusterVersion replaces clusterDefinition - tplName := configSpec.Name - if _, ok := (mergedTplMap)[tplName]; ok { - continue - } - mergedCfgTpl = append(mergedCfgTpl, configSpec) - mergedTplMap[tplName] = struct{}{} - } - - return mergedCfgTpl + return nil, nil } func IsSupportConfigFileReconfigure(configTemplateSpec appsv1alpha1.ComponentConfigSpec, configFileKey string) bool { diff --git a/pkg/configuration/core/configtemplate_util_test.go b/pkg/configuration/core/configtemplate_util_test.go index 4e77fd76a10..18f51422991 100644 --- a/pkg/configuration/core/configtemplate_util_test.go +++ b/pkg/configuration/core/configtemplate_util_test.go @@ -27,155 +27,28 @@ import ( appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1" ) -func TestMergeConfigTemplates(t *testing.T) { - type args struct { - cvTpl []appsv1alpha1.ComponentConfigSpec - cdTpl []appsv1alpha1.ComponentConfigSpec - } - tests := []struct { - name string - args args - want []appsv1alpha1.ComponentConfigSpec - }{{ - name: "merge_configtpl_test", - args: args{ - cvTpl: nil, - cdTpl: nil, - }, - want: nil, - }, { - name: "merge_configtpl_test", - args: args{ - cvTpl: []appsv1alpha1.ComponentConfigSpec{{ - ComponentTemplateSpec: appsv1alpha1.ComponentTemplateSpec{ - Name: "test1", - TemplateRef: "tpl1", - VolumeName: "test1", - }}, { - ComponentTemplateSpec: appsv1alpha1.ComponentTemplateSpec{ - Name: "test2", - TemplateRef: "tpl2", - VolumeName: "test2", - }}}, - cdTpl: nil, - }, - want: []appsv1alpha1.ComponentConfigSpec{{ - ComponentTemplateSpec: appsv1alpha1.ComponentTemplateSpec{ - Name: "test1", - TemplateRef: "tpl1", - VolumeName: "test1", - }}, { - ComponentTemplateSpec: appsv1alpha1.ComponentTemplateSpec{ - Name: "test2", - TemplateRef: "tpl2", - VolumeName: "test2", - }}}, - }, { - name: "merge_configtpl_test", - args: args{ - cvTpl: nil, - cdTpl: []appsv1alpha1.ComponentConfigSpec{{ - ComponentTemplateSpec: appsv1alpha1.ComponentTemplateSpec{ - Name: "test1", - TemplateRef: "tpl1", - VolumeName: "test1", - }}, { - ComponentTemplateSpec: appsv1alpha1.ComponentTemplateSpec{ - Name: "test2", - TemplateRef: "tpl2", - VolumeName: "test2", - }}}, - }, - want: []appsv1alpha1.ComponentConfigSpec{{ - ComponentTemplateSpec: appsv1alpha1.ComponentTemplateSpec{ - Name: "test1", - TemplateRef: "tpl1", - VolumeName: "test1", - }}, { - ComponentTemplateSpec: appsv1alpha1.ComponentTemplateSpec{ - Name: "test2", - TemplateRef: "tpl2", - VolumeName: "test2", - }}}, - }, { - name: "merge_configtpl_test", - args: args{ - cvTpl: []appsv1alpha1.ComponentConfigSpec{{ - // update volume - ComponentTemplateSpec: appsv1alpha1.ComponentTemplateSpec{ - Name: "tpl1", - TemplateRef: "config1_new", - VolumeName: "volume1", - }}, { - // add volume - ComponentTemplateSpec: appsv1alpha1.ComponentTemplateSpec{ - Name: "tpl2", - TemplateRef: "config2_new", - VolumeName: "volume2", - }}}, - cdTpl: []appsv1alpha1.ComponentConfigSpec{{ - ComponentTemplateSpec: appsv1alpha1.ComponentTemplateSpec{ - Name: "tpl1", - TemplateRef: "config1", - VolumeName: "volume1", - }}, { - ComponentTemplateSpec: appsv1alpha1.ComponentTemplateSpec{ - Name: "tpl3", - TemplateRef: "config3", - VolumeName: "volume3", - }}}, - }, - want: []appsv1alpha1.ComponentConfigSpec{ - { - ComponentTemplateSpec: appsv1alpha1.ComponentTemplateSpec{ - Name: "tpl1", - TemplateRef: "config1_new", - VolumeName: "volume1", - }}, { - ComponentTemplateSpec: appsv1alpha1.ComponentTemplateSpec{ - Name: "tpl2", - TemplateRef: "config2_new", - VolumeName: "volume2", - }}, { - ComponentTemplateSpec: appsv1alpha1.ComponentTemplateSpec{ - Name: "tpl3", - TemplateRef: "config3", - VolumeName: "volume3", - }}}, - }} - - for _, tt := range tests { - got := MergeConfigTemplates(tt.args.cvTpl, tt.args.cdTpl) - require.EqualValues(t, tt.want, got) - } -} - func TestGetConfigTemplatesFromComponent(t *testing.T) { var ( comName = "replicats_name" comType = "replicats" - cComponents = []appsv1alpha1.ClusterComponentSpec{{ - Name: comName, - ComponentDefRef: comType, - }} - tpl1 = appsv1alpha1.ComponentConfigSpec{ + cComponents = []appsv1alpha1.ClusterComponentSpec{ + { + Name: comName, + ComponentDefRef: comType, + }, + } + tpl = appsv1alpha1.ComponentConfigSpec{ ComponentTemplateSpec: appsv1alpha1.ComponentTemplateSpec{ Name: "tpl1", TemplateRef: "cm1", VolumeName: "volum1", - }} - tpl2 = appsv1alpha1.ComponentConfigSpec{ - ComponentTemplateSpec: appsv1alpha1.ComponentTemplateSpec{ - Name: "tpl2", - TemplateRef: "cm2", - VolumeName: "volum2", - }} + }, + } ) type args struct { cComponents []appsv1alpha1.ClusterComponentSpec dComponents []appsv1alpha1.ClusterComponentDefinition - aComponents []appsv1alpha1.ClusterComponentVersion comName string } tests := []struct { @@ -183,66 +56,55 @@ func TestGetConfigTemplatesFromComponent(t *testing.T) { args args want []appsv1alpha1.ComponentConfigSpec wantErr bool - }{{ - name: "normal_test", - args: args{ - comName: comName, - cComponents: cComponents, - dComponents: []appsv1alpha1.ClusterComponentDefinition{{ - Name: comType, - ConfigSpecs: []appsv1alpha1.ComponentConfigSpec{tpl1}, - }}, - aComponents: []appsv1alpha1.ClusterComponentVersion{{ - ComponentDefRef: comType, - ConfigSpecs: []appsv1alpha1.ComponentConfigSpec{tpl2}, - }}, - }, - want: []appsv1alpha1.ComponentConfigSpec{ - tpl2, - tpl1, - }, - wantErr: false, - }, { - name: "failed_test", - args: args{ - comName: "not exist component", - cComponents: cComponents, - dComponents: []appsv1alpha1.ClusterComponentDefinition{{ - Name: comType, - ConfigSpecs: []appsv1alpha1.ComponentConfigSpec{tpl1}, - }}, - aComponents: []appsv1alpha1.ClusterComponentVersion{{ - ComponentDefRef: comType, - ConfigSpecs: []appsv1alpha1.ComponentConfigSpec{tpl2}, - }}, + }{ + { + name: "normal_test", + args: args{ + comName: comName, + cComponents: cComponents, + dComponents: []appsv1alpha1.ClusterComponentDefinition{{ + Name: comType, + ConfigSpecs: []appsv1alpha1.ComponentConfigSpec{tpl}, + }}, + }, + want: []appsv1alpha1.ComponentConfigSpec{ + tpl, + }, + wantErr: false, }, - want: nil, - wantErr: true, - }, { - name: "not_exist_and_not_failed", - args: args{ - comName: comName, - cComponents: cComponents, - dComponents: []appsv1alpha1.ClusterComponentDefinition{{ - Name: comType, - ConfigSpecs: []appsv1alpha1.ComponentConfigSpec{tpl1}, - }}, - aComponents: []appsv1alpha1.ClusterComponentVersion{{ - ComponentDefRef: "not exist", - ConfigSpecs: []appsv1alpha1.ComponentConfigSpec{tpl2}, + { + name: "failed_test", + args: args{ + comName: "not exist component", + cComponents: cComponents, + dComponents: []appsv1alpha1.ClusterComponentDefinition{{ + Name: comType, + ConfigSpecs: []appsv1alpha1.ComponentConfigSpec{tpl}, + }}, + }, + want: nil, + wantErr: true, + }, { + name: "not_exist_and_not_failed", + args: args{ + comName: comName, + cComponents: cComponents, + dComponents: []appsv1alpha1.ClusterComponentDefinition{{ + Name: comType, + ConfigSpecs: []appsv1alpha1.ComponentConfigSpec{tpl}, + }}, }, - }}, - want: []appsv1alpha1.ComponentConfigSpec{ - tpl1, + want: []appsv1alpha1.ComponentConfigSpec{ + tpl, + }, + wantErr: false, }, - wantErr: false, - }} + } for _, tt := range tests { got, err := GetConfigTemplatesFromComponent( tt.args.cComponents, tt.args.dComponents, - tt.args.aComponents, tt.args.comName) require.Equal(t, err != nil, tt.wantErr) require.EqualValues(t, got, tt.want) diff --git a/pkg/configuration/core/type.go b/pkg/configuration/core/type.go index 83a72941312..468e6f6b4fd 100644 --- a/pkg/configuration/core/type.go +++ b/pkg/configuration/core/type.go @@ -163,7 +163,6 @@ func GenerateConstraintsUniqLabelKeyWithConfig(configKey string) string { return GenerateUniqKeyWithConfig(constant.ConfigurationConstraintsLabelPrefixKey, configKey) } -// GetInstanceCMName {{statefulset.Name}}-{{clusterVersion.Name}}-{{tpl.Name}}-"config" func GetInstanceCMName(obj client.Object, tpl *appsv1alpha1.ComponentTemplateSpec) string { return getInstanceCfgCMName(obj.GetName(), tpl.Name) } diff --git a/pkg/constant/annotations.go b/pkg/constant/annotations.go index 3385c566219..f80ed431312 100644 --- a/pkg/constant/annotations.go +++ b/pkg/constant/annotations.go @@ -37,7 +37,6 @@ const ( BackupPolicyTemplateAnnotationKey = "apps.kubeblocks.io/backup-policy-template" LastAppliedClusterAnnotationKey = "apps.kubeblocks.io/last-applied-cluster" PVLastClaimPolicyAnnotationKey = "apps.kubeblocks.io/pv-last-claim-policy" - HaltRecoveryAllowInconsistentCVAnnotKey = "clusters.apps.kubeblocks.io/allow-inconsistent-cv" HaltRecoveryAllowInconsistentResAnnotKey = "clusters.apps.kubeblocks.io/allow-inconsistent-resource" KubeBlocksGenerationKey = "kubeblocks.io/generation" ExtraEnvAnnotationKey = "kubeblocks.io/extra-env" diff --git a/pkg/constant/config.go b/pkg/constant/config.go index 8df6197812f..cfc81b2fa32 100644 --- a/pkg/constant/config.go +++ b/pkg/constant/config.go @@ -20,7 +20,7 @@ const ( TPLRenderToolPath = "/bin/config_render" ConfigManagerToolPath = "/bin/reloader" - // ConfigurationTplLabelPrefixKey clusterVersion or clusterdefinition using tpl + // ConfigurationTplLabelPrefixKey clusterdefinition using tpl ConfigurationTplLabelPrefixKey = "config.kubeblocks.io/tpl" ConfigurationConstraintsLabelPrefixKey = "config.kubeblocks.io/constraints" diff --git a/pkg/constant/labels.go b/pkg/constant/labels.go index b1bccfbabe7..83bde789e26 100644 --- a/pkg/constant/labels.go +++ b/pkg/constant/labels.go @@ -54,7 +54,6 @@ const ( WorkloadTypeLabelKey = "apps.kubeblocks.io/workload-type" KBAppPodNameLabelKey = "apps.kubeblocks.io/pod-name" ClusterDefLabelKey = "clusterdefinition.kubeblocks.io/name" - ClusterVerLabelKey = "clusterversion.kubeblocks.io/name" ComponentDefinitionLabelKey = "componentdefinition.kubeblocks.io/name" ComponentVersionLabelKey = "componentversion.kubeblocks.io/name" ConsensusSetAccessModeLabelKey = "cs.apps.kubeblocks.io/access-mode" diff --git a/pkg/controller/component/action_post_provision_test.go b/pkg/controller/component/action_post_provision_test.go index 3f044c074b2..cc6f2b02bd3 100644 --- a/pkg/controller/component/action_post_provision_test.go +++ b/pkg/controller/component/action_post_provision_test.go @@ -41,30 +41,23 @@ import ( var _ = Describe("Component PostProvision Test", func() { Context("has the BuildComponent function", func() { const ( - clusterDefName = "test-clusterdef" - clusterVersionName = "test-clusterversion" - clusterName = "test-cluster" - mysqlCompDefName = "replicasets" - mysqlCompName = "mysql" + clusterDefName = "test-clusterdef" + clusterName = "test-cluster" + mysqlCompDefName = "replicasets" + mysqlCompName = "mysql" ) var ( - clusterDef *appsv1alpha1.ClusterDefinition - clusterVersion *appsv1alpha1.ClusterVersion - cluster *appsv1alpha1.Cluster + clusterDef *appsv1alpha1.ClusterDefinition + cluster *appsv1alpha1.Cluster ) BeforeEach(func() { clusterDef = testapps.NewClusterDefFactory(clusterDefName). AddComponentDef(testapps.StatefulMySQLComponent, mysqlCompDefName). GetObject() - clusterVersion = testapps.NewClusterVersionFactory(clusterVersionName, clusterDefName). - AddComponentVersion(mysqlCompDefName). - AddContainerShort("mysql", testapps.ApeCloudMySQLImage). - GetObject() pvcSpec := testapps.NewPVCSpec("1Gi") - cluster = testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, - clusterDef.Name, clusterVersion.Name). + cluster = testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, clusterDef.Name). SetUID(clusterName). AddComponent(mysqlCompName, mysqlCompDefName). AddVolumeClaimTemplate(testapps.DataVolumeName, pvcSpec). @@ -112,7 +105,6 @@ var _ = Describe("Component PostProvision Test", func() { reqCtx, testCtx.Cli, clusterDef, - clusterVersion, cluster, &cluster.Spec.ComponentSpecs[0]) Expect(err).Should(Succeed()) diff --git a/pkg/controller/component/action_pre_terminate_test.go b/pkg/controller/component/action_pre_terminate_test.go index 110781a0a86..a8c7f5cc8c5 100644 --- a/pkg/controller/component/action_pre_terminate_test.go +++ b/pkg/controller/component/action_pre_terminate_test.go @@ -41,30 +41,23 @@ import ( var _ = Describe("Component PreTerminate Test", func() { Context("has the BuildComponent function", func() { const ( - clusterDefName = "test-clusterdef" - clusterVersionName = "test-clusterversion" - clusterName = "test-cluster" - mysqlCompDefName = "replicasets" - mysqlCompName = "mysql" + clusterDefName = "test-clusterdef" + clusterName = "test-cluster" + mysqlCompDefName = "replicasets" + mysqlCompName = "mysql" ) var ( - clusterDef *appsv1alpha1.ClusterDefinition - clusterVersion *appsv1alpha1.ClusterVersion - cluster *appsv1alpha1.Cluster + clusterDef *appsv1alpha1.ClusterDefinition + cluster *appsv1alpha1.Cluster ) BeforeEach(func() { clusterDef = testapps.NewClusterDefFactory(clusterDefName). AddComponentDef(testapps.StatefulMySQLComponent, mysqlCompDefName). GetObject() - clusterVersion = testapps.NewClusterVersionFactory(clusterVersionName, clusterDefName). - AddComponentVersion(mysqlCompDefName). - AddContainerShort("mysql", testapps.ApeCloudMySQLImage). - GetObject() pvcSpec := testapps.NewPVCSpec("1Gi") - cluster = testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, - clusterDef.Name, clusterVersion.Name). + cluster = testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, clusterDef.Name). SetUID(clusterName). AddComponent(mysqlCompName, mysqlCompDefName). AddVolumeClaimTemplate(testapps.DataVolumeName, pvcSpec). @@ -112,7 +105,6 @@ var _ = Describe("Component PreTerminate Test", func() { reqCtx, testCtx.Cli, clusterDef, - clusterVersion, cluster, &cluster.Spec.ComponentSpecs[0]) Expect(err).Should(Succeed()) diff --git a/pkg/controller/component/action_utils_test.go b/pkg/controller/component/action_utils_test.go index 2b4bba48137..7a204e100d6 100644 --- a/pkg/controller/component/action_utils_test.go +++ b/pkg/controller/component/action_utils_test.go @@ -43,30 +43,23 @@ var tlog = ctrl.Log.WithName("component_testing") var _ = Describe("Component LifeCycle Action Utils Test", func() { Context("has the BuildComponent function", func() { const ( - clusterDefName = "test-clusterdef" - clusterVersionName = "test-clusterversion" - clusterName = "test-cluster" - mysqlCompDefName = "replicasets" - mysqlCompName = "mysql" + clusterDefName = "test-clusterdef" + clusterName = "test-cluster" + mysqlCompDefName = "replicasets" + mysqlCompName = "mysql" ) var ( - clusterDef *appsv1alpha1.ClusterDefinition - clusterVersion *appsv1alpha1.ClusterVersion - cluster *appsv1alpha1.Cluster + clusterDef *appsv1alpha1.ClusterDefinition + cluster *appsv1alpha1.Cluster ) BeforeEach(func() { clusterDef = testapps.NewClusterDefFactory(clusterDefName). AddComponentDef(testapps.StatefulMySQLComponent, mysqlCompDefName). GetObject() - clusterVersion = testapps.NewClusterVersionFactory(clusterVersionName, clusterDefName). - AddComponentVersion(mysqlCompDefName). - AddContainerShort("mysql", testapps.ApeCloudMySQLImage). - GetObject() pvcSpec := testapps.NewPVCSpec("1Gi") - cluster = testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, - clusterDef.Name, clusterVersion.Name). + cluster = testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, clusterDef.Name). SetUID(clusterName). AddComponent(mysqlCompName, mysqlCompDefName). AddVolumeClaimTemplate(testapps.DataVolumeName, pvcSpec). @@ -114,7 +107,6 @@ var _ = Describe("Component LifeCycle Action Utils Test", func() { reqCtx, testCtx.Cli, clusterDef, - clusterVersion, cluster, &cluster.Spec.ComponentSpecs[0]) Expect(err).Should(Succeed()) diff --git a/pkg/controller/component/component.go b/pkg/controller/component/component.go index 2e601c1d14d..705086b597c 100644 --- a/pkg/controller/component/component.go +++ b/pkg/controller/component/component.go @@ -122,13 +122,12 @@ func BuildComponent(cluster *appsv1alpha1.Cluster, compSpec *appsv1alpha1.Cluste } func BuildComponentDefinition(clusterDef *appsv1alpha1.ClusterDefinition, - clusterVer *appsv1alpha1.ClusterVersion, clusterCompSpec *appsv1alpha1.ClusterComponentSpec) (*appsv1alpha1.ComponentDefinition, error) { - clusterCompDef, clusterCompVer, err := getClusterCompDefAndVersion(clusterDef, clusterVer, clusterCompSpec) + clusterCompDef, err := getClusterCompDef(clusterDef, clusterCompSpec) if err != nil { return nil, err } - compDef, err := buildComponentDefinitionByConversion(clusterCompDef, clusterCompVer) + compDef, err := buildComponentDefinitionByConversion(clusterCompDef) if err != nil { return nil, err } @@ -137,11 +136,10 @@ func BuildComponentDefinition(clusterDef *appsv1alpha1.ClusterDefinition, func getOrBuildComponentDefinition(ctx context.Context, cli client.Reader, clusterDef *appsv1alpha1.ClusterDefinition, - clusterVer *appsv1alpha1.ClusterVersion, cluster *appsv1alpha1.Cluster, clusterCompSpec *appsv1alpha1.ClusterComponentSpec) (*appsv1alpha1.ComponentDefinition, error) { if len(cluster.Spec.ClusterDefRef) > 0 && len(clusterCompSpec.ComponentDefRef) > 0 { - return BuildComponentDefinition(clusterDef, clusterVer, clusterCompSpec) + return BuildComponentDefinition(clusterDef, clusterCompSpec) } if len(clusterCompSpec.ComponentDef) > 0 { compDef := &appsv1alpha1.ComponentDefinition{} @@ -154,48 +152,36 @@ func getOrBuildComponentDefinition(ctx context.Context, cli client.Reader, } func getClusterReferencedResources(ctx context.Context, cli client.Reader, - cluster *appsv1alpha1.Cluster) (*appsv1alpha1.ClusterDefinition, *appsv1alpha1.ClusterVersion, error) { + cluster *appsv1alpha1.Cluster) (*appsv1alpha1.ClusterDefinition, error) { var ( clusterDef *appsv1alpha1.ClusterDefinition - clusterVer *appsv1alpha1.ClusterVersion ) if len(cluster.Spec.ClusterDefRef) > 0 { clusterDef = &appsv1alpha1.ClusterDefinition{} if err := cli.Get(ctx, types.NamespacedName{Name: cluster.Spec.ClusterDefRef}, clusterDef); err != nil { - return nil, nil, err - } - } - if len(cluster.Spec.ClusterVersionRef) > 0 { - clusterVer = &appsv1alpha1.ClusterVersion{} - if err := cli.Get(ctx, types.NamespacedName{Name: cluster.Spec.ClusterVersionRef}, clusterVer); err != nil { - return nil, nil, err + return nil, err } } if clusterDef == nil { if len(cluster.Spec.ClusterDefRef) == 0 { - return nil, nil, fmt.Errorf("cluster definition is needed for generated component") + return nil, fmt.Errorf("cluster definition is needed for generated component") } else { - return nil, nil, fmt.Errorf("referenced cluster definition is not found: %s", cluster.Spec.ClusterDefRef) + return nil, fmt.Errorf("referenced cluster definition is not found: %s", cluster.Spec.ClusterDefRef) } } - return clusterDef, clusterVer, nil + return clusterDef, nil } -func getClusterCompDefAndVersion(clusterDef *appsv1alpha1.ClusterDefinition, - clusterVer *appsv1alpha1.ClusterVersion, - clusterCompSpec *appsv1alpha1.ClusterComponentSpec) (*appsv1alpha1.ClusterComponentDefinition, *appsv1alpha1.ClusterComponentVersion, error) { +func getClusterCompDef(clusterDef *appsv1alpha1.ClusterDefinition, + clusterCompSpec *appsv1alpha1.ClusterComponentSpec) (*appsv1alpha1.ClusterComponentDefinition, error) { if len(clusterCompSpec.ComponentDefRef) == 0 { - return nil, nil, fmt.Errorf("cluster component definition ref is empty: %s", clusterCompSpec.Name) + return nil, fmt.Errorf("cluster component definition ref is empty: %s", clusterCompSpec.Name) } clusterCompDef := clusterDef.GetComponentDefByName(clusterCompSpec.ComponentDefRef) if clusterCompDef == nil { - return nil, nil, fmt.Errorf("referenced cluster component definition is not defined: %s", clusterCompSpec.ComponentDefRef) - } - var clusterCompVer *appsv1alpha1.ClusterComponentVersion - if clusterVer != nil { - clusterCompVer = clusterVer.Spec.GetDefNameMappingComponents()[clusterCompSpec.ComponentDefRef] + return nil, fmt.Errorf("referenced cluster component definition is not defined: %s", clusterCompSpec.ComponentDefRef) } - return clusterCompDef, clusterCompVer, nil + return clusterCompDef, nil } func getClusterCompSpec4Component(ctx context.Context, cli client.Reader, diff --git a/pkg/controller/component/component_test.go b/pkg/controller/component/component_test.go index d9618277fa3..2a019739a6d 100644 --- a/pkg/controller/component/component_test.go +++ b/pkg/controller/component/component_test.go @@ -42,7 +42,6 @@ var _ = Describe("Component", func() { Context("has the BuildComponent function", func() { const ( clusterDefName = "test-clusterdef" - clusterVersionName = "test-clusterversion" clusterName = "test-cluster" mysqlCompDefName = "replicasets" mysqlCompName = "mysql" @@ -53,9 +52,8 @@ var _ = Describe("Component", func() { ) var ( - clusterDef *appsv1alpha1.ClusterDefinition - clusterVersion *appsv1alpha1.ClusterVersion - cluster *appsv1alpha1.Cluster + clusterDef *appsv1alpha1.ClusterDefinition + cluster *appsv1alpha1.Cluster ) BeforeEach(func() { @@ -63,49 +61,14 @@ var _ = Describe("Component", func() { AddComponentDef(testapps.StatefulMySQLComponent, mysqlCompDefName). AddComponentDef(testapps.StatelessNginxComponent, proxyCompDefName). GetObject() - clusterVersion = testapps.NewClusterVersionFactory(clusterVersionName, clusterDefName). - AddComponentVersion(mysqlCompDefName). - AddContainerShort("mysql", testapps.ApeCloudMySQLImage). - AddComponentVersion(proxyCompDefName). - AddInitContainerShort("nginx-init", testapps.NginxImage). - AddContainerShort("nginx", testapps.NginxImage). - GetObject() pvcSpec := testapps.NewPVCSpec("1Gi") - cluster = testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, clusterDef.Name, clusterVersion.Name). + cluster = testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, clusterDef.Name). AddComponent(mysqlCompName, mysqlCompDefName). AddVolumeClaimTemplate(testapps.DataVolumeName, pvcSpec). AddComponent(proxyCompName, proxyCompDefName). GetObject() }) - It("should work as expected with various inputs", func() { - By("assign every available fields") - reqCtx := intctrlutil.RequestCtx{ - Ctx: ctx, - Log: logger, - } - component, err := BuildSynthesizedComponentWrapper4Test(reqCtx, testCtx.Cli, clusterDef, clusterVersion, cluster, &cluster.Spec.ComponentSpecs[0]) - Expect(err).Should(Succeed()) - Expect(component).ShouldNot(BeNil()) - - By("leave clusterVersion.versionCtx empty initContains and containers") - clusterVersion.Spec.ComponentVersions[0].VersionsCtx.Containers = nil - clusterVersion.Spec.ComponentVersions[0].VersionsCtx.InitContainers = nil - component, err = BuildSynthesizedComponentWrapper4Test(reqCtx, testCtx.Cli, clusterDef, clusterVersion, cluster, &cluster.Spec.ComponentSpecs[0]) - Expect(err).Should(Succeed()) - Expect(component).ShouldNot(BeNil()) - - By("new container in clusterVersion not in clusterDefinition") - component, err = BuildSynthesizedComponentWrapper4Test(reqCtx, testCtx.Cli, clusterDef, clusterVersion, cluster, &cluster.Spec.ComponentSpecs[0]) - Expect(err).Should(Succeed()) - Expect(len(component.PodSpec.Containers) >= 2).Should(BeTrue()) - - By("new init container in clusterVersion not in clusterDefinition") - component, err = BuildSynthesizedComponentWrapper4Test(reqCtx, testCtx.Cli, clusterDef, clusterVersion, cluster, &cluster.Spec.ComponentSpecs[1]) - Expect(err).Should(Succeed()) - Expect(len(component.PodSpec.InitContainers)).Should(Equal(1)) - }) - It("should auto fill first component if it's empty", func() { reqCtx := intctrlutil.RequestCtx{ Ctx: ctx, @@ -123,7 +86,7 @@ var _ = Describe("Component", func() { cluster.Spec.ComponentSpecs = nil By("build first component from simplified fields") - synthesizeComp, err := BuildSynthesizedComponentWrapper4Test(reqCtx, testCtx.Cli, clusterDef, clusterVersion, cluster, nil) + synthesizeComp, err := BuildSynthesizedComponentWrapper4Test(reqCtx, testCtx.Cli, clusterDef, cluster, nil) Expect(err).Should(Succeed()) Expect(synthesizeComp).ShouldNot(BeNil()) Expect(synthesizeComp.Replicas).Should(Equal(*cluster.Spec.Replicas)) @@ -141,7 +104,7 @@ var _ = Describe("Component", func() { By("clear cluster's component spec") cluster.Spec.ComponentSpecs = nil By("call build") - synthesizeComp, err := BuildSynthesizedComponentWrapper4Test(reqCtx, testCtx.Cli, clusterDef, clusterVersion, cluster, nil) + synthesizeComp, err := BuildSynthesizedComponentWrapper4Test(reqCtx, testCtx.Cli, clusterDef, cluster, nil) Expect(err).Should(Succeed()) Expect(synthesizeComp).ShouldNot(BeNil()) Expect(synthesizeComp.PodSpec.Affinity.PodAntiAffinity.PreferredDuringSchedulingIgnoredDuringExecution[0].PodAffinityTerm.TopologyKey).Should(Equal("topology.kubernetes.io/zone")) @@ -163,7 +126,7 @@ var _ = Describe("Component", func() { By("clear cluster's component spec") cluster.Spec.ComponentSpecs = nil By("call build") - synthesizeComp, err := BuildSynthesizedComponentWrapper4Test(reqCtx, testCtx.Cli, clusterDef, clusterVersion, cluster, nil) + synthesizeComp, err := BuildSynthesizedComponentWrapper4Test(reqCtx, testCtx.Cli, clusterDef, cluster, nil) Expect(err).Should(Succeed()) Expect(synthesizeComp).ShouldNot(BeNil()) Expect(synthesizeComp.ComponentServices).Should(HaveLen(2)) @@ -216,7 +179,7 @@ var _ = Describe("Component", func() { By("clear cluster's component spec") cluster.Spec.ComponentSpecs = nil By("call build") - synthesizeComp, err := BuildSynthesizedComponentWrapper4Test(reqCtx, testCtx.Cli, clusterDef, clusterVersion, cluster, nil) + synthesizeComp, err := BuildSynthesizedComponentWrapper4Test(reqCtx, testCtx.Cli, clusterDef, cluster, nil) Expect(err).Should(Succeed()) Expect(synthesizeComp).Should(BeNil()) }) @@ -247,7 +210,7 @@ var _ = Describe("Component", func() { testapps.NginxImage: serviceDescriptor, } By("call build") - synthesizeComp, err := BuildSynthesizedComponentWrapper4Test(reqCtx, testCtx.Cli, clusterDef, clusterVersion, cluster, &cluster.Spec.ComponentSpecs[0]) + synthesizeComp, err := BuildSynthesizedComponentWrapper4Test(reqCtx, testCtx.Cli, clusterDef, cluster, &cluster.Spec.ComponentSpecs[0]) Expect(err).Should(Succeed()) Expect(synthesizeComp).ShouldNot(BeNil()) Expect(synthesizeComp.ServiceReferences).ShouldNot(BeNil()) @@ -314,7 +277,7 @@ var _ = Describe("Component", func() { } cluster.Spec.ComponentSpecs[0].Resources.Requests[corev1.ResourceMemory] = _512m cluster.Spec.ComponentSpecs[0].Resources.Limits[corev1.ResourceMemory] = _1024m - comp, err := BuildSynthesizedComponentWrapper4Test(reqCtx, testCtx.Cli, clusterDef, nil, cluster, &cluster.Spec.ComponentSpecs[0]) + comp, err := BuildSynthesizedComponentWrapper4Test(reqCtx, testCtx.Cli, clusterDef, cluster, &cluster.Spec.ComponentSpecs[0]) Expect(err).Should(Succeed()) Expect(comp).ShouldNot(BeNil()) for _, vol := range comp.PodSpec.Volumes { @@ -335,7 +298,7 @@ var _ = Describe("Component", func() { By("without memory resource set") delete(cluster.Spec.ComponentSpecs[0].Resources.Requests, corev1.ResourceMemory) delete(cluster.Spec.ComponentSpecs[0].Resources.Limits, corev1.ResourceMemory) - comp, err = BuildSynthesizedComponentWrapper4Test(reqCtx, testCtx.Cli, clusterDef, nil, cluster, &cluster.Spec.ComponentSpecs[0]) + comp, err = BuildSynthesizedComponentWrapper4Test(reqCtx, testCtx.Cli, clusterDef, cluster, &cluster.Spec.ComponentSpecs[0]) Expect(err).Should(Succeed()) Expect(comp).ShouldNot(BeNil()) for _, vol := range comp.PodSpec.Volumes { diff --git a/pkg/controller/component/definition_convertor.go b/pkg/controller/component/definition_convertor.go index ebc3b5d22fb..90fb6355adb 100644 --- a/pkg/controller/component/definition_convertor.go +++ b/pkg/controller/component/definition_convertor.go @@ -27,7 +27,6 @@ import ( appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1" workloads "github.com/apecloud/kubeblocks/apis/workloads/v1alpha1" "github.com/apecloud/kubeblocks/pkg/apiutil" - cfgcore "github.com/apecloud/kubeblocks/pkg/configuration/core" "github.com/apecloud/kubeblocks/pkg/constant" "github.com/apecloud/kubeblocks/pkg/controller/builder" ) @@ -35,8 +34,7 @@ import ( // TODO(component): type check // buildComponentDefinitionByConversion builds a ComponentDefinition from a ClusterComponentDefinition and a ClusterComponentVersion. -func buildComponentDefinitionByConversion(clusterCompDef *appsv1alpha1.ClusterComponentDefinition, - clusterCompVer *appsv1alpha1.ClusterComponentVersion) (*appsv1alpha1.ComponentDefinition, error) { +func buildComponentDefinitionByConversion(clusterCompDef *appsv1alpha1.ClusterComponentDefinition) (*appsv1alpha1.ComponentDefinition, error) { if clusterCompDef == nil { return nil, nil } @@ -64,7 +62,7 @@ func buildComponentDefinitionByConversion(clusterCompDef *appsv1alpha1.ClusterCo "exporter": &compDefExporterConvertor{}, } compDef := &appsv1alpha1.ComponentDefinition{} - if err := covertObject(convertors, &compDef.Spec, clusterCompDef, clusterCompVer); err != nil { + if err := covertObject(convertors, &compDef.Spec, clusterCompDef); err != nil { return nil, err } return compDef, nil @@ -104,23 +102,10 @@ type compDefRuntimeConvertor struct{} func (c *compDefRuntimeConvertor) convert(args ...any) (any, error) { clusterCompDef := args[0].(*appsv1alpha1.ClusterComponentDefinition) - var clusterCompVer *appsv1alpha1.ClusterComponentVersion - if len(args) > 1 { - clusterCompVer = args[1].(*appsv1alpha1.ClusterComponentVersion) - } if clusterCompDef.PodSpec == nil { return nil, fmt.Errorf("no pod spec") } - podSpec := clusterCompDef.PodSpec.DeepCopy() - if clusterCompVer != nil { - for _, container := range clusterCompVer.VersionsCtx.InitContainers { - podSpec.InitContainers = appendOrOverrideContainerAttr(podSpec.InitContainers, container) - } - for _, container := range clusterCompVer.VersionsCtx.Containers { - podSpec.Containers = appendOrOverrideContainerAttr(podSpec.Containers, container) - } - } return *podSpec, nil } @@ -290,14 +275,7 @@ type compDefConfigsConvertor struct{} func (c *compDefConfigsConvertor) convert(args ...any) (any, error) { clusterCompDef := args[0].(*appsv1alpha1.ClusterComponentDefinition) - var clusterCompVer *appsv1alpha1.ClusterComponentVersion - if len(args) > 1 { - clusterCompVer = args[1].(*appsv1alpha1.ClusterComponentVersion) - } - if clusterCompVer == nil { - return clusterCompDef.ConfigSpecs, nil - } - return cfgcore.MergeConfigTemplates(clusterCompVer.ConfigSpecs, clusterCompDef.ConfigSpecs), nil + return clusterCompDef.ConfigSpecs, nil } // compDefLogConfigsConvertor is an implementation of the convertor interface, used to convert the given object into ComponentDefinition.Spec.LogConfigs. @@ -487,10 +465,6 @@ type compDefLifecycleActionsConvertor struct{} func (c *compDefLifecycleActionsConvertor) convert(args ...any) (any, error) { clusterCompDef := args[0].(*appsv1alpha1.ClusterComponentDefinition) - var clusterCompVer *appsv1alpha1.ClusterComponentVersion - if len(args) > 1 { - clusterCompVer = args[1].(*appsv1alpha1.ClusterComponentVersion) - } lifecycleActions := &appsv1alpha1.ComponentLifecycleActions{} @@ -500,7 +474,7 @@ func (c *compDefLifecycleActionsConvertor) convert(args ...any) (any, error) { } if clusterCompDef.SwitchoverSpec != nil { - lifecycleActions.Switchover = c.convertSwitchover(clusterCompDef.SwitchoverSpec, clusterCompVer) + lifecycleActions.Switchover = c.convertSwitchover(clusterCompDef.SwitchoverSpec) } if clusterCompDef.PostStartSpec != nil { @@ -613,12 +587,8 @@ func (c *compDefLifecycleActionsConvertor) convertPostProvision(postStart *appsv } } -func (c *compDefLifecycleActionsConvertor) convertSwitchover(switchover *appsv1alpha1.SwitchoverSpec, - clusterCompVer *appsv1alpha1.ClusterComponentVersion) *appsv1alpha1.ComponentSwitchover { +func (c *compDefLifecycleActionsConvertor) convertSwitchover(switchover *appsv1alpha1.SwitchoverSpec) *appsv1alpha1.ComponentSwitchover { spec := *switchover - if clusterCompVer != nil { - overrideSwitchoverSpecAttr(&spec, clusterCompVer.SwitchoverSpec) - } if spec.WithCandidate == nil && spec.WithoutCandidate == nil { return nil } diff --git a/pkg/controller/component/definition_convertor_test.go b/pkg/controller/component/definition_convertor_test.go index 1fa9290af77..7c64ab03c18 100644 --- a/pkg/controller/component/definition_convertor_test.go +++ b/pkg/controller/component/definition_convertor_test.go @@ -307,43 +307,6 @@ var _ = Describe("Component Definition Convertor", func() { Expect(err).Should(HaveOccurred()) Expect(res).Should(BeNil()) }) - - It("w/o comp version", func() { - convertor := &compDefRuntimeConvertor{} - res, err := convertor.convert(clusterCompDef) - Expect(err).Should(Succeed()) - Expect(res).Should(BeEquivalentTo(*clusterCompDef.PodSpec)) - }) - - It("w/ comp version", func() { - clusterCompVer := &appsv1alpha1.ClusterComponentVersion{ - VersionsCtx: appsv1alpha1.VersionsContext{ - InitContainers: []corev1.Container{ - { - Name: "init", - Image: "init", - }, - }, - Containers: []corev1.Container{ - { - Name: "mysql", - Image: "image", - }, - }, - }, - } - - convertor := &compDefRuntimeConvertor{} - res, err := convertor.convert(clusterCompDef, clusterCompVer) - Expect(err).Should(Succeed()) - - expectedPodSpec := clusterCompDef.PodSpec - Expect(expectedPodSpec.Containers[0].Image).Should(BeEmpty()) - Expect(expectedPodSpec.InitContainers).Should(HaveLen(0)) - expectedPodSpec.Containers[0].Image = clusterCompVer.VersionsCtx.Containers[0].Image - expectedPodSpec.InitContainers = clusterCompVer.VersionsCtx.InitContainers - Expect(res).Should(BeEquivalentTo(*expectedPodSpec)) - }) }) Context("vars", func() { @@ -547,37 +510,11 @@ var _ = Describe("Component Definition Convertor", func() { }) }) - Context("configs", func() { - It("w/o comp version", func() { - convertor := &compDefConfigsConvertor{} - res, err := convertor.convert(clusterCompDef) - Expect(err).Should(Succeed()) - Expect(res).Should(BeEquivalentTo(clusterCompDef.ConfigSpecs)) - }) - - It("w/ comp version", func() { - clusterCompVer := &appsv1alpha1.ClusterComponentVersion{ - ConfigSpecs: []appsv1alpha1.ComponentConfigSpec{ - { - ComponentTemplateSpec: appsv1alpha1.ComponentTemplateSpec{ - Name: "agamotto-config", - TemplateRef: "agamotto-config-template", - VolumeName: "agamotto-config", - DefaultMode: &defaultVolumeMode, - }, - }, - }, - } - - convertor := &compDefConfigsConvertor{} - res, err := convertor.convert(clusterCompDef, clusterCompVer) - Expect(err).Should(Succeed()) - - expectedConfigs := make([]appsv1alpha1.ComponentConfigSpec, 0) - expectedConfigs = append(expectedConfigs, clusterCompVer.ConfigSpecs...) - expectedConfigs = append(expectedConfigs, clusterCompDef.ConfigSpecs...) - Expect(res).Should(BeEquivalentTo(expectedConfigs)) - }) + It("configs", func() { + convertor := &compDefConfigsConvertor{} + res, err := convertor.convert(clusterCompDef) + Expect(err).Should(Succeed()) + Expect(res).Should(BeEquivalentTo(clusterCompDef.ConfigSpecs)) }) It("log configs", func() { @@ -752,7 +689,7 @@ var _ = Describe("Component Definition Convertor", func() { }) Context("lifecycle actions", func() { - It("w/o comp version", func() { + It("ok", func() { clusterCompDef.Probes.RoleProbe = nil convertor := &compDefLifecycleActionsConvertor{} @@ -764,19 +701,6 @@ var _ = Describe("Component Definition Convertor", func() { Expect(*actions).Should(BeEquivalentTo(*expectedActions)) }) - It("w/ comp version", func() { - clusterCompDef.Probes.RoleProbe = nil - clusterCompVer := &appsv1alpha1.ClusterComponentVersion{} - - convertor := &compDefLifecycleActionsConvertor{} - res, err := convertor.convert(clusterCompDef, clusterCompVer) - Expect(err).Should(Succeed()) - - actions := res.(*appsv1alpha1.ComponentLifecycleActions) - expectedActions := &appsv1alpha1.ComponentLifecycleActions{} - Expect(*actions).Should(BeEquivalentTo(*expectedActions)) - }) - It("switchover", func() { clusterCompDef.Probes.RoleProbe = nil convertor := &compDefLifecycleActionsConvertor{} diff --git a/pkg/controller/component/fieldref_util_test.go b/pkg/controller/component/fieldref_util_test.go index 1589cacb471..47e9d49cef0 100644 --- a/pkg/controller/component/fieldref_util_test.go +++ b/pkg/controller/component/fieldref_util_test.go @@ -33,7 +33,6 @@ import ( var _ = Describe("ComponentRef Fields Tests", func() { const clusterDefName = "test-clusterdef" const clusterName = "test-cluster" - const clusterVersionName = "test-clusterversion" const clusterNamespace = "test-compref" const mysqlCompDefName = "mysql-def" const referredCompDefName = "maxscale-def" @@ -54,8 +53,8 @@ var _ = Describe("ComponentRef Fields Tests", func() { // add one mysql component clusterDefBuilder = clusterDefBuilder.AddComponentDef(testapps.StatefulMySQLComponent, mysqlCompDefName) - By("create cluste builder") - clusterBuilder = testapps.NewClusterFactory(clusterNamespace, clusterName, clusterDefName, clusterVersionName) + By("create cluster builder") + clusterBuilder = testapps.NewClusterFactory(clusterNamespace, clusterName, clusterDefName) }) It("test fieldref", func() { diff --git a/pkg/controller/component/service_descriptor_utils_test.go b/pkg/controller/component/service_descriptor_utils_test.go index fe37c432116..991142b60a1 100644 --- a/pkg/controller/component/service_descriptor_utils_test.go +++ b/pkg/controller/component/service_descriptor_utils_test.go @@ -52,7 +52,6 @@ var _ = Describe("build service references", func() { // resources should be released in following order // non-namespaced - testapps.ClearResourcesWithRemoveFinalizerOption(&testCtx, generics.ClusterVersionSignature, true, ml) testapps.ClearResourcesWithRemoveFinalizerOption(&testCtx, generics.ClusterDefinitionSignature, true, ml) testapps.ClearResources(&testCtx, generics.ConfigConstraintSignature, ml) @@ -63,7 +62,6 @@ var _ = Describe("build service references", func() { var ( mockClient *testutil.K8sClientMockHelper clusterDef *appsv1alpha1.ClusterDefinition - clusterVersion *appsv1alpha1.ClusterVersion cluster *appsv1alpha1.Cluster beReferencedCluster *appsv1alpha1.Cluster ) @@ -73,7 +71,6 @@ var _ = Describe("build service references", func() { clusterName = "cluster" beReferencedClusterName = "cluster-be-referenced" clusterDefName = "test-cd" - clusterVersionName = "test-cv" nginxCompName = "nginx" nginxCompDefName = "nginx" mysqlCompName = "mysql" @@ -101,7 +98,6 @@ var _ = Describe("build service references", func() { buildServiceReferences4Test := func(ctx context.Context, cli client.Reader, clusterDef *appsv1alpha1.ClusterDefinition, - clusterVer *appsv1alpha1.ClusterVersion, cluster *appsv1alpha1.Cluster, clusterCompSpec *appsv1alpha1.ClusterComponentSpec) (map[string]*appsv1alpha1.ServiceDescriptor, error) { var ( @@ -109,7 +105,7 @@ var _ = Describe("build service references", func() { comp *appsv1alpha1.Component err error ) - if compDef, err = BuildComponentDefinition(clusterDef, clusterVer, clusterCompSpec); err != nil { + if compDef, err = BuildComponentDefinition(clusterDef, clusterCompSpec); err != nil { return nil, err } if comp, err = BuildComponent(cluster, clusterCompSpec, nil, nil); err != nil { @@ -152,11 +148,6 @@ var _ = Describe("build service references", func() { AddComponentDef(testapps.StatelessNginxComponent, nginxCompDefName). AddServiceRefDeclarations(serviceRefDeclarations). Create(&testCtx).GetObject() - clusterVersion = testapps.NewClusterVersionFactory(clusterVersionName, clusterDefName). - AddComponentVersion(nginxCompDefName). - AddInitContainerShort("nginx-init", testapps.NginxImage). - AddContainerShort("nginx", testapps.NginxImage). - Create(&testCtx).GetObject() }) It("serviceRefDeclaration serviceVersion regex validation test", func() { @@ -226,8 +217,7 @@ var _ = Describe("build service references", func() { It("generate service descriptor test", func() { By("Create cluster and beReferencedCluster object") - beReferencedCluster = testapps.NewClusterFactory(testCtx.DefaultNamespace, beReferencedClusterName, - clusterDef.Name, clusterVersion.Name). + beReferencedCluster = testapps.NewClusterFactory(testCtx.DefaultNamespace, beReferencedClusterName, clusterDef.Name). AddComponent(mysqlCompName, mysqlCompDefName). Create(&testCtx).GetObject() @@ -241,14 +231,13 @@ var _ = Describe("build service references", func() { Cluster: beReferencedCluster.Name, }, } - cluster = testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, - clusterDef.Name, clusterVersion.Name). + cluster = testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, clusterDef.Name). AddComponent(nginxCompName, nginxCompDefName). SetServiceRefs(serviceRefs). Create(&testCtx).GetObject() By("GenServiceReferences failed because external service descriptor not found") - serviceReferences, err := buildServiceReferences4Test(testCtx.Ctx, testCtx.Cli, clusterDef, nil, cluster, &cluster.Spec.ComponentSpecs[0]) + serviceReferences, err := buildServiceReferences4Test(testCtx.Ctx, testCtx.Cli, clusterDef, cluster, &cluster.Spec.ComponentSpecs[0]) Expect(err).ShouldNot(Succeed()) Expect(apierrors.IsNotFound(err)).Should(BeTrue()) Expect(serviceReferences).Should(BeNil()) @@ -279,7 +268,7 @@ var _ = Describe("build service references", func() { Create(&testCtx).GetObject() By("GenServiceReferences failed because external service descriptor status is not available") - serviceReferences, err = buildServiceReferences4Test(testCtx.Ctx, testCtx.Cli, clusterDef, nil, cluster, &cluster.Spec.ComponentSpecs[0]) + serviceReferences, err = buildServiceReferences4Test(testCtx.Ctx, testCtx.Cli, clusterDef, cluster, &cluster.Spec.ComponentSpecs[0]) Expect(err).ShouldNot(Succeed()) Expect(err.Error()).Should(ContainSubstring("status is not available")) Expect(serviceReferences).Should(BeNil()) @@ -290,7 +279,7 @@ var _ = Describe("build service references", func() { })).Should(Succeed()) By("GenServiceReferences failed because external service descriptor kind and version not match") - serviceReferences, err = buildServiceReferences4Test(testCtx.Ctx, testCtx.Cli, clusterDef, nil, cluster, &cluster.Spec.ComponentSpecs[0]) + serviceReferences, err = buildServiceReferences4Test(testCtx.Ctx, testCtx.Cli, clusterDef, cluster, &cluster.Spec.ComponentSpecs[0]) Expect(err).ShouldNot(Succeed()) Expect(err.Error()).Should(ContainSubstring("kind or version is not match with")) Expect(serviceReferences).Should(BeNil()) @@ -318,7 +307,7 @@ var _ = Describe("build service references", func() { Expect(testCtx.CheckedCreateObj(ctx, secret)).Should(Succeed()) Expect(k8sClient.Get(context.Background(), client.ObjectKey{Name: secret.Name, Namespace: secret.Namespace}, secret)).Should(Succeed()) - serviceReferences, err = buildServiceReferences4Test(testCtx.Ctx, testCtx.Cli, clusterDef, nil, cluster, &cluster.Spec.ComponentSpecs[0]) + serviceReferences, err = buildServiceReferences4Test(testCtx.Ctx, testCtx.Cli, clusterDef, cluster, &cluster.Spec.ComponentSpecs[0]) Expect(err).Should(Succeed()) Expect(serviceReferences).ShouldNot(BeNil()) Expect(len(serviceReferences)).Should(Equal(2)) diff --git a/pkg/controller/component/service_reference_test.go b/pkg/controller/component/service_reference_test.go index c9b0c066181..d444ff697b9 100644 --- a/pkg/controller/component/service_reference_test.go +++ b/pkg/controller/component/service_reference_test.go @@ -51,7 +51,6 @@ var _ = Describe("service reference", func() { // resources should be released in following order // non-namespaced testapps.ClearResources(&testCtx, generics.ConfigConstraintSignature, ml) - testapps.ClearResourcesWithRemoveFinalizerOption(&testCtx, generics.ClusterVersionSignature, true, ml) testapps.ClearResourcesWithRemoveFinalizerOption(&testCtx, generics.ClusterDefinitionSignature, true, ml) // namespaced @@ -62,7 +61,6 @@ var _ = Describe("service reference", func() { var ( mockClient *testutil.K8sClientMockHelper clusterDef *appsv1alpha1.ClusterDefinition - clusterVersion *appsv1alpha1.ClusterVersion cluster *appsv1alpha1.Cluster beReferencedCluster *appsv1alpha1.Cluster beReferencedServiceDescriptor *appsv1alpha1.ServiceDescriptor @@ -73,7 +71,6 @@ var _ = Describe("service reference", func() { clusterName = "mycluster" beReferencedClusterName = "mycluster-be-referenced" clusterDefName = "test-clusterdef" - clusterVersionName = "test-clusterversion" nginxCompName = "nginx" nginxCompDefName = "nginx" mysqlCompName = "mysql" @@ -120,11 +117,6 @@ var _ = Describe("service reference", func() { AddComponentDef(testapps.StatelessNginxComponent, nginxCompDefName). AddServiceRefDeclarations(serviceRefDeclarations). Create(&testCtx).GetObject() - clusterVersion = testapps.NewClusterVersionFactory(clusterVersionName, clusterDefName). - AddComponentVersion(nginxCompDefName). - AddInitContainerShort("nginx-init", testapps.NginxImage). - AddContainerShort("nginx", testapps.NginxImage). - Create(&testCtx).GetObject() By("mock a service descriptor and the configmap referenced") configMap := &corev1.ConfigMap{ @@ -218,7 +210,7 @@ var _ = Describe("service reference", func() { }, } Expect(testCtx.CheckedCreateObj(ctx, secret)).Should(Succeed()) - beReferencedCluster = testapps.NewClusterFactory(testCtx.DefaultNamespace, beReferencedClusterName, clusterDef.Name, clusterVersion.Name). + beReferencedCluster = testapps.NewClusterFactory(testCtx.DefaultNamespace, beReferencedClusterName, clusterDef.Name). AddComponent(mysqlCompName, mysqlCompDefName). Create(&testCtx). GetObject() @@ -233,8 +225,7 @@ var _ = Describe("service reference", func() { Cluster: beReferencedCluster.Name, }, } - cluster = testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, - clusterDef.Name, clusterVersion.Name). + cluster = testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, clusterDef.Name). AddComponent(nginxCompName, nginxCompDefName). SetServiceRefs(serviceRefs). Create(&testCtx).GetObject() diff --git a/pkg/controller/component/synthesize_component.go b/pkg/controller/component/synthesize_component.go index 943e31c4b1f..d56e1ccf561 100644 --- a/pkg/controller/component/synthesize_component.go +++ b/pkg/controller/component/synthesize_component.go @@ -57,7 +57,7 @@ func BuildSynthesizedComponent4Generated(reqCtx intctrlutil.RequestCtx, cli client.Reader, cluster *appsv1alpha1.Cluster, comp *appsv1alpha1.Component) (*appsv1alpha1.ComponentDefinition, *SynthesizedComponent, error) { - clusterDef, clusterVer, err := getClusterReferencedResources(reqCtx.Ctx, cli, cluster) + clusterDef, err := getClusterReferencedResources(reqCtx.Ctx, cli, cluster) if err != nil { return nil, nil, err } @@ -68,7 +68,7 @@ func BuildSynthesizedComponent4Generated(reqCtx intctrlutil.RequestCtx, if clusterCompSpec == nil { return nil, nil, fmt.Errorf("cluster component spec is not found: %s", comp.Name) } - compDef, err := getOrBuildComponentDefinition(reqCtx.Ctx, cli, clusterDef, clusterVer, cluster, clusterCompSpec) + compDef, err := getOrBuildComponentDefinition(reqCtx.Ctx, cli, clusterDef, cluster, clusterCompSpec) if err != nil { return nil, nil, err } @@ -85,18 +85,17 @@ func BuildSynthesizedComponentWrapper(reqCtx intctrlutil.RequestCtx, cli client.Reader, cluster *appsv1alpha1.Cluster, clusterCompSpec *appsv1alpha1.ClusterComponentSpec) (*SynthesizedComponent, error) { - clusterDef, clusterVer, err := getClusterReferencedResources(reqCtx.Ctx, cli, cluster) + clusterDef, err := getClusterReferencedResources(reqCtx.Ctx, cli, cluster) if err != nil { return nil, err } - return BuildSynthesizedComponentWrapper4Test(reqCtx, cli, clusterDef, clusterVer, cluster, clusterCompSpec) + return BuildSynthesizedComponentWrapper4Test(reqCtx, cli, clusterDef, cluster, clusterCompSpec) } // BuildSynthesizedComponentWrapper4Test builds a new SynthesizedComponent object with a given ClusterComponentSpec. func BuildSynthesizedComponentWrapper4Test(reqCtx intctrlutil.RequestCtx, cli client.Reader, clusterDef *appsv1alpha1.ClusterDefinition, - clusterVer *appsv1alpha1.ClusterVersion, cluster *appsv1alpha1.Cluster, clusterCompSpec *appsv1alpha1.ClusterComponentSpec) (*SynthesizedComponent, error) { if clusterCompSpec == nil { @@ -105,7 +104,7 @@ func BuildSynthesizedComponentWrapper4Test(reqCtx intctrlutil.RequestCtx, if clusterCompSpec == nil { return nil, nil } - compDef, err := getOrBuildComponentDefinition(reqCtx.Ctx, cli, clusterDef, clusterVer, cluster, clusterCompSpec) + compDef, err := getOrBuildComponentDefinition(reqCtx.Ctx, cli, clusterDef, cluster, clusterCompSpec) if err != nil { return nil, err } @@ -117,7 +116,7 @@ func BuildSynthesizedComponentWrapper4Test(reqCtx intctrlutil.RequestCtx, } // buildSynthesizedComponent builds a new SynthesizedComponent object, which is a mixture of component-related configs from ComponentDefinition and Component. -// !!! Do not use @clusterDef, @clusterVer, @cluster and @clusterCompSpec since they are used for the backward compatibility only. +// !!! Do not use @clusterDef, @cluster and @clusterCompSpec since they are used for the backward compatibility only. // TODO: remove @reqCtx & @cli func buildSynthesizedComponent(reqCtx intctrlutil.RequestCtx, cli client.Reader, @@ -185,8 +184,8 @@ func buildSynthesizedComponent(reqCtx intctrlutil.RequestCtx, EnabledLogs: comp.Spec.EnabledLogs, } - // build backward compatible fields, including workload, services, componentRefEnvs, clusterDefName, clusterCompDefName, and clusterCompVer, etc. - // if cluster referenced a clusterDefinition and clusterVersion, for backward compatibility, we need to merge the clusterDefinition and clusterVersion into the component + // build backward compatible fields, including workload, services, componentRefEnvs, clusterDefName, clusterCompDefName, etc. + // if cluster referenced a clusterDefinition, for backward compatibility, we need to merge the clusterDefinition into the component // TODO(xingran): it will be removed in the future if clusterDef != nil && cluster != nil && clusterCompSpec != nil { if err = buildBackwardCompatibleFields(reqCtx, clusterDef, cluster, clusterCompSpec, synthesizeComp); err != nil { @@ -690,79 +689,6 @@ func buildCompatibleHorizontalScalePolicy(compDef *appsv1alpha1.ComponentDefinit } } -// appendOrOverrideContainerAttr appends targetContainer to compContainers or overrides the attributes of compContainers with a given targetContainer, -// if targetContainer does not exist in compContainers, it will be appended. otherwise it will be updated with the attributes of the target container. -func appendOrOverrideContainerAttr(compContainers []corev1.Container, targetContainer corev1.Container) []corev1.Container { - index, compContainer := intctrlutil.GetContainerByName(compContainers, targetContainer.Name) - if compContainer == nil { - compContainers = append(compContainers, targetContainer) - } else { - doContainerAttrOverride(&compContainers[index], targetContainer) - } - return compContainers -} - -// doContainerAttrOverride overrides the attributes in compContainer with the attributes in container. -func doContainerAttrOverride(compContainer *corev1.Container, container corev1.Container) { - if compContainer == nil { - return - } - if container.Image != "" { - compContainer.Image = container.Image - } - if len(container.Command) != 0 { - compContainer.Command = container.Command - } - if len(container.Args) != 0 { - compContainer.Args = container.Args - } - if container.WorkingDir != "" { - compContainer.WorkingDir = container.WorkingDir - } - if len(container.Ports) != 0 { - compContainer.Ports = container.Ports - } - if len(container.EnvFrom) != 0 { - compContainer.EnvFrom = container.EnvFrom - } - if len(container.Env) != 0 { - compContainer.Env = container.Env - } - if container.Resources.Limits != nil || container.Resources.Requests != nil { - compContainer.Resources = container.Resources - } - if len(container.VolumeMounts) != 0 { - compContainer.VolumeMounts = container.VolumeMounts - } - if len(container.VolumeDevices) != 0 { - compContainer.VolumeDevices = container.VolumeDevices - } - if container.LivenessProbe != nil { - compContainer.LivenessProbe = container.LivenessProbe - } - if container.ReadinessProbe != nil { - compContainer.ReadinessProbe = container.ReadinessProbe - } - if container.StartupProbe != nil { - compContainer.StartupProbe = container.StartupProbe - } - if container.Lifecycle != nil { - compContainer.Lifecycle = container.Lifecycle - } - if container.TerminationMessagePath != "" { - compContainer.TerminationMessagePath = container.TerminationMessagePath - } - if container.TerminationMessagePolicy != "" { - compContainer.TerminationMessagePolicy = container.TerminationMessagePolicy - } - if container.ImagePullPolicy != "" { - compContainer.ImagePullPolicy = container.ImagePullPolicy - } - if container.SecurityContext != nil { - compContainer.SecurityContext = container.SecurityContext - } -} - // GetEnvReplacementMapForConnCredential gets the replacement map for connect credential // TODO: deprecated, will be removed later. func GetEnvReplacementMapForConnCredential(clusterName string) map[string]string { @@ -822,30 +748,6 @@ func ReplaceSecretEnvVars(namedValuesMap map[string]string, envs []corev1.EnvVar return newEnvs } -// overrideSwitchoverSpecAttr overrides the attributes in switchoverSpec with the attributes of SwitchoverShortSpec in clusterVersion. -func overrideSwitchoverSpecAttr(switchoverSpec *appsv1alpha1.SwitchoverSpec, cvSwitchoverSpec *appsv1alpha1.SwitchoverShortSpec) { - if switchoverSpec == nil || cvSwitchoverSpec == nil || cvSwitchoverSpec.CmdExecutorConfig == nil { - return - } - applyCmdExecutorConfig := func(cmdExecutorConfig *appsv1alpha1.CmdExecutorConfig) { - if cmdExecutorConfig == nil { - return - } - if len(cvSwitchoverSpec.CmdExecutorConfig.Image) > 0 { - cmdExecutorConfig.Image = cvSwitchoverSpec.CmdExecutorConfig.Image - } - if len(cvSwitchoverSpec.CmdExecutorConfig.Env) > 0 { - cmdExecutorConfig.Env = cvSwitchoverSpec.CmdExecutorConfig.Env - } - } - if switchoverSpec.WithCandidate != nil { - applyCmdExecutorConfig(switchoverSpec.WithCandidate.CmdExecutorConfig) - } - if switchoverSpec.WithoutCandidate != nil { - applyCmdExecutorConfig(switchoverSpec.WithoutCandidate.CmdExecutorConfig) - } -} - func GetConfigSpecByName(synthesizedComp *SynthesizedComponent, configSpec string) *appsv1alpha1.ComponentConfigSpec { for i := range synthesizedComp.ConfigTemplates { template := &synthesizedComp.ConfigTemplates[i] diff --git a/pkg/controller/configuration/configuration_test.go b/pkg/controller/configuration/configuration_test.go index 92626977008..eb1033ca338 100644 --- a/pkg/controller/configuration/configuration_test.go +++ b/pkg/controller/configuration/configuration_test.go @@ -33,7 +33,6 @@ import ( ) const clusterDefName = "test-clusterdef" -const clusterVersionName = "test-clusterversion" const clusterName = "test-cluster" const mysqlCompDefName = "replicasets" const scriptConfigName = "test-script-config" @@ -56,32 +55,13 @@ func allFieldsClusterDefObj(needCreate bool) *appsv1alpha1.ClusterDefinition { return clusterDefObj } -func allFieldsClusterVersionObj(needCreate bool) *appsv1alpha1.ClusterVersion { - clusterVersionObj := testapps.NewClusterVersionFactory(clusterVersionName, clusterDefName). - AddComponentVersion(mysqlCompDefName). - AddContainerShort("mysql", testapps.ApeCloudMySQLImage). - GetObject() - if needCreate { - Expect(testCtx.CreateObj(testCtx.Ctx, clusterVersionObj)).Should(Succeed()) - } - return clusterVersionObj -} - -func newAllFieldsClusterObj( - clusterDefObj *appsv1alpha1.ClusterDefinition, - clusterVersionObj *appsv1alpha1.ClusterVersion, - needCreate bool, -) (*appsv1alpha1.Cluster, *appsv1alpha1.ClusterDefinition, *appsv1alpha1.ClusterVersion, types.NamespacedName) { - // setup Cluster obj requires default ClusterDefinition and ClusterVersion objects +func newAllFieldsClusterObj(clusterDefObj *appsv1alpha1.ClusterDefinition, needCreate bool) (*appsv1alpha1.Cluster, *appsv1alpha1.ClusterDefinition, types.NamespacedName) { + // setup Cluster obj requires default ClusterDefinition object if clusterDefObj == nil { clusterDefObj = allFieldsClusterDefObj(needCreate) } - if clusterVersionObj == nil { - clusterVersionObj = allFieldsClusterVersionObj(needCreate) - } pvcSpec := testapps.NewPVCSpec("1Gi") - clusterObj := testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, - clusterDefObj.Name, clusterVersionObj.Name). + clusterObj := testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, clusterDefObj.Name). AddComponent(mysqlCompName, mysqlCompDefName).SetReplicas(1). AddVolumeClaimTemplate(testapps.DataVolumeName, pvcSpec). AddComponentService(testapps.ServiceVPCName, corev1.ServiceTypeLoadBalancer). @@ -91,16 +71,15 @@ func newAllFieldsClusterObj( if needCreate { Expect(testCtx.CreateObj(testCtx.Ctx, clusterObj)).Should(Succeed()) } - return clusterObj, clusterDefObj, clusterVersionObj, key + return clusterObj, clusterDefObj, key } -func newAllFieldsSynthesizedComponent(clusterDef *appsv1alpha1.ClusterDefinition, - clusterVer *appsv1alpha1.ClusterVersion, cluster *appsv1alpha1.Cluster) *component.SynthesizedComponent { +func newAllFieldsSynthesizedComponent(clusterDef *appsv1alpha1.ClusterDefinition, cluster *appsv1alpha1.Cluster) *component.SynthesizedComponent { reqCtx := intctrlutil.RequestCtx{ Ctx: testCtx.Ctx, Log: logger, } - synthesizeComp, err := component.BuildSynthesizedComponentWrapper4Test(reqCtx, testCtx.Cli, clusterDef, clusterVer, cluster, &cluster.Spec.ComponentSpecs[0]) + synthesizeComp, err := component.BuildSynthesizedComponentWrapper4Test(reqCtx, testCtx.Cli, clusterDef, cluster, &cluster.Spec.ComponentSpecs[0]) Expect(err).Should(Succeed()) Expect(synthesizeComp).ShouldNot(BeNil()) addTestVolumeMount(synthesizeComp.PodSpec, mysqlCompName) diff --git a/pkg/controller/configuration/envfrom_utils_test.go b/pkg/controller/configuration/envfrom_utils_test.go index 1c0d2841cdd..ef2a4b17ea8 100644 --- a/pkg/controller/configuration/envfrom_utils_test.go +++ b/pkg/controller/configuration/envfrom_utils_test.go @@ -38,17 +38,15 @@ import ( var _ = Describe("ConfigEnvFrom test", func() { const ( - clusterDefName = "test-clusterdef" - clusterVersionName = "test-clusterversion" - clusterName = "test-cluster" + clusterDefName = "test-clusterdef" + clusterName = "test-cluster" mysqlCompDefName = "replicasets" mysqlCompName = "mysql" ) var ( - clusterDef *appsv1alpha1.ClusterDefinition - clusterVersion *appsv1alpha1.ClusterVersion - cluster *appsv1alpha1.Cluster + clusterDef *appsv1alpha1.ClusterDefinition + cluster *appsv1alpha1.Cluster k8sMockClient *testutil.K8sClientMockHelper origCMObject *corev1.ConfigMap @@ -68,13 +66,8 @@ var _ = Describe("ConfigEnvFrom test", func() { AddComponentDef(testapps.StatefulMySQLComponent, mysqlCompDefName). AddConfigTemplate(cm.Name, cm.Name, configConstraint.Name, testCtx.DefaultNamespace, "mysql-config", testapps.DefaultMySQLContainerName). GetObject() - clusterVersion = testapps.NewClusterVersionFactory(clusterVersionName, clusterDefName). - AddComponentVersion(mysqlCompDefName). - AddContainerShort("mysql", testapps.ApeCloudMySQLImage). - GetObject() pvcSpec := testapps.NewPVCSpec("1Gi") - cluster = testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, - clusterDef.Name, clusterVersion.Name). + cluster = testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, clusterDef.Name). AddComponent(mysqlCompName, mysqlCompDefName). AddVolumeClaimTemplate(testapps.DataVolumeName, pvcSpec). GetObject() @@ -93,7 +86,7 @@ var _ = Describe("ConfigEnvFrom test", func() { Ctx: ctx, Log: logger, } - synthesizeComp, err := component.BuildSynthesizedComponentWrapper4Test(reqCtx, testCtx.Cli, clusterDef, clusterVersion, cluster, &cluster.Spec.ComponentSpecs[0]) + synthesizeComp, err := component.BuildSynthesizedComponentWrapper4Test(reqCtx, testCtx.Cli, clusterDef, cluster, &cluster.Spec.ComponentSpecs[0]) Expect(err).Should(Succeed()) podSpec := &corev1.PodSpec{ diff --git a/pkg/controller/configuration/operator.go b/pkg/controller/configuration/operator.go index 1e83824f45e..1cbffd7bf9c 100644 --- a/pkg/controller/configuration/operator.go +++ b/pkg/controller/configuration/operator.go @@ -53,8 +53,6 @@ func NewConfigReconcileTask(resourceCtx *ResourceCtx, func (c *configOperator) Reconcile() error { var synthesizedComponent = c.SynthesizedComponent - // Need to Merge configTemplateRef of ClusterVersion.Components[*].ConfigTemplateRefs and - // ClusterDefinition.Components[*].ConfigTemplateRefs if len(synthesizedComponent.ConfigTemplates) == 0 && len(synthesizedComponent.ScriptTemplates) == 0 { return c.UpdateConfiguration() } diff --git a/pkg/controller/configuration/operator_test.go b/pkg/controller/configuration/operator_test.go index 37dd8a8db83..82747e53d8e 100644 --- a/pkg/controller/configuration/operator_test.go +++ b/pkg/controller/configuration/operator_test.go @@ -39,9 +39,7 @@ import ( ) var _ = Describe("ConfigurationOperatorTest", func() { - var clusterObj *appsv1alpha1.Cluster - var clusterVersionObj *appsv1alpha1.ClusterVersion var clusterDefObj *appsv1alpha1.ClusterDefinition var componentObj *appsv1alpha1.Component var synthesizedComponent *component.SynthesizedComponent @@ -70,8 +68,8 @@ var _ = Describe("ConfigurationOperatorTest", func() { BeforeEach(func() { // Add any setup steps that needs to be executed before each test k8sMockClient = testutil.NewK8sMockClient() - clusterObj, clusterDefObj, clusterVersionObj, _ = newAllFieldsClusterObj(nil, nil, false) - synthesizedComponent = newAllFieldsSynthesizedComponent(clusterDefObj, clusterVersionObj, clusterObj) + clusterObj, clusterDefObj, _ = newAllFieldsClusterObj(nil, false) + synthesizedComponent = newAllFieldsSynthesizedComponent(clusterDefObj, clusterObj) componentObj = newAllFieldsComponent(clusterObj) configMapObj = testapps.NewConfigMap("default", mysqlConfigName, testapps.SetConfigMapData("test", "test")) @@ -114,7 +112,6 @@ var _ = Describe("ConfigurationOperatorTest", func() { k8sMockClient.MockGetMethod(testutil.WithGetReturned(testutil.WithConstructSimpleGetResult( []client.Object{ clusterDefObj, - clusterVersionObj, clusterObj, clusterObj, scriptsObj, @@ -151,7 +148,6 @@ var _ = Describe("ConfigurationOperatorTest", func() { k8sMockClient.MockGetMethod(testutil.WithGetReturned(testutil.WithConstructSimpleGetResult( []client.Object{ clusterDefObj, - clusterVersionObj, clusterObj, clusterObj, }, diff --git a/pkg/controller/configuration/pipeline_test.go b/pkg/controller/configuration/pipeline_test.go index b75a831d30a..341468f51e0 100644 --- a/pkg/controller/configuration/pipeline_test.go +++ b/pkg/controller/configuration/pipeline_test.go @@ -42,12 +42,10 @@ import ( ) var _ = Describe("ConfigurationPipelineTest", func() { - const testConfigFile = "postgresql.conf" var clusterObj *appsv1alpha1.Cluster var componentObj *appsv1alpha1.Component - var clusterVersionObj *appsv1alpha1.ClusterVersion var clusterDefObj *appsv1alpha1.ClusterDefinition var synthesizedComponent *component.SynthesizedComponent var configMapObj *corev1.ConfigMap @@ -59,7 +57,6 @@ var _ = Describe("ConfigurationPipelineTest", func() { k8sMockClient.MockGetMethod(testutil.WithGetReturned(testutil.WithConstructSimpleGetResult( []client.Object{ clusterDefObj, - clusterVersionObj, clusterObj, clusterObj, configMapObj, @@ -94,9 +91,9 @@ var _ = Describe("ConfigurationPipelineTest", func() { BeforeEach(func() { // Add any setup steps that needs to be executed before each test k8sMockClient = testutil.NewK8sMockClient() - clusterObj, clusterDefObj, clusterVersionObj, _ = newAllFieldsClusterObj(nil, nil, false) + clusterObj, clusterDefObj, _ = newAllFieldsClusterObj(nil, false) componentObj = newAllFieldsComponent(clusterObj) - synthesizedComponent = newAllFieldsSynthesizedComponent(clusterDefObj, clusterVersionObj, clusterObj) + synthesizedComponent = newAllFieldsSynthesizedComponent(clusterDefObj, clusterObj) configMapObj = testapps.NewConfigMap("default", mysqlConfigName, testapps.SetConfigMapData(testConfigFile, ` bgwriter_delay = '200ms' diff --git a/pkg/controller/configuration/resource_wrapper.go b/pkg/controller/configuration/resource_wrapper.go index 926bb4f3a4d..0dd0f4bd944 100644 --- a/pkg/controller/configuration/resource_wrapper.go +++ b/pkg/controller/configuration/resource_wrapper.go @@ -57,8 +57,6 @@ type ResourceFetcher[T any] struct { // Deprecated: this API will be removed from version 0.9.0 ClusterDefObj *appsv1alpha1.ClusterDefinition - // Deprecated: use ComponentDefinition instead - ClusterVerObj *appsv1alpha1.ClusterVersion ConfigMapObj *corev1.ConfigMap ConfigurationObj *appsv1alpha1.Configuration @@ -136,22 +134,6 @@ func (r *ResourceFetcher[T]) ClusterDef() *T { }) } -// ClusterVer get clusterVersion cr -// Deprecated: this API will be removed from version 0.9.0 -func (r *ResourceFetcher[T]) ClusterVer() *T { - clusterVerKey := client.ObjectKey{ - Namespace: "", - Name: r.ClusterObj.Spec.ClusterVersionRef, - } - return r.Wrap(func() error { - if clusterVerKey.Name == "" { - return nil - } - r.ClusterVerObj = &appsv1alpha1.ClusterVersion{} - return r.Client.Get(r.Context, clusterVerKey, r.ClusterVerObj) - }) -} - func (r *ResourceFetcher[T]) ComponentSpec() *T { return r.Wrap(func() (err error) { r.ClusterComObj, err = controllerutil.GetOriginalOrGeneratedComponentSpecByName(r.Context, r.Client, r.ClusterObj, r.ComponentName) diff --git a/pkg/controller/configuration/resource_wrapper_test.go b/pkg/controller/configuration/resource_wrapper_test.go index 509e0875b63..2a88bf3d620 100644 --- a/pkg/controller/configuration/resource_wrapper_test.go +++ b/pkg/controller/configuration/resource_wrapper_test.go @@ -37,9 +37,8 @@ import ( var _ = Describe("resource Fetcher", func() { const ( - clusterDefName = "test-clusterdef" - clusterVersionName = "test-clusterversion" - clusterName = "test-cluster" + clusterDefName = "test-clusterdef" + clusterName = "test-cluster" mysqlCompDefName = "replicasets" mysqlCompName = "mysql" @@ -48,10 +47,9 @@ var _ = Describe("resource Fetcher", func() { ) var ( - k8sMockClient *testutil.K8sClientMockHelper - clusterDef *appsv1alpha1.ClusterDefinition - clusterVersion *appsv1alpha1.ClusterVersion - cluster *appsv1alpha1.Cluster + k8sMockClient *testutil.K8sClientMockHelper + clusterDef *appsv1alpha1.ClusterDefinition + cluster *appsv1alpha1.Cluster ) BeforeEach(func() { @@ -60,13 +58,8 @@ var _ = Describe("resource Fetcher", func() { AddComponentDef(testapps.StatefulMySQLComponent, mysqlCompDefName). AddConfigTemplate(mysqlConfigName, mysqlConfigName, mysqlConfigName, "default", mysqlVolumeName). GetObject() - clusterVersion = testapps.NewClusterVersionFactory(clusterVersionName, clusterDefName). - AddComponentVersion(mysqlCompDefName). - AddContainerShort("mysql", testapps.ApeCloudMySQLImage). - GetObject() pvcSpec := testapps.NewPVCSpec("1Gi") - cluster = testapps.NewClusterFactory("default", clusterName, - clusterDef.Name, clusterVersion.Name). + cluster = testapps.NewClusterFactory("default", clusterName, clusterDef.Name). AddComponent(mysqlCompName, mysqlCompDefName). AddVolumeClaimTemplate(testapps.DataVolumeName, pvcSpec). GetObject() @@ -81,7 +74,6 @@ var _ = Describe("resource Fetcher", func() { k8sMockClient.MockGetMethod(testutil.WithGetReturned(testutil.WithConstructSimpleGetResult( []client.Object{ clusterDef, - clusterVersion, cluster, testapps.NewConfigMap("default", cfgcore.GetComponentCfgName(clusterName, mysqlCompName, mysqlConfigName)), &appsv1beta1.ConfigConstraint{ @@ -94,7 +86,6 @@ var _ = Describe("resource Fetcher", func() { err := NewTest(k8sMockClient.Client(), ctx). Cluster(). ClusterDef(). - ClusterVer(). ComponentSpec(). ConfigMap(mysqlConfigName). ConfigConstraints(mysqlConfigName). diff --git a/pkg/controller/configuration/template_wrapper_test.go b/pkg/controller/configuration/template_wrapper_test.go index d74a76c20b4..0bf686a143c 100644 --- a/pkg/controller/configuration/template_wrapper_test.go +++ b/pkg/controller/configuration/template_wrapper_test.go @@ -36,11 +36,9 @@ import ( ) var _ = Describe("TemplateWrapperTest", func() { - var mockK8sCli *testutil.K8sClientMockHelper var clusterObj *appsv1alpha1.Cluster var componentObj *appsv1alpha1.Component - var clusterVersionObj *appsv1alpha1.ClusterVersion var clusterDefObj *appsv1alpha1.ClusterDefinition var clusterComponent *component.SynthesizedComponent @@ -54,8 +52,8 @@ var _ = Describe("TemplateWrapperTest", func() { // Add any setup steps that needs to be executed before each test mockK8sCli = testutil.NewK8sMockClient() - clusterObj, clusterDefObj, clusterVersionObj, _ = newAllFieldsClusterObj(nil, nil, false) - clusterComponent = newAllFieldsSynthesizedComponent(clusterDefObj, clusterVersionObj, clusterObj) + clusterObj, clusterDefObj, _ = newAllFieldsClusterObj(nil, false) + clusterComponent = newAllFieldsSynthesizedComponent(clusterDefObj, clusterObj) componentObj = newAllFieldsComponent(clusterObj) }) diff --git a/pkg/controller/configuration/tool_image_builder_test.go b/pkg/controller/configuration/tool_image_builder_test.go index d2c45316c36..1f9f54478db 100644 --- a/pkg/controller/configuration/tool_image_builder_test.go +++ b/pkg/controller/configuration/tool_image_builder_test.go @@ -35,19 +35,17 @@ import ( ) var _ = Describe("ToolsImageBuilderTest", func() { - const kbToolsImage = "apecloud/kubeblocks-tools:latest" var noneCommand = []string{"/bin/true"} var clusterObj *appsv1alpha1.Cluster - var clusterVersionObj *appsv1alpha1.ClusterVersion var ClusterDefObj *appsv1alpha1.ClusterDefinition var clusterComponent *component.SynthesizedComponent BeforeEach(func() { // Add any setup steps that needs to be executed before each test - clusterObj, ClusterDefObj, clusterVersionObj, _ = newAllFieldsClusterObj(nil, nil, false) - clusterComponent = newAllFieldsSynthesizedComponent(ClusterDefObj, clusterVersionObj, clusterObj) + clusterObj, ClusterDefObj, _ = newAllFieldsClusterObj(nil, false) + clusterComponent = newAllFieldsSynthesizedComponent(ClusterDefObj, clusterObj) viper.SetDefault(constant.KBToolsImage, kbToolsImage) }) diff --git a/pkg/controller/factory/builder_test.go b/pkg/controller/factory/builder_test.go index e051b0059a3..7d80a2a6ce9 100644 --- a/pkg/controller/factory/builder_test.go +++ b/pkg/controller/factory/builder_test.go @@ -45,7 +45,6 @@ import ( var _ = Describe("builder", func() { const clusterDefName = "test-clusterdef" - const clusterVersionName = "test-clusterversion" const clusterName = "test-cluster" const mysqlCompDefName = "replicasets" const proxyCompDefName = "proxy" @@ -64,21 +63,6 @@ var _ = Describe("builder", func() { return clusterDefObj } - allFieldsClusterVersionObj := func(needCreate bool) *appsv1alpha1.ClusterVersion { - By("By assure an clusterVersion obj") - clusterVersionObj := testapps.NewClusterVersionFactory(clusterVersionName, clusterDefName). - AddComponentVersion(mysqlCompDefName). - AddContainerShort("mysql", testapps.ApeCloudMySQLImage). - AddComponentVersion(proxyCompDefName). - AddInitContainerShort("nginx-init", testapps.NginxImage). - AddContainerShort("nginx", testapps.NginxImage). - GetObject() - if needCreate { - Expect(testCtx.CreateObj(testCtx.Ctx, clusterVersionObj)).Should(Succeed()) - } - return clusterVersionObj - } - newExtraEnvs := func() map[string]string { jsonStr, _ := json.Marshal(map[string]string{ "mock-key": "mock-value", @@ -88,21 +72,13 @@ var _ = Describe("builder", func() { } } - newAllFieldsClusterObj := func( - clusterDefObj *appsv1alpha1.ClusterDefinition, - clusterVersionObj *appsv1alpha1.ClusterVersion, - needCreate bool, - ) (*appsv1alpha1.Cluster, *appsv1alpha1.ClusterDefinition, *appsv1alpha1.ClusterVersion, types.NamespacedName) { - // setup Cluster obj requires default ClusterDefinition and ClusterVersion objects + newAllFieldsClusterObj := func(clusterDefObj *appsv1alpha1.ClusterDefinition, needCreate bool) (*appsv1alpha1.Cluster, *appsv1alpha1.ClusterDefinition, types.NamespacedName) { + // setup Cluster obj requires default ClusterDefinition object if clusterDefObj == nil { clusterDefObj = allFieldsClusterDefObj(needCreate) } - if clusterVersionObj == nil { - clusterVersionObj = allFieldsClusterVersionObj(needCreate) - } pvcSpec := testapps.NewPVCSpec("1Gi") - clusterObj := testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, - clusterDefObj.Name, clusterVersionObj.Name). + clusterObj := testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, clusterDefObj.Name). AddAnnotationsInMap(newExtraEnvs()). AddComponent(mysqlCompName, mysqlCompDefName).SetReplicas(1). AddVolumeClaimTemplate(testapps.DataVolumeName, pvcSpec). @@ -113,7 +89,7 @@ var _ = Describe("builder", func() { if needCreate { Expect(testCtx.CreateObj(testCtx.Ctx, clusterObj)).Should(Succeed()) } - return clusterObj, clusterDefObj, clusterVersionObj, key + return clusterObj, clusterDefObj, key } newItsObj := func() *workloads.InstanceSet { @@ -142,12 +118,11 @@ var _ = Describe("builder", func() { } return reqCtx } - newAllFieldsSynthesizedComponent := func(clusterDef *appsv1alpha1.ClusterDefinition, - clusterVer *appsv1alpha1.ClusterVersion, cluster *appsv1alpha1.Cluster) *component.SynthesizedComponent { + newAllFieldsSynthesizedComponent := func(clusterDef *appsv1alpha1.ClusterDefinition, cluster *appsv1alpha1.Cluster) *component.SynthesizedComponent { reqCtx := newReqCtx() By("assign every available fields") synthesizeComp, err := component.BuildSynthesizedComponentWrapper4Test(reqCtx, testCtx.Cli, - clusterDef, clusterVer, cluster, &cluster.Spec.ComponentSpecs[0]) + clusterDef, cluster, &cluster.Spec.ComponentSpecs[0]) Expect(err).Should(Succeed()) Expect(synthesizeComp).ShouldNot(BeNil()) // to resolve and inject env vars @@ -158,8 +133,8 @@ var _ = Describe("builder", func() { return synthesizeComp } newClusterObjs := func(clusterDefObj *appsv1alpha1.ClusterDefinition) (*appsv1alpha1.ClusterDefinition, *appsv1alpha1.Cluster, *component.SynthesizedComponent) { - cluster, clusterDef, clusterVersion, _ := newAllFieldsClusterObj(clusterDefObj, nil, false) - synthesizedComponent := newAllFieldsSynthesizedComponent(clusterDef, clusterVersion, cluster) + cluster, clusterDef, _ := newAllFieldsClusterObj(clusterDefObj, false) + synthesizedComponent := newAllFieldsSynthesizedComponent(clusterDef, cluster) return clusterDef, cluster, synthesizedComponent } @@ -272,7 +247,7 @@ var _ = Describe("builder", func() { }, } cluster.Spec.ComponentSpecs[0].Replicas = 2 - replComponent := newAllFieldsSynthesizedComponent(clusterDef, nil, cluster) + replComponent := newAllFieldsSynthesizedComponent(clusterDef, cluster) its, err = BuildInstanceSet(replComponent, nil) Expect(err).Should(BeNil()) Expect(its).ShouldNot(BeNil()) @@ -311,7 +286,7 @@ var _ = Describe("builder", func() { clusterDef.Spec.ComponentDefs[0].ConsensusSpec = appsv1alpha1.NewConsensusSetSpec() clusterDef.Spec.ComponentDefs[0].ConsensusSpec.UpdateStrategy = appsv1alpha1.BestEffortParallelStrategy cluster.Spec.ComponentSpecs[0].Replicas = 3 - csComponent := newAllFieldsSynthesizedComponent(clusterDef, nil, cluster) + csComponent := newAllFieldsSynthesizedComponent(clusterDef, cluster) its, err = BuildInstanceSet(csComponent, nil) Expect(err).Should(BeNil()) Expect(its).ShouldNot(BeNil()) diff --git a/pkg/controller/job/job_utils_test.go b/pkg/controller/job/job_utils_test.go index e9d5dd7aaff..4d7e71f0025 100644 --- a/pkg/controller/job/job_utils_test.go +++ b/pkg/controller/job/job_utils_test.go @@ -37,18 +37,16 @@ var _ = Describe("Job Utils Test", func() { Context("Job Utils Test function", func() { const ( - clusterDefName = "test-clusterdef" - clusterVersionName = "test-clusterversion" - clusterName = "test-cluster" - mysqlCompDefName = "replicasets" - mysqlCompName = "mysql" - labelKey = "test-label" + clusterDefName = "test-clusterdef" + clusterName = "test-cluster" + mysqlCompDefName = "replicasets" + mysqlCompName = "mysql" + labelKey = "test-label" ) var ( - clusterDef *appsv1alpha1.ClusterDefinition - clusterVersion *appsv1alpha1.ClusterVersion - cluster *appsv1alpha1.Cluster + clusterDef *appsv1alpha1.ClusterDefinition + cluster *appsv1alpha1.Cluster ) createJob := func(name string, keys ...string) *batchv1.Job { @@ -82,12 +80,7 @@ var _ = Describe("Job Utils Test", func() { clusterDef = testapps.NewClusterDefFactory(clusterDefName). AddComponentDef(testapps.StatefulMySQLComponent, mysqlCompDefName). GetObject() - clusterVersion = testapps.NewClusterVersionFactory(clusterVersionName, clusterDefName). - AddComponentVersion(mysqlCompDefName). - AddContainerShort("mysql", testapps.ApeCloudMySQLImage). - GetObject() - cluster = testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, - clusterDef.Name, clusterVersion.Name). + cluster = testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, clusterDef.Name). AddComponent(mysqlCompName, mysqlCompDefName). GetObject() }) diff --git a/pkg/controller/plan/prepare_test.go b/pkg/controller/plan/prepare_test.go index ea18b9605b2..19e7e59a17e 100644 --- a/pkg/controller/plan/prepare_test.go +++ b/pkg/controller/plan/prepare_test.go @@ -64,38 +64,28 @@ var _ = Describe("Prepare Test", func() { }) const ( - clusterDefName = "test-clusterdef" - clusterVersionName = "test-clusterversion" - clusterName = "test-cluster" + clusterDefName = "test-clusterdef" + clusterName = "test-cluster" mysqlClusterCompDefName = "mysql-cluster-comp-def" mysqlCompDefName = "mysql-comp-def" mysqlCompName = "mysql" ) var ( - clusterDefObj *appsv1alpha1.ClusterDefinition - clusterVersionObj *appsv1alpha1.ClusterVersion - compDefObj *appsv1alpha1.ComponentDefinition - cluster *appsv1alpha1.Cluster - comp *appsv1alpha1.Component - configSpecName string + clusterDefObj *appsv1alpha1.ClusterDefinition + compDefObj *appsv1alpha1.ComponentDefinition + cluster *appsv1alpha1.Cluster + comp *appsv1alpha1.Component + configSpecName string ) Context("create cluster with component and component definition API, testing render configuration", func() { - createAllWorkloadTypesClusterDef := func(noCreateAssociateCV ...bool) { + createAllWorkloadTypesClusterDef := func() { By("Create a clusterDefinition obj") clusterDefObj = testapps.NewClusterDefFactory(clusterDefName). AddComponentDef(testapps.ConsensusMySQLComponent, mysqlClusterCompDefName). Create(&testCtx).GetObject() - if len(noCreateAssociateCV) > 0 && noCreateAssociateCV[0] { - return - } - By("Create a clusterVersion obj") - clusterVersionObj = testapps.NewClusterVersionFactory(clusterVersionName, clusterDefObj.GetName()). - AddComponentVersion(mysqlClusterCompDefName).AddContainerShort("mysql", testapps.ApeCloudMySQLImage). - Create(&testCtx).GetObject() - By("Create a componentDefinition obj") compDefObj = testapps.NewComponentDefinitionFactory(mysqlCompDefName). WithRandomName(). @@ -115,7 +105,7 @@ var _ = Describe("Prepare Test", func() { configSpecName = tpl.Name pvcSpec := testapps.NewPVCSpec("1Gi") - cluster = testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, clusterDefObj.Name, clusterVersionObj.Name). + cluster = testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, clusterDefObj.Name). AddComponentV2(mysqlCompName, compDefObj.Name). SetReplicas(1). AddVolumeClaimTemplate(testapps.DataVolumeName, pvcSpec). diff --git a/pkg/controller/plan/restore_test.go b/pkg/controller/plan/restore_test.go index 32753c696aa..0feb996628a 100644 --- a/pkg/controller/plan/restore_test.go +++ b/pkg/controller/plan/restore_test.go @@ -61,7 +61,7 @@ var _ = Describe("Restore", func() { // create the new objects. By("clean resources") - // delete cluster(and all dependent sub-resources), clusterversion and clusterdef + // delete cluster(and all dependent sub-resources), cluster definition testapps.ClearClusterResources(&testCtx) inNS := client.InNamespace(testCtx.DefaultNamespace) ml := client.HasLabels{testCtx.TestObjLabelKey} @@ -91,19 +91,17 @@ var _ = Describe("Restore", func() { Context("Cluster Restore", func() { const ( - clusterDefName = "test-clusterdef" - clusterVersionName = "test-clusterversion" - mysqlCompType = "replicasets" - mysqlCompName = "mysql" - nginxCompType = "proxy" - topologyKey = "testTopologyKey" - labelKey = "testNodeLabelKey" - labelValue = "testLabelValue" + clusterDefName = "test-clusterdef" + mysqlCompType = "replicasets" + mysqlCompName = "mysql" + nginxCompType = "proxy" + topologyKey = "testTopologyKey" + labelKey = "testNodeLabelKey" + labelValue = "testLabelValue" ) var ( clusterDef *appsv1alpha1.ClusterDefinition - clusterVersion *appsv1alpha1.ClusterVersion cluster *appsv1alpha1.Cluster synthesizedComponent *component.SynthesizedComponent compObj *appsv1alpha1.Component @@ -118,16 +116,8 @@ var _ = Describe("Restore", func() { AddComponentDef(testapps.ConsensusMySQLComponent, mysqlCompType). AddComponentDef(testapps.StatelessNginxComponent, nginxCompType). Create(&testCtx).GetObject() - clusterVersion = testapps.NewClusterVersionFactory(clusterVersionName, clusterDefName). - AddComponentVersion(mysqlCompType). - AddContainerShort("mysql", testapps.ApeCloudMySQLImage). - AddComponentVersion(nginxCompType). - AddInitContainerShort("nginx-init", testapps.NginxImage). - AddContainerShort("nginx", testapps.NginxImage). - Create(&testCtx).GetObject() pvcSpec := testapps.NewPVCSpec("1Gi") - cluster = testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, - clusterDef.Name, clusterVersion.Name). + cluster = testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, clusterDef.Name). AddComponent(mysqlCompName, mysqlCompType). SetReplicas(3). SetClusterAffinity(&appsv1alpha1.Affinity{ diff --git a/pkg/controller/scheduling/scheduling_utils_test.go b/pkg/controller/scheduling/scheduling_utils_test.go index 29474ae841e..effe72347e1 100644 --- a/pkg/controller/scheduling/scheduling_utils_test.go +++ b/pkg/controller/scheduling/scheduling_utils_test.go @@ -62,13 +62,12 @@ var _ = Describe("affinity utils", func() { Effect: corev1.TaintEffectNoExecute, } - clusterObj = testapps.NewClusterFactory("default", clusterName, "", ""). + clusterObj = testapps.NewClusterFactory("default", clusterName, ""). AddComponent(compName, ""). SetClusterAffinity(affinity). AddClusterToleration(toleration). GetObject() compSpec = &clusterObj.Spec.ComponentSpecs[0] - } ) diff --git a/pkg/controllerutil/cluster_utils_test.go b/pkg/controllerutil/cluster_utils_test.go index 2d96fc0bb0f..e900cbdd1ab 100644 --- a/pkg/controllerutil/cluster_utils_test.go +++ b/pkg/controllerutil/cluster_utils_test.go @@ -41,7 +41,7 @@ var _ = Describe("cluster utils test", func() { // create the new objects. By("clean resources") - // delete cluster(and all dependent sub-resources), clusterversion and clusterdef + // delete cluster(and all dependent sub-resources), cluster definition testapps.ClearClusterResourcesWithRemoveFinalizerOption(&testCtx) // delete rest mocked objects @@ -56,7 +56,6 @@ var _ = Describe("cluster utils test", func() { Context("cluster utils test", func() { const ( clusterDefName = "test-clusterdef" - clusterVersionName = "test-clusterversion" clusterName = "test-cls" mysqlCompDefName = "replicasets" mysqlCompName = "mysql" @@ -65,9 +64,8 @@ var _ = Describe("cluster utils test", func() { ) var ( - clusterDef *appsv1alpha1.ClusterDefinition - clusterVersion *appsv1alpha1.ClusterVersion - cluster *appsv1alpha1.Cluster + clusterDef *appsv1alpha1.ClusterDefinition + cluster *appsv1alpha1.Cluster ) BeforeEach(func() { @@ -76,12 +74,7 @@ var _ = Describe("cluster utils test", func() { clusterDef = testapps.NewClusterDefFactory(clusterDefName). AddComponentDef(testapps.StatefulMySQLComponent, mysqlCompDefName). GetObject() - clusterVersion = testapps.NewClusterVersionFactory(clusterVersionName, clusterDefName). - AddComponentVersion(mysqlCompDefName). - AddContainerShort("mysql", testapps.ApeCloudMySQLImage). - GetObject() - cluster = testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, - clusterDef.Name, clusterVersion.Name). + cluster = testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, clusterDef.Name). SetUID(clusterName). AddComponent(mysqlCompName, mysqlCompDefName). AddShardingSpecV2(mysqlShardingName, mysqlCompDefName). diff --git a/pkg/controllerutil/sharding_utils_test.go b/pkg/controllerutil/sharding_utils_test.go index 014e990f5b1..d43b8a71f1b 100644 --- a/pkg/controllerutil/sharding_utils_test.go +++ b/pkg/controllerutil/sharding_utils_test.go @@ -41,7 +41,7 @@ var _ = Describe("cluster shard component", func() { // create the new objects. By("clean resources") - // delete cluster(and all dependent sub-resources), clusterversion and clusterdef + // delete cluster(and all dependent sub-resources), cluster definition testapps.ClearClusterResourcesWithRemoveFinalizerOption(&testCtx) // delete rest mocked objects @@ -56,7 +56,6 @@ var _ = Describe("cluster shard component", func() { Context("cluster shard component", func() { const ( clusterDefName = "test-clusterdef" - clusterVersionName = "test-clusterversion" clusterName = "test-cluster" mysqlCompDefName = "replicasets" mysqlCompName = "mysql" @@ -65,9 +64,8 @@ var _ = Describe("cluster shard component", func() { ) var ( - clusterDef *appsv1alpha1.ClusterDefinition - clusterVersion *appsv1alpha1.ClusterVersion - cluster *appsv1alpha1.Cluster + clusterDef *appsv1alpha1.ClusterDefinition + cluster *appsv1alpha1.Cluster ) BeforeEach(func() { @@ -76,12 +74,7 @@ var _ = Describe("cluster shard component", func() { clusterDef = testapps.NewClusterDefFactory(clusterDefName). AddComponentDef(testapps.StatefulMySQLComponent, mysqlCompDefName). GetObject() - clusterVersion = testapps.NewClusterVersionFactory(clusterVersionName, clusterDefName). - AddComponentVersion(mysqlCompDefName). - AddContainerShort("mysql", testapps.ApeCloudMySQLImage). - GetObject() - cluster = testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, - clusterDef.Name, clusterVersion.Name). + cluster = testapps.NewClusterFactory(testCtx.DefaultNamespace, clusterName, clusterDef.Name). SetUID(clusterName). AddComponent(mysqlCompName, mysqlCompDefName). AddShardingSpecV2(mysqlShardingName, mysqlCompDefName). diff --git a/pkg/generics/type.go b/pkg/generics/type.go index 1d7797bd12e..ddc697e5310 100644 --- a/pkg/generics/type.go +++ b/pkg/generics/type.go @@ -88,8 +88,6 @@ var VolumeSnapshotClassSignature = func(_ snapshotv1.VolumeSnapshotClass, _ *sna var ClusterSignature = func(_ appsv1alpha1.Cluster, _ *appsv1alpha1.Cluster, _ appsv1alpha1.ClusterList, _ *appsv1alpha1.ClusterList) { } -var ClusterVersionSignature = func(_ appsv1alpha1.ClusterVersion, _ *appsv1alpha1.ClusterVersion, _ appsv1alpha1.ClusterVersionList, _ *appsv1alpha1.ClusterVersionList) { -} var ClusterDefinitionSignature = func(_ appsv1alpha1.ClusterDefinition, _ *appsv1alpha1.ClusterDefinition, _ appsv1alpha1.ClusterDefinitionList, _ *appsv1alpha1.ClusterDefinitionList) { } var ComponentSignature = func(appsv1alpha1.Component, *appsv1alpha1.Component, appsv1alpha1.ComponentList, *appsv1alpha1.ComponentList) { diff --git a/pkg/testutil/apps/backuppolicytemplate_factory.go b/pkg/testutil/apps/backuppolicytemplate_factory.go index 46008801160..1e6eb97fc06 100644 --- a/pkg/testutil/apps/backuppolicytemplate_factory.go +++ b/pkg/testutil/apps/backuppolicytemplate_factory.go @@ -90,8 +90,7 @@ func (f *MockBackupPolicyTemplateFactory) AddSchedule(method, schedule, retentio return f } -func (f *MockBackupPolicyTemplateFactory) AddBackupMethod(name string, - snapshotVolumes bool, actionSetName string, mappingEnvWithClusterVersion ...string) *MockBackupPolicyTemplateFactory { +func (f *MockBackupPolicyTemplateFactory) AddBackupMethod(name string, snapshotVolumes bool, actionSetName string) *MockBackupPolicyTemplateFactory { backupPolicy := f.getLastBackupPolicy() backupMethod := appsv1alpha1.BackupMethod{ BackupMethod: dpv1alpha1.BackupMethod{ @@ -100,21 +99,6 @@ func (f *MockBackupPolicyTemplateFactory) AddBackupMethod(name string, ActionSetName: actionSetName, TargetVolumes: &dpv1alpha1.TargetVolumeInfo{}, }} - if len(mappingEnvWithClusterVersion) > 0 { - backupMethod.EnvMapping = []appsv1alpha1.EnvMappingVar{ - { - Key: EnvKeyImageTag, - ValueFrom: appsv1alpha1.ValueFrom{ - ClusterVersionRef: []appsv1alpha1.ValueMapping{ - { - Names: mappingEnvWithClusterVersion, - MappingValue: DefaultImageTag, - }, - }, - }, - }, - } - } backupPolicy.BackupMethods = append(backupPolicy.BackupMethods, backupMethod) return f } diff --git a/pkg/testutil/apps/cluster_factory.go b/pkg/testutil/apps/cluster_factory.go index 16b6306927b..d1fe15aeaca 100644 --- a/pkg/testutil/apps/cluster_factory.go +++ b/pkg/testutil/apps/cluster_factory.go @@ -29,13 +29,12 @@ type MockClusterFactory struct { BaseFactory[appsv1alpha1.Cluster, *appsv1alpha1.Cluster, MockClusterFactory] } -func NewClusterFactory(namespace, name, cdRef, cvRef string) *MockClusterFactory { +func NewClusterFactory(namespace, name, cdRef string) *MockClusterFactory { f := &MockClusterFactory{} f.Init(namespace, name, &appsv1alpha1.Cluster{ Spec: appsv1alpha1.ClusterSpec{ ClusterDefRef: cdRef, - ClusterVersionRef: cvRef, ComponentSpecs: []appsv1alpha1.ClusterComponentSpec{}, TerminationPolicy: appsv1alpha1.WipeOut, }, diff --git a/pkg/testutil/apps/cluster_instance_set_test_util.go b/pkg/testutil/apps/cluster_instance_set_test_util.go index 068c5404200..6922c83559e 100644 --- a/pkg/testutil/apps/cluster_instance_set_test_util.go +++ b/pkg/testutil/apps/cluster_instance_set_test_util.go @@ -45,24 +45,21 @@ const ( ) // InitConsensusMysql initializes a cluster environment which only contains a component of ConsensusSet type for testing, -// includes ClusterDefinition/ClusterVersion/Cluster resources. +// includes ClusterDefinition/Cluster resources. func InitConsensusMysql(testCtx *testutil.TestContext, clusterDefName, - clusterVersionName, clusterName, consensusCompType, - consensusCompName string) (*appsv1alpha1.ClusterDefinition, *appsv1alpha1.ClusterVersion, *appsv1alpha1.Cluster) { + consensusCompName string) (*appsv1alpha1.ClusterDefinition, *appsv1alpha1.Cluster) { clusterDef := CreateConsensusMysqlClusterDef(testCtx, clusterDefName, consensusCompType) - clusterVersion := CreateConsensusMysqlClusterVersion(testCtx, clusterDefName, clusterVersionName, consensusCompType) - cluster := CreateConsensusMysqlCluster(testCtx, clusterDefName, clusterVersionName, clusterName, consensusCompType, consensusCompName) - return clusterDef, clusterVersion, cluster + cluster := CreateConsensusMysqlCluster(testCtx, clusterDefName, clusterName, consensusCompType, consensusCompName) + return clusterDef, cluster } // CreateConsensusMysqlCluster creates a mysql cluster with a component of ConsensusSet type. func CreateConsensusMysqlCluster( testCtx *testutil.TestContext, clusterDefName, - clusterVersionName, clusterName, workloadType, consensusCompName string, pvcSize ...string) *appsv1alpha1.Cluster { @@ -71,7 +68,7 @@ func CreateConsensusMysqlCluster( size = pvcSize[0] } pvcSpec := NewPVCSpec(size) - return NewClusterFactory(testCtx.DefaultNamespace, clusterName, clusterDefName, clusterVersionName). + return NewClusterFactory(testCtx.DefaultNamespace, clusterName, clusterDefName). AddComponent(consensusCompName, workloadType).SetReplicas(ConsensusReplicas).SetEnabledLogs(errorLogName). AddVolumeClaimTemplate("data", pvcSpec).Create(testCtx).GetObject() } @@ -83,12 +80,6 @@ func CreateConsensusMysqlClusterDef(testCtx *testutil.TestContext, clusterDefNam AddLogConfig(errorLogName, filePathPattern).Create(testCtx).GetObject() } -// CreateConsensusMysqlClusterVersion creates a mysql clusterVersion with a component of ConsensusSet type. -func CreateConsensusMysqlClusterVersion(testCtx *testutil.TestContext, clusterDefName, clusterVersionName, workloadType string) *appsv1alpha1.ClusterVersion { - return NewClusterVersionFactory(clusterVersionName, clusterDefName).AddComponentVersion(workloadType).AddContainerShort("mysql", ApeCloudMySQLImage). - Create(testCtx).GetObject() -} - // MockInstanceSetComponent mocks the ITS component, just using in envTest func MockInstanceSetComponent( testCtx *testutil.TestContext, diff --git a/pkg/testutil/apps/cluster_util.go b/pkg/testutil/apps/cluster_util.go index b461c94473e..14304eb5cdb 100644 --- a/pkg/testutil/apps/cluster_util.go +++ b/pkg/testutil/apps/cluster_util.go @@ -32,34 +32,28 @@ import ( "github.com/apecloud/kubeblocks/pkg/testutil" ) -// InitClusterWithHybridComps initializes a cluster environment for testing, includes ClusterDefinition/ClusterVersion/Cluster resources. +// InitClusterWithHybridComps initializes a cluster environment for testing, includes ClusterDefinition/Cluster resources. func InitClusterWithHybridComps( testCtx *testutil.TestContext, clusterDefName, - clusterVersionName, clusterName, statelessCompDefName, statefulCompDefName, - consensusCompDefName string) (*appsv1alpha1.ClusterDefinition, *appsv1alpha1.ClusterVersion, *appsv1alpha1.Cluster) { + consensusCompDefName string) (*appsv1alpha1.ClusterDefinition, *appsv1alpha1.Cluster) { clusterDef := NewClusterDefFactory(clusterDefName). AddComponentDef(StatelessNginxComponent, statelessCompDefName). AddComponentDef(ConsensusMySQLComponent, consensusCompDefName). AddComponentDef(StatefulMySQLComponent, statefulCompDefName). Create(testCtx).GetObject() - clusterVersion := NewClusterVersionFactory(clusterVersionName, clusterDefName). - AddComponentVersion(statelessCompDefName).AddContainerShort(DefaultNginxContainerName, NginxImage). - AddComponentVersion(consensusCompDefName).AddContainerShort(DefaultMySQLContainerName, NginxImage). - AddComponentVersion(statefulCompDefName).AddContainerShort(DefaultMySQLContainerName, NginxImage). - Create(testCtx).GetObject() pvcSpec := NewPVCSpec("1Gi") - cluster := NewClusterFactory(testCtx.DefaultNamespace, clusterName, clusterDefName, clusterVersionName). + cluster := NewClusterFactory(testCtx.DefaultNamespace, clusterName, clusterDefName). AddComponent(statelessCompDefName, statelessCompDefName).SetReplicas(1). AddComponent(consensusCompDefName, consensusCompDefName).SetReplicas(3). AddVolumeClaimTemplate(DataVolumeName, pvcSpec). AddComponent(statefulCompDefName, statefulCompDefName).SetReplicas(3). AddVolumeClaimTemplate(DataVolumeName, pvcSpec). Create(testCtx).GetObject() - return clusterDef, clusterVersion, cluster + return clusterDef, cluster } func CreateK8sResource(testCtx *testutil.TestContext, obj client.Object) client.Object { diff --git a/pkg/testutil/apps/clusterversion_factory.go b/pkg/testutil/apps/clusterversion_factory.go deleted file mode 100644 index f93b27e8e09..00000000000 --- a/pkg/testutil/apps/clusterversion_factory.go +++ /dev/null @@ -1,106 +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 apps - -import ( - corev1 "k8s.io/api/core/v1" - - appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1" -) - -type MockClusterVersionFactory struct { - BaseFactory[appsv1alpha1.ClusterVersion, *appsv1alpha1.ClusterVersion, MockClusterVersionFactory] -} - -func NewClusterVersionFactory(name, cdRef string) *MockClusterVersionFactory { - f := &MockClusterVersionFactory{} - f.Init("", name, - &appsv1alpha1.ClusterVersion{ - Spec: appsv1alpha1.ClusterVersionSpec{ - ClusterDefinitionRef: cdRef, - ComponentVersions: []appsv1alpha1.ClusterComponentVersion{}, - }, - }, f) - return f -} - -func (factory *MockClusterVersionFactory) AddComponentVersion(compDefName string) *MockClusterVersionFactory { - comp := appsv1alpha1.ClusterComponentVersion{ - ComponentDefRef: compDefName, - } - factory.Get().Spec.ComponentVersions = append(factory.Get().Spec.ComponentVersions, comp) - return factory -} - -func (factory *MockClusterVersionFactory) AddInitContainer(container corev1.Container) *MockClusterVersionFactory { - comps := factory.Get().Spec.ComponentVersions - if len(comps) > 0 { - comp := comps[len(comps)-1] - comp.VersionsCtx.InitContainers = append(comp.VersionsCtx.InitContainers, container) - comps[len(comps)-1] = comp - } - factory.Get().Spec.ComponentVersions = comps - return factory -} - -func (factory *MockClusterVersionFactory) AddInitContainerShort(name string, image string) *MockClusterVersionFactory { - return factory.AddInitContainer(corev1.Container{ - Name: name, - Image: image, - }) -} - -func (factory *MockClusterVersionFactory) AddContainer(container corev1.Container) *MockClusterVersionFactory { - comps := factory.Get().Spec.ComponentVersions - if len(comps) > 0 { - comp := comps[len(comps)-1] - comp.VersionsCtx.Containers = append(comp.VersionsCtx.Containers, container) - comps[len(comps)-1] = comp - } - factory.Get().Spec.ComponentVersions = comps - return factory -} - -func (factory *MockClusterVersionFactory) AddContainerShort(name string, image string) *MockClusterVersionFactory { - return factory.AddContainer(corev1.Container{ - Name: name, - Image: image, - }) -} - -func (factory *MockClusterVersionFactory) AddConfigTemplate(name string, - configTemplateRef string, configConstraintRef string, volumeName string) *MockClusterVersionFactory { - comps := factory.Get().Spec.ComponentVersions - if len(comps) > 0 { - comp := comps[len(comps)-1] - comp.ConfigSpecs = append(comp.ConfigSpecs, - appsv1alpha1.ComponentConfigSpec{ - ComponentTemplateSpec: appsv1alpha1.ComponentTemplateSpec{ - Name: name, - TemplateRef: configTemplateRef, - VolumeName: volumeName, - }, - ConfigConstraintRef: configConstraintRef, - }) - comps[len(comps)-1] = comp - } - factory.Get().Spec.ComponentVersions = comps - return factory -} diff --git a/pkg/testutil/apps/common_util.go b/pkg/testutil/apps/common_util.go index 743f8f01a5e..32e4e9ecc2f 100644 --- a/pkg/testutil/apps/common_util.go +++ b/pkg/testutil/apps/common_util.go @@ -355,13 +355,9 @@ func ClearResourcesWithRemoveFinalizerOption[T intctrlutil.Object, PT intctrluti // environment without UseExistingCluster set, where garbage collection lacks. func ClearClusterResources(testCtx *testutil.TestContext) { inNS := client.InNamespace(testCtx.DefaultNamespace) - ClearResources(testCtx, intctrlutil.ClusterSignature, inNS, - client.HasLabels{testCtx.TestObjLabelKey}) - // finalizer of ConfigMap are deleted in ClusterDef&ClusterVersion controller - ClearResources(testCtx, intctrlutil.ClusterVersionSignature, - client.HasLabels{testCtx.TestObjLabelKey}) - ClearResources(testCtx, intctrlutil.ClusterDefinitionSignature, - client.HasLabels{testCtx.TestObjLabelKey}) + ClearResources(testCtx, intctrlutil.ClusterSignature, inNS, client.HasLabels{testCtx.TestObjLabelKey}) + // finalizer of ConfigMap are deleted in ClusterDefinition controller + ClearResources(testCtx, intctrlutil.ClusterDefinitionSignature, client.HasLabels{testCtx.TestObjLabelKey}) } // ClearClusterResourcesWithRemoveFinalizerOption clears all dependent resources belonging to existing clusters. @@ -369,8 +365,7 @@ func ClearClusterResourcesWithRemoveFinalizerOption(testCtx *testutil.TestContex inNs := client.InNamespace(testCtx.DefaultNamespace) hasLabels := client.HasLabels{testCtx.TestObjLabelKey} ClearResourcesWithRemoveFinalizerOption(testCtx, intctrlutil.ClusterSignature, true, inNs, hasLabels) - // finalizer of ConfigMap are deleted in ClusterDef & ClusterVersion controller - ClearResourcesWithRemoveFinalizerOption(testCtx, intctrlutil.ClusterVersionSignature, true, hasLabels) + // finalizer of ConfigMap are deleted in ClusterDefinition controller ClearResourcesWithRemoveFinalizerOption(testCtx, intctrlutil.ClusterDefinitionSignature, true, hasLabels) ClearResourcesWithRemoveFinalizerOption(testCtx, intctrlutil.ComponentDefinitionSignature, true, hasLabels) ClearResourcesWithRemoveFinalizerOption(testCtx, intctrlutil.ComponentVersionSignature, true, hasLabels) diff --git a/pkg/testutil/apps/constant.go b/pkg/testutil/apps/constant.go index d534ec93619..c97c6e3be80 100644 --- a/pkg/testutil/apps/constant.go +++ b/pkg/testutil/apps/constant.go @@ -54,9 +54,6 @@ const ( DefaultRedisContainerName = "redis" DefaultRedisInitContainerName = "redis-init-container" - EnvKeyImageTag = "IMAGE_TAG" - DefaultImageTag = "test" - DefaultConfigSpecName = "config-cm" DefaultConfigSpecTplRef = "env-from-config-tpl" DefaultConfigSpecVolumeName = "volume" diff --git a/pkg/testutil/dataprotection/backup_utils.go b/pkg/testutil/dataprotection/backup_utils.go index 2aaa330bd84..8deed3a928a 100644 --- a/pkg/testutil/dataprotection/backup_utils.go +++ b/pkg/testutil/dataprotection/backup_utils.go @@ -177,8 +177,7 @@ func NewFakeCluster(testCtx *testutil.TestContext) *BackupClusterInfo { } By("mocking a cluster") - cluster := testapps.NewClusterFactory(testCtx.DefaultNamespace, ClusterName, - "test-cd", "test-cv"). + cluster := testapps.NewClusterFactory(testCtx.DefaultNamespace, ClusterName, "test-cd"). AddLabels(constant.AppInstanceLabelKey, ClusterName). AddComponent("test-cmp", "test-cmpd").AddSystemAccount("test-account", nil, nil). Create(testCtx).GetObject() diff --git a/test/e2e/testdata/config/postgresql_cv.yaml b/test/e2e/testdata/config/postgresql_cv.yaml deleted file mode 100644 index a41f8708917..00000000000 --- a/test/e2e/testdata/config/postgresql_cv.yaml +++ /dev/null @@ -1,23 +0,0 @@ -apiVersion: apps.kubeblocks.io/v1alpha1 -kind: ClusterVersion -metadata: - name: postgresql-14.7.2-latest -spec: - clusterDefinitionRef: postgresql - componentVersions: - - componentDefRef: postgresql - versionsContext: - containers: - - name: postgresql - image: apecloud-registry.cn-zhangjiakou.cr.aliyuncs.com/apecloud/spilo:14.7.2 - - name: pgbouncer - image: apecloud-registry.cn-zhangjiakou.cr.aliyuncs.com/apecloud/pgbouncer:1.19.0 - initContainers: - - image: apecloud-registry.cn-zhangjiakou.cr.aliyuncs.com/apecloud/spilo:14.7.2 - name: pg-init-container - systemAccountSpec: - cmdExecutorConfig: - image: apecloud-registry.cn-zhangjiakou.cr.aliyuncs.com/apecloud/spilo:14.7.2 - switchoverSpec: - cmdExecutorConfig: - image: apecloud-registry.cn-zhangjiakou.cr.aliyuncs.com/apecloud/spilo:14.7.2 \ No newline at end of file