github.com/Azure/aad-pod-identity@v1.8.17/pkg/mic/node.go (about) 1 package mic 2 3 import ( 4 corev1 "k8s.io/api/core/v1" 5 informerv1 "k8s.io/client-go/informers/core/v1" 6 "k8s.io/client-go/tools/cache" 7 ) 8 9 // NodeClient handles fetching node details from kubernetes 10 type NodeClient struct { 11 informer informerv1.NodeInformer 12 } 13 14 // Get gets the specified kubernetes node. 15 // 16 // Note that this is using a local, eventually consistent cache which may not 17 // be up to date with the actual state of the cluster. 18 func (c *NodeClient) Get(name string) (*corev1.Node, error) { 19 return c.informer.Lister().Get(name) 20 } 21 22 // Start starts syncing the underlying cache with kubernetes. 23 // 24 // The passed in channel should be used to signal that the client should stop 25 // syncing. Close this channel when you want syncing to stop. 26 func (c *NodeClient) Start(exit <-chan struct{}) { 27 go c.informer.Informer().Run(exit) 28 cache.WaitForCacheSync(exit, c.informer.Informer().HasSynced) 29 }