in pkg/common/utils/resource/pod.go [95:190]
func NewPodTemplateSpec(dcr *v1.DorisCluster, config map[string]interface{}, componentType v1.ComponentType) corev1.PodTemplateSpec {
spec := getBaseSpecFromCluster(dcr, componentType)
var volumes []corev1.Volume
var si *v1.SystemInitialization
var dcrAffinity *corev1.Affinity
var defaultInitContainers []corev1.Container
var SecurityContext *corev1.PodSecurityContext
var skipInit bool
sharedVolumes, _, sharedPaths := BuildSharedVolumesAndVolumeMounts(dcr.Spec.SharedPersistentVolumeClaims, componentType)
switch componentType {
case v1.Component_FE:
volumes = newVolumesFromBaseSpec(dcr.Spec.FeSpec.BaseSpec, sharedPaths, config, componentType)
si = dcr.Spec.FeSpec.BaseSpec.SystemInitialization
dcrAffinity = dcr.Spec.FeSpec.BaseSpec.Affinity
SecurityContext = dcr.Spec.FeSpec.BaseSpec.SecurityContext
case v1.Component_BE:
volumes = newVolumesFromBaseSpec(dcr.Spec.BeSpec.BaseSpec, sharedPaths, config, componentType)
si = dcr.Spec.BeSpec.BaseSpec.SystemInitialization
dcrAffinity = dcr.Spec.BeSpec.BaseSpec.Affinity
SecurityContext = dcr.Spec.BeSpec.BaseSpec.SecurityContext
skipInit = dcr.Spec.BeSpec.SkipDefaultSystemInit
case v1.Component_CN:
si = dcr.Spec.CnSpec.BaseSpec.SystemInitialization
dcrAffinity = dcr.Spec.CnSpec.BaseSpec.Affinity
SecurityContext = dcr.Spec.CnSpec.BaseSpec.SecurityContext
skipInit = dcr.Spec.CnSpec.SkipDefaultSystemInit
case v1.Component_Broker:
si = dcr.Spec.BrokerSpec.BaseSpec.SystemInitialization
dcrAffinity = dcr.Spec.BrokerSpec.BaseSpec.Affinity
SecurityContext = dcr.Spec.BrokerSpec.BaseSpec.SecurityContext
default:
klog.Errorf("NewPodTemplateSpec dorisClusterName %s, namespace %s componentType %s not supported.", dcr.Name, dcr.Namespace, componentType)
}
if len(volumes) == 0 {
volumes, _ = getDefaultVolumesVolumeMounts(componentType)
}
//map pod labels and annotations into pod
volumes, _ = appendPodInfoVolumesVolumeMounts(volumes, nil)
if dcr.Spec.AuthSecret != "" {
volumes = append(volumes, corev1.Volume{
Name: auth_volume_name,
VolumeSource: corev1.VolumeSource{
Secret: &corev1.SecretVolumeSource{
SecretName: dcr.Spec.AuthSecret,
},
},
})
}
if len(GetMountConfigMapInfo(spec.ConfigMapInfo)) != 0 {
configVolumes, _ := getMultiConfigVolumeAndVolumeMount(&spec.ConfigMapInfo, componentType)
volumes = append(volumes, configVolumes...)
}
if len(spec.Secrets) != 0 {
secretVolumes, _ := getMultiSecretVolumeAndVolumeMount(spec, componentType)
volumes = append(volumes, secretVolumes...)
}
if dcr.Spec.KerberosInfo != nil {
kerberosVolumes, _ := getKerberosVolumeAndVolumeMount(dcr.Spec.KerberosInfo)
volumes = append(volumes, kerberosVolumes...)
}
if len(sharedVolumes) != 0 {
volumes = append(volumes, sharedVolumes...)
}
pts := corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Name: GeneratePodTemplateName(dcr, componentType),
Annotations: spec.Annotations,
Labels: v1.GetPodLabels(dcr, componentType),
},
Spec: corev1.PodSpec{
ImagePullSecrets: spec.ImagePullSecrets,
NodeSelector: spec.NodeSelector,
Volumes: volumes,
ServiceAccountName: spec.ServiceAccount,
Affinity: spec.Affinity.DeepCopy(),
Tolerations: spec.Tolerations,
HostAliases: spec.HostAliases,
InitContainers: defaultInitContainers,
SecurityContext: SecurityContext,
},
}
constructInitContainers(skipInit, componentType, &pts.Spec, si)
pts.Spec.Affinity = constructAffinity(dcrAffinity, componentType)
return pts
}