Closed Holinc19 closed 3 months ago
我的环境是这样的,使用EasyConnect VPN连接公司内网,可以正常启动本地服务,但是API请求会路由不到本地。这里我估计是因为EasyConnenct VPN是单向的。
所以,我这个场景能用kubeVPN路由到本地调试吗
运行
kubevpn connect
命令输出的是一下信息,请问下在哪里能看到环境变量信息呢。和这个文档的输出内容不一样https://www.kubevpn.cn/docs/blog/connect_mode/Starting connect Got network CIDR from cache Use exist traffic manager Forwarding port... Connected tunnel Adding route... Configured DNS service +----------------------------------------------------------+ | Now you can access resources in the kubernetes cluster ! | +----------------------------------------------------------+
直接在pod中执行env命令获取环境变量 例如:
# 获取运行时依赖的环境变量
export KUBECONFIG=/var/folders/30/cmv9c_5j3mq_kthx63sb1t5c0000gn/T/342259381.kubeconfig
kubectl exec -it deployment/ry-server -n vke-system -c server -- env | pbcopy
我的环境是这样的,使用EasyConnect VPN连接公司内网,可以正常启动本地服务,但是API请求会路由不到本地。这里我估计是因为EasyConnenct VPN是单向的。
所以,我这个场景能用kubeVPN路由到本地调试吗
可以使用kubevpn本地调试的哈
你看看直接在本地使用 datagrip 是否可以链接到mysql尼,直接链接 mysql pod或者service的ip就行。
On Aug 18, 2024, at 22:22, Holinc19 @.***> wrote:
了IP环境变量访问
需要指定什么IP信息吗,比如:spring.cloud.inetutils.preferred-networks
现在本地IDEA服务启动了,但是呢,还是路由不进来。查看了一下注册中心上的服务,发现用的是本地电脑WiFi的IP,这个应该再网络上就是不通的吧
{
"failed": true,
"code": "error.unknownGatewayError",
"message": "connection timed out: /192.168.19.1:9140",
"type": "UNKNOWN_GATEWAY_ERROR",
"detailsMessage": "服务发生未知错误,请稍后再试"
}
或者可以直接进腾讯会议,我帮你看看?https://meeting.tencent.com/dm/ejqz2CaDQqbN
On Aug 18, 2024, at 22:22, Holinc19 @.***> wrote:
我的环境是这样的,使用EasyConnect VPN连接公司内网,可以正常启动本地服务,但是API请求会路由不到本地。这里我估计是因为EasyConnenct VPN是单向的。 所以,我这个场景能用kubeVPN路由到本地调试吗
可以使用kubevpn本地调试的哈
配置了vpn输出的环境变量以后,发现一个问题,服务启动以后会报错MySQL、Redis连接不上了,这种情况是要怎么处理呢。
MySQL、Redis是再开发环境上搭建的,配置了IP环境变量访问
com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. at com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:174) at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:64) at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:835) at com.mysql.cj.jdbc.ConnectionImpl.
(ConnectionImpl.java:455) at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:240) at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:199) at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138) at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:364) at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:206) at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:476) at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561) at com.zaxxer.hikari.pool.HikariPool. (HikariPool.java:115) at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112) at io.choerodon.mybatis.MybatisMapperAutoConfiguration.dialect(MybatisMapperAutoConfiguration.java:307) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653) at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:638) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:955) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:920) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:780) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:453) at org.springframework.boot.SpringApplication.run(SpringApplication.java:343) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1370) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1359) at org.o2.customer.management.O2CustomerManagementApplication.main(O2CustomerManagementApplication.java:21) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:65) Caused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failure — Reply to this email directly, view it on GitHub https://github.com/kubenetworks/kubevpn/issues/321#issuecomment-2295281178, or unsubscribe https://github.com/notifications/unsubscribe-auth/AICAMAYYL5PLKAQJVD6MHO3ZSCU3DAVCNFSM6AAAAABMWAG55GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOJVGI4DCMJXHA. You are receiving this because you commented.
非常感谢大佬的详细解答👍
需要指定什么IP信息吗,比如:spring.cloud.inetutils.preferred-networks
现在本地IDEA服务启动了,但是呢,还是路由不进来。查看了一下注册中心上的服务,发现用的是本地电脑WiFi的IP,这个应该再网络上就是不通的吧
{ "failed": true, "code": "error.unknownGatewayError", "message": "connection timed out: /192.168.19.1:9140", "type": "UNKNOWN_GATEWAY_ERROR", "detailsMessage": "服务发生未知错误,请稍后再试" }
使用 proxy
模式,可实现K8S与本地网络互通,实现本地调试,配合--headers
参数,可实现带指定请求头参数的流量打到本地服务。与connect
模式不同的是,connect
模式是本地单向访问K8S
运行
kubevpn connect
命令输出的是一下信息,请问下在哪里能看到环境变量信息呢。和这个文档的输出内容不一样https://www.kubevpn.cn/docs/blog/connect_mode/