Skip to content

Commit

Permalink
Merge pull request #6935 from Lyndon-Li/release-1.12
Browse files Browse the repository at this point in the history
[1.12] Issue 6734: spread backup pod evenly
  • Loading branch information
Lyndon-Li authored Oct 10, 2023
2 parents 17b495f + 8775921 commit 15dd67e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelogs/unreleased/6935-Lyndon-Li
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Partially fix #6734, guide Kubernetes' scheduler to spread backup pods evenly across nodes as much as possible, so that data mover backup could achieve better parallelism
18 changes: 18 additions & 0 deletions pkg/exposer/csi_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,12 @@ func (e *csiSnapshotExposer) createBackupPod(ctx context.Context, ownerObject co
var gracePeriod int64 = 0
volumeMounts, volumeDevices := kube.MakePodPVCAttachment(volumeName, backupPVC.Spec.VolumeMode)

if label == nil {
label = make(map[string]string)
}

label[podGroupLabel] = podGroupSnapshot

pod := &corev1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: podName,
Expand All @@ -377,6 +383,18 @@ func (e *csiSnapshotExposer) createBackupPod(ctx context.Context, ownerObject co
Labels: label,
},
Spec: corev1.PodSpec{
TopologySpreadConstraints: []corev1.TopologySpreadConstraint{
{
MaxSkew: 1,
TopologyKey: "kubernetes.io/hostname",
WhenUnsatisfiable: corev1.ScheduleAnyway,
LabelSelector: &metav1.LabelSelector{
MatchLabels: map[string]string{
podGroupLabel: podGroupSnapshot,
},
},
},
},
Containers: []corev1.Container{
{
Name: containerName,
Expand Down
2 changes: 2 additions & 0 deletions pkg/exposer/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import (
const (
AccessModeFileSystem = "by-file-system"
AccessModeBlock = "by-block-device"
podGroupLabel = "velero.io/exposer-pod-group"
podGroupSnapshot = "snapshot-exposer"
)

// ExposeResult defines the result of expose.
Expand Down

0 comments on commit 15dd67e

Please sign in to comment.