Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions README_RUS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Сохраните изменения и закройте редактор.
Expand Down
8 changes: 4 additions & 4 deletions deploy/crds/tarantool_v1alpha1_role_crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ spec:
scope: Namespaced
subresources:
scale:
specReplicasPath: .spec.replicas
statusReplicasPath: .status.replicas
specReplicasPath: .spec.numReplicasets
statusReplicasPath: .status.numReplicasets
status: {}
validation:
openAPIV3Schema:
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion deploy/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions examples/kv/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ spec:
selector:
matchLabels:
tarantool.io/replicaset-template: "storage-template"
replicas: 1
numReplicasets: 1
---
apiVersion: tarantool.io/v1alpha1
kind: Role
Expand All @@ -33,7 +33,7 @@ spec:
selector:
matchLabels:
tarantool.io/replicaset-template: "router-template"
replicas: 1
numReplicasets: 1
---
apiVersion: tarantool.io/v1alpha1
kind: ReplicasetTemplate
Expand Down
6 changes: 3 additions & 3 deletions pkg/apis/tarantool/v1alpha1/role_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand All @@ -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"`
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/tarantool/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pkg/apis/tarantool/v1alpha1/zz_generated.openapi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions pkg/controller/role/role_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down