Skip to content

Commit f88f2a3

Browse files
authored
resolve #7: rename Role.Spec.Replicas to NumReplicasets
1 parent 80feddc commit f88f2a3

File tree

9 files changed

+23
-23
lines changed

9 files changed

+23
-23
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,11 @@ Tarantool Operator is up and running.
203203
```
204204

205205
This will open the resource in a text editor.
206-
Change `spec.replicas` field value to 3:
206+
Change `spec.numReplicasets` field value to 3:
207207

208208
```shell
209209
spec:
210-
replicas: 3
210+
numReplicasets: 3
211211
```
212212

213213
Save your changes and exit the editor.

README_RUS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,12 @@ Kubernetes-оператор реализует API версии `tarantool.io/v1
203203
kubectl edit roles.tarantool.io storage
204204
```
205205

206-
В открывшемся текстовом редакторе поменяйте значение поля `spec.replicas`
206+
В открывшемся текстовом редакторе поменяйте значение поля `spec.numReplicasets`
207207
на 3:
208208

209209
```shell
210210
spec:
211-
replicas: 3
211+
numReplicasets: 3
212212
```
213213

214214
Сохраните изменения и закройте редактор.

deploy/crds/tarantool_v1alpha1_role_crd.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ spec:
1212
scope: Namespaced
1313
subresources:
1414
scale:
15-
specReplicasPath: .spec.replicas
16-
statusReplicasPath: .status.replicas
15+
specReplicasPath: .spec.numReplicasets
16+
statusReplicasPath: .status.numReplicasets
1717
status: {}
1818
validation:
1919
openAPIV3Schema:
@@ -32,8 +32,8 @@ spec:
3232
type: object
3333
spec:
3434
properties:
35-
replicas:
36-
description: Replicas is a number of StatefulSets (Tarantol replicasets)
35+
numReplicasets:
36+
description: NumReplicasets is a number of StatefulSets (Tarantol replicasets)
3737
created under this Role
3838
format: int32
3939
type: integer

deploy/operator.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ spec:
1515
serviceAccountName: tarantool-operator
1616
containers:
1717
- name: tarantool-operator
18-
image: tarantool/tarantool-operator:0.0.1
18+
image: tarantool/tarantool-operator:0.0.2
1919
command:
2020
- tarantool-operator
2121
imagePullPolicy: Always

examples/kv/deployment.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ spec:
1919
selector:
2020
matchLabels:
2121
tarantool.io/replicaset-template: "storage-template"
22-
replicas: 1
22+
numReplicasets: 1
2323
---
2424
apiVersion: tarantool.io/v1alpha1
2525
kind: Role
@@ -33,7 +33,7 @@ spec:
3333
selector:
3434
matchLabels:
3535
tarantool.io/replicaset-template: "router-template"
36-
replicas: 1
36+
numReplicasets: 1
3737
---
3838
apiVersion: tarantool.io/v1alpha1
3939
kind: ReplicasetTemplate

pkg/apis/tarantool/v1alpha1/role_types.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import (
77
// RoleSpec defines the desired state of Role
88
// +k8s:openapi-gen=true
99
type RoleSpec struct {
10-
// Replicas is a number of StatefulSets (Tarantol replicasets) created under this Role
11-
Replicas *int32 `json:"replicas,omitempty"`
10+
// NumReplicasets is a number of StatefulSets (Tarantol replicasets) created under this Role
11+
NumReplicasets *int32 `json:"numReplicasets,omitempty"`
1212
StorageTemplate *ReplicasetTemplate `json:"storageTemplate,omitempty"`
1313
// Selector is a LabelSelector to find ReplicasetTemplate resources from which StatefulSet created
1414
Selector *metav1.LabelSelector `json:"selector,omitempty"`
@@ -27,7 +27,7 @@ type RoleStatus struct {
2727
// Role is the Schema for the roles API
2828
// +k8s:openapi-gen=true
2929
// +kubebuilder:subresource:status
30-
// +kubebuilder:subresource:scale:specpath=.spec.replicas,statuspath=.status.replicas
30+
// +kubebuilder:subresource:scale:specpath=.spec.numReplicasets,statuspath=.status.numReplicasets
3131
type Role struct {
3232
metav1.TypeMeta `json:",inline"`
3333
metav1.ObjectMeta `json:"metadata,omitempty"`

pkg/apis/tarantool/v1alpha1/zz_generated.deepcopy.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/tarantool/v1alpha1/zz_generated.openapi.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/controller/role/role_controller.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,9 @@ func (r *ReconcileRole) Reconcile(request reconcile.Request) (reconcile.Result,
156156
}
157157

158158
// ensure num of statefulsets matches user expectations
159-
if len(stsList.Items) > int(*role.Spec.Replicas) {
160-
reqLogger.Info("Role", "more instances", *role.Spec.Replicas)
161-
for i := len(stsList.Items); i > int(*role.Spec.Replicas); i-- {
159+
if len(stsList.Items) > int(*role.Spec.NumReplicasets) {
160+
reqLogger.Info("Role", "more instances", *role.Spec.NumReplicasets)
161+
for i := len(stsList.Items); i > int(*role.Spec.NumReplicasets); i-- {
162162
sts := &appsv1.StatefulSet{}
163163
sts.Name = fmt.Sprintf("%s-%d", role.Name, i-1)
164164
sts.Namespace = request.Namespace
@@ -185,8 +185,8 @@ func (r *ReconcileRole) Reconcile(request reconcile.Request) (reconcile.Result,
185185
}
186186
template := templateList.Items[0]
187187

188-
if len(stsList.Items) < int(*role.Spec.Replicas) {
189-
for i := 0; i < int(*role.Spec.Replicas); i++ {
188+
if len(stsList.Items) < int(*role.Spec.NumReplicasets) {
189+
for i := 0; i < int(*role.Spec.NumReplicasets); i++ {
190190
sts := &appsv1.StatefulSet{}
191191
sts.Name = fmt.Sprintf("%s-%d", role.Name, i)
192192
sts.Namespace = request.Namespace

0 commit comments

Comments
 (0)