@Override
    public List<ProviderGroup> subscribe(ConsumerConfig config) {
        String appName = config.getAppName();
        if (!registryConfig.isSubscribe()) {
            // registry ignored
            if (LOGGER.isInfoEnabled(appName)) {
                LOGGER.infoWithApp(appName, LogCodes.getLog(LogCodes.INFO_REGISTRY_IGNORE));
            }
            return null;
        }

        if (config.isSubscribe()) {

            ProviderInfoListener providerInfoListener = config.getProviderInfoListener();
            kubernetesRegistryProviderWatcher.addProviderListener(config, providerInfoListener);

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

            SharedIndexInformer<Pod> inform = podPodListPodResourceFilterWatchListDeletable.inform(new ResourceEventHandler<Pod>() {
                @Override
                public void onAdd(Pod pod) {
                    kubernetesRegistryProviderWatcher.updateProviders(config, getPods());
                }

                @Override
                public void onUpdate(Pod pod, Pod t1) {
                    kubernetesRegistryProviderWatcher.updateProviders(config, getPods());
                }

                @Override
                public void onDelete(Pod pod, boolean b) {
                    kubernetesRegistryProviderWatcher.updateProviders(config, getPods());
                }
            });

            consumerListeners.put(config, inform);

            inform.start();

            List<Pod> pods = podPodListPodResourceFilterWatchListDeletable.list().getItems();
            List<ProviderInfo> providerInfos = KubernetesRegistryHelper.convertPodsToProviders(pods, config);
            return Collections.singletonList(new ProviderGroup().addAll(providerInfos));
        }

        return null;
    }
Instantiates a new kubernetes registry.

@param registryConfig
registry/registry-kubernetes/src/main/java/com/alipay/sofa/rpc/registry/kubernetes/KubernetesRegistry.java