dubbo
dubbo copied to clipboard
发现一个很奇怪的问题,dubbo部署到k8s后给pod创建service提示Failed to bind properties under 'dubbo.providers.port' to org.apache.dubbo.config.ProviderConfig:
我用的dubbo3.0.5,使用的springboot和dubbo-spring-boot-starter搭建的dubbo服务,我打包成镜像,放到k8s中运行正常,当我给这个pod创建service后,重启一下pod就提示: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'dubbo-org.apache.dubbo.spring.boot.autoconfigure.DubboConfigurationProperties': Could not bind properties to 'DubboConfigurationProperties' : prefix=dubbo, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'dubbo.providers.port' to org.apache.dubbo.config.ProviderConfig
2022-01-24 13:55:18.845 INFO 1 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2022-01-24 13:55:18.858 INFO 1 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-01-24 13:55:18.878 ERROR 1 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
APPLICATION FAILED TO START
Description:
Failed to bind properties under 'dubbo.providers.port' to org.apache.dubbo.config.ProviderConfig:
Reason: org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.lang.String] to type [org.apache.dubbo.config.ProviderConfig]
Action:
Update your application's configuration
当我删除掉service之后重启pod又正常,再创建service后又重启又报错,心想:service和dubbo是有什么联系吗?
配置文件如下 server.port=8081
dubbo.application.name=dubbo-providers dubbo.protocol.port=20880 dubbo.protocol.name=dubbo dubbo.registry.address=zookeeper://10.233.23.209:2181
进入 pod 里面看一下 env 你就知道了,dubbo 用 K8S 做注册中心的话, 默认是靠DNS完成的, 你的pod没有禁用环境变量,创建的时候就会添加环境变量 DUBBO_xxx, 这里报错是因为 DUBBO_PROVIDER_PORT=tcp://x.x.x.x:8080, 但是 DUBBO 用到了这个东西, 虽然已经标记过期, 如果你熟悉dubbo2的话,你就知道配置 dubbo.provider.port=-1; 参考一下这个链接禁用就行了 https://kubernetes.io/zh-cn/docs/concepts/services-networking/connect-applications-service/
请问最终如何解决的?