in pkg/resources/statefulset/ndbmtd_statefulset.go [216:289]
func (nss *ndbmtdStatefulSet) getContainers(nc *v1.NdbCluster, addInitialFlag bool) ([]corev1.Container, error) {
// Command and args to run the Data node
cmdAndArgs := []string{
"/usr/sbin/ndbmtd",
"-c", nc.GetConnectstring(),
"--foreground",
// Pass the nodeId to be used to prevent invalid
// nodeId allocation during statefulset patching.
"--ndb-nodeid=$(cat " + NodeIdFilePath + ")",
}
if debug.Enabled {
// Increase verbosity in debug mode
cmdAndArgs = append(cmdAndArgs, "-v")
}
if nc.Spec.TDESecretName != "" {
secret, err := nss.secretLister.Secrets(nc.Namespace).Get(nc.Spec.TDESecretName)
if err != nil {
// Secret does not exist
klog.Errorf("Failed to retrieve Secret %q : %s", nc.Spec.TDESecretName, err)
return nil, err
}
pass := string(secret.Data[corev1.BasicAuthPasswordKey])
cmdAndArgs = append(cmdAndArgs, "--filesystem-password="+pass)
}
if addInitialFlag {
cmdAndArgs = append(cmdAndArgs, "--initial")
}
ndbmtdContainer := nss.createContainer(
nc, nss.getContainerName(false), cmdAndArgs,
nss.getVolumeMounts(), ndbmtdPorts)
// Setup startup probe for data nodes.
// The probe uses a script that checks if a data node has started, by
// connecting to the Management node via ndb_mgm. This implies that atleast
// one Management node has to be available for the probe to succeed. This
// is fine as that is already a requirement for a data node to start. Even
// if the Management node crashes or becomes unavailable when the data node
// is going through the start phases, the Management node will be
// rescheduled immediately and will become ready within a few seconds,
// enabling the data node startup probe to succeed.
ndbmtdContainer.StartupProbe = &corev1.Probe{
ProbeHandler: corev1.ProbeHandler{
Exec: &corev1.ExecAction{
// ndbmtd-startup-probe.sh
Command: []string{
"/bin/bash",
helperScriptsMountPath + "/" + constants.DataNodeStartupProbeScript,
},
},
},
// expect data node to get ready within 15 minutes
PeriodSeconds: 2,
TimeoutSeconds: 2,
FailureThreshold: 450,
}
// Set resource request to data node container
resList, err := nss.getResourceRequestRequirements(nc)
if err == nil {
ndbmtdContainer.Resources = corev1.ResourceRequirements{
Requests: resList,
}
} else {
klog.Warningf("Failed to set ResourceRequirements to %s", ndbmtdContainer.Name)
}
return []corev1.Container{ndbmtdContainer}, nil
}