4.3 Using NdbClusterPodSpec

The NDB Cluster Custom Resource Definition provides the NdbClusterPodSpec structure for defining specifications of pods for individual management, data, and SQL nodes using their respective .spec.managementNode.ndbPodSpec, .spec.dataNode.ndbPodSpec, and .spec.mysqlNode.ndbPodSpec fields. Values set for these NdbPodSpec fields are copied into their respective StatefulSet definitions. This chapter explains how these NdbClusterPodSpec fields can be used for assigning pods to specific worker nodes, defining affinity rules, and specifying pod resource requirements.

Assigning NDB node pods to worker pods.  You can specify the label of the worker node on which a given NDB Cluster node should be scheduled by specifying it in the nodeSelector field.

See Assigning Pods to Nodes for more information.

Affinity and anti-affinity.  Affinity and anti-affinity rules for NDB Cluster nodes can be defined using the affinity field. The Kubernetes Cluster uses these rules to decide where to schedule an NDB Cluster pod. These rules are applied after filtering out the available worker node pool based on any specified nodeSelector labels.

NDB Operator defines default anti-affinity rules for each of the three MySQL Cluster node types (ndb_mgmd, ndbmtd, and mysqld) to prevent them from being scheduled on the same worker node whenever possible. Such a rule is always defined as preferredDuringSchedulingIgnoredDuringExecution, so that it is satisfied by the Kubernetes scheduler only if there are sufficient resources. For example, if four data nodes must be scheduled on four worker nodes, each data node is scheduled on a separate worker node, but if six data nodes must be scheduled on four worker nodes, the first four data nodes are scheduled on four separate worker nodes while the fifth and sixth data nodes must be scheduled on worker nodes where a data node is already running. Default anti-affinity rules can be overridden by specifying the desired anti-affinity rules in the affinity field.

For more information, see Affinity and anti-affinity.

Specify Resource Requirements.  Pod resource requirements can be specified using the resources field. These requirements are copied into the container definitions.

NDB Operator defines default memory requirements for data nodes based on the configuration of the NDB Cluster. The minimum calculated by NDB Operator for this purpose is an estimate, and can be overridden by specifying an alternative using the data node's ndbPodSpec.

For more information, see Resource Management for Pods and Containers.