|
| 1 | +/* |
| 2 | +Copyright 2025 NVIDIA CORPORATION |
| 3 | +SPDX-License-Identifier: Apache-2.0 |
| 4 | +*/ |
| 5 | +package rd |
| 6 | + |
| 7 | +import ( |
| 8 | + appsv1 "k8s.io/api/apps/v1" |
| 9 | + v1 "k8s.io/api/core/v1" |
| 10 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 11 | + "k8s.io/utils/ptr" |
| 12 | + |
| 13 | + "github.com/NVIDIA/KAI-scheduler/pkg/common/constants" |
| 14 | + "github.com/NVIDIA/KAI-scheduler/test/e2e/modules/constant" |
| 15 | + "github.com/NVIDIA/KAI-scheduler/test/e2e/modules/utils" |
| 16 | +) |
| 17 | + |
| 18 | +const DeploymentAppLabel = "deployment-app-name" |
| 19 | + |
| 20 | +func CreateDeploymentObject(namespace, queueName string) *appsv1.Deployment { |
| 21 | + matchLabelValue := utils.GenerateRandomK8sName(10) |
| 22 | + |
| 23 | + return &appsv1.Deployment{ |
| 24 | + ObjectMeta: metav1.ObjectMeta{ |
| 25 | + Name: utils.GenerateRandomK8sName(10), |
| 26 | + Namespace: namespace, |
| 27 | + Labels: map[string]string{ |
| 28 | + constants.AppLabelName: "engine-e2e", |
| 29 | + DeploymentAppLabel: matchLabelValue, |
| 30 | + }, |
| 31 | + }, |
| 32 | + Spec: appsv1.DeploymentSpec{ |
| 33 | + Replicas: ptr.To(int32(1)), |
| 34 | + Selector: &metav1.LabelSelector{ |
| 35 | + MatchLabels: map[string]string{ |
| 36 | + constants.AppLabelName: "engine-e2e", |
| 37 | + DeploymentAppLabel: matchLabelValue, |
| 38 | + }, |
| 39 | + }, |
| 40 | + Template: v1.PodTemplateSpec{ |
| 41 | + ObjectMeta: metav1.ObjectMeta{ |
| 42 | + Labels: map[string]string{ |
| 43 | + constants.AppLabelName: "engine-e2e", |
| 44 | + DeploymentAppLabel: matchLabelValue, |
| 45 | + "runai/queue": queueName, |
| 46 | + }, |
| 47 | + }, |
| 48 | + Spec: v1.PodSpec{ |
| 49 | + Containers: []v1.Container{ |
| 50 | + { |
| 51 | + Image: "gcr.io/run-ai-lab/ubuntu", |
| 52 | + Name: "ubuntu-container", |
| 53 | + Args: []string{ |
| 54 | + "sleep", |
| 55 | + "infinity", |
| 56 | + }, |
| 57 | + SecurityContext: DefaultSecurityContext(), |
| 58 | + }, |
| 59 | + }, |
| 60 | + TerminationGracePeriodSeconds: ptr.To(int64(0)), |
| 61 | + SchedulerName: constant.RunaiSchedulerName, |
| 62 | + Tolerations: []v1.Toleration{ |
| 63 | + { |
| 64 | + Key: "nvidia.com/gpu", |
| 65 | + Operator: v1.TolerationOpExists, |
| 66 | + Effect: v1.TaintEffectNoSchedule, |
| 67 | + }, |
| 68 | + }, |
| 69 | + }, |
| 70 | + }, |
| 71 | + }, |
| 72 | + } |
| 73 | +} |
0 commit comments