kubernetes watch의 원본 코드 사용

5521 단어 Kubernetes
 , mybase , , 。。。。
func GetNodeLister(kubeClient *kube_client.Clientset) (v1listers.NodeLister, *cache.Reflector, error) {
   lw := cache.NewListWatchFromClient(kubeClient.CoreV1().RESTClient(), "nodes", kube_api.NamespaceAll, fields.Everything())
   store := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
   nodeLister := v1listers.NewNodeLister(store)
   reflector := cache.NewReflector(lw, &kube_api.Node{}, store, time.Second)
   reflector.Run()
   return nodeLister, reflector, nil
}
func getPodLister(kubeClient *kube_client.Clientset) (v1listers.PodLister, error) {
   lw := cache.NewListWatchFromClient(kubeClient.CoreV1().RESTClient(), "pods", kube_api.NamespaceAll, fields.Everything())
   store := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
   podLister := v1listers.NewPodLister(store)
   reflector := cache.NewReflector(lw, &kube_api.Pod{}, store, time.Second)
   reflector.Run()
   return podLister, nil
}

좋은 웹페이지 즐겨찾기