Skip to content

Eureka Integration

joesondow edited this page Nov 13, 2012 · 6 revisions

Eureka Integration

What is Eureka?

Eureka is Netflix's open source AWS service registry for resilient mid-tier load balancing and failover. For inter-instance discovery within the cloud, Eureka can take the place of a DNS-like service. If you choose to adopt both the Eureka and Asgard components of the Netflix Cloud Platform, this document will help you configure the two applications to work together harmoniously, giving you more power over your cloud account, including:

  • Knowing what apps are running where
  • Knowing which instances are healthy
  • Knowing whether a cloud deployment was successful
  • Turning inter-instance mid-tier traffic on and off

Set up Eureka

To set up Eureka instances, see the Eureka Wiki at https://github.com/Netflix/eureka/wiki

Get a canonical Eureka DNS name per AWS region

For each Amazon region where you use Eureka, use a regular DNS service to register a CNAME for your collection of Eureka instances. For example, let's say you work at Big Acme Anvils and have Eureka running in Amazon's region in Dublin, Ireland. You could set up http://eureka-euwest1.bigacmeanvils.com to point to those Eureka instances using in a round-robin fashion.

Add Eureka to your ~/.asgard/Config.groovy file

On your Asgard server(s) there is a configuration file at ~/.asgard/Config.groovy that allows you to use external dependencies such as Eureka. Edit this Groovy file. (Groovy is an alternative JVM language similar to Java.)

Add this line at the top of the file:

import com.netflix.asgard.Region

Next, add a block of configuration code like the following near the bottom of Config.groovy. Specify the regions and CNAMEs where you have Eureka running.

eureka {
    regionsToServers = [
        (Region.US_EAST_1): 'eureka-useast1.bigacmeanvils.com',
        (Region.US_WEST_1): 'eureka-uswest1.bigacmeanvils.com',
        (Region.US_WEST_2): 'eureka-uswest2.bigacmeanvils.com',
        (Region.EU_WEST_1): 'eureka-euwest1.bigacmeanvils.com',
    ]
}

Restart and test Asgard

Restart the web server to pick up the configuration change. If the configuration change worked, then:

  • The bottom of the Asgard home page should show links to your Eureka GUI and REST endpoint URLs.
  • Every Auto Scaling Group detail screen that has an instance sub-list should have "Eureka" and "Health" columns, as well as a "Run All Health Checks" button.
  • The EC2 instance list should have a new "Application" column. This is only populated for instances that correctly register their app names with Eureka.
  • The ASG "Rolling Push" form and the Cluster screen's "Create Next Group" form should both include a checkbox to "Wait for Eureka health check pass".

Instances app names and health check URLs

In order to ensure tooling support, check that your instances are conforming to the expected model of the Netflix Cloud Platform. Each instance should report itself to Eureka as an instance of a single application name, which should match the application registered in Asgard and used to construct the name of the Auto Scaling Group that owns the instance.

Each instance should also provide a health check URL that Asgard can call repeatedly to determine whether the instance is yet ready for traffic. That health check URL should be reported to Eureka as instance metadata so that Asgard can determine the health check URL of every instance.

In your the application.properties file on each instance, configure the app name and the health check URL like this example:

#Name of the application to be identified by other services
eureka.name=sampleservice

#Formula for constructing the URL other tools should use to check the instance's health
eureka.healthCheckUrl=http://${eureka.hostname}:8001/healthcheck

Other ways of setting the health check to be secure and/or relative URLs are explained on the Eureka wiki: https://github.com/Netflix/eureka/wiki/Integrating-Eureka-and-Asgard

An example properties file for configuring a health check URL in a Eureka client app: https://github.com/Netflix/eureka/blob/master/eureka-server/conf/sampleservice/sample-eureka-service.properties

Profit!

Now that Eureka, Asgard, and your instances are configured to work together, your deployments can include the step of waiting for instance health according to your own custom logic.

Cluster detail screen

  • Collates instance counts based on similar state in Eureka, ELBs, and EC2.
  • The Disable button sets all of an ASG's instances to "OUT_OF_SERVICE" in Eureka, in addition to deregistering the instances from ELBs connected to the ASG.
  • The Enable button sets all of an ASG's instances to "UP" in Eureka, in addition to registering the instances with ELBs connected to the ASG.

ASG detail screen

  • Shows health check results for all instances. If fewer than 20 instances, health checks run on page load. If 20 instances or more, the user must click the "Run all health checks" button to see health results.
  • Shows Eureka status for each instance, such as "UP" if the instance is set to receive traffic from other Eureka clients, "OUT_OF_SERVICE" if traffic to the instance is disabled, or "Not found" if the instance has failed to register with Eureka.
  • Controls to select instances and do batch operations on them such as Disable or Enable traffic to the instances in Eureka.

Instance detail screen

  • Shows instance metadata reported by the Eureka client to the Eureka server.
  • Controls to Disable to Enable traffic to the instance in Eureka.
  • Current health check result.
  • Current Eureka status.