diff --git a/internal/services/executor/driver/k8s.go b/internal/services/executor/driver/k8s.go index dc9344c..9270922 100644 --- a/internal/services/executor/driver/k8s.go +++ b/internal/services/executor/driver/k8s.go @@ -165,6 +165,26 @@ func NewK8sDriver(logger *zap.Logger, executorID, toolboxPath string) (*K8sDrive d.executorsGroupID = executorsGroupID ctx := context.TODO() + factory := informers.NewSharedInformerFactoryWithOptions(d.client, informerResyncInterval, informers.WithNamespace(d.namespace)) + + nodeInformer := factory.Core().V1().Nodes() + d.nodeLister = nodeInformer.Lister() + go nodeInformer.Informer().Run(ctx.Done()) + + podInformer := factory.Core().V1().Pods() + d.podLister = podInformer.Lister() + go podInformer.Informer().Run(ctx.Done()) + + if d.useLeaseAPI { + leaseInformer := factory.Coordination().V1().Leases() + d.leaseLister = leaseInformer.Lister() + go leaseInformer.Informer().Run(ctx.Done()) + } else { + cmInformer := factory.Core().V1().ConfigMaps() + d.cmLister = cmInformer.Lister() + go cmInformer.Informer().Run(ctx.Done()) + } + go func() { for { if err := d.updateLease(ctx); err != nil { @@ -197,26 +217,6 @@ func NewK8sDriver(logger *zap.Logger, executorID, toolboxPath string) (*K8sDrive } }() - factory := informers.NewSharedInformerFactoryWithOptions(d.client, informerResyncInterval, informers.WithNamespace(d.namespace)) - - nodeInformer := factory.Core().V1().Nodes() - d.nodeLister = nodeInformer.Lister() - go nodeInformer.Informer().Run(ctx.Done()) - - podInformer := factory.Core().V1().Pods() - d.podLister = podInformer.Lister() - go podInformer.Informer().Run(ctx.Done()) - - if d.useLeaseAPI { - leaseInformer := factory.Coordination().V1().Leases() - d.leaseLister = leaseInformer.Lister() - go leaseInformer.Informer().Run(ctx.Done()) - } else { - cmInformer := factory.Core().V1().ConfigMaps() - d.cmLister = cmInformer.Lister() - go cmInformer.Informer().Run(ctx.Done()) - } - return d, nil }