Home > Mobile >  What happens when creaing crd without relating operator?
What happens when creaing crd without relating operator?

Time:09-17

  1. Once I register the crd into the k8s cluster, I can use .yaml to create it, without operator running. Then What happends to these created resouces?

  2. I have seen the Reconciler of operator, but it's more like an async status transfer. When we create a pod, we can directly get the pod ip from the create result. But it seems that I didn't find a place to write my OnCreate hook. (I just see some validate webhook, but never see a hook that be called when creation request made, defines how to create the resourse, and return the created resourse info to the caller ).

  3. If my story is that for one kind of resource, in a time window, all coming creation will multiplex only one pod. Can you give me some advice?

CodePudding user response:

That's a big story for kubernetes crd/controller life cycle, I try to make a simple representation.

  1. After register a new CRD, and create CR, kube-api-server do not care if there is a related controller existed or not. see the process: enter image description here

That's means the resource(your CR) will be store to etcd, has no business of your controller

  1. ok, let talk about your controller. your controller will setup a list/watch(actually a long live http link) to the api-server and register hook(what you ask, right?) for different event: onCreate, onUpdate and onDelete. Actually you will handle all event in your controller's reconcile (remember kubernetes reconcile's responsibility: move current state to desired state). see the diagram: enter image description here
  1. For the list/watch link in your controller, you need set different link for different kind of resource. for example: if you care about event for pod, you need set pod list/watch or care about deployment, and set a deployment list/watch...
  • Related