@@ -37,6 +37,9 @@ pub struct SandboxClient {
3737 client : Client ,
3838 namespace : String ,
3939 default_image : String ,
40+ /// Kubernetes `imagePullPolicy` for sandbox containers. When empty the
41+ /// field is omitted from the pod spec and Kubernetes applies its default.
42+ image_pull_policy : String ,
4043 grpc_endpoint : String ,
4144 ssh_listen_addr : String ,
4245 ssh_handshake_secret : String ,
@@ -59,6 +62,7 @@ impl SandboxClient {
5962 pub async fn new (
6063 namespace : String ,
6164 default_image : String ,
65+ image_pull_policy : String ,
6266 grpc_endpoint : String ,
6367 ssh_listen_addr : String ,
6468 ssh_handshake_secret : String ,
@@ -79,6 +83,7 @@ impl SandboxClient {
7983 client,
8084 namespace,
8185 default_image,
86+ image_pull_policy,
8287 grpc_endpoint,
8388 ssh_listen_addr,
8489 ssh_handshake_secret,
@@ -149,6 +154,7 @@ impl SandboxClient {
149154 obj. data = sandbox_to_k8s_spec (
150155 sandbox. spec . as_ref ( ) ,
151156 & self . default_image ,
157+ & self . image_pull_policy ,
152158 & sandbox. id ,
153159 & sandbox. name ,
154160 & self . grpc_endpoint ,
@@ -721,6 +727,7 @@ fn apply_supervisor_bootstrap(pod_template: &mut serde_json::Value, default_imag
721727fn sandbox_to_k8s_spec (
722728 spec : Option < & SandboxSpec > ,
723729 default_image : & str ,
730+ image_pull_policy : & str ,
724731 sandbox_id : & str ,
725732 sandbox_name : & str ,
726733 grpc_endpoint : & str ,
@@ -746,6 +753,7 @@ fn sandbox_to_k8s_spec(
746753 sandbox_template_to_k8s (
747754 template,
748755 default_image,
756+ image_pull_policy,
749757 sandbox_id,
750758 sandbox_name,
751759 grpc_endpoint,
@@ -777,6 +785,7 @@ fn sandbox_to_k8s_spec(
777785 sandbox_template_to_k8s (
778786 & SandboxTemplate :: default ( ) ,
779787 default_image,
788+ image_pull_policy,
780789 sandbox_id,
781790 sandbox_name,
782791 grpc_endpoint,
@@ -798,6 +807,7 @@ fn sandbox_to_k8s_spec(
798807fn sandbox_template_to_k8s (
799808 template : & SandboxTemplate ,
800809 default_image : & str ,
810+ image_pull_policy : & str ,
801811 sandbox_id : & str ,
802812 sandbox_name : & str ,
803813 grpc_endpoint : & str ,
@@ -812,6 +822,7 @@ fn sandbox_template_to_k8s(
812822 pod_template,
813823 template,
814824 default_image,
825+ image_pull_policy,
815826 sandbox_id,
816827 sandbox_name,
817828 grpc_endpoint,
@@ -861,6 +872,12 @@ fn sandbox_template_to_k8s(
861872 } ;
862873 if !image. is_empty ( ) {
863874 container. insert ( "image" . to_string ( ) , serde_json:: json!( image) ) ;
875+ if !image_pull_policy. is_empty ( ) {
876+ container. insert (
877+ "imagePullPolicy" . to_string ( ) ,
878+ serde_json:: json!( image_pull_policy) ,
879+ ) ;
880+ }
864881 }
865882
866883 // Build environment variables - start with OpenShell-required vars
@@ -945,6 +962,7 @@ fn inject_pod_template(
945962 mut pod_template : serde_json:: Value ,
946963 template : & SandboxTemplate ,
947964 default_image : & str ,
965+ image_pull_policy : & str ,
948966 sandbox_id : & str ,
949967 sandbox_name : & str ,
950968 grpc_endpoint : & str ,
@@ -1006,6 +1024,16 @@ fn inject_pod_template(
10061024 !client_tls_secret_name. is_empty ( ) ,
10071025 ) ;
10081026
1027+ // Inject imagePullPolicy on the agent container.
1028+ if !image_pull_policy. is_empty ( ) {
1029+ if let Some ( container_obj) = container. as_object_mut ( ) {
1030+ container_obj. insert (
1031+ "imagePullPolicy" . to_string ( ) ,
1032+ serde_json:: json!( image_pull_policy) ,
1033+ ) ;
1034+ }
1035+ }
1036+
10091037 // Inject TLS volumeMount on the agent container.
10101038 if !client_tls_secret_name. is_empty ( )
10111039 && let Some ( container_obj) = container. as_object_mut ( )
0 commit comments