Skip to content

Commit

Permalink
support sofa registry kubernetes
Browse files Browse the repository at this point in the history
  • Loading branch information
呈铭 committed Mar 20, 2024
1 parent 2da24a7 commit 3feb714
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ public void register(ProviderConfig config) {
podResource.edit(pod -> new PodBuilder(pod).editOrNewMetadata()
// 将ProviderConfig存在Annotations上
.addToAnnotations(dataId, JSON.toJSONString(config, true))
// 为了过滤而不是订阅全部pod
.addToLabels(dataId, "")
.endMetadata().build());
}
}
Expand Down Expand Up @@ -154,6 +156,7 @@ public void unRegister(ProviderConfig config) {

podResource.edit(pod -> new PodBuilder(pod).editOrNewMetadata()
.removeFromAnnotations(dataId)
.removeFromLabels(dataId)
.endMetadata()
.build());
}
Expand Down Expand Up @@ -189,9 +192,11 @@ public List<ProviderGroup> subscribe(ConsumerConfig config) {
ProviderInfoListener providerInfoListener = config.getProviderInfoListener();
kubernetesRegistryProviderWatcher.addProviderListener(config, providerInfoListener);

String dataId = KubernetesRegistryHelper.buildDataId(config, config.getProtocol());
FilterWatchListDeletable<Pod, PodList, PodResource> podPodListPodResourceFilterWatchListDeletable =
kubernetesClient.pods()
.inNamespace(namespace);
.inNamespace(namespace)
.withLabel(dataId);

SharedIndexInformer<Pod> inform = podPodListPodResourceFilterWatchListDeletable.inform(new ResourceEventHandler<Pod>() {
@Override
Expand Down

0 comments on commit 3feb714

Please sign in to comment.