Skip to content

Commit

Permalink
Make replicas configurable in scalable DeploymentConfigs
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelsorianod committed Sep 20, 2019
1 parent 05e9c02 commit bd426d7
Show file tree
Hide file tree
Showing 8 changed files with 489 additions and 24 deletions.
54 changes: 54 additions & 0 deletions deploy/crds/apps_v1alpha1_apimanager_crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,49 @@ spec:
type: string
openSSLVerify:
type: boolean
productionSpec:
properties:
replicas:
format: int64
type: integer
type: object
registryURL:
type: string
responseCodes:
type: boolean
stagingSpec:
properties:
replicas:
format: int64
type: integer
type: object
type: object
appLabel:
type: string
backend:
properties:
cronSpec:
properties:
replicas:
format: int64
type: integer
type: object
image:
type: string
listenerSpec:
properties:
replicas:
format: int64
type: integer
type: object
redisImage:
type: string
workerSpec:
properties:
replicas:
format: int64
type: integer
type: object
type: object
highAvailability:
properties:
Expand All @@ -62,6 +92,12 @@ spec:
type: boolean
system:
properties:
appSpec:
properties:
replicas:
format: int64
type: integer
type: object
database:
properties:
mysql:
Expand Down Expand Up @@ -107,17 +143,35 @@ spec:
type: string
redisImage:
type: string
sidekiqSpec:
properties:
replicas:
format: int64
type: integer
type: object
type: object
tenantName:
type: string
wildcardDomain:
type: string
zync:
properties:
appSpec:
properties:
replicas:
format: int64
type: integer
type: object
image:
type: string
postgreSQLImage:
type: string
queSpec:
properties:
replicas:
format: int64
type: integer
type: object
type: object
required:
- wildcardDomain
Expand Down
6 changes: 2 additions & 4 deletions pkg/3scale/amp/operator/apicast.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ func (o *OperatorApicastOptionsProvider) setResourceRequirementsOptions(b *compo
}

func (o *OperatorApicastOptionsProvider) setReplicas(b *component.ApicastOptionsBuilder) {
if o.APIManagerSpec.HighAvailability != nil && o.APIManagerSpec.HighAvailability.Enabled {
b.StagingReplicas(2)
b.ProductionReplicas(2)
}
b.StagingReplicas(int32(*o.APIManagerSpec.Apicast.StagingSpec.Replicas))
b.ProductionReplicas(int32(*o.APIManagerSpec.Apicast.ProductionSpec.Replicas))
}
8 changes: 3 additions & 5 deletions pkg/3scale/amp/operator/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,7 @@ func (o *OperatorBackendOptionsProvider) setBackendRedisOptions(b *component.Bac
}

func (o *OperatorBackendOptionsProvider) setReplicas(b *component.BackendOptionsBuilder) {
if o.APIManagerSpec.HighAvailability != nil && o.APIManagerSpec.HighAvailability.Enabled {
b.ListenerReplicas(2)
b.WorkerReplicas(2)
b.CronReplicas(2)
}
b.ListenerReplicas(int32(*o.APIManagerSpec.Backend.ListenerSpec.Replicas))
b.WorkerReplicas(int32(*o.APIManagerSpec.Backend.WorkerSpec.Replicas))
b.CronReplicas(int32(*o.APIManagerSpec.Backend.CronSpec.Replicas))
}
7 changes: 1 addition & 6 deletions pkg/3scale/amp/operator/deployment_config_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,7 @@ func DeploymentConfigReconcileReplicas(desired, existing *appsv1.DeploymentConfi
desiredName := ObjectInfo(desired)
update := false

// TODO implement right replica reconciliation with replica fields in CRD

// Currently, to alllow scaling manually, we do no reconcile repolicas.
// One exception: Just in case some configuration (like HA conf) sets replica to higher than 1 and existing replica is 1,
// then the replica will be reconciled. This is a hack to be removed when replica reconciliation is implemented.
if desired.Spec.Replicas > 1 && existing.Spec.Replicas == 1 {
if desired.Spec.Replicas != existing.Spec.Replicas {
logger.Info(fmt.Sprintf("%s spec.replicas differs, recreating dc", desiredName))
existing.Spec.Replicas = desired.Spec.Replicas
update = true
Expand Down
6 changes: 2 additions & 4 deletions pkg/3scale/amp/operator/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,6 @@ func (o *OperatorSystemOptionsProvider) setAWSSecretOptions(sob *component.Syste
}

func (o *OperatorSystemOptionsProvider) setReplicas(sob *component.SystemOptionsBuilder) {
if o.APIManagerSpec.HighAvailability != nil && o.APIManagerSpec.HighAvailability.Enabled {
sob.AppReplicas(2)
sob.SidekiqReplicas(2)
}
sob.AppReplicas(int32(*o.APIManagerSpec.System.AppSpec.Replicas))
sob.SidekiqReplicas(int32(*o.APIManagerSpec.System.SidekiqSpec.Replicas))
}
6 changes: 2 additions & 4 deletions pkg/3scale/amp/operator/zync.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ func (o *OperatorZyncOptionsProvider) setResourceRequirementsOptions(b *componen
}

func (o *OperatorZyncOptionsProvider) setReplicas(zob *component.ZyncOptionsBuilder) {
if o.APIManagerSpec.HighAvailability != nil && o.APIManagerSpec.HighAvailability.Enabled {
zob.ZyncReplicas(2)
zob.ZyncQueReplicas(2)
}
zob.ZyncReplicas(int32(*o.APIManagerSpec.Zync.AppSpec.Replicas))
zob.ZyncQueReplicas(int32(*o.APIManagerSpec.Zync.QueSpec.Replicas))
}
Loading

0 comments on commit bd426d7

Please sign in to comment.