@@ -160,11 +160,11 @@ func (rs *RouterService) Process(stream ext_proc.ExternalProcessor_ProcessServer
160160// watchConfigAndReload watches the config file and reloads router on changes.
161161func (s * Server ) watchConfigAndReload (ctx context.Context ) {
162162 // Check if we're using Kubernetes config source
163- // If so, skip file watching as config is managed by the Kubernetes controller
164163 cfg := config .Get ()
165164 if cfg != nil && cfg .ConfigSource == config .ConfigSourceKubernetes {
166- logging .Infof ("ConfigSource is kubernetes, skipping file watcher" )
167- <- ctx .Done () // Just wait for context cancellation
165+ logging .Infof ("ConfigSource is kubernetes, watching for config updates from controller" )
166+ // Watch for config updates from the Kubernetes controller
167+ s .watchKubernetesConfigUpdates (ctx )
168168 return
169169 }
170170
@@ -244,3 +244,35 @@ func (s *Server) watchConfigAndReload(ctx context.Context) {
244244 }
245245 }
246246}
247+
248+ // watchKubernetesConfigUpdates watches for config updates from the Kubernetes controller
249+ func (s * Server ) watchKubernetesConfigUpdates (ctx context.Context ) {
250+ updateCh := config .WatchConfigUpdates ()
251+
252+ for {
253+ select {
254+ case <- ctx .Done ():
255+ return
256+ case newCfg := <- updateCh :
257+ if newCfg == nil {
258+ continue
259+ }
260+
261+ // Build a new router with the updated config
262+ // Note: We pass the configPath but NewOpenAIRouter will use the global config
263+ newRouter , err := NewOpenAIRouter (s .configPath )
264+ if err != nil {
265+ logging .LogEvent ("config_reload_failed" , map [string ]interface {}{
266+ "source" : "kubernetes" ,
267+ "error" : err .Error (),
268+ })
269+ continue
270+ }
271+
272+ s .service .Swap (newRouter )
273+ logging .LogEvent ("config_reloaded" , map [string ]interface {}{
274+ "source" : "kubernetes" ,
275+ })
276+ }
277+ }
278+ }
0 commit comments