EKS pod无法通过clusterip或nodeport与其他服务通信



我在eks中有服务(pod(,即"abc";,其需要与同一集群中的另一个名为"pod"的pod通信;活动";。

我们已经配置了一个clusterip服务来介于两者之间。

当尝试从abc的pod连接到应用程序时,它通过集群ip服务工作。

root@abc-5d8d95fb44-5w7ff:/# curl --location --request GET 'http://clusterip-service:8080/internal/xml/ping'
"message" : "PING OK from Internal"

但当从外部尝试时

curl --location --request GET 'https://domain/service/abc/ping?debug=true&activity=Internal' 
{"errorCode":"","errorMessage":""}%

并且得到一个错误

org.springframework.web.client.HttpServerErrorException: 503 Service Unavailable
at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:94)
at org.springframework.web.client.RestTemplate.handleResponse(RestTemplate.java:700)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:653)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:613)
at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:531)
at com..campaign.controller.PingController.pingActivityInternal(PingController.java:179)
at com.campaign.controller.PingController.handlePing(PingController.java:104)

java代码是

public ResponseEntity<Map> handlePing(@RequestParam(required = false) String debug,
@RequestParam(value = "activity", required = false, defaultValue = "No") String activity) throws UnknownHostException {
logger.debug("Processing ping request...");
final HashMap<String, String> ping = new HashMap<>();
logger.info("Starting Ping debugging Activityping Debug[{}]",debug);
logger.info("Starting Ping debugging Activity activity[{}]",activity);
if (activity.equalsIgnoreCase("Yes")) {
pingActivity();
ping.put("message", "PING OK from Activity..");
}else if (activity.equalsIgnoreCase("Internal")) {
pingActivityInternal();
ping.put("message", "PING OK from Activity Internal..");

该函数称为

public static void pingActivityInternal() {
try {
logger.info("Starting Ping Internal Activity");
final String activityUrl = "http://clusterip-service:8080/internal/xml/ping";
RestTemplate restTemplate = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));

您需要从外部公开服务,请参阅此处的示例。

最新更新