Add Zuul to Netflix OSS installation

304 views Asked by At

I have a netflix oss stack running on a linux box. this stack has Eureka, and a bunch of microservices (hello services) installed, all running in individual docker containers.

It was installed using Maven and Spring Boot.

My question is: How can I add Zuul to this stack? I've found some things on the net but they install Eureka too, and I'm affarid to overwrite the current Eureka if I run this.

2

There are 2 answers

0
gaston On

You need to add the @EnableZuulProxy annotation to the main class

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

and in the application.yml file add the routes with the names of your eureka-microservices

zuul:
   ignoredServices: '*'
   routes:
      microservice1: 
         path: /microservice1/** 
         stripPrefix: false

      microservice2:
         path: /microservice2/**
         stripPrefix: false

      ...
      #If you have hystrix
      hystrix: 
          threadpool:
            default:
               maxQueueSize: 100
               queueSizeRejectionThreshold: 100
          command:      
            default:
             execution:
                 isolation:
                     thread:
                        timeoutInMilliseconds: 60000
     #load balancing
      ribbon:
         MaxAutoRetries: 2 
         MaxAutoRetriesNextServer: 2        
         OkToRetryOnAllOperations: true
         ServerListRefreshInterval: 2000
         ConnectTimeout: 50000
         ReadTimeout: 50000

By default zuul runs on port 8500.

The maven dependency

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-zuul</artifactId>
</dependency>
0
akshaya pandey On
  1. Also, ensure that you use serviceid, for url routing. E.g:

    zuul:
      routes:
        httpbin:
          path: /**
          serviceId: httpbin
    
  2. Zuul should be aware of eureka to be able to fetch the correct ip's for various services which are running.

     ribbon:
       eureka:
        enabled: false
    

The above configuration ensure that you can dynamically add more servers for specific services in future without modifying the zull routing server configuration as it will be able to query and update the servers where specific services are running by querying eureka