Skip to content

Commit a71fbc7

Browse files
modify
Signed-off-by: Rui Zhang <[email protected]>
1 parent 3edc18f commit a71fbc7

File tree

6 files changed

+15
-83
lines changed

6 files changed

+15
-83
lines changed

operator/config/default/kustomization.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Adds namespace to all resources.
2-
namespace: production-stack-system
2+
namespace: default
33

44
# Value of this field is prepended to the
55
# names of all resources, e.g. a deployment named
@@ -18,6 +18,7 @@ resources:
1818
- ../crd
1919
- ../rbac
2020
- ../manager
21+
- ../storage
2122
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
2223
# crd/kustomization.yaml
2324
#- ../webhook

operator/config/manager/deployment.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: apps/v1
22
kind: Deployment
33
metadata:
4-
name: production-stack-controller-manager
4+
name: controller-manager
55
namespace: production-stack-system
66
labels:
77
app.kubernetes.io/name: production-stack
@@ -86,7 +86,7 @@ spec:
8686
requests:
8787
cpu: 10m
8888
memory: 64Mi
89-
volumeMounts:
89+
volumeMounts:
9090
- name: shared-pvc-storage
9191
mountPath: /data/shared-pvc-storage
9292
volumes:
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
resources:
2-
- namespace.yaml
3-
- deployment.yaml
4-
- pvc.yaml
51
apiVersion: kustomize.config.k8s.io/v1beta1
62
kind: Kustomization
73
images:
84
- name: controller
95
newName: controller
106
newTag: latest
7+
resources:
8+
- deployment.yaml
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
resources:
4+
- pvc.yaml

operator/config/manager/pvc.yaml renamed to operator/config/storage/pvc.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ apiVersion: v1
2020
kind: PersistentVolumeClaim
2121
metadata:
2222
name: shared-pvc-storage-claim
23-
namespace: production-stack-system
23+
namespace: default
2424
labels:
2525
app: production-stack
2626
component: shared-pvc-storage

operator/internal/controller/vllmruntime_controller.go

Lines changed: 4 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -107,40 +107,6 @@ func (r *VLLMRuntimeReconciler) Reconcile(ctx context.Context, req ctrl.Request)
107107
return ctrl.Result{Requeue: true}, nil
108108
}
109109

110-
// Check if the pv already exists, if not create a new one
111-
foundPV := &corev1.PersistentVolume{}
112-
err = r.Get(ctx, types.NamespacedName{Name: "shared-pvc-storage", Namespace: vllmRuntime.Namespace}, foundPV)
113-
if err != nil && errors.IsNotFound(err) {
114-
// Define a new pv
115-
pv := r.pvForVLLMRuntime(vllmRuntime)
116-
log.Info("Creating a new PV", "PV.Namespace", pv.Namespace, "PV.Name", pv.Name)
117-
err = r.Create(ctx, pv)
118-
if err != nil {
119-
log.Error(err, "Failed to create new PV", "PV.Namespace", pv.Namespace, "PV.Name", pv.Name)
120-
return ctrl.Result{}, err
121-
}
122-
} else if err != nil {
123-
log.Error(err, "Failed to get PV")
124-
return ctrl.Result{}, err
125-
}
126-
127-
// Check if the pvc already exists, if not create a new one
128-
foundPVC := &corev1.PersistentVolumeClaim{}
129-
err = r.Get(ctx, types.NamespacedName{Name: "shared-pvc-storage-claim", Namespace: vllmRuntime.Namespace}, foundPVC)
130-
if err != nil && errors.IsNotFound(err) {
131-
// Define a new pvc
132-
pvc := r.pvcForVLLMRuntime(vllmRuntime)
133-
log.Info("Creating a new PVC", "PVC.Namespace", pvc.Namespace, "PVC.Name", pvc.Name)
134-
err = r.Create(ctx, pvc)
135-
if err != nil {
136-
log.Error(err, "Failed to create new PVC", "PVC.Namespace", pvc.Namespace, "PVC.Name", pvc.Name)
137-
return ctrl.Result{}, err
138-
}
139-
} else if err != nil {
140-
log.Error(err, "Failed to get PVC")
141-
return ctrl.Result{}, err
142-
}
143-
144110
// Check if the deployment already exists, if not create a new one
145111
found := &appsv1.Deployment{}
146112
err = r.Get(ctx, types.NamespacedName{Name: vllmRuntime.Name, Namespace: vllmRuntime.Namespace}, found)
@@ -184,43 +150,6 @@ func (r *VLLMRuntimeReconciler) Reconcile(ctx context.Context, req ctrl.Request)
184150
return ctrl.Result{}, nil
185151
}
186152

187-
func (r *VLLMRuntimeReconciler) pvForVLLMRuntime(vllmRuntime *productionstackv1alpha1.VLLMRuntime) *corev1.PersistentVolume {
188-
return &corev1.PersistentVolume{
189-
ObjectMeta: metav1.ObjectMeta{
190-
Name: "shared-pvc-storage",
191-
Namespace: vllmRuntime.Namespace,
192-
Labels: map[string]string{"app": vllmRuntime.Name},
193-
},
194-
Spec: corev1.PersistentVolumeSpec{
195-
AccessModes: []corev1.PersistentVolumeAccessMode{corev1.ReadWriteMany},
196-
StorageClassName: "",
197-
Capacity: corev1.ResourceList{corev1.ResourceStorage: resource.MustParse("100Gi")},
198-
PersistentVolumeSource: corev1.PersistentVolumeSource{
199-
HostPath: &corev1.HostPathVolumeSource{
200-
Path: "/data/shared-pvc-storage",
201-
},
202-
},
203-
},
204-
}
205-
}
206-
207-
func (r *VLLMRuntimeReconciler) pvcForVLLMRuntime(vllmRuntime *productionstackv1alpha1.VLLMRuntime) *corev1.PersistentVolumeClaim {
208-
return &corev1.PersistentVolumeClaim{
209-
ObjectMeta: metav1.ObjectMeta{
210-
Name: "shared-pvc-storage-claim",
211-
Namespace: vllmRuntime.Namespace,
212-
Labels: map[string]string{"app": vllmRuntime.Name},
213-
},
214-
Spec: corev1.PersistentVolumeClaimSpec{
215-
AccessModes: []corev1.PersistentVolumeAccessMode{corev1.ReadWriteMany},
216-
StorageClassName: &[]string{""}[0],
217-
Resources: corev1.VolumeResourceRequirements{
218-
Requests: corev1.ResourceList{corev1.ResourceStorage: resource.MustParse("100Gi")},
219-
},
220-
},
221-
}
222-
}
223-
224153
// deploymentForVLLMRuntime returns a VLLMRuntime Deployment object
225154
func (r *VLLMRuntimeReconciler) deploymentForVLLMRuntime(vllmRuntime *productionstackv1alpha1.VLLMRuntime) *appsv1.Deployment {
226155
labels := map[string]string{"app": vllmRuntime.Name}
@@ -252,11 +181,11 @@ func (r *VLLMRuntimeReconciler) deploymentForVLLMRuntime(vllmRuntime *production
252181
Scheme: corev1.URISchemeHTTP,
253182
},
254183
},
255-
InitialDelaySeconds: 500,
256-
PeriodSeconds: 10,
184+
InitialDelaySeconds: 300,
185+
PeriodSeconds: 20,
257186
TimeoutSeconds: 3,
258187
SuccessThreshold: 1,
259-
FailureThreshold: 3,
188+
FailureThreshold: 10,
260189
}
261190

262191
// Build command line arguments
@@ -520,7 +449,7 @@ func (r *VLLMRuntimeReconciler) deploymentForVLLMRuntime(vllmRuntime *production
520449
Name: "shared-pvc-storage",
521450
VolumeSource: corev1.VolumeSource{
522451
PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{
523-
ClaimName: "shared-pvc-storage-claim",
452+
ClaimName: "production-stack-shared-pvc-storage-claim",
524453
},
525454
},
526455
},

0 commit comments

Comments
 (0)