This is what I am trying to achieve but getting Zuul forwarding error.
Zuul GitHub
UserRegistration Microservice - which will call another Microservice. Also, it has some other APIs'. GitHub Link
UserSearchDelete: above UserRegistration microservice will call this service. GitHub Link
Eureka Server: GitHub Link
If I run the services in Springboot STS at localhost then eveything is working fine.
But if I dockarise all the services and run different containers then I am getting Zuul forrwarding error.
Refer the application.yml files in the Github repos. All the services are getting registered with Eureka.
Could please help? Is it a bug or I am doing something wrong?
GitHub issue reference: https://github.com/spring-cloud/spring-cloud-netflix/issues/3408
Getting the below errors:
"cause": {
"cause": null,
"stackTrace": [
{....
"nStatusCode": 500,
"errorCause": "GENERAL",
"message": "Forwarding error",
"localizedMessage": "Forwarding error",
"suppressed": []
}```
Verify that your Zuul paths are setup properly.
If running on a Docker network, each docker deployment must be connected to the same docker network using the --net myCommonNet tag in the run command. Note that you will have to create this network first. Then you can reference the container hosts on their names.
If you are using kubernetes as your deployment environment, you can access the different microservices using the service name. Then you configure your Zuul's properties.yml as:
zuul:
routes:
myService:
path: /myService/**
url: http://myService.default.svc.cluster.local:8086
Related
I'm trying to deploy a spring boot project to azure using docker containers.
If I do az container logs --name ... --resource-group ... I see
Tomcat started on port(s): 80 (http) with context path ''
az container show --name ... --resource-group ...
"ipAddress": {
"dnsNameLabel": "X",
"dnsNameLabelReusePolicy": "Unsecure",
"fqdn": "X.centralus.azurecontainer.io",
"ip": "Y",
"ports": [
{
"port": 80,
"protocol": "TCP"
}
],
"type": "Public"
},
Now if I go to X.centralus.azurecontainer.io I only see 404 page not found and don't see any request being made in the logs for the spring container (have logs set to debug to see if it serves anything)
On the azure portal it also confirms that my container is in state "Running"
For what reasons does "page not found" show instead of just forwarding to the container on the same port? Anyone know what could be wrong here?
• I would highly recommend you to please refer to the below Microsoft documentation links for troubleshooting common Azure Spring cloud application deployment issues and in general issues faced while deploying an Azure Container Instance. As they are quite helpful in resolving the common issues faced by users regarding Azure Container Instances.
https://learn.microsoft.com/en-us/azure/container-instances/container-instances-troubleshooting
https://learn.microsoft.com/en-us/azure/spring-cloud/troubleshoot
Hi openshift community,
I am currently migrating an app to Openshift and has encountered failed health probes due to connection refused. What I find strange is that if I ssh into the pod and use
curl localhost:10080/xxx-service/info
It returns HTTP 200 but if I use the IP address then it fails with
This is the details:
POD status
Logs in Openshift saying Spring boot started successfully
Openshift events saying probes failed due to connection refused
Tried SSH to pod to check using localhost which works
Not sure why the IP address is not resolving at the POD level.... Does anyone know the answer or have encountered it?
It is hard to say in your case what exactly the issue is, as it is environment specific.
In general, you should avoid using IP addresses when working with Kubernetes, as these will change whenever a Pod is restarted (which may be the root cause for the issue you are seeing).
When defining readiness and liveness probes for your container, I would recommend that you always use the following syntax to define your checks (note that it does not specify the host):
...
readinessProbe:
httpGet:
path: /xxx-service/info
port: 10080
initialDelaySeconds: 15
timeoutSeconds: 1
...
See also the Kubernetes or OpenShift documentation for more information:
https://docs.openshift.com/container-platform/3.11/dev_guide/application_health.html
https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#define-a-liveness-http-request
I found the root cause, it turns out it was Spring related.
It was a Spring Boot app that was being packaged as WAR file and deployed to Tomcat server. In the application.properties, it had this field:
server.address=127.0.0.1
Removing it has fixed this issue.
https://docs.spring.io/spring-boot/docs/current/reference/html/appendix-application-properties.html#common-application-properties-server
I've following services and working fine when they are deployed in localhost (through eclipse). But unable to invoke the rest service when deployed as separate docker containers.
I'm new docker and attended the tutorials to have knowledge on how this works.
Following services are running in separate docker containers and configured as follows (local environment)
Eureka
Docker IP : 172.17.0.3
Docker port mapping : 8761:8761
spring.application.name=naming-server
server.port=8761
Zuul API gate way
Docker IP : 172.17.0.4
Docker port mapping : 8765:8765
spring.application.name=gateway-server
server.port=8765
User service
Docker IP : 172.17.0.5
Docker port mapping : 8101:8101
spring.application.name=user-service
server.port=8101
Registered services info in Eureka
Application AMIs Availability Zones Status
USER-SERVICE n/a (1) (1) UP (1) - de4396a354ea:user-service:8101
API-GATEWAY n/a (1) (1) UP (1) - e5dd509065cd:api-gateway:8765
When tried to invoke the service in "User service" through gateway, it's throwing exception
com.netflix.zuul.exception.ZuulException: Forwarding error
at org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter.handleException(RibbonRoutingFilter.java:198) ~[spring-cloud-netflix-zuul-2.2.0.RELEASE.jar!/:2.2.0.RELEASE]
at org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter.forward(RibbonRoutingFilter.java:173) ~[spring-cloud-netflix-zuul-2.2.0.RELEASE.jar!/:2.2.0.RELEASE]
Caused by: java.net.UnknownHostException: de4396a354ea: Name or service not known
at java.base/java.net.Inet4AddressImpl.lookupAllHostAddr(Native Method) ~[na:na]
at java.base/java.net.InetAddress$PlatformNameService.lookupAllHostAddr(InetAddress.java:929) ~[na:na]
at java.base/java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1515) ~[na:na]
Note: "de4396a354ea" is the container id for "User service"
Please guide on how to resolve this issue and also provide any links where I can get more info regarding deploying microservices in docker containers.
Able to resolve this by adding "eureka.instance.hostname=" property.
I want to deploy my spring boot app in a docker component to gcp App Engine
When I run the docker componet local I get access to the web site.
When I deploy the component to the gcp app engine with the command gcloud app deploy
I get a http error 502 Bad Gateway nginx
The Docker file look like this
FROM adoptopenjdk/openjdk14
MAINTAINER steinko
VOLUME /tmp
COPY build/libs/atm.jar ./
ENTRYPOINT ["java"]
CMD ["-jar", "/atm.jar"]
EXPOSE 4001
The app.yaml files looks like this
runtime: custom
env: flex
handlers:
- url: /.*
script: this field is required, but ignored
service: atm
How do I fix this error?
According to this document: The App Engine front end will route incoming requests to the appropriate module on port 8080. You must be sure that your application code is listening on 8080. Also, it looks like the FROM should be one of Google's base image, also in that document.
I'm trying to build sample microservice app using this tutorial Tutorial. jhipster v5.2.1 So I've created a gateway and an armory started consul using this command:
docker-compose -f src/main/docker/consul.yml up
While I've pointed into the armory folder writing this command :
./gradlew
I got this error :
2018-09-03 13:20:11.235 WARN 7224 --- [ restartedMain] o.s.c.c.c.ConsulPropertySourceLocator : Unable to load consul config from config/armory-swagger/
com.ecwid.consul.transport.TransportException: org.apache.http.conn.HttpHostConnectException: Connect to localhost:8600 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect
Could you please help me
If you are using the toolbox you have to replace localhost by the IP of your Docker machine vm. You will have to ajust the bootstrap.yml properties to point to this adress.
You should also be able to apply this trick : https://www.jhipster.tech/tips/020_tip_using_docker_containers_as_localhost_on_mac_and_windows.html
I just changed fail-fast to false in bootstrap-prod.yml
You can disable Spring Cloud Config this way.
fail-fast: false
Otherwise you have to provide proper configuration as stated above.
Or you can run this command if you have already installed consul on your development machine.
consul agent -dev