2121Copies any Kubernetes manifest file into the PVC for later use by jobs.
2222Both the source manifest path and destination path in the PVC are required.
2323
24+ IMPORTANT: The PVC is mounted at /data in the access pod for security reasons.
25+ All destination paths must start with '/data/'.
26+
2427Usage:
2528 python3 inject_manifest.py --namespace <namespace> --src <local_manifest.yaml> --dest <absolute_path_in_pvc>
2629
2730Examples:
28- python3 inject_manifest.py --namespace <ns> --src ./my- disagg.yaml --dest /configs/disagg.yaml
29- python3 inject_manifest.py --namespace <ns> --src ./my-agg .yaml --dest /configs/agg .yaml
31+ python3 inject_manifest.py --namespace <ns> --src ./disagg.yaml --dest /data /configs/disagg.yaml
32+ python3 inject_manifest.py --namespace <ns> --src ./my-data .yaml --dest /data/custom/path/data .yaml
3033"""
3134
3235import argparse
3740 PVC_ACCESS_POD_NAME ,
3841 check_kubectl_access ,
3942 cleanup_access_pod ,
40- deploy_access_pod ,
43+ ensure_clean_access_pod ,
4144 run_command ,
4245)
4346
@@ -100,16 +103,39 @@ def main():
100103 parser .add_argument (
101104 "--dest" ,
102105 required = True ,
103- help = "Absolute target path in PVC (e.g., /profiling_results /agg.yaml)" ,
106+ help = "Absolute target path in PVC (must start with /data/, e.g., /data/configs /agg.yaml)" ,
104107 )
105108
106109 args = parser .parse_args ()
107110
108- # Validate target_path to prevent directory traversal
109- if not args .dest .startswith ("/" ):
110- print (
111- "ERROR: Target path must be an absolute path inside the PVC (start with '/')."
112- )
111+ # Validate target_path to prevent directory traversal and ensure it's within PVC
112+ if not args .dest .startswith ("/data/" ):
113+ print ("=" * 60 )
114+ print ("❌ ERROR: Invalid target path" )
115+ print ("=" * 60 )
116+ print ("The PVC is mounted at /data in the access pod." )
117+ print ("All paths must start with '/data/' for security reasons." )
118+ print ("" )
119+ print ("💡 QUICK FIX:" )
120+ if args .dest .startswith ("/" ):
121+ # Suggest the fix
122+ suggested_path = f"/data{ args .dest } "
123+ print (f" Change: { args .dest } " )
124+ print (f" To: { suggested_path } " )
125+ print ("" )
126+ print ("📝 Example commands:" )
127+ print (" python3 -m deploy.utils.inject_manifest \\ " )
128+ print (f" --namespace { args .namespace } \\ " )
129+ print (f" --src { args .src } \\ " )
130+ print (f" --dest { suggested_path } " )
131+ else :
132+ print (f" Use: /data/{ args .dest .lstrip ('/' )} " )
133+ print ("" )
134+ print ("🔍 Common patterns:" )
135+ print (" /configs/file.yaml → /data/configs/file.yaml" )
136+ print (" /results/data.yaml → /data/results/data.yaml" )
137+ print (" /profiling_results/... → /data/profiling_results/..." )
138+ print ("=" * 60 )
113139 sys .exit (1 )
114140
115141 if ".." in args .dest :
@@ -123,7 +149,7 @@ def main():
123149 check_kubectl_access (args .namespace )
124150
125151 # Deploy access pod
126- deploy_access_pod (args .namespace )
152+ ensure_clean_access_pod (args .namespace )
127153 try :
128154 # Copy manifest
129155 copy_manifest (args .namespace , args .src , args .dest )
0 commit comments