| 123456789101112131415161718192021222324252627282930 |
- package transfer
- import (
- "context"
- "k8s.io/client-go/informers"
- "k8s.io/client-go/kubernetes"
- "time"
- )
- type CwK8sClient struct {
- K8sClient *kubernetes.Clientset
- InformerSharedfactory informers.SharedInformerFactory
- ctx context.Context
- }
- func NewCwK8sClient(ctx context.Context, client *kubernetes.Clientset) *CwK8sClient {
- sharedInformer := informers.NewSharedInformerFactory(client, 30*time.Second)
- sharedInformer.Core().V1().Pods().Informer()
- sharedInformer.Core().V1().Nodes().Informer()
- sharedInformer.Core().V1().Namespaces().Informer()
- sharedInformer.Apps().V1().StatefulSets().Informer()
- sharedInformer.Apps().V1().DaemonSets().Informer()
- sharedInformer.Apps().V1().Deployments().Informer()
- sharedInformer.Apps().V1().ReplicaSets().Informer()
- return &CwK8sClient{
- K8sClient: client,
- ctx: ctx,
- InformerSharedfactory: sharedInformer,
- }
- }
|