Support mutual requests for pods under different namespaces
Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Describe the solution you'd like We hope a solution what can make mutual requests for pods under different namespaces,At present, pods access under the same namespace can only be realized based on ribbon or other LB client.
Describe alternatives you've considered In class KubernetesServicesServerList or KubernetesEndpointsServerList, Can you provide a solution for all namespaces but not the default namespace of the current pod.
Additional context Add any other context or screenshots about the feature request here.
I can not make any sense of the issue or feature you are trying to reason about here. We do not have any classes called KubernetesServicesServerList or KubernetesEndpointsServerList. So, can you please explain exactly what your point is? Thank you.
@wind57 org.springframework.cloud.kubernetes.ribbon.KubernetesEndpointsServerList not in this code or other of yours?
In my project,I use the dependencies like this:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-kubernetes-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-kubernetes-discovery</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-kubernetes-ribbon</artifactId>
</dependency>
if I set spring.cloud.kubernetes.ribbon.mode=POD, print the logs like these when I request B project from A.
2021-11-10 01:24:28.590:88 [PollingServerListUpdater-1] WARN org.springframework.cloud.kubernetes.ribbon.KubernetesEndpointsServerList -Did not find any endpoints in ribbon in namespace [system-server] for name [kube-dns] and portName [null]
2021-11-10 01:24:29.605:88 [PollingServerListUpdater-1] WARN org.springframework.cloud.kubernetes.ribbon.KubernetesEndpointsServerList -Did not find any endpoints in ribbon in namespace [system-server] for name [kube-dns] and portName [null]
2021-11-10 01:24:58.592:88 [PollingServerListUpdater-1] WARN org.springframework.cloud.kubernetes.ribbon.KubernetesEndpointsServerList -Did not find any endpoints in ribbon in namespace [system-server] for name [kube-dns] and portName [null]
2021-11-10 01:24:59.608:88 [PollingServerListUpdater-1] WARN org.springframework.cloud.kubernetes.ribbon.KubernetesEndpointsServerList -Did not find any endpoints in ribbon in namespace [system-server] for name [kube-dns] and portName [null]
2021-11-10 01:28:28.609:88 [PollingServerListUpdater-1] WARN org.springframework.cloud.kubernetes.ribbon.KubernetesEndpointsServerList -Did not find any endpoints in ribbon in namespace [system-server] for name [kube-dns] and portName [null]
2021-11-10 01:28:29.630:88 [PollingServerListUpdater-1] WARN org.springframework.cloud.kubernetes.ribbon.KubernetesEndpointsServerList -Did not find any endpoints in ribbon in namespace [system-server] for name [kube-dns] and portName [null]
2021-11-10 01:28:58.612:88 [PollingServerListUpdater-1] WARN org.springframework.cloud.kubernetes.ribbon.KubernetesEndpointsServerList -Did not find any endpoints in ribbon in namespace [system-server] for name [kube-dns] and portName [null]
2021-11-10 01:28:59.632:88 [PollingServerListUpdater-1] WARN org.springframework.cloud.kubernetes.ribbon.KubernetesEndpointsServerList -Did not find any endpoints in ribbon in namespace [system-server] for name [kube-dns] and portName [null]
or spring.cloud.kubernetes.ribbon.mode=SERVICE, the logs:
org.springframework.cloud.kubernetes.ribbon.KubernetesServicesServerList -Did not find any services in ribbon in namespace [system-server] for name [kube-dns] and portName [null]
I think you should look here. That dependency was removed and we do not have it in our dependencies anymore. I am talking about spring-cloud-starter-kubernetes-ribbon, just in case.
@wind57 All in all, I have a question: Does it support accessing pods across namespaces? spring-cloud-kubernetes. In the native k8s, support like this:
$(service name).$(namespace).svc.cluster.local
We don't want to use this method. We hope you can provide like this http://${serviceName} access to other pods access to other namespaces. Because, you support find Services from all namespaces or all of the cluster like this: spring.cloud.kubernetes.discovery.all-namespaces=true
To be honest, I do not understand your question. I think the correct way to handle this is:
- you close this issue, since it seems there is not much we can do here
- ask a separate question and please be specific.
You say:
Does it support accessing pods across namespaces?
Which I do not understand, but then you show $(service name).$(namespace).svc.cluster.local that is a service thing, not pods at all. So, if you want to get a clear answer, please ask a clear question. Thank you.
I think you should look here. That dependency was removed and we do not have it in our dependencies anymore. I am talking about
spring-cloud-starter-kubernetes-ribbon, just in case.
@wind57 This can not answer my questions. How to solve mutual requests for pods under different namespaces.
@wind57
First, the solution of spring-cloud-kubernetes, access to pods from services in k8s.
second, we hope you can provide a solution for access to pods for the other namespace. because our applications maybe not In the same namespace. For example:
ns-app diff-ns-service-deployment-d88b9c4fd-m26t8 1/1 Running 0 6d
system-server cas-server-deployment-7c84d467f5-4qq6f 1/1 Running 0 7d18h
system-server cas-server-deployment-7c84d467f5-wjkkw 1/1 Running 0 7d18h
system-server gateway-service-deployment-766b6747bf-w5twt 1/1 Running 0 5d23h
system-server rest-service-deployment-cc7c5b559-kkf7f 1/1 Running 0 4d16h
system-server rest-service-deployment-cc7c5b559-wnsvt 1/1 Running 0 4d16h
diff-ns-service want to access the app named rest-service, but it in the namespace of system-server, not in namespace named ns-app.
In this issue, Did I can understand the case without solution by Hoxton-SR12 or SR* in spring-cloud-kubernetes?
@spencergibb how can I solve the cases: mutual requests for pods under different namespaces? does only base on spring-cloud-starter-kubernetes-loadbalancer,not base on spring-cloud-starter-kubernetes-ribbon,because I found something: when I use spring-cloud-starter-kubernetes-ribbon, I try A to access to B what it is not with same namespace by A.I saw the logs:
2021-11-10 01:28:59.632:88 [PollingServerListUpdater-1] WARN org.springframework.cloud.kubernetes.ribbon.KubernetesEndpointsServerList -Did not find any endpoints in ribbon in namespace [default] for name [b-svc] and portName [null]
case like this:
namespace pods svc
default A-deployment-*** a-svc
system-server B-deployment-*** b-svc
code like this:
@LoadBalanced
@Bean
public RestTemplate restTemplate() {
RestTemplate rt = new RestTemplate();
return rt;
}
@Autowired
private RestTemplate restTemplate;
...
ResponseEntity<String> responseEntity = restTemplate.exchange("http://b-svc/api/***",
HttpMethod.GET, formEntity, String.class);
...
@spencergibb how can I solve the cases: mutual requests for pods under different namespaces? does only base on
spring-cloud-starter-kubernetes-loadbalancer,not base onspring-cloud-starter-kubernetes-ribbon,because I found something: when I usespring-cloud-starter-kubernetes-ribbon, I try A to access to B what it is not with same namespace by A.I saw the logs:2021-11-12 09:08:31.226:89 [http-nio2-2001-exec-2] WARN org.springframework.cloud.kubernetes.ribbon.KubernetesServicesServerList -Did not find any service in ribbon in namespace [default] for name [b-svc] and portName [null]case like this:
namespace pods svc default A-deployment-*** a-svc system-server B-deployment-*** b-svccode like this:
@LoadBalanced @Bean public RestTemplate restTemplate() { RestTemplate rt = new RestTemplate(); return rt; } @Autowired private RestTemplate restTemplate; ... ResponseEntity<String> responseEntity = restTemplate.exchange("http://b-svc/api/***", HttpMethod.GET, formEntity, String.class); ...
All in all,Base on spring-cloud-starter-kubernetes-ribbon, I can not access to B from A in k8s cluster, but only base on spring-cloud-starter-kubernetes-loadbalancer, I can do it.
@spencergibb I hope to have an official answer.
@spencergibb
If base on spring-cloud-starter-kubernetes-loadbalancer, not Ribbon. How can I realize retries in applications?
I suggest you use Spring Cloud Loadbalancer and set spring.cloud.kubernetes.discovery.all-namespaces=true. The DiscoveryClient will then return services across all namespaces and the LoadBalancer will load balance between them.