How to implement a K8S proxy watcher api-server?

139 views Asked by At

I need to create a K8S proxy watcher api-server, it receives list requests (for some k8s resources) with watch=true from clients, and proxy requests to the real upstream K8S API-Server, then receives responses from upstream continuously and send them back.

This is what I did:

  1. For server side, original K8S api-server implements watch operation using a long-lived HTTP connection, plus chunked response. In code there is a WatchServer struct to serve watch requests: enter image description here

its first member Watching needs an struct implements watch.Interface interface. So I have to find a suitable obj to fill this field so that I can implement a similar K8S apiserver.

  1. For client side, I have to get real watch events from upstream server, so I used SharedInformer in K8S, use add/delete/update event handler to receive up-to-date event notification.

The problem is that SharedInformer doesn't implement watch.Interface interface, cannot be used to create WatchServer struct. So are there any ways to connect these two things together? Or is there any objs that can be used to implement my requirements?

0

There are 0 answers