New to KubeDB? Please start here.

Neo4jAutoscaler

What is Neo4jAutoscaler?

Neo4jAutoscaler is a Kubernetes custom resource that declares how KubeDB should automatically scale the compute resources and persistent storage of a Neo4j cluster. The Autoscaler operator translates its recommendations into Neo4jOpsRequest resources, which are executed by Ops Manager.

The following example enables both compute and storage autoscaling:

apiVersion: autoscaling.kubedb.com/v1alpha1
kind: Neo4jAutoscaler
metadata:
  name: neo4j-autoscaler
  namespace: demo
spec:
  databaseRef:
    name: neo4j-autoscale
  opsRequestOptions:
    apply: IfReady
    timeout: 10m
    maxRetries: 3
  compute:
    neo4j:
      trigger: "On"
      podLifeTimeThreshold: 5m
      resourceDiffPercentage: 20
      minAllowed:
        cpu: 600m
        memory: 1200Mi
      maxAllowed:
        cpu: "2"
        memory: 2Gi
      controlledResources:
        - cpu
        - memory
      containerControlledValues: RequestsAndLimits
  storage:
    neo4j:
      trigger: "On"
      usageThreshold: 80
      scalingThreshold: 50
      expansionMode: Online

Specification

Like other Kubernetes resources, Neo4jAutoscaler contains apiVersion, kind, metadata, spec, and status. Users declare the policy in spec; the operator reports observed state in status.

spec.databaseRef

spec.databaseRef is required and identifies the Neo4j resource in the same namespace.

FieldDescription
nameName of the target KubeDB Neo4j resource.

spec.opsRequestOptions

These options are copied to every Neo4jOpsRequest created by the Autoscaler.

FieldDescription
applyIfReady creates operations only while the database is ready; Always permits creation regardless of readiness. Defaults to IfReady.
timeoutMaximum duration allowed for each operation step.
maxRetriesMaximum retries for a failed operation. Defaults to 1.

spec.compute

spec.compute.neo4j controls CPU and memory recommendations for the neo4j container.

FieldDescription
triggerEnables autoscaling when set to On; use Off to disable it without deleting the resource.
minAllowedLower CPU and memory bounds for recommendations.
maxAllowedUpper CPU and memory bounds for recommendations.
controlledResourcesResources controlled by the Autoscaler, normally cpu and memory.
containerControlledValuesRequestsAndLimits updates both values; RequestsOnly updates only requests.
resourceDiffPercentageMinimum percentage difference between the current allocation and a recommendation before an update is applied. Defaults to 50.
podLifeTimeThresholdMinimum pod lifetime considered when deciding whether to apply a recommendation. Defaults to 15m.

spec.compute.nodeTopology is optional. When set, the Autoscaler selects resources from the named NodeTopology instead of applying an arbitrary recommendation. scaleUpDiffPercentage and scaleDownDiffPercentage control when it moves between topology entries; their defaults are 15 and 25, respectively.

spec.storage

spec.storage.neo4j controls expansion of the Neo4j data volumes.

FieldDescription
triggerEnables storage autoscaling when set to On.
usageThresholdUsed-capacity percentage at which expansion is triggered. Defaults to 80.
scalingThresholdPercentage by which the current volume is increased. Defaults to 50.
scalingRulesOptional size-dependent rules. Each rule has an appliesUpto capacity and a threshold percentage or absolute quantity.
upperBoundOptional maximum volume size.
expansionModeRequired expansion strategy: Online or Offline.

For example, the following rules grow smaller volumes proportionally and larger volumes by a fixed amount:

storage:
  neo4j:
    trigger: "On"
    usageThreshold: 80
    expansionMode: Online
    upperBound: 2Ti
    scalingRules:
      - appliesUpto: 500Gi
        threshold: 30pc
      - appliesUpto: 1Ti
        threshold: 20pc
      - appliesUpto: ""
        threshold: 100Gi

status

The status is managed by KubeDB and should not be edited. Important fields include:

FieldDescription
phaseCurrent Autoscaler phase, such as InProgress, Current, or Failed.
observedGenerationMost recent resource generation processed by the operator.
conditionsEvents and outcomes reported by the Autoscaler controller.
vpasCurrent compute recommendations and their conditions.
checkpointsHistorical CPU and memory samples used by the recommender.

Next Steps