Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

k8s pod对接非k8s环境apollo疑问 #4988

Closed
zihan524 opened this issue Oct 8, 2023 · 7 comments
Closed

k8s pod对接非k8s环境apollo疑问 #4988

zihan524 opened this issue Oct 8, 2023 · 7 comments
Labels

Comments

@zihan524
Copy link

zihan524 commented Oct 8, 2023

目前我的apollo部署在虚拟机非k8s环境,那么我的部署在k8s下的应用pod能对接apollo吗?如果能对接apollo,那么在apollo界面实例列表里的貌似只有ip字段,是不是经常会变?

@dosubot
Copy link

dosubot bot commented Oct 8, 2023

🤖

您的Kubernetes(k8s)环境下的应用pod可以对接部署在非k8s环境的Apollo。Apollo通过KubernetesDiscoveryService类处理来自k8s pod的连接。当请求一个服务实例时,Apollo会使用预定义的映射(SERVICE_ID_TO_CONFIG_NAME)来获取请求服务的配置名称。如果找到了请求的服务ID的配置名称,Apollo会从BizConfig对象中检索此配置的值,该值是URL的逗号分隔列表。然后,Apollo为每个URL创建一个ServiceDTO对象,该对象包含服务ID,实例ID(服务ID和URL的组合)和主页URL。最后,Apollo返回这些ServiceDTO对象的列表。如果未找到请求的服务ID的配置名称或配置值为空,Apollo将返回一个空列表。

关于Apollo如何处理实例的IP地址,Apollo通过使用属性文件来处理其配置管理系统中实例的IP地址。在提供的apollo-env.properties文件中,每个环境(local,dev,fat,uat,lpt,pro)都有一个对应的.meta属性,该属性设置为该环境的实例的URL。此URL包括实例的IP地址和端口号。

至于IP地址的变化问题,我找到了一个类似的已解决问题:k8s 集群外部客户端访问,Apollo无法正确记录客户端ip。建议的解决方案是:在访问configservice时向HTTP请求添加'X-FORWARDED-FOR'头。这允许Apollo正确记录客户端IP。

Sources


This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

@nobodyiam
Copy link
Member

我的部署在k8s下的应用pod能对接apollo吗

只要网络通就可以

在apollo界面实例列表里的貌似只有ip字段,是不是经常会变

这个取决于 pod 的生命周期

@zihan524
Copy link
Author

zihan524 commented Oct 8, 2023

我的部署在k8s下的应用pod能对接apollo吗

只要网络通就可以

在apollo界面实例列表里的貌似只有ip字段,是不是经常会变

这个取决于 pod 的生命周期

如果一个宿主机里的多个pod同时访问apollo,pod出去的话如果是宿主机ip的话,那apollo实例里面岂不是可以看到很多相同的ip?那怎么来做灰度呢?

Copy link

stale bot commented Nov 8, 2023

This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 7 days unless it is tagged "help wanted" or other activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Nov 8, 2023
Copy link

stale bot commented Nov 16, 2023

This issue has been automatically closed because it has not had activity in the last 7 days. If this issue is still valid, please ping a maintainer and ask them to label it as "help wanted". Thank you for your contributions.

@stale stale bot closed this as completed Nov 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants