Merge branch 'online_demonstration' of https://bdgit.educoder.net/pgpc5xf4t/hami into online_demonstration

online_demonstration^2
陈博文 2 weeks ago
commit ecfba02e9a

@ -15,7 +15,6 @@ import (
k8stypes "k8s.io/apimachinery/pkg/types" k8stypes "k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/informers" "k8s.io/client-go/informers"
listerscorev1 "k8s.io/client-go/listers/core/v1" listerscorev1 "k8s.io/client-go/listers/core/v1"
"k8s.io/client-go/tools/cache"
) )
type podRepo struct { type podRepo struct {
@ -41,12 +40,12 @@ func NewPodRepo(data *Data, logger log.Logger) biz.PodRepo {
func (r *podRepo) init() { func (r *podRepo) init() {
informerFactory := informers.NewSharedInformerFactoryWithOptions(r.data.k8sCl, time.Hour*1) informerFactory := informers.NewSharedInformerFactoryWithOptions(r.data.k8sCl, time.Hour*1)
r.podLister = informerFactory.Core().V1().Pods().Lister() r.podLister = informerFactory.Core().V1().Pods().Lister()
informer := informerFactory.Core().V1().Pods().Informer() //informer := informerFactory.Core().V1().Pods().Informer()
informer.AddEventHandler(cache.ResourceEventHandlerFuncs{ //informer.AddEventHandler(cache.ResourceEventHandlerFuncs{
AddFunc: r.onAddPod, // AddFunc: r.onAddPod,
UpdateFunc: r.onUpdatePod, // UpdateFunc: r.onUpdatePod,
DeleteFunc: r.onDeletedPod, // DeleteFunc: r.onDeletedPod,
}) //})
stopCh := make(chan struct{}) stopCh := make(chan struct{})
informerFactory.Start(stopCh) informerFactory.Start(stopCh)
informerFactory.WaitForCacheSync(stopCh) informerFactory.WaitForCacheSync(stopCh)

Loading…
Cancel
Save