kubernetes custom resource definition to keep track of the number of services/namespaces

6/15/2018

I am trying to create a custom kubernetes controller which keeps the track of the number kubernetes resources, for example count the number services created in a cluster.

there are 2 parts to the above question:

  1. 1st I need to create a controller which listens to when a service is created, lets call this counter as svc_count. This is easy, as I can write a custom controller to listen on services.

  2. I need to store the svc_count in the etcd, so that I can show the value when some user queries for the svc_count. So I thought of using the CRD's. I can do that by following the example in https://github.com/yaronha/kube-crd. This has the Rest-API-client to POST,PUT,GET.

  3. The 3rd part is relating the part 1 and part 2. Whenever a Service is created, then in the ADD eventhandler of the controller I need make changes to the CRD, so that the user can see the update.

Issue/Question: My question how to update a CRD from the custom controller's eventhandler??. Can I save the CRD rest-api-client in the custom controller and call the respective Update function.

Please, let me know if there is any other way of doing this.

Thanks

-- Invictus
kubernetes
kubernetes-custom-resources

0 Answers