Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.12] Issue 6734: spread backup pod evenly #6935

Merged
merged 1 commit into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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