| 370 | } |
| 371 | |
| 372 | func (c *Controller) initSharedInformers() { |
| 373 | |
| 374 | // Postgresqls |
| 375 | c.postgresqlInformer = acidv1informer.NewPostgresqlInformer( |
| 376 | c.KubeClient.AcidV1ClientSet, |
| 377 | c.opConfig.WatchedNamespace, |
| 378 | constants.QueueResyncPeriodTPR, |
| 379 | cache.Indexers{}) |
| 380 | |
| 381 | c.postgresqlInformer.AddEventHandler(cache.ResourceEventHandlerFuncs{ |
| 382 | AddFunc: c.postgresqlAdd, |
| 383 | UpdateFunc: c.postgresqlUpdate, |
| 384 | DeleteFunc: c.postgresqlDelete, |
| 385 | }) |
| 386 | |
| 387 | // PostgresTeams |
| 388 | if c.opConfig.EnablePostgresTeamCRD { |
| 389 | c.postgresTeamInformer = acidv1informer.NewPostgresTeamInformer( |
| 390 | c.KubeClient.AcidV1ClientSet, |
| 391 | c.opConfig.WatchedNamespace, |
| 392 | constants.QueueResyncPeriodTPR*6, // 30 min |
| 393 | cache.Indexers{}) |
| 394 | |
| 395 | c.postgresTeamInformer.AddEventHandler(cache.ResourceEventHandlerFuncs{ |
| 396 | AddFunc: c.postgresTeamAdd, |
| 397 | UpdateFunc: c.postgresTeamUpdate, |
| 398 | }) |
| 399 | } |
| 400 | |
| 401 | // Pods |
| 402 | podLw := &cache.ListWatch{ |
| 403 | ListFunc: c.podListFunc, |
| 404 | WatchFunc: c.podWatchFunc, |
| 405 | } |
| 406 | |
| 407 | c.podInformer = cache.NewSharedIndexInformer( |
| 408 | podLw, |
| 409 | &v1.Pod{}, |
| 410 | constants.QueueResyncPeriodPod, |
| 411 | cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}) |
| 412 | |
| 413 | c.podInformer.AddEventHandler(cache.ResourceEventHandlerFuncs{ |
| 414 | AddFunc: c.podAdd, |
| 415 | UpdateFunc: c.podUpdate, |
| 416 | DeleteFunc: c.podDelete, |
| 417 | }) |
| 418 | |
| 419 | // Kubernetes Nodes |
| 420 | nodeLw := &cache.ListWatch{ |
| 421 | ListFunc: c.nodeListFunc, |
| 422 | WatchFunc: c.nodeWatchFunc, |
| 423 | } |
| 424 | |
| 425 | c.nodesInformer = cache.NewSharedIndexInformer( |
| 426 | nodeLw, |
| 427 | &v1.Node{}, |
| 428 | constants.QueueResyncPeriodNode, |
| 429 | cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}) |