-
Notifications
You must be signed in to change notification settings - Fork 220
Operator watching resources outside K8s Cluster #2807
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi, the mysql-schema sample operator shows how to check external resources that live outside of the cluster and still trigger your primary resource reconciler based on events that happen on non-k8s resources. |
see also here out of the box event sources supporting that: https://javaoperatorsdk.io/docs/documentation/eventing/#perresourcepollingeventsource |
Thank you for the sample! From it I understand that operator watch for K8S custom resource and it will prompt the operator to create a schema in DB. My question is can operator watch K8S custom resource but not from K8S, but from external API for example? In my case, I do not have K8s cluster. We have server which is based on K8s cluster, but the API is different. When I try the example it tries to fetch resources from https://kubernetes.default.svc/apis/mysql.sample.javaoperatorsdk/v1/mysqlschemas?resourceVersion=0 |
There's no reason why you couldn't create an event source that would call to your API using your own client, as long as you can associate whatever you're calling to with a primary resource to trigger your operator. Very often this is done by polling but if your API is able to stream, your event source could react to events and use them to identify the associated primary resource and then trigger the associated reconciler. It's difficult to tell without more details but this generic idea should be doable. |
@cviktorov I you mean to replace primary resource (central resource that is passed to the reconciler) that is not possible ATM. However having a custom resource just to identify your target resource on the other api and have an EventSource for that is almost that good. You need just a secondary job maybe to create the simple custom resources for each resource of your type. This is rather workaround but a feasible one. |
I tried with second job and is working. But I need to duplicate each custom resource from external server in my k8s cluster. I see that there is an option to create my own KubernetesClient. If create a new class which implements KubernetesClient.java and create the operator with: So, is it possible to add my http client in MyKubernetesClient which will communicate with the external server? |
You mean a non Kubernetes Cluster? that is not possible But we might consider this for v6, although probably won't happen. |
It would be great if it is possible to use custom non Kubernetes client, or to use PerResourcePollingEventSource, but with option reconciling to be trigger without Kubernetes resource, just with external resource. Can you consider some of these options for next version, please? |
That would be only possible for next major release, what will probably take some time. But event for that it is highly questionable. The project's scope is Kubernetes Operators, which by definition work on top of custom resources, and mainly we realy on some features on the fact that the resource has certain structure, for |
OK, thank you all for the help! |
Hi Colleagues,
Is it possible to use Java Operator SDK for watching and updating resources from some special API server, which is not K8S client (fabric8). For example, some extension of K8s, but the http client which watches and updates the resources is custom. So, is it possible to change the K8S API client with my own client?
Thank you!
Best regards,
Tsvetislav
The text was updated successfully, but these errors were encountered: