K8s secondary development operator writing (1)

where the code is located

https://github.com/mafa1993/kubernetes-learn/tree/main/operator/client-go

Where k8s can be expanded

  1. kubectl

  2. api server , block requests, edit requests, delete requests, etc.

  3. Use label and annotate to modify k8s resources

  4. crd, custom resource

  5. scheduler

  6. kubelet,CSI CNI CRI

  7. controller manager collection of controllers

  8. custom controller

  9. client go

k8s controler

  1. It is generally recommended that a controller track at least one k8s resource

  2. Bring the status to the state defined by the spec

  3. Different controllers can cooperate with each other to realize complex tasks

  4. Use client go to interact with api server

client go

  1. Source address https://github.com/kubernetes/client-go

  2. Explanation of client-go directory

    • kubernetes saves all clients accessed by k8s api

    • informer

    • listers Read the resource information of k8s in the cache

    • Discovery is used to discover the api supported by the api server

    • dynamic is used to manipulate resource objects

    • auth authentication

    • tools

    • transport creates connections, etc.

  3. k8s controller architecture diagram

controller logic

  1. Observe, obtain the loading of the current object by monitoring the changes of kubernetes resources, inject the observer into the eventHandler, and put the transformed object into the workQueue

  2. Analysis, comparing the current state and the expected state, completed by the worker

  3. Execute, execute the current state into the desired state, and the worker completes

  4. Update, update the current status of the object, completed by the worker

     

Guess you like

Origin blog.csdn.net/mafa1993/article/details/131320646