consts.go 9.42 KB
Newer Older
1
2
package consts

3
4
5
6
7
import (
	"time"

	"k8s.io/apimachinery/pkg/runtime/schema"
)
8

9
10
11
12
const (
	DefaultUserId = "default"
	DefaultOrgId  = "default"

13
	DynamoServicePort       = 8000
14
15
	DynamoServicePortName   = "http"
	DynamoContainerPortName = "http"
16

17
18
19
	DynamoPlannerMetricsPort = 9085
	DynamoMetricsPortName    = "metrics"

20
21
	DynamoSystemPort     = 9090
	DynamoSystemPortName = "system"
22

23
24
25
26
	// EPP (Endpoint Picker Plugin) ports
	EPPGRPCPort     = 9002
	EPPGRPCPortName = "grpc"

27
28
29
	DynamoNixlPort     = 19090
	DynamoNixlPortName = "nixl"

30
31
	MpiRunSshPort = 2222

32
33
34
35
36
	// Default security context values
	// These provide secure defaults for running containers as non-root
	// Users can override these via extraPodSpec.securityContext in their DynamoGraphDeployment
	DefaultSecurityContextFSGroup = 1000

37
	EnvDynamoServicePort = "DYNAMO_PORT"
38

39
40
	KubeLabelDynamoSelector = "nvidia.com/selector"

41
42
	KubeAnnotationEnableGrove = "nvidia.com/enable-grove"

43
	KubeAnnotationDisableImagePullSecretDiscovery = "nvidia.com/disable-image-pull-secret-discovery"
44
	KubeAnnotationDynamoDiscoveryBackend          = "nvidia.com/dynamo-discovery-backend"
45

46
47
48
49
50
51
52
53
54
55
56
	KubeLabelDynamoGraphDeploymentName = "nvidia.com/dynamo-graph-deployment-name"
	KubeLabelDynamoComponent           = "nvidia.com/dynamo-component"
	KubeLabelDynamoNamespace           = "nvidia.com/dynamo-namespace"
	KubeLabelDynamoComponentType       = "nvidia.com/dynamo-component-type"
	KubeLabelDynamoSubComponentType    = "nvidia.com/dynamo-sub-component-type"
	KubeLabelDynamoBaseModel           = "nvidia.com/dynamo-base-model"
	KubeLabelDynamoBaseModelHash       = "nvidia.com/dynamo-base-model-hash"
	KubeAnnotationDynamoBaseModel      = "nvidia.com/dynamo-base-model"
	KubeLabelDynamoDiscoveryBackend    = "nvidia.com/dynamo-discovery-backend"
	KubeLabelDynamoDiscoveryEnabled    = "nvidia.com/dynamo-discovery-enabled"
	KubeLabelDynamoWorkerHash          = "nvidia.com/dynamo-worker-hash"
57

58
59
60
	KubeLabelValueFalse = "false"
	KubeLabelValueTrue  = "true"

61
	KubeLabelDynamoComponentPod = "nvidia.com/dynamo-component-pod"
62
63
64

	KubeResourceGPUNvidia = "nvidia.com/gpu"

65
66
67
68
69
70
	DynamoDeploymentConfigEnvVar      = "DYN_DEPLOYMENT_CONFIG"
	DynamoNamespaceEnvVar             = "DYN_NAMESPACE"
	DynamoNamespacePrefixEnvVar       = "DYN_NAMESPACE_PREFIX"
	DynamoNamespaceWorkerSuffixEnvVar = "DYN_NAMESPACE_WORKER_SUFFIX"
	DynamoComponentEnvVar             = "DYN_COMPONENT"
	DynamoDiscoveryBackendEnvVar      = "DYN_DISCOVERY_BACKEND"
71

72
73
	GlobalDynamoNamespace = "dynamo"

74
	ComponentTypePlanner      = "planner"
75
	ComponentTypeFrontend     = "frontend"
76
	ComponentTypeWorker       = "worker"
77
78
	ComponentTypePrefill      = "prefill"
	ComponentTypeDecode       = "decode"
79
	ComponentTypeEPP          = "epp"
80
	ComponentTypeDefault      = "default"
81
	PlannerServiceAccountName = "planner-serviceaccount"
82
83
	EPPServiceAccountName     = "epp-serviceaccount"
	EPPClusterRoleName        = "epp-cluster-role"
84
85

	DefaultIngressSuffix = "local"
86
87

	DefaultGroveTerminationDelay = 15 * time.Minute
88

89
90
91
92
	// Operator origin version: stamped on DGD at creation time by mutating webhook.
	// Records which operator version created the resource, enabling version-gated behavior changes.
	KubeAnnotationDynamoOperatorOriginVersion = "nvidia.com/dynamo-operator-origin-version"

93
94
95
96
97
98
99
100
101
102
103
	// vLLM distributed executor backend override annotation.
	// Users can set this on a DGD to explicitly choose "mp" or "ray" for multi-node vLLM deployments.
	// When present, takes priority over the version-based default.
	KubeAnnotationVLLMDistributedExecutorBackend = "nvidia.com/vllm-distributed-executor-backend"

	// VLLMMpMasterPort is the default port for vLLM multiprocessing coordination between nodes.
	VLLMMpMasterPort = "29500"

	// VLLMNixlSideChannelHostEnvVar is the env var that tells vLLM which host IP to use for the NIXL side channel.
	VLLMNixlSideChannelHostEnvVar = "VLLM_NIXL_SIDE_CHANNEL_HOST"

104
	// Metrics related constants
105
106
107
108
109
	KubeAnnotationEnableMetrics  = "nvidia.com/enable-metrics"  // User-provided annotation to control metrics
	KubeLabelMetricsEnabled      = "nvidia.com/metrics-enabled" // Controller-managed label for pod selection
	KubeValueNameSharedMemory    = "shared-memory"
	DefaultSharedMemoryMountPath = "/dev/shm"
	DefaultSharedMemorySize      = "8Gi"
110

111
112
113
	// Compilation cache default mount points
	DefaultVLLMCacheMountPoint = "/root/.cache/vllm"

114
115
116
117
118
119
	// Kai-scheduler related constants
	KubeAnnotationKaiSchedulerQueue = "nvidia.com/kai-scheduler-queue" // User-provided annotation to specify queue name
	KubeLabelKaiSchedulerQueue      = "kai.scheduler/queue"            // Label injected into pods for kai-scheduler
	KaiSchedulerName                = "kai-scheduler"                  // Scheduler name for kai-scheduler
	DefaultKaiSchedulerQueue        = "dynamo"                         // Default queue name when none specified

120
121
122
	// Grove multinode role suffixes
	GroveRoleSuffixLeader = "ldr"
	GroveRoleSuffixWorker = "wkr"
123
124

	MainContainerName = "main"
125
126

	RestartAnnotation = "nvidia.com/restartAt"
127
128
129
130
131
132
133
134
135
136
137
138
139

	// Resource type constants - match Kubernetes Kind names
	// Used consistently across controllers, webhooks, and metrics
	ResourceTypeDynamoGraphDeployment               = "DynamoGraphDeployment"
	ResourceTypeDynamoComponentDeployment           = "DynamoComponentDeployment"
	ResourceTypeDynamoModel                         = "DynamoModel"
	ResourceTypeDynamoGraphDeploymentRequest        = "DynamoGraphDeploymentRequest"
	ResourceTypeDynamoGraphDeploymentScalingAdapter = "DynamoGraphDeploymentScalingAdapter"

	// Resource state constants - used in status reporting and metrics
	ResourceStateReady    = "ready"
	ResourceStateNotReady = "not_ready"
	ResourceStateUnknown  = "unknown"
140
141
142
143
144
145

	// Checkpoint/restore constants
	// CROSS-REFERENCE: Some constants below are duplicated in the chrek package at
	// deploy/chrek/pkg/config/constants.go. If you change a value here, update there too.

	// Kubernetes labels
146
147
148
	KubeLabelIsCheckpointSource = "nvidia.com/chrek-is-checkpoint-source" // Pod label that triggers DaemonSet auto-checkpoint
	KubeLabelCheckpointHash     = "nvidia.com/chrek-checkpoint-hash"      // Checkpoint identity hash (= DynamoCheckpoint CR name)
	KubeLabelIsRestoreTarget    = "nvidia.com/chrek-is-restore-target"    // Pod label that triggers DaemonSet auto-restore
149
150
151
152
153
154
155
156
157

	// Environment variables injected into pods
	EnvCheckpointStorageType  = "DYN_CHECKPOINT_STORAGE_TYPE"   // Storage backend (pvc, s3, oci) — checkpoint job pods only
	EnvCheckpointLocation     = "DYN_CHECKPOINT_LOCATION"       // Full checkpoint URI — future S3/OCI; for PVC, use PATH+HASH instead
	EnvCheckpointPath         = "DYN_CHECKPOINT_PATH"           // Base checkpoint directory (e.g., /checkpoints) — PVC restored pods
	EnvCheckpointHash         = "DYN_CHECKPOINT_HASH"           // Identity hash — all checkpoint-related pods
	EnvReadyForCheckpointFile = "DYN_READY_FOR_CHECKPOINT_FILE" // Ready-for-checkpoint file path — checkpoint job pods
	EnvSkipWaitForCheckpoint  = "SKIP_WAIT_FOR_CHECKPOINT"      // Skip polling, check once — restored/DGD pods
	// Checkpoint pod-internal constants
158
	CheckpointVolumeName = "checkpoint-storage" // Pod-internal volume name for checkpoint PVC
159
160
161
162
163
164
165
166

	// SeccompProfilePath is the localhost seccomp profile that blocks io_uring syscalls.
	// Deployed to nodes by the chrek DaemonSet init container.
	SeccompProfilePath = "profiles/block-iouring.json"

	// Pod identity (Downward API) ---
	// After CRIU restore, env vars contain stale values from the checkpoint pod.
	// The Downward API files at /etc/podinfo always reflect the current pod.
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
	PodInfoVolumeName = "podinfo"
	PodInfoMountPath  = "/etc/podinfo"

	// Downward API field paths
	PodInfoFieldPodName      = "metadata.name"
	PodInfoFieldPodUID       = "metadata.uid"
	PodInfoFieldPodNamespace = "metadata.namespace"

	// Downward API file names for DGD annotations
	PodInfoFileDynNamespace        = "dyn_namespace"
	PodInfoFileDynComponent        = "dyn_component"
	PodInfoFileDynParentDGDName    = "dyn_parent_dgd_name"
	PodInfoFileDynParentDGDNS      = "dyn_parent_dgd_namespace"
	PodInfoFileDynDiscoveryBackend = "dyn_discovery_backend"

	// Annotation keys for DGD info (exposed via Downward API)
	AnnotationDynNamespace        = "nvidia.com/dyn-namespace"
	AnnotationDynComponent        = "nvidia.com/dyn-component"
	AnnotationDynParentDGDName    = "nvidia.com/dyn-parent-dgd-name"
	AnnotationDynParentDGDNS      = "nvidia.com/dyn-parent-dgd-namespace"
	AnnotationDynDiscoveryBackend = "nvidia.com/dyn-discovery-backend"
188
189
190
191
192
193
194
195

	// Rolling update annotations
	AnnotationCurrentWorkerHash = "nvidia.com/current-worker-hash"

	// LegacyWorkerHash is a sentinel value used during migration from pre-rolling-update
	// operator versions. Legacy worker DCDs (those without a worker hash label) are tagged
	// with this value so the existing rolling update machinery can manage the transition.
	LegacyWorkerHash = "legacy"
196
197
198
199
200
201
202
)

type MultinodeDeploymentType string

const (
	MultinodeDeploymentTypeGrove MultinodeDeploymentType = "grove"
	MultinodeDeploymentTypeLWS   MultinodeDeploymentType = "lws"
203
)
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225

// GroupVersionResources for external APIs
var (
	// Grove GroupVersionResources for scaling operations
	PodCliqueGVR = schema.GroupVersionResource{
		Group:    "grove.io",
		Version:  "v1alpha1",
		Resource: "podcliques",
	}
	PodCliqueScalingGroupGVR = schema.GroupVersionResource{
		Group:    "grove.io",
		Version:  "v1alpha1",
		Resource: "podcliquescalinggroups",
	}

	// KAI-Scheduler GroupVersionResource for queue validation
	QueueGVR = schema.GroupVersionResource{
		Group:    "scheduling.run.ai",
		Version:  "v2",
		Resource: "queues",
	}
)