diff --git a/README.md b/README.md index c8bc1d5f..277d0309 100644 --- a/README.md +++ b/README.md @@ -203,11 +203,11 @@ Tarantool Operator is up and running. ``` This will open the resource in a text editor. - Change `spec.replicas` field value to 3: + Change `spec.numReplicasets` field value to 3: ```shell spec: - replicas: 3 + numReplicasets: 3 ``` Save your changes and exit the editor. diff --git a/README_RUS.md b/README_RUS.md index 3f067919..2c7b6a8d 100644 --- a/README_RUS.md +++ b/README_RUS.md @@ -203,12 +203,12 @@ Kubernetes-оператор реализует API версии `tarantool.io/v1 kubectl edit roles.tarantool.io storage ``` - В открывшемся текстовом редакторе поменяйте значение поля `spec.replicas` + В открывшемся текстовом редакторе поменяйте значение поля `spec.numReplicasets` на 3: ```shell spec: - replicas: 3 + numReplicasets: 3 ``` Сохраните изменения и закройте редактор. diff --git a/deploy/crds/tarantool_v1alpha1_role_crd.yaml b/deploy/crds/tarantool_v1alpha1_role_crd.yaml index d6b9c7b8..4e22d84c 100644 --- a/deploy/crds/tarantool_v1alpha1_role_crd.yaml +++ b/deploy/crds/tarantool_v1alpha1_role_crd.yaml @@ -12,8 +12,8 @@ spec: scope: Namespaced subresources: scale: - specReplicasPath: .spec.replicas - statusReplicasPath: .status.replicas + specReplicasPath: .spec.numReplicasets + statusReplicasPath: .status.numReplicasets status: {} validation: openAPIV3Schema: @@ -32,8 +32,8 @@ spec: type: object spec: properties: - replicas: - description: Replicas is a number of StatefulSets (Tarantol replicasets) + numReplicasets: + description: NumReplicasets is a number of StatefulSets (Tarantol replicasets) created under this Role format: int32 type: integer diff --git a/deploy/operator.yaml b/deploy/operator.yaml index a51a98b3..8e3a06bb 100644 --- a/deploy/operator.yaml +++ b/deploy/operator.yaml @@ -15,7 +15,7 @@ spec: serviceAccountName: tarantool-operator containers: - name: tarantool-operator - image: tarantool/tarantool-operator:0.0.1 + image: tarantool/tarantool-operator:0.0.2 command: - tarantool-operator imagePullPolicy: Always diff --git a/examples/kv/deployment.yaml b/examples/kv/deployment.yaml index acbc9a21..c5da26d8 100644 --- a/examples/kv/deployment.yaml +++ b/examples/kv/deployment.yaml @@ -19,7 +19,7 @@ spec: selector: matchLabels: tarantool.io/replicaset-template: "storage-template" - replicas: 1 + numReplicasets: 1 --- apiVersion: tarantool.io/v1alpha1 kind: Role @@ -33,7 +33,7 @@ spec: selector: matchLabels: tarantool.io/replicaset-template: "router-template" - replicas: 1 + numReplicasets: 1 --- apiVersion: tarantool.io/v1alpha1 kind: ReplicasetTemplate diff --git a/pkg/apis/tarantool/v1alpha1/role_types.go b/pkg/apis/tarantool/v1alpha1/role_types.go index 3fe9af82..062b3622 100644 --- a/pkg/apis/tarantool/v1alpha1/role_types.go +++ b/pkg/apis/tarantool/v1alpha1/role_types.go @@ -7,8 +7,8 @@ import ( // RoleSpec defines the desired state of Role // +k8s:openapi-gen=true type RoleSpec struct { - // Replicas is a number of StatefulSets (Tarantol replicasets) created under this Role - Replicas *int32 `json:"replicas,omitempty"` + // NumReplicasets is a number of StatefulSets (Tarantol replicasets) created under this Role + NumReplicasets *int32 `json:"numReplicasets,omitempty"` StorageTemplate *ReplicasetTemplate `json:"storageTemplate,omitempty"` // Selector is a LabelSelector to find ReplicasetTemplate resources from which StatefulSet created Selector *metav1.LabelSelector `json:"selector,omitempty"` @@ -27,7 +27,7 @@ type RoleStatus struct { // Role is the Schema for the roles API // +k8s:openapi-gen=true // +kubebuilder:subresource:status -// +kubebuilder:subresource:scale:specpath=.spec.replicas,statuspath=.status.replicas +// +kubebuilder:subresource:scale:specpath=.spec.numReplicasets,statuspath=.status.numReplicasets type Role struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` diff --git a/pkg/apis/tarantool/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/tarantool/v1alpha1/zz_generated.deepcopy.go index 0098ab02..4906af98 100644 --- a/pkg/apis/tarantool/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/tarantool/v1alpha1/zz_generated.deepcopy.go @@ -269,8 +269,8 @@ func (in *RoleList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *RoleSpec) DeepCopyInto(out *RoleSpec) { *out = *in - if in.Replicas != nil { - in, out := &in.Replicas, &out.Replicas + if in.NumReplicasets != nil { + in, out := &in.NumReplicasets, &out.NumReplicasets *out = new(int32) **out = **in } diff --git a/pkg/apis/tarantool/v1alpha1/zz_generated.openapi.go b/pkg/apis/tarantool/v1alpha1/zz_generated.openapi.go index b5b06313..be87fecb 100644 --- a/pkg/apis/tarantool/v1alpha1/zz_generated.openapi.go +++ b/pkg/apis/tarantool/v1alpha1/zz_generated.openapi.go @@ -224,9 +224,9 @@ func schema_pkg_apis_tarantool_v1alpha1_RoleSpec(ref common.ReferenceCallback) c SchemaProps: spec.SchemaProps{ Description: "RoleSpec defines the desired state of Role", Properties: map[string]spec.Schema{ - "replicas": { + "numReplicasets": { SchemaProps: spec.SchemaProps{ - Description: "Replicas is a number of StatefulSets (Tarantol replicasets) created under this Role", + Description: "NumReplicasets is a number of StatefulSets (Tarantol replicasets) created under this Role", Type: []string{"integer"}, Format: "int32", }, diff --git a/pkg/controller/role/role_controller.go b/pkg/controller/role/role_controller.go index be44c502..3ea2a31c 100644 --- a/pkg/controller/role/role_controller.go +++ b/pkg/controller/role/role_controller.go @@ -156,9 +156,9 @@ func (r *ReconcileRole) Reconcile(request reconcile.Request) (reconcile.Result, } // ensure num of statefulsets matches user expectations - if len(stsList.Items) > int(*role.Spec.Replicas) { - reqLogger.Info("Role", "more instances", *role.Spec.Replicas) - for i := len(stsList.Items); i > int(*role.Spec.Replicas); i-- { + if len(stsList.Items) > int(*role.Spec.NumReplicasets) { + reqLogger.Info("Role", "more instances", *role.Spec.NumReplicasets) + for i := len(stsList.Items); i > int(*role.Spec.NumReplicasets); i-- { sts := &appsv1.StatefulSet{} sts.Name = fmt.Sprintf("%s-%d", role.Name, i-1) sts.Namespace = request.Namespace @@ -185,8 +185,8 @@ func (r *ReconcileRole) Reconcile(request reconcile.Request) (reconcile.Result, } template := templateList.Items[0] - if len(stsList.Items) < int(*role.Spec.Replicas) { - for i := 0; i < int(*role.Spec.Replicas); i++ { + if len(stsList.Items) < int(*role.Spec.NumReplicasets) { + for i := 0; i < int(*role.Spec.NumReplicasets); i++ { sts := &appsv1.StatefulSet{} sts.Name = fmt.Sprintf("%s-%d", role.Name, i) sts.Namespace = request.Namespace