apache / dubbo-samples

samples for Apache Dubbo
Apache License 2.0
2.25k stars 1.92k forks source link

dubbo-samples-kubernetes-dns 不可用 #347

Open shenhuaxx opened 3 years ago

shenhuaxx commented 3 years ago

kubernetes部署kubernetes-dns-demo-provider后,通过其它Pod验证域名成功

/ # nslookup kubernetes-apiserver-demo-provider.examples.svc.cluster.local
nslookup: can't resolve '(null)': Name does not resolve

Name:      kubernetes-apiserver-demo-provider.examples.svc.cluster.local
Address 1: 10.233.90.98 10-233-90-98.kubernetes-apiserver-demo-provider.examples.svc.cluster.local
Address 2: 10.233.105.82 10-233-105-82.kubernetes-apiserver-demo-provider.examples.svc.cluster.local

但是在kubernetes内部署kubernetes-dns-demo-consumer之后报错如下:

[16/07/21 09:52:25:025 UTC] main  INFO annotation.AnnotationConfigApplicationContext: Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@4ccabbaa: startup date [Fri Jul 16 09:52:25 UTC 2021]; root of context hierarchy
[16/07/21 09:52:25:025 UTC] main  INFO logger.LoggerFactory: using logger: org.apache.dubbo.common.logger.log4j.Log4jLoggerAdapter
[16/07/21 09:52:25:025 UTC] main  INFO annotation.ServiceAnnotationPostProcessor:  [DUBBO] BeanNameGenerator bean can't be found in BeanFactory with name [org.springframework.context.annotation.internalConfigurationBeanNameGenerator], dubbo version: 1.0-SNAPSHOT, current host: 10.233.105.83
[16/07/21 09:52:25:025 UTC] main  INFO annotation.ServiceAnnotationPostProcessor:  [DUBBO] BeanNameGenerator will be a instance of org.springframework.context.annotation.AnnotationBeanNameGenerator , it maybe a potential problem on bean name generation., dubbo version: 1.0-SNAPSHOT, current host: 10.233.105.83
[16/07/21 09:52:25:025 UTC] main  WARN annotation.ServiceAnnotationPostProcessor:  [DUBBO] No class annotated by Dubbo @Service was found under package [org.apache.dubbo.samples.action], ignore re-scanned classes: 0, dubbo version: 1.0-SNAPSHOT, current host: 10.233.105.83
[16/07/21 09:52:25:025 UTC] main  INFO annotation.ReferenceAnnotationBeanPostProcessor: Register dubbo reference bean: greetingService = ReferenceBean:org.apache.dubbo.samples.api.GreetingService:1.0.0(services=[kubernetes-dns-demo-provider]) at private org.apache.dubbo.samples.api.GreetingService org.apache.dubbo.samples.action.GreetingServiceConsumer.greetingService
[16/07/21 09:52:26:026 UTC] main  INFO reference.ReferenceCreator: The configBean[type:ReferenceConfig] has been built.
[16/07/21 09:52:26:026 UTC] main  INFO bootstrap.DubboBootstrap:  [DUBBO] No value is configured in the registry, the DynamicConfigurationFactory extension[name : dns] does not support as the config center, dubbo version: 1.0-SNAPSHOT, current host: 10.233.105.83
[16/07/21 09:52:26:026 UTC] main  INFO bootstrap.DubboBootstrap:  [DUBBO] The registry[<dubbo:registry address="dns://10.233.0.3:53?registry-type=service&duplicate=false&addressSuffix=.examples.svc.cluster.local" protocol="dns" port="53" />] will be not used as the config center, dubbo version: 1.0-SNAPSHOT, current host: 10.233.105.83
[16/07/21 09:52:26:026 UTC] main  INFO bootstrap.DubboBootstrap:  [DUBBO] use registry as config-center: [], dubbo version: 1.0-SNAPSHOT, current host: 10.233.105.83
[16/07/21 09:52:26:026 UTC] main  INFO bootstrap.DubboBootstrap:  [DUBBO] No value is configured in the registry, the MetadataReportFactory extension[name : dns] does not support as the metadata center, dubbo version: 1.0-SNAPSHOT, current host: 10.233.105.83
[16/07/21 09:52:26:026 UTC] main  INFO bootstrap.DubboBootstrap:  [DUBBO] The registry[<dubbo:registry address="dns://10.233.0.3:53?registry-type=service&duplicate=false&addressSuffix=.examples.svc.cluster.local" protocol="dns" port="53" />] will be not used as the metadata center, dubbo version: 1.0-SNAPSHOT, current host: 10.233.105.83
[16/07/21 09:52:26:026 UTC] main  INFO bootstrap.DubboBootstrap:  [DUBBO] use registry as metadata-center: [], dubbo version: 1.0-SNAPSHOT, current host: 10.233.105.83
[16/07/21 09:52:26:026 UTC] main  INFO bootstrap.DubboBootstrap:  [DUBBO] DubboBootstrap has been initialized!, dubbo version: 1.0-SNAPSHOT, current host: 10.233.105.83
[16/07/21 09:52:26:026 UTC] main  INFO bootstrap.DubboBootstrap:  [DUBBO] DubboBootstrap is starting..., dubbo version: 1.0-SNAPSHOT, current host: 10.233.105.83
[16/07/21 09:52:26:026 UTC] main  INFO server.Server:  [DUBBO] qos-server bind localhost:22222, dubbo version: 1.0-SNAPSHOT, current host: 10.233.105.83
[16/07/21 09:52:26:026 UTC] main  WARN migration.MigrationRuleListener:  [DUBBO] Using default configuration rule because config center is not configured!, dubbo version: 1.0-SNAPSHOT, current host: 10.233.105.83
[16/07/21 09:52:26:026 UTC] main  WARN metadata.MetadataServiceNameMapping:  [DUBBO] the metadata report was not inited., dubbo version: 1.0-SNAPSHOT, current host: 10.233.105.83
java.lang.IllegalStateException: the metadata report was not inited.
    at org.apache.dubbo.metadata.report.MetadataReportInstance.checkInit(MetadataReportInstance.java:83)
    at org.apache.dubbo.metadata.report.MetadataReportInstance.getMetadataReport(MetadataReportInstance.java:72)
    at org.apache.dubbo.registry.client.metadata.MetadataServiceNameMapping.lambda$getAndListen$1(MetadataServiceNameMapping.java:82)
    at org.apache.dubbo.registry.client.metadata.MetadataServiceNameMapping.execute(MetadataServiceNameMapping.java:103)
    at org.apache.dubbo.registry.client.metadata.MetadataServiceNameMapping.getAndListen(MetadataServiceNameMapping.java:79)
    at org.apache.dubbo.registry.client.ServiceDiscoveryRegistry.findMappedServices(ServiceDiscoveryRegistry.java:469)
    at org.apache.dubbo.registry.client.ServiceDiscoveryRegistry.getServices(ServiceDiscoveryRegistry.java:455)
    at org.apache.dubbo.registry.client.ServiceDiscoveryRegistry.doSubscribe(ServiceDiscoveryRegistry.java:230)
    at org.apache.dubbo.registry.client.ServiceDiscoveryRegistry.subscribe(ServiceDiscoveryRegistry.java:220)
    at org.apache.dubbo.registry.ListenerRegistryWrapper.subscribe(ListenerRegistryWrapper.java:106)
    at org.apache.dubbo.registry.integration.DynamicDirectory.subscribe(DynamicDirectory.java:136)
    at org.apache.dubbo.registry.integration.RegistryProtocol.doCreateInvoker(RegistryProtocol.java:514)
    at org.apache.dubbo.registry.integration.RegistryProtocol.getServiceDiscoveryInvoker(RegistryProtocol.java:492)
    at org.apache.dubbo.registry.client.migration.MigrationInvoker.refreshServiceDiscoveryInvoker(MigrationInvoker.java:426)
    at org.apache.dubbo.registry.client.migration.MigrationInvoker.migrateToForceApplicationInvoker(MigrationInvoker.java:203)
    at org.apache.dubbo.registry.client.migration.MigrationRuleHandler.refreshInvoker(MigrationRuleHandler.java:84)
    at org.apache.dubbo.registry.client.migration.MigrationRuleHandler.doMigrate(MigrationRuleHandler.java:44)
    at org.apache.dubbo.registry.client.migration.MigrationRuleListener.onRefer(MigrationRuleListener.java:148)
    at org.apache.dubbo.registry.integration.RegistryProtocol.interceptInvoker(RegistryProtocol.java:485)
    at org.apache.dubbo.registry.integration.RegistryProtocol.doRefer(RegistryProtocol.java:467)
    at org.apache.dubbo.registry.integration.RegistryProtocol.refer(RegistryProtocol.java:452)
    at org.apache.dubbo.rpc.protocol.ProtocolListenerWrapper.refer(ProtocolListenerWrapper.java:74)
    at org.apache.dubbo.rpc.cluster.filter.ProtocolFilterWrapper.refer(ProtocolFilterWrapper.java:68)
    at org.apache.dubbo.qos.protocol.QosProtocolWrapper.refer(QosProtocolWrapper.java:73)
    at org.apache.dubbo.rpc.Protocol$Adaptive.refer(Protocol$Adaptive.java)
    at org.apache.dubbo.config.ReferenceConfig.createProxy(ReferenceConfig.java:392)
    at org.apache.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:328)
    at org.apache.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:205)
    at org.apache.dubbo.config.utils.ReferenceConfigCache.lambda$get$3(ReferenceConfigCache.java:114)
    at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660)
    at org.apache.dubbo.config.utils.ReferenceConfigCache.get(ReferenceConfigCache.java:113)
    at org.apache.dubbo.config.bootstrap.DubboBootstrap.lambda$referServices$8(DubboBootstrap.java:1342)
    at java.util.HashMap$Values.forEach(HashMap.java:981)
    at org.apache.dubbo.config.bootstrap.DubboBootstrap.referServices(DubboBootstrap.java:1321)
    at org.apache.dubbo.config.bootstrap.DubboBootstrap.start(DubboBootstrap.java:1100)
    at org.apache.dubbo.config.spring.context.DubboBootstrapApplicationListener.onContextRefreshedEvent(DubboBootstrapApplicationListener.java:70)
    at org.apache.dubbo.config.spring.context.DubboBootstrapApplicationListener.onApplicationContextEvent(DubboBootstrapApplicationListener.java:63)
    at com.alibaba.spring.context.OnceApplicationContextEventListener.onApplicationEvent(OnceApplicationContextEventListener.java:52)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:393)
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:347)
    at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:883)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546)
    at org.springframework.context.annotation.AnnotationConfigApplicationContext.<init>(AnnotationConfigApplicationContext.java:84)
    at org.apache.dubbo.samples.ConsumerBootstrap.main(ConsumerBootstrap.java:32)
[16/07/21 09:52:26:026 UTC] main  INFO client.ServiceDiscoveryRegistry:  [DUBBO] org.apache.dubbo.samples.api.GreetingService mapping to [] instructed by remote metadata center., dubbo version: 1.0-SNAPSHOT, current host: 10.233.105.83
[16/07/21 09:52:26:026 UTC] main  INFO client.ServiceDiscoveryRegistry:  [DUBBO] org.apache.dubbo.samples.api.GreetingService mapping to [] by default., dubbo version: 1.0-SNAPSHOT, current host: 10.233.105.83
[16/07/21 09:52:26:026 UTC] main  INFO migration.MigrationRuleHandler:  [DUBBO] Succeed Migrated to FORCE_APPLICATION mode. Service Name: org.apache.dubbo.samples.api.GreetingService:1.0.0, dubbo version: 1.0-SNAPSHOT, current host: 10.233.105.83
[16/07/21 09:52:26:026 UTC] main  INFO config.ReferenceConfig:  [DUBBO] Referred dubbo service org.apache.dubbo.samples.api.GreetingService, dubbo version: 1.0-SNAPSHOT, current host: 10.233.105.83
Exception in thread "main" java.lang.IllegalStateException: Failed to check the status of the service org.apache.dubbo.samples.api.GreetingService. No provider available for the service org.apache.dubbo.samples.api.GreetingService:1.0.0 from the url dubbo://10.233.105.83/org.apache.dubbo.samples.api.GreetingService?application=kubernetes-dns-demo-consumer&dubbo=2.0.2&interface=org.apache.dubbo.samples.api.GreetingService&metadata-service-port=20885&methods=sayHello&pid=1&qos.accept.foreign.ip=true&qos.enable=true&register.ip=10.233.105.83&release=1.0-SNAPSHOT&revision=1.0-SNAPSHOT&side=consumer&sticky=false&subscribed-services=kubernetes-dns-demo-provider&timeout=3000&timestamp=1626429146372&version=1.0.0 to the consumer 10.233.105.83 use dubbo version 1.0-SNAPSHOT
    at org.apache.dubbo.config.ReferenceConfig.checkInvokerAvailable(ReferenceConfig.java:463)
    at org.apache.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:338)
    at org.apache.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:205)
    at org.apache.dubbo.config.utils.ReferenceConfigCache.lambda$get$3(ReferenceConfigCache.java:114)
    at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660)
    at org.apache.dubbo.config.utils.ReferenceConfigCache.get(ReferenceConfigCache.java:113)
    at org.apache.dubbo.config.bootstrap.DubboBootstrap.lambda$referServices$8(DubboBootstrap.java:1342)
    at java.util.HashMap$Values.forEach(HashMap.java:981)
    at org.apache.dubbo.config.bootstrap.DubboBootstrap.referServices(DubboBootstrap.java:1321)
    at org.apache.dubbo.config.bootstrap.DubboBootstrap.start(DubboBootstrap.java:1100)
    at org.apache.dubbo.config.spring.context.DubboBootstrapApplicationListener.onContextRefreshedEvent(DubboBootstrapApplicationListener.java:70)
    at org.apache.dubbo.config.spring.context.DubboBootstrapApplicationListener.onApplicationContextEvent(DubboBootstrapApplicationListener.java:63)
    at com.alibaba.spring.context.OnceApplicationContextEventListener.onApplicationEvent(OnceApplicationContextEventListener.java:52)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:393)
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:347)
    at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:883)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546)
    at org.springframework.context.annotation.AnnotationConfigApplicationContext.<init>(AnnotationConfigApplicationContext.java:84)
    at org.apache.dubbo.samples.ConsumerBootstrap.main(ConsumerBootstrap.java:32)
AlbumenJ commented 3 years ago

如果没有单独部署 metadata 元数据中心,需要在服务手动指定 provided-by 属性

shenhuaxx commented 3 years ago

谢谢,已跑通。