@@ -118,6 +118,7 @@ impl FromStr for KubernetesControlConnection {
118118#[ derive( Debug , Clone , Serialize , Deserialize ) ]
119119#[ serde( default , deny_unknown_fields) ]
120120pub struct KubernetesSandboxRuntimeConfig {
121+ pub app_listener : KubernetesAppListenerConfig ,
121122 /// TCP port of the Sandbox Protocol listener: the workload boundary for
122123 /// supervisor-initiated sandboxes, the supervisor for runtime-initiated ones.
123124 pub boundary_port : u16 ,
@@ -127,12 +128,32 @@ impl Default for KubernetesSandboxRuntimeConfig {
127128 fn default ( ) -> Self {
128129 Self {
129130 boundary_port : 5500 ,
131+ app_listener : KubernetesAppListenerConfig :: default ( ) ,
130132 }
131133 }
132134}
133135
136+ /// Driver-owned TLS deployment inputs. Common listener settings
137+ /// are injected by the gateway so there is only one port/domain source.
138+ #[ derive( Clone , Debug , Default , Serialize , Deserialize ) ]
139+ #[ serde( default , deny_unknown_fields) ]
140+ pub struct KubernetesAppListenerConfig {
141+ pub tls_secret_name : String ,
142+ #[ serde( skip) ]
143+ pub common : openshell_core:: app_listener:: AppListenerConfig ,
144+ }
145+
134146impl KubernetesSandboxRuntimeConfig {
135147 pub fn validate ( & self ) -> Result < ( ) , String > {
148+ self . app_listener . common . validate ( ) ?;
149+ if self . app_listener . common . enabled {
150+ if !is_dns_subdomain ( & self . app_listener . tls_secret_name ) {
151+ return Err ( "sandbox_runtime.app_listener.tls_secret_name is required when the app listener is enabled" . into ( ) ) ;
152+ }
153+ if [ self . boundary_port , 5501 ] . contains ( & self . app_listener . common . port ) {
154+ return Err ( "supervisor.app_listener.port conflicts with a supervisor runtime or health port" . into ( ) ) ;
155+ }
156+ }
136157 if self . boundary_port < 1024 {
137158 return Err ( "sandbox_runtime.boundary_port must be at least 1024" . to_string ( ) ) ;
138159 }
@@ -557,6 +578,11 @@ impl KubernetesComputeConfig {
557578 "supervisor_topology=gateway requires shared_supervisor" . to_string ( )
558579 } ) ?;
559580 shared. validate ( ) ?;
581+ if self . sandbox_runtime . app_listener . common . enabled
582+ && self . sandbox_runtime . app_listener . common . port == shared. runtime_port
583+ {
584+ return Err ( "supervisor.app_listener.port conflicts with shared_supervisor.runtime_port" . into ( ) ) ;
585+ }
560586 if self . provider_spiffe_enabled ( ) {
561587 return Err ( "supervisor_topology=gateway does not support provider_spiffe_workload_api_socket_path; a shared supervisor has no per-sandbox workload identity" . into ( ) ) ;
562588 }
@@ -1118,6 +1144,25 @@ mod tests {
11181144 use super :: * ;
11191145 use std:: collections:: BTreeMap as HashMap ;
11201146
1147+ #[ test]
1148+ fn app_endpoint_configuration_has_one_port_source_and_explicit_enablement ( ) {
1149+ let mut config = KubernetesSandboxRuntimeConfig :: default ( ) ;
1150+ config. app_listener . tls_secret_name = "app-tls" . into ( ) ;
1151+ assert ! ( !config. app_listener. common. enabled) ;
1152+ assert ! ( config. validate( ) . is_ok( ) ) ;
1153+ config. app_listener . common = openshell_core:: app_listener:: AppListenerConfig {
1154+ enabled : true ,
1155+ port : 9443 ,
1156+ domain : "services.example.com" . into ( ) ,
1157+ } ;
1158+ assert ! ( config. validate( ) . is_ok( ) ) ;
1159+ config. app_listener . common . port = config. boundary_port ;
1160+ assert ! ( config. validate( ) . is_err( ) ) ;
1161+ config. app_listener . common . port = 9443 ;
1162+ config. app_listener . tls_secret_name . clear ( ) ;
1163+ assert ! ( config. validate( ) . is_err( ) ) ;
1164+ }
1165+
11211166 #[ test]
11221167 fn gateway_supervisor_topology_requires_its_connection_and_refuses_unsupported_inputs ( ) {
11231168 let shared = || SharedSupervisorConfig {
0 commit comments