in pkg/resources/statefulset/ndb_statefulset_interface.go [186:248]
func (bss *baseStatefulSet) newStatefulSet(
nc *v1.NdbCluster, cs *ndbconfig.ConfigSummary) *appsv1.StatefulSet {
// Fill in the podSpec with any provided ImagePullSecrets
var podSpec corev1.PodSpec
imagePullSecretName := nc.Spec.ImagePullSecretName
if imagePullSecretName != "" {
podSpec.ImagePullSecrets = append(podSpec.ImagePullSecrets, corev1.LocalObjectReference{
Name: imagePullSecretName,
})
}
// Add the default init container and add the ndbOperatorImagePullSecretName
// to the existing ImagePullSecrets list.
podSpec.InitContainers = bss.getDefaultInitContainers(nc)
ndbOperatorImagePullSecretName := os.Getenv("NDB_OPERATOR_IMAGE_PULL_SECRET_NAME")
if ndbOperatorImagePullSecretName != "" {
podSpec.ImagePullSecrets = append(podSpec.ImagePullSecrets, corev1.LocalObjectReference{
Name: ndbOperatorImagePullSecretName,
})
}
// Add the empty dir volume
podSpec.Volumes = []corev1.Volume{*bss.getEmptyDirPodVolume(workDirVolName)}
podSpec.ServiceAccountName = nc.GetServiceAccountName()
// Labels to be used for the statefulset pods
podLabels := bss.getPodLabels(nc)
return &appsv1.StatefulSet{
ObjectMeta: metav1.ObjectMeta{
Name: bss.GetName(nc),
Labels: bss.getStatefulSetLabels(nc),
// Owner reference pointing to the Ndb resource
OwnerReferences: nc.GetOwnerReferences(),
Annotations: map[string]string{
// Add the NdbCluster generation this statefulset is based on to the annotation
LastAppliedConfigGeneration: strconv.FormatInt(cs.NdbClusterGeneration, 10),
},
},
Spec: appsv1.StatefulSetSpec{
Selector: &metav1.LabelSelector{
// Use the pods labels as the selector
MatchLabels: podLabels,
},
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: podLabels,
// Annotate the spec template with the config.ini version.
// A change in the config will create a new version of the spec template.
Annotations: map[string]string{
LastAppliedMySQLClusterConfigVersion: strconv.FormatInt(int64(cs.MySQLClusterConfigVersion), 10),
},
},
Spec: podSpec,
},
// The services must exist before the StatefulSet,
// and is responsible for the network identity of the set.
ServiceName: nc.GetServiceName(bss.nodeType),
},
}
}