in pkg/common/utils/resource/statefulset.go [35:91]
func NewStatefulSet(dcr *v1.DorisCluster, config map[string]interface{}, componentType v1.ComponentType) appv1.StatefulSet {
bSpec := getBaseSpecFromCluster(dcr, componentType)
orf := metav1.OwnerReference{
APIVersion: dcr.APIVersion,
Kind: dcr.Kind,
Name: dcr.Name,
UID: dcr.UID,
}
selector := metav1.LabelSelector{
MatchLabels: v1.GenerateStatefulSetSelector(dcr, componentType),
}
var volumeClaimTemplates []corev1.PersistentVolumeClaim
_, _, sharedPaths := BuildSharedVolumesAndVolumeMounts(dcr.Spec.SharedPersistentVolumeClaims, componentType)
dorisPersistentVolumes, _ := GenerateEveryoneMountPathDorisPersistentVolume(bSpec, sharedPaths, config, componentType)
for _, dorisPersistentVolume := range dorisPersistentVolumes {
pvc := corev1.PersistentVolumeClaim{
ObjectMeta: metav1.ObjectMeta{
Name: dorisPersistentVolume.Name,
Annotations: buildPVCAnnotations(dorisPersistentVolume),
},
Spec: dorisPersistentVolume.PersistentVolumeClaimSpec,
}
volumeClaimTemplates = append(volumeClaimTemplates, pvc)
}
st := appv1.StatefulSet{
ObjectMeta: metav1.ObjectMeta{
Namespace: dcr.Namespace,
Name: v1.GenerateComponentStatefulSetName(dcr, componentType),
Labels: v1.GenerateStatefulSetLabels(dcr, componentType),
OwnerReferences: []metav1.OwnerReference{orf},
},
Spec: appv1.StatefulSetSpec{
Replicas: bSpec.Replicas,
Selector: &selector,
Template: NewPodTemplateSpec(dcr, config, componentType),
VolumeClaimTemplates: volumeClaimTemplates,
ServiceName: v1.GenerateInternalCommunicateServiceName(dcr, componentType),
RevisionHistoryLimit: metadata.GetInt32Pointer(5),
UpdateStrategy: appv1.StatefulSetUpdateStrategy{
Type: appv1.RollingUpdateStatefulSetStrategyType,
RollingUpdate: &appv1.RollingUpdateStatefulSetStrategy{
Partition: metadata.GetInt32Pointer(defaultRollingUpdateStartPod),
},
},
PodManagementPolicy: appv1.ParallelPodManagement,
},
}
return st
}