Custom Controller 之 Informer(二)

    !FILENAME informers/generic.go:58

    !FILENAME informers/factory.go:185

    1. internalinterfaces.SharedInformerFactory
    2. ForResource(resource schema.GroupVersionResource) (GenericInformer, error)
    3. WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool
    4. Admissionregistration() admissionregistration.Interface
    5. Apps() apps.Interface
    6. Auditregistration() auditregistration.Interface
    7. Autoscaling() autoscaling.Interface
    8. Batch() batch.Interface
    9. Certificates() certificates.Interface
    10. Coordination() coordination.Interface
    11. Core() core.Interface
    12. Events() events.Interface
    13. Extensions() extensions.Interface
    14. Networking() networking.Interface
    15. Policy() policy.Interface
    16. Rbac() rbac.Interface
    17. Scheduling() scheduling.Interface
    18. Settings() settings.Interface
    19. Storage() storage.Interface

    从 apps.Interface 一路到 DeploymentInformer

    1. type Interface interface {
    2. // V1 provides access to shared informers for resources in V1.
    3. V1() v1.Interface
    4. // V1beta1 provides access to shared informers for resources in V1beta1.
    5. V1beta1() v1beta1.Interface
    6. // V1beta2 provides access to shared informers for resources in V1beta2.
    7. V1beta2() v1beta2.Interface
    8. }

    v1.Interface

    !FILENAME informers/apps/v1/interface.go:26

    1. type Interface interface {
    2. ControllerRevisions() ControllerRevisionInformer
    3. // DaemonSets returns a DaemonSetInformer.
    4. DaemonSets() DaemonSetInformer
    5. // Deployments returns a DeploymentInformer.
    6. Deployments() DeploymentInformer
    7. // ReplicaSets returns a ReplicaSetInformer.
    8. ReplicaSets() ReplicaSetInformer
    9. // StatefulSets returns a StatefulSetInformer.
    10. StatefulSets() StatefulSetInformer
    11. }

    DeploymentInformer

    !FILENAME informers/apps/v1/deployment.go:36

    deploymentInformer

    !FILENAME informers/apps/v1/deployment.go:41

    1. type deploymentInformer struct {
    2. factory internalinterfaces.SharedInformerFactory
    3. tweakListOptions internalinterfaces.TweakListOptionsFunc
    4. namespace string
    5. }
    1. func (f *deploymentInformer) defaultInformer(client kubernetes.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
    2. return NewFilteredDeploymentInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
    3. }
    4. func (f *deploymentInformer) Informer() cache.SharedIndexInformer {
    5. return f.factory.InformerFor(&appsv1.Deployment{}, f.defaultInformer)
    6. }
    7. func (f *deploymentInformer) Lister() v1.DeploymentLister {
    8. return v1.NewDeploymentLister(f.Informer().GetIndexer())

    !FILENAME informers/factory.go:53

    1. type sharedInformerFactory struct {
    2. client kubernetes.Interface
    3. namespace string
    4. tweakListOptions internalinterfaces.TweakListOptionsFunc
    5. defaultResync time.Duration
    6. customResync map[reflect.Type]time.Duration
    7. informers map[reflect.Type]cache.SharedIndexInformer
    8. // startedInformers is used for tracking which informers have been started.
    9. // This allows Start() to be called multiple times safely.
    10. startedInformers map[reflect.Type]bool
    11. }

    kubernetes.Interface

    1556213817097

    Clientset

    appsv1.AppsV1Client

    !FILENAME kubernetes/typed/apps/v1/apps_client.go:38

    1. type AppsV1Client struct {
    2. restClient rest.Interface
    3. }

    rest.Interface

    1. type Interface interface {
    2. GetRateLimiter() flowcontrol.RateLimiter
    3. Verb(verb string) *Request
    4. Post() *Request
    5. Put() *Request
    6. Patch(pt types.PatchType) *Request
    7. Get() *Request
    8. Delete() *Request
    9. APIVersion() schema.GroupVersion
    10. }

    RESTClient

    !FILENAME rest/client.go:61

    1. type RESTClient struct {
    2. // base is the root URL for all invocations of the client
    3. base *url.URL
    4. versionedAPIPath string
    5. contentConfig ContentConfig
    6. serializers Serializers
    7. createBackoffMgr func() BackoffManager
    8. Throttle flowcontrol.RateLimiter
    9. Client *http.Client