From fe0a45eac69328d3440869b188940884eea8543b Mon Sep 17 00:00:00 2001 From: Lyndon-Li Date: Tue, 17 Dec 2024 13:30:45 +0800 Subject: [PATCH] restict velero server in linux nodes Signed-off-by: Lyndon-Li --- pkg/install/deployment.go | 6 ++++++ pkg/install/deployment_test.go | 3 +++ 2 files changed, 9 insertions(+) diff --git a/pkg/install/deployment.go b/pkg/install/deployment.go index 4ee8e52383..41fe474d0c 100644 --- a/pkg/install/deployment.go +++ b/pkg/install/deployment.go @@ -331,6 +331,12 @@ func Deployment(namespace string, opts ...podTemplateOption) *appsv1.Deployment Spec: corev1.PodSpec{ RestartPolicy: corev1.RestartPolicyAlways, ServiceAccountName: c.serviceAccountName, + NodeSelector: map[string]string{ + "kubernetes.io/os": "linux", + }, + OS: &corev1.PodOS{ + Name: "linux", + }, Containers: []corev1.Container{ { Name: "velero", diff --git a/pkg/install/deployment_test.go b/pkg/install/deployment_test.go index 48e02fb5e1..4f91563d18 100644 --- a/pkg/install/deployment_test.go +++ b/pkg/install/deployment_test.go @@ -99,4 +99,7 @@ func TestDeployment(t *testing.T) { deploy = Deployment("velero", WithRepoMaintenanceJobConfigMap("test-repo-maintenance-config")) assert.Len(t, deploy.Spec.Template.Spec.Containers[0].Args, 2) assert.Equal(t, "--repo-maintenance-job-configmap=test-repo-maintenance-config", deploy.Spec.Template.Spec.Containers[0].Args[1]) + + assert.Equal(t, "linux", deploy.Spec.Template.Spec.NodeSelector["kubernetes.io/os"]) + assert.Equal(t, "linux", string(deploy.Spec.Template.Spec.OS.Name)) }