Skip to content

Commit

Permalink
Ability to scale Pravega Controller (#99)
Browse files Browse the repository at this point in the history
Signed-off-by: Adrian Moreno <[email protected]>
  • Loading branch information
adrianmo authored Nov 28, 2018
1 parent d86f62e commit 220f918
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions pkg/pravega/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ func syncClusterSize(pravegaCluster *api.PravegaCluster) (err error) {
return err
}

err = syncControllerSize(pravegaCluster)
if err != nil {
return err
}

return nil
}

Expand Down Expand Up @@ -112,3 +117,30 @@ func syncSegmentStoreSize(pravegaCluster *api.PravegaCluster) (err error) {
}
return nil
}

func syncControllerSize(pravegaCluster *api.PravegaCluster) (err error) {
deploy := &appsv1.Deployment{
TypeMeta: metav1.TypeMeta{
Kind: "Deployment",
APIVersion: "apps/v1",
},
ObjectMeta: metav1.ObjectMeta{
Name: k8sutil.DeploymentNameForController(pravegaCluster.Name),
Namespace: pravegaCluster.Namespace,
},
}

err = sdk.Get(deploy)
if err != nil {
return fmt.Errorf("failed to get deployment (%s): %v", deploy.Name, err)
}

if *deploy.Spec.Replicas != pravegaCluster.Spec.Pravega.ControllerReplicas {
deploy.Spec.Replicas = &(pravegaCluster.Spec.Pravega.ControllerReplicas)
err = sdk.Update(deploy)
if err != nil {
return fmt.Errorf("failed to update size of deployment (%s): %v", deploy.Name, err)
}
}
return nil
}

0 comments on commit 220f918

Please sign in to comment.