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?
I have seen the
Reconcilerof 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 myOnCreatehook. (I just see somevalidatewebhook, 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 ).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.
- After register a new CRD, and create CR,
kube-api-serverdo not care if there is a relatedcontrollerexisted or not. see the process:
That's means the resource(your CR) will be store to etcd, has no business of your controller
- ok, let talk about your controller. your controller will setup a
list/watch(actually a long live http link) to theapi-serverand registerhook(what you ask, right?) for different event:onCreate,onUpdateandonDelete. Actually you will handle all event in your controller'sreconcile(remember kubernetes reconcile's responsibility: move current state to desired state). see the diagram:
- For the
list/watchlink in yourcontroller, you need set different link for different kind of resource. for example: if you care about event forpod, you need setpodlist/watchor care about deployment, and set adeploymentlist/watch...
