How to extend the Kubernetes API using CustomResourceDefinitions and CustomResources. Also, how to write a custom controller to operate on these CustomResources.
Google Summer of Code student for CNCF (Kubernetes) • Undergrad student from VJTI, Mumbai You can find me on: ➔ Twitter: @TheNikhita ➔ Github: nikhita ➔ Website: https://www.nikhita.github.io @TheNikhita
current state same as the desired state. 2. Do something extra on add, update, delete of a resource. Example: - Write a message in a CustomResource. - Create the CustomResource. - A Github comment is created with this message. Link: https://github.com/nikhita/kube-custom-controller (inspired from https://github.com/munnerz/k8s-api-pager-demo) @TheNikhita
client => kubeconfig file - github client => github API token 2. Create an informer: Use sharedInformers: - notify or “inform” about add/update/delete of a resource - use a common cache across all controllers @TheNikhita
the informer: - to tell what happens on add/update/delete - here, we will put it into a queue 4. Start the informer - wait for the informer cache sync across all resources @TheNikhita
the queue: - take the object from the queue - get it’s latest version - sync it! 6. Sync it! (current state -> desired state): - do some action. Here, we send a Github comment. - update the status (the current state) - update the resource @TheNikhita
- Create a CustomResource - Write your own controller to use the CustomResource! If you have even more specific needs, you should use Aggregated API Servers....but we won’t be discussing that today. @TheNikhita