Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
7a2b227
feat: rebase kubernetes overwrites
atchernych Jun 5, 2025
0dad025
Changes per Julien
atchernych Jun 6, 2025
f4eb61e
remove claim related stuff for now
atchernych Jun 6, 2025
82838a5
cleanup
atchernych Jun 6, 2025
a36b593
Dead-end changes
atchernych Jun 10, 2025
ecd64c5
Refactored the python part after rebase
atchernych Jun 11, 2025
ea1271d
Move overrides into the extraPodSpecMainContainer
atchernych Jun 11, 2025
16fe788
Cleanup after moving the overrides.
atchernych Jun 11, 2025
8d4d91f
rerun make manifests
atchernych Jun 11, 2025
2ad84af
correct the manifest generation
atchernych Jun 11, 2025
457db96
fixed a bug with args
atchernych Jun 12, 2025
a806050
bring back licenses
atchernych Jun 12, 2025
6542ad3
Copy crds to deploy/cloud/helm/crds/template
atchernych Jun 12, 2025
4266372
Brign back helm.sh/resource-policy: keep
atchernych Jun 12, 2025
4d8520c
add comments
atchernych Jun 12, 2025
f576948
add DynamoGraphDeploymentController changes
atchernych Jun 13, 2025
3194e3b
Fix the parsing of the ExtraPodSpec
atchernych Jun 13, 2025
ec45e87
fix up the overrides
atchernych Jun 13, 2025
40b13cd
Move the ExtraPodSpec Overrides
atchernych Jun 13, 2025
0a227b1
proper naming for sharedSpec
atchernych Jun 13, 2025
1905078
move the override
atchernych Jun 13, 2025
f0f2861
revert default args
atchernych Jun 13, 2025
731269a
change the parsing library for yaml case
atchernych Jun 13, 2025
8e0e249
replace parsing lib and remove comments
atchernych Jun 13, 2025
a664e2e
Cleanup.
atchernych Jun 13, 2025
6fb1cbe
remove logger
atchernych Jun 14, 2025
81a841a
Use BaseModel for KubernetesOverrides.
atchernych Jun 14, 2025
d25c54e
Add a go test for overrides.
atchernych Jun 14, 2025
45b0b5f
refactor GenerateDynamoComponentsDeployments
atchernych Jun 14, 2025
89c6a14
fix the help func
atchernych Jun 14, 2025
dbb901a
Streamline the ExtraPodEverrides
atchernych Jun 14, 2025
bbe4d0a
validations on KubernetesOverrides
atchernych Jun 14, 2025
438916b
Simplify GenerateDynamoComponentsDeployments
atchernych Jun 14, 2025
b1e6c35
Merge branch 'main' into dep-157-extend-decor
atchernych Jun 14, 2025
7b0e22c
Update run.sh
atchernych Jun 16, 2025
0688b97
Merge branch 'main' into dep-157-extend-decor
atchernych Jun 16, 2025
4c30222
Merge branch 'main' into dep-157-extend-decor
atchernych Jun 16, 2025
6fa26a2
Merge branch 'main' into dep-157-extend-decor
atchernych Jun 17, 2025
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
Next Next commit
feat: rebase kubernetes overwrites
Overview:
Add the ability for a user to overwrite the entrypoint
and PVCs in the sdk.
DEP-157

Details:
It is the first iteration of the feature.
A more generic approach will be developed.
  • Loading branch information
atchernych committed Jun 12, 2025
commit 7a2b22792ae85804abb9f7748f2463e880f71156
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ type DynamoComponentDeploymentSharedSpec struct {
LivenessProbe *corev1.Probe `json:"livenessProbe,omitempty"`
ReadinessProbe *corev1.Probe `json:"readinessProbe,omitempty"`
Replicas *int32 `json:"replicas,omitempty"`

// Kubernetes overwrites for the deployment
KubernetesOverwrites *KubernetesOverwrites `json:"kubernetesOverwrites,omitempty"`
}

type RunMode struct {
Expand Down Expand Up @@ -108,6 +111,11 @@ type IngressSpec struct {
IngressControllerClassName *string `json:"ingressControllerClassName,omitempty"`
}

type KubernetesOverwrites struct {
Entrypoint *string `json:"entrypoint,omitempty"`
PVCSettings map[string]*PVC `json:"pvcSettings,omitempty"`
}

// DynamoComponentDeploymentStatus defines the observed state of DynamoComponentDeployment
type DynamoComponentDeploymentStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1337,6 +1337,69 @@ func getDynamoComponentRepositoryNameAndDynamoComponentVersion(dynamoComponent *
return
}

func buildPVCVolumesAndMounts(
component *v1alpha1.DynamoComponentDeployment,
) (volumes []corev1.Volume, mounts []corev1.VolumeMount) {
used := map[string]bool{}

// addPVC adds a volume and corresponding volume mount to the pod spec based on the provided PVC configuration.
addPVC := func(volumeName string, pvc *v1alpha1.PVC) {
if pvc == nil || pvc.Name == nil {
return
}
claimName := *pvc.Name
mountPath := "/mnt/default"
if pvc.MountPoint != nil && *pvc.MountPoint != "" {
mountPath = *pvc.MountPoint
}
volume := corev1.Volume{
Name: volumeName,
VolumeSource: corev1.VolumeSource{
PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{
ClaimName: claimName,
},
},
}
mount := corev1.VolumeMount{
Name: volumeName,
MountPath: mountPath,
}
if used[volumeName] {
for i, v := range volumes {
if v.Name == volumeName {
volumes[i] = volume
break
}
}
for i, m := range mounts {
if m.Name == volumeName {
mounts[i] = mount
break
}
}
} else {
volumes = append(volumes, volume)
mounts = append(mounts, mount)
used[volumeName] = true
}
}

// Handle default PVC
if component.Spec.PVC != nil {
volumeName := getPvcName(component, component.Spec.PVC.Name)
addPVC(volumeName, component.Spec.PVC)
}

// Handle overwrites
if ow := component.Spec.KubernetesOverwrites; ow != nil && ow.PVCSettings != nil {
for volumeName, pvc := range ow.PVCSettings {
addPVC(volumeName, pvc)
}
}

return volumes, mounts
}

//nolint:gocyclo,nakedret
func (r *DynamoComponentDeploymentReconciler) generatePodTemplateSpec(ctx context.Context, opt generateResourceOption) (podTemplateSpec *corev1.PodTemplateSpec, err error) {
podLabels := r.getKubeLabels(opt.dynamoComponentDeployment, opt.dynamoComponent)
Expand Down Expand Up @@ -1499,33 +1562,10 @@ func (r *DynamoComponentDeploymentReconciler) generatePodTemplateSpec(ctx contex
sharedMemorySizeLimit.SetMilli(memoryLimit.MilliValue() / 2)
}

volumes = append(volumes, corev1.Volume{
Name: KubeValueNameSharedMemory,
VolumeSource: corev1.VolumeSource{
EmptyDir: &corev1.EmptyDirVolumeSource{
Medium: corev1.StorageMediumMemory,
SizeLimit: &sharedMemorySizeLimit,
},
},
})
volumeMounts = append(volumeMounts, corev1.VolumeMount{
Name: KubeValueNameSharedMemory,
MountPath: "/dev/shm",
})
if opt.dynamoComponentDeployment.Spec.PVC != nil {
volumes = append(volumes, corev1.Volume{
Name: getPvcName(opt.dynamoComponentDeployment, opt.dynamoComponentDeployment.Spec.PVC.Name),
VolumeSource: corev1.VolumeSource{
PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{
ClaimName: getPvcName(opt.dynamoComponentDeployment, opt.dynamoComponentDeployment.Spec.PVC.Name),
},
},
})
volumeMounts = append(volumeMounts, corev1.VolumeMount{
Name: getPvcName(opt.dynamoComponentDeployment, opt.dynamoComponentDeployment.Spec.PVC.Name),
MountPath: *opt.dynamoComponentDeployment.Spec.PVC.MountPoint,
})
}
// Handle default PVC settings. Apply overwrites if the name matches, add otherwise.
pvcVolumes, pvcMounts := buildPVCVolumesAndMounts(opt.dynamoComponentDeployment)
volumes = append(volumes, pvcVolumes...)
volumeMounts = append(volumeMounts, pvcMounts...)

imageName := opt.dynamoComponent.GetImage()
if imageName == "" {
Expand Down Expand Up @@ -1653,6 +1693,21 @@ func (r *DynamoComponentDeploymentReconciler) generatePodTemplateSpec(ctx contex
container.SecurityContext.RunAsUser = &[]int64{0}[0]
}

if opt.dynamoComponentDeployment.Spec.KubernetesOverwrites != nil {
overwrites := opt.dynamoComponentDeployment.Spec.KubernetesOverwrites

// Handle Entrypoint overwrite. Entrypoint needs to be renamed to Command.
if overwrites.Entrypoint != nil {
parts := strings.Fields(*overwrites.Entrypoint)
if len(parts) > 0 {
container.Command = []string{parts[0]}
if len(parts) > 1 {
container.Args = parts[1:]
}
}
}
}

containers = append(containers, container)

debuggerImage := "python:3.12-slim"
Expand Down
12 changes: 12 additions & 0 deletions deploy/sdk/src/dynamo/sdk/cli/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class ServiceInfo(BaseModel):
module_path: str
class_name: str
config: ServiceConfig
kubernetes_overwrites: t.Optional[t.Dict[str, t.Any]] = None

@classmethod
def from_service(cls, service: ServiceInterface[T]) -> ServiceInfo:
Expand Down Expand Up @@ -145,12 +146,16 @@ def from_service(cls, service: ServiceInterface[T]) -> ServiceInfo:
http_exposed=len(api_endpoints) > 0,
api_endpoints=api_endpoints,
)
kubernetes_overwrites = None
if hasattr(service, "kubernetes_overwrites") and service.kubernetes_overwrites:
kubernetes_overwrites = service.kubernetes_overwrites.model_dump()

return cls(
name=name,
module_path=service.__module__,
class_name=service_class.__name__,
config=config,
kubernetes_overwrites=kubernetes_overwrites,
)


Expand Down Expand Up @@ -225,6 +230,13 @@ def to_dict(self) -> t.Dict[str, t.Any]:
service_dict["config"]["api_endpoints"] = service["config"][
"api_endpoints"
]

# Add kubernetes overwrites if available
if service.get("kubernetes_overwrites"):
service_dict["config"]["kubernetes_overwrites"] = service[
"kubernetes_overwrites"
]

services_dict.append(service_dict)
result["services"] = services_dict
return result
Expand Down