Netflix Zuul server - /routes endpoint not available
Asked Answered
M

1

11

In this coding exercise for learning microservices, I've created a Netflix Zuul project for service routing my microservices.

Sadly, the /routes endpoint does not seem to be mounted. Everything else seems to be working fine: Defining prefixes and setting up specific routes for my services.

There are no errors on the zuul server log files. When I try to hit the /routes url on postman, I get an 404 error: Zuul Routes not returning anything

My Zuul application class:

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;

@SpringBootApplication
@EnableZuulProxy
public class ZuulServerApplication {
    public static void main(String[] args) {
        SpringApplication.run(ZuulServerApplication.class, args);
    }
}

pom.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion> <!--should be set to 4.0.0 -->
    <groupId>com.booking.system.hotel</groupId>
    <version>0.0.1-SNAPSHOT</version>
    <artifactId>hotel-gateway-service-server</artifactId>

    <name>Hotel Gateway service - zuul</name>
    <description>Hotel Gateway service - it uses Netflix Zuul Proxy Server</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.5.RELEASE</version>
    </parent>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>Finchley.RELEASE</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>1.8</java.version>
        <start-class>com.booking.system.hotel.zuulsvr.ZuulServerApplication</start-class>
    </properties>
    <dependencies>

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-zuul</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-config</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-config-client</artifactId>
        </dependency>
    </dependencies>

    <build>
    <finalName>hotel-gateway-service-server</finalName> <!--name of the jar -->
        <plugins>
            <!-- packages the project as an executable jar, as an Spring Boot application -->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <!-- used for running tests at various stages -->
        </plugins>
    </build>
</project>

bootstrap.yml file:

spring:
  application:
    name: hotel-gateway-service-server
  profiles:
    active:
      default
  cloud:
    config:
      enabled: true

Zuul configuration file from configuration server:

zuul.ignored-services: "*"
zuul.prefix:  /api
zuul.routes.hotel-reservations-service: /reservations/**
zuul.routes.hotel-rooms-service: /rooms/**

docker-compose.yml entry for initializing the zuul gateway server:

   hotel-gateway-service-server: #zuul server
      image: imageprefix/hotel-gateway-service-server
      ports:
         - 5555:5555
      environment:
         PROFILE: "dev"
         SERVER_PORT: "5555" 
         CONFIGSERVER_URI: "http://hotel-configuration-server:8888"
         CONFIGSERVER_PORT: "8888"
         EUREKASERVER_URI: "http://hotel-service-discovery-server:8761/eureka/"
         EUREKASERVER_PORT: "8761"

I don't seem to spot what I am missing.

Myalgia answered 19/9, 2018 at 9:29 Comment(10)
It seems that the route URL is localhost:5555 and /routes is not defined. Did you try that ?Bary
Thanks, @AarishRamesh. I tried hitting localhost:5555 on postman and I get the same error. The zuul server works fine when I call other webservices via zuul, for example: localhost:5555/api/reservations/v1/hotels/hotel01/reservations/…Myalgia
Could you please try to call private-intmon/routes instead of routes?Astrodynamics
Thanks, @staszko032. I called localhost:5555/private-intmon/routes and I get the same "status": 404, "error": "Not Found" result.Myalgia
I think you are checking at the wrong port. Can you check the edge server default port and check /routes on that ? or can you define server.port=8080 in your bootstrap.yml ?Bary
Thank you, @AarishRamesh. On my src/main/resources/application.yml, I have set the following property server: port: 5555. Also, on my docker-compose.yml file, I have hotel-gateway-service-server: #zuul server image: imageprefix/hotel-gateway-service-server ports: - 5555:5555Myalgia
According to documentation - /routes endpoint comes from actuator so please add: <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency>Astrodynamics
Thank you, @staszko032. I've added the dependency to my pom file. But I still get the same "status": 404, "error": "Not Found" result.Myalgia
Could you please post your zuul configuration (I mean file with routes defined)?Astrodynamics
Thank you, @staszko032. I've updated my post to include configuration file reference and docker compose entry.Myalgia
H
20

The actuator base path has changed to /actuator. So you need to use /actuator/routes. It is also not enabled by default.

management.endpoints.web.exposure.include=*
Heffron answered 19/9, 2018 at 16:41 Comment(3)
Thank you, @spencergibb. I've added that to the config file, on the config repo and it works like a charm. Also, I noticed that when running localhost:5555/actuator there are numerous new URLS. =0)Myalgia
Also, relevant post: #50115001Myalgia
Thank you @spencerbigg. In case someone could need this in YML (as I did): https://mcmap.net/q/298726/-how-to-enable-all-endpoints-in-actuator-spring-boot-2-0-0-rc1Macdonald

© 2022 - 2024 — McMap. All rights reserved.