Ошибка при запуске localstack в kubernetes ⇐ JAVA
-
Anonymous
Ошибка при запуске localstack в kubernetes
I've installed localstack using Helm:
https://artifacthub.io/packages/helm/lo ... localstack
The localstack chart was installed in its own localstack namespace, and I saw no errors in the localstack pod logs. In a different namespace I have a Spring Boot app (version 3.2.1), that needs to communicate with SQS in localstack. Here's the Sqs service:
package com.myapp.gateway.common; import com.myapp.gateway.config.ConfigProperties; import org.springframework.stereotype.Service; import software.amazon.awssdk.services.sqs.SqsClient; import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.sqs.model.ListQueuesRequest; import software.amazon.awssdk.services.sqs.model.ListQueuesResponse; import software.amazon.awssdk.services.sqs.model.SqsException; import java.net.URI; @Service public class SqsService { private final SqsClient sqsClient; private final ConfigProperties configProperties; public SqsService(ConfigProperties configProperties) { this.configProperties = configProperties; this.sqsClient = SqsClient.builder() .endpointOverride(URI.create("http://localstack.localstack.svc.cluster.local")) .region(Region.of(configProperties.awsRegion())) .build(); } public void listQueues() { System.out.println("\nList Queues:"); try { ListQueuesRequest listQueuesRequest = ListQueuesRequest.builder().build(); ListQueuesResponse listQueuesResponse = sqsClient.listQueues(listQueuesRequest); for (String url : listQueuesResponse.queueUrls()) { System.out.println("Queue url: " + url); } } catch (SqsException e) { System.err.println( "SqsException: " + "getMessage: " + e.getMessage() + " | sdkHttpResponse.statusCode: " + e.awsErrorDetails().sdkHttpResponse().statusCode() + " | sdkHttpResponse.statusText: " + e.awsErrorDetails().sdkHttpResponse().statusText() ); } } } As you see, I'm using the localstack service FQDN, but my service logs show the following:
List Queues: SqsException: getMessage: Service returned HTTP status code 403 (Service: Sqs, Status Code: 403, Request ID: null) | sdkHttpResponse.statusCode: 403 | sdkHttpResponse.statusText: Optional[connecting to localstack.localstack.svc.cluster.local:80: resolving host localstack.localstack.svc.cluster.local: lookup localstack.localstack.svc.cluster.local: no such host] It is not clear why this is happening, because when I kubectl exec into my service container and run:
nc -zv localstack.localstack.svc.cluster.local 80 I get:
localstack.localstack.svc.cluster.local (10.104.143.32:80) open Port 4566 is also open but it doesn't work either. What is the correct endpoint URL?
Источник: https://stackoverflow.com/questions/780 ... kubernetes
I've installed localstack using Helm:
https://artifacthub.io/packages/helm/lo ... localstack
The localstack chart was installed in its own localstack namespace, and I saw no errors in the localstack pod logs. In a different namespace I have a Spring Boot app (version 3.2.1), that needs to communicate with SQS in localstack. Here's the Sqs service:
package com.myapp.gateway.common; import com.myapp.gateway.config.ConfigProperties; import org.springframework.stereotype.Service; import software.amazon.awssdk.services.sqs.SqsClient; import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.sqs.model.ListQueuesRequest; import software.amazon.awssdk.services.sqs.model.ListQueuesResponse; import software.amazon.awssdk.services.sqs.model.SqsException; import java.net.URI; @Service public class SqsService { private final SqsClient sqsClient; private final ConfigProperties configProperties; public SqsService(ConfigProperties configProperties) { this.configProperties = configProperties; this.sqsClient = SqsClient.builder() .endpointOverride(URI.create("http://localstack.localstack.svc.cluster.local")) .region(Region.of(configProperties.awsRegion())) .build(); } public void listQueues() { System.out.println("\nList Queues:"); try { ListQueuesRequest listQueuesRequest = ListQueuesRequest.builder().build(); ListQueuesResponse listQueuesResponse = sqsClient.listQueues(listQueuesRequest); for (String url : listQueuesResponse.queueUrls()) { System.out.println("Queue url: " + url); } } catch (SqsException e) { System.err.println( "SqsException: " + "getMessage: " + e.getMessage() + " | sdkHttpResponse.statusCode: " + e.awsErrorDetails().sdkHttpResponse().statusCode() + " | sdkHttpResponse.statusText: " + e.awsErrorDetails().sdkHttpResponse().statusText() ); } } } As you see, I'm using the localstack service FQDN, but my service logs show the following:
List Queues: SqsException: getMessage: Service returned HTTP status code 403 (Service: Sqs, Status Code: 403, Request ID: null) | sdkHttpResponse.statusCode: 403 | sdkHttpResponse.statusText: Optional[connecting to localstack.localstack.svc.cluster.local:80: resolving host localstack.localstack.svc.cluster.local: lookup localstack.localstack.svc.cluster.local: no such host] It is not clear why this is happening, because when I kubectl exec into my service container and run:
nc -zv localstack.localstack.svc.cluster.local 80 I get:
localstack.localstack.svc.cluster.local (10.104.143.32:80) open Port 4566 is also open but it doesn't work either. What is the correct endpoint URL?
Источник: https://stackoverflow.com/questions/780 ... kubernetes
Мобильная версия