@@ -26,6 +26,7 @@ import (
2626
2727 "k8s.io/apimachinery/pkg/runtime"
2828 utilruntime "k8s.io/apimachinery/pkg/util/runtime"
29+ "k8s.io/client-go/dynamic"
2930 clientgoscheme "k8s.io/client-go/kubernetes/scheme"
3031 ctrl "sigs.k8s.io/controller-runtime"
3132 "sigs.k8s.io/controller-runtime/pkg/healthz"
@@ -63,10 +64,14 @@ func main() {
6364 var enableLeaderElection bool
6465 var probeAddr string
6566 var namespace string
67+ var enableServiceActivator bool
68+ var podIP string
6669
6770 flag .StringVar (& metricsAddr , "metrics-bind-address" , ":8080" , "The address the metric endpoint binds to." )
6871 flag .StringVar (& probeAddr , "health-probe-bind-address" , ":8081" , "The address the probe endpoint binds to." )
6972 flag .StringVar (& namespace , "namespace" , "llmaz-system" , "The namespace of the llmaz to deploy" )
73+ flag .BoolVar (& enableServiceActivator , "enable-service-activator" , false , "Enable the service activator feature. This is an experimental feature." )
74+ flag .StringVar (& podIP , "pod-ip" , "" , "The pod IP of the llmaz controller manager. Only used when service activator is enabled." )
7075 flag .BoolVar (& enableLeaderElection , "leader-elect" , false ,
7176 "Enable leader election for controller manager. " +
7277 "Enabling this will ensure there is only one active controller manager." )
@@ -120,7 +125,7 @@ func main() {
120125 // Cert won't be ready until manager starts, so start a goroutine here which
121126 // will block until the cert is ready before setting up the controllers.
122127 // Controllers who register after manager starts will start directly.
123- go setupControllers (mgr , certsReady )
128+ go setupControllers (mgr , certsReady , enableServiceActivator , podIP )
124129
125130 //+kubebuilder:scaffold:builder
126131
@@ -140,7 +145,7 @@ func main() {
140145 }
141146}
142147
143- func setupControllers (mgr ctrl.Manager , certsReady chan struct {}) {
148+ func setupControllers (mgr ctrl.Manager , certsReady chan struct {}, enableServiceActivator bool , podIP string ) {
144149 // The controllers won't work until the webhooks are operating,
145150 // and the webhook won't work until the certs are all in places.
146151 setupLog .Info ("waiting for the cert generation to complete" )
@@ -176,6 +181,20 @@ func setupControllers(mgr ctrl.Manager, certsReady chan struct{}) {
176181 os .Exit (1 )
177182 }
178183
184+ if enableServiceActivator {
185+ dynamicClient , err := dynamic .NewForConfig (mgr .GetConfig ())
186+ if err != nil {
187+ setupLog .Error (err , "unable to create dynamic client" )
188+ os .Exit (1 )
189+ }
190+
191+ activatorReconciler := inferencecontroller .NewActivatorReconciler (mgr , dynamicClient , podIP )
192+ if err := activatorReconciler .SetupWithManager (mgr ); err != nil {
193+ setupLog .Error (err , "unable to create controller" , "controller" , "Activator" )
194+ os .Exit (1 )
195+ }
196+ }
197+
179198 if os .Getenv ("ENABLE_WEBHOOKS" ) != "false" {
180199 if err := webhook .SetupOpenModelWebhook (mgr ); err != nil {
181200 setupLog .Error (err , "unable to create webhook" , "webhook" , "Model" )
0 commit comments