@@ -60,7 +60,7 @@ func handleMount(clientset *kubernetes.Clientset, namespace, pvcName, localMount
60
60
return err
61
61
}
62
62
63
- podName , port , err := setupPod (clientset , namespace , pvcName , sshKey , "standalone" , 2137 )
63
+ podName , port , err := setupPod (clientset , namespace , pvcName , sshKey , "standalone" , 2137 , "" )
64
64
if err != nil {
65
65
return err
66
66
}
@@ -89,7 +89,7 @@ func handleRWOConflict(clientset *kubernetes.Clientset, namespace, pvcName, loca
89
89
return err
90
90
}
91
91
92
- podName , port , err := setupPod (clientset , namespace , pvcName , publicKey , "proxy" , 6666 )
92
+ podName , port , err := setupPod (clientset , namespace , pvcName , publicKey , "proxy" , 6666 , podUsingPVC )
93
93
if err != nil {
94
94
return err
95
95
}
@@ -263,9 +263,9 @@ func checkPVCUsage(clientset *kubernetes.Clientset, namespace, pvcName string) (
263
263
return pvc , nil
264
264
}
265
265
266
- func setupPod (clientset * kubernetes.Clientset , namespace , pvcName , sshKey , role string , sshPort int ) (string , int , error ) {
266
+ func setupPod (clientset * kubernetes.Clientset , namespace , pvcName , sshKey , role string , sshPort int , originalPodName string ) (string , int , error ) {
267
267
podName , port := generatePodNameAndPort (pvcName , role )
268
- pod := createPodSpec (podName , port , pvcName , sshKey , role , sshPort )
268
+ pod := createPodSpec (podName , port , pvcName , sshKey , role , sshPort , originalPodName )
269
269
if _ , err := clientset .CoreV1 ().Pods (namespace ).Create (context .TODO (), pod , metav1.CreateOptions {}); err != nil {
270
270
return "" , 0 , fmt .Errorf ("failed to create pod: %v" , err )
271
271
}
@@ -322,7 +322,7 @@ func generatePodNameAndPort(pvcName, role string) (string, int) {
322
322
return podName , port
323
323
}
324
324
325
- func createPodSpec (podName string , port int , pvcName , sshKey , role string , sshPort int ) * corev1.Pod {
325
+ func createPodSpec (podName string , port int , pvcName , sshKey , role string , sshPort int , originalPodName string ) * corev1.Pod {
326
326
envVars := []corev1.EnvVar {
327
327
{
328
328
Name : "SSH_KEY" ,
@@ -366,14 +366,21 @@ func createPodSpec(podName string, port int, pvcName, sshKey, role string, sshPo
366
366
},
367
367
}
368
368
369
+ labels := map [string ]string {
370
+ "app" : "volume-exposer" ,
371
+ "pvcName" : pvcName ,
372
+ "portNumber" : fmt .Sprintf ("%d" , port ),
373
+ }
374
+
375
+ // Add the original pod name label if provided
376
+ if originalPodName != "" {
377
+ labels ["originalPodName" ] = originalPodName
378
+ }
379
+
369
380
podSpec := & corev1.Pod {
370
381
ObjectMeta : metav1.ObjectMeta {
371
- Name : podName ,
372
- Labels : map [string ]string {
373
- "app" : "volume-exposer" ,
374
- "pvcName" : pvcName ,
375
- "portNumber" : fmt .Sprintf ("%d" , port ),
376
- },
382
+ Name : podName ,
383
+ Labels : labels ,
377
384
},
378
385
Spec : corev1.PodSpec {
379
386
Containers : []corev1.Container {container },
0 commit comments