karmada-io / karmada

Open, Multi-Cloud, Multi-Cluster Kubernetes Orchestration
https://karmada.io
Apache License 2.0
4.12k stars 807 forks source link

Auto-sync of labels for Cluster object from external json API #4844

Closed kutsyk closed 1 week ago

kutsyk commented 2 weeks ago

Hi there,

We have external API, let's call is clusters-service-directory, that returns JSON array, where each item is JSON that contains name of the cluster and other fields that describe that cluster (zone, region, provider and so on).

After I joined a cluster to Karmada, it is pretty empty and I can't configure propagation policies to base on fields or labels.

What would be good way to sync external API and Karmada so that cluster objects have labels that are corresponding to fields from JSON response?

Should we develop out own plugin for that? if yes, are there examples of such?

If not, than what would be most efficient way to move forward with this?

Thanks

RainbowMango commented 1 week ago

What would be good way to sync external API and Karmada so that cluster objects have labels that are corresponding to fields from JSON response?

Is it possible to sync the external metadata before joining the cluster in Karmada? Something like joining a cluster with all the necessary metadata(fields, labels, and so on).

Should we develop out own plugin for that? if yes, are there examples of such?

Unfortunately, no such example. But I bet it is not so hard to have it. You can use the Cluster clientset to manipulate Cluster objects.

kutsyk commented 1 week ago

Yeah, I was able to implement it with simple Go script that runs as a cronjob and updates Cluster object.

Thanks