The module lifecycle stage: Preview

The module has requirements for installation

OpensearchClass

The cluster-wide OpensearchClass resource allows restricting invalid configurations and predefining deployment parameters. Each Opensearch resource must be associated with an existing OpensearchClass resource. Before deploying the service, all user configuration is validated against the corresponding OpensearchClass.

The OpensearchClass spec is immutable after creation. To change configuration, create a new class.

Sizing Policies

Sizing policies define allowed CPU and memory ranges for linked Opensearch instances. This helps avoid uneven distribution of CPU and memory resources across cluster nodes. The determining factor for choosing a particular policy is falling within the cores interval. Then compliance with other fields of the specific policy will be checked.

spec:
  sizingPolicies:
    - cores:
        min: 1
        max: 4
      memory:
        min: 2Gi
        max: 8Gi
        step: 1Gi
      coreFractions:
        - "50%"
        - "100%"
    - cores:
        min: 5
        max: 16
      memory:
        min: 8Gi
        max: 32Gi
        step: 1Gi
      coreFractions:
        - "100%"

Validation Rules

CEL (Common Expression Language) is used for creating flexible validation mechanisms. Predefined variables available in rule:

  • instance.memory.size
  • instance.cpu.cores
spec:
  validations:
    - message: "Memory must be at least 2x CPU cores in GiB"
      rule: "instance.memory.size >= instance.cpu.cores * 2147483648"

Affinity

Standard Kubernetes mechanism for managing scheduling of deployed pods.

spec:
  nodeAffinity:
    requiredDuringSchedulingIgnoredDuringExecution:
      nodeSelectorTerms:
      - matchExpressions:
        - key: "node.deckhouse.io/group"
          operator: "In"
          values:
          - "opensearch"

Tolerations

spec:
  tolerations:
  - key: dedicated
    operator: Equal
    value: opensearch
    effect: NoSchedule

Node Selector

spec:
  nodeSelector:
    "node.deckhouse.io/group": "opensearch"

Class Configuration

spec.configuration holds OpenSearch settings that apply to every Opensearch of the class. The effective configuration of an instance is built from three layers, each overriding the previous one:

  1. the module defaults (the OpenSearch defaults);
  2. OpensearchClass.spec.configuration;
  3. Opensearch.spec.configuration, but only for the keys listed in spec.overridableConfiguration.

So an administrator may set a key in the class that users are not allowed to change, by leaving it out of overridableConfiguration.

spec:
  configuration:
    searchMaxBuckets: 90000
    actionAutoCreateIndex: false
  overridableConfiguration:
    - searchMaxBuckets

Supported keys: searchMaxBuckets (search.max_buckets, default 65535) and actionAutoCreateIndex (action.auto_create_index, default true). Both are applied to the running instance without a restart. overridableConfiguration lists the same field names as spec.configuration.

Classes created with module versions before v0.0.4 list OpenSearch setting keys instead (search.max_buckets, action.auto_create_index). They keep working as they are; new classes must use the field names.

The maximum HTTP request body size (http.max_content_length) is not configurable: the operator derives it from the instance memory, 10 MiB below 16Gi and 100 MiB from 16Gi.

Usage Examples

Basic Usage

apiVersion: managed-services.deckhouse.io/v1alpha1
kind: OpensearchClass
metadata:
  name: default
spec:
  # parameters users may override in Opensearch.spec.configuration
  overridableConfiguration:
    - searchMaxBuckets
    - actionAutoCreateIndex
  sizingPolicies:
    - cores:
        min: 1
        max: 4
      memory:
        min: 2Gi
        max: 8Gi
        step: 1Gi
      coreFractions:
        - "50%"
        - "100%"
    - cores:
        min: 5
        max: 16
      memory:
        min: 8Gi
        max: 32Gi
        step: 1Gi
      coreFractions:
        - "100%"

Class with Validation and Placement

apiVersion: managed-services.deckhouse.io/v1alpha1
kind: OpensearchClass
metadata:
  name: production
spec:
  sizingPolicies:
    - cores:
        min: 4
        max: 16
      memory:
        min: 8Gi
        max: 32Gi
        step: 1Gi
      coreFractions:
        - "100%"
  validations:
    - message: "Memory must be at least 2x CPU cores in GiB"
      rule: "instance.memory.size >= instance.cpu.cores * 2147483648"
  nodeSelector:
    "node.deckhouse.io/group": "opensearch"
  tolerations:
    - key: dedicated
      operator: Equal
      value: opensearch
      effect: NoSchedule