Eureka Server Discovery Service
Eureka is a REST-based service that is primarily used for locating services for the purpose of load balancing and failover of middle-tier servers. Eureka provides both a discovery server and also support for clients which would be the individual CAS servers themselves in the pool. The server can be configured and deployed to be highly available, with each server replicating state about the registered services to the others.
CAS provides a Eureka-enabled service discovery server that is based on Spring Cloud Netflix and bootstrapped via Spring Cloud.
Installation
The Eureka discovery server is not part of the CAS server and is a standalone web application which can be deployed using the CAS Initializr.
You may also ook for a suitable and relevant ready-made Docker image via docker search eureka
.
When deployed the following URLs become available:
URL | Description |
---|---|
/ |
Home page listing service registrations. |
/eureka/apps |
Raw registration metadata. |
High Availability Mode
You always want to make sure the discovery server is run in high-availability mode. One option is to ensure each individual Eureka server is peer aware. See this guide to learn how to manage that.
CAS Discovery Service Clients
Each individual CAS server is given the ability to auto-register itself with the discovery server, provided configuration is made available to instruct the CAS server how to locate and connect to the discover server service.
Support is added by including the following dependency in the WAR overlay:
1
2
3
4
5
<dependency>
<groupId>org.apereo.cas</groupId>
<artifactId>cas-server-support-eureka-client</artifactId>
<version>${cas.version}</version>
</dependency>
1
implementation "org.apereo.cas:cas-server-support-eureka-client:${project.'cas.version'}"
1
2
3
4
5
6
7
8
9
dependencyManagement {
imports {
mavenBom "org.apereo.cas:cas-server-support-bom:${project.'cas.version'}"
}
}
dependencies {
implementation "org.apereo.cas:cas-server-support-eureka-client"
}
1
2
3
4
5
6
7
8
9
10
dependencies {
/*
The following platform references should be included automatically and are listed here for reference only.
implementation enforcedPlatform("org.apereo.cas:cas-server-support-bom:${project.'cas.version'}")
implementation platform(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES)
*/
implementation "org.apereo.cas:cas-server-support-eureka-client"
}
The following settings and properties are available from the CAS configuration catalog:
eureka.client.allow-redirects=false
Indicates whether server can redirect a client request to a backup server/cluster. If set to false, the server will handle the request directly, If set to true, it may send HTTP redirect to the client, with a new server location.
|
eureka.client.availability-zones=
Gets the list of availability zones (used in AWS data centers) for the region in which this instance resides. The changes are effective at runtime at the next registry fetch cycle as specified by registryFetchIntervalSeconds.
|
eureka.client.backup-registry-impl=
Gets the name of the implementation which implements BackupRegistry to fetch the registry information as a fall back option for only the first time when the eureka client starts. This may be needed for applications which needs additional resiliency for registry information without which it cannot operate.
|
eureka.client.cache-refresh-executor-exponential-back-off-bound=10
Cache refresh executor exponential back off related property. It is a maximum multiplier value for retry delay, in case where a sequence of timeouts occurred.
|
eureka.client.cache-refresh-executor-thread-pool-size=2
The thread pool size for the cacheRefreshExecutor to initialise with.
|
eureka.client.client-data-accept=
EurekaAccept name for client data accept.
|
eureka.client.decoder-name=
This is a transient config and once the latest codecs are stable, can be removed (as there will only be one).
|
eureka.client.disable-delta=false
Indicates whether the eureka client should disable fetching of delta and should rather resort to getting the full registry information. Note that the delta fetches can reduce the traffic tremendously, because the rate of change with the eureka server is normally much lower than the rate of fetches. The changes are effective at runtime at the next registry fetch cycle as specified by registryFetchIntervalSeconds
|
eureka.client.dollar-replacement=_-
Get a replacement string for Dollar sign
|
eureka.client.enabled=true
Flag to indicate that the Eureka client is enabled.
|
eureka.client.encoder-name=
This is a transient config and once the latest codecs are stable, can be removed (as there will only be one).
|
eureka.client.escape-char-replacement=__
Get a replacement string for underscore sign
|
eureka.client.eureka-connection-idle-timeout-seconds=30
Indicates how much time (in seconds) that the HTTP connections to eureka server can stay idle before it can be closed. In the AWS environment, it is recommended that the values is 30 seconds or less, since the firewall cleans up the connection information after a few mins leaving the connection hanging in limbo.
|
eureka.client.eureka-server-connect-timeout-seconds=5
Indicates how long to wait (in seconds) before a connection to eureka server needs to timeout. Note that the connections in the client are pooled by org.apache.http.client.HttpClient and this setting affects the actual connection creation and also the wait time to get the connection from the pool.
|
eureka.client.eureka-server-d-n-s-name=
Gets the DNS name to be queried to get the list of eureka servers.This information is not required if the contract returns the service urls by implementing serviceUrls. The DNS mechanism is used when useDnsForFetchingServiceUrls is set to true and the eureka client expects the DNS to configured a certain way so that it can fetch changing eureka servers dynamically. The changes are effective at runtime.
|
eureka.client.eureka-server-port=
Gets the port to be used to construct the service url to contact eureka server when the list of eureka servers come from the DNS.This information is not required if the contract returns the service urls eurekaServerServiceUrls(String). The DNS mechanism is used when useDnsForFetchingServiceUrls is set to true and the eureka client expects the DNS to configured a certain way so that it can fetch changing eureka servers dynamically. The changes are effective at runtime.
|
eureka.client.eureka-server-read-timeout-seconds=8
Indicates how long to wait (in seconds) before a read from eureka server needs to timeout.
|
eureka.client.eureka-server-total-connections=200
Gets the total number of connections that is allowed from eureka client to all eureka servers.
|
eureka.client.eureka-server-total-connections-per-host=50
Gets the total number of connections that is allowed from eureka client to a eureka server host.
|
eureka.client.eureka-server-u-r-l-context=
Gets the URL context to be used to construct the service url to contact eureka server when the list of eureka servers come from the DNS. This information is not required if the contract returns the service urls from eurekaServerServiceUrls. The DNS mechanism is used when useDnsForFetchingServiceUrls is set to true and the eureka client expects the DNS to configured a certain way so that it can fetch changing eureka servers dynamically. The changes are effective at runtime.
|
eureka.client.eureka-service-url-poll-interval-seconds=0
Indicates how often(in seconds) to poll for changes to eureka server information. Eureka servers could be added or removed and this setting controls how soon the eureka clients should know about it.
|
eureka.client.fetch-registry=true
Indicates whether this client should fetch eureka registry information from eureka server.
|
eureka.client.fetch-remote-regions-registry=
Comma separated list of regions for which the eureka registry information will be fetched. It is mandatory to define the availability zones for each of these regions as returned by availabilityZones. Failing to do so, will result in failure of discovery client startup.
|
eureka.client.filter-only-up-instances=true
Indicates whether to get the applications after filtering the applications for instances with only InstanceStatus UP states.
|
eureka.client.g-zip-content=true
Indicates whether the content fetched from eureka server has to be compressed whenever it is supported by the server. The registry information from the eureka server is compressed for optimum network traffic.
|
eureka.client.healthcheck.enabled=true
|
eureka.client.heartbeat-executor-exponential-back-off-bound=10
Heartbeat executor exponential back off related property. It is a maximum multiplier value for retry delay, in case where a sequence of timeouts occurred.
|
eureka.client.heartbeat-executor-thread-pool-size=2
The thread pool size for the heartbeatExecutor to initialise with.
|
eureka.client.initial-instance-info-replication-interval-seconds=40
Indicates how long initially (in seconds) to replicate instance info to the eureka server.
|
eureka.client.instance-info-replication-interval-seconds=30
Indicates how often(in seconds) to replicate instance changes to be replicated to the eureka server.
|
eureka.client.log-delta-diff=false
Indicates whether to log differences between the eureka server and the eureka client in terms of registry information. Eureka client tries to retrieve only delta changes from eureka server to minimize network traffic. After receiving the deltas, eureka client reconciles the information from the server to verify it has not missed out some information. Reconciliation failures could happen when the client has had network issues communicating to server.If the reconciliation fails, eureka client gets the full registry information. While getting the full registry information, the eureka client can log the differences between the client and the server and this setting controls that. The changes are effective at runtime at the next registry fetch cycle as specified by registryFetchIntervalSecondsr
|
eureka.client.on-demand-update-status-change=true
If set to true, local status updates via ApplicationInfoManager will trigger on-demand (but rate limited) register/updates to remote eureka servers.
|
eureka.client.order=0
Order of the discovery client used by `CompositeDiscoveryClient` for sorting available clients.
|
eureka.client.prefer-same-zone-eureka=true
Indicates whether or not this instance should try to use the eureka server in the same zone for latency and/or other reason. Ideally eureka clients are configured to talk to servers in the same zone The changes are effective at runtime at the next registry fetch cycle as specified by registryFetchIntervalSeconds
|
eureka.client.property-resolver=
|
eureka.client.proxy-host=
Gets the proxy host to eureka server if any.
|
eureka.client.proxy-password=
Gets the proxy password if any.
|
eureka.client.proxy-port=
Gets the proxy port to eureka server if any.
|
eureka.client.proxy-user-name=
Gets the proxy user name if any.
|
eureka.client.refresh.enable=true
Determines whether the EurekaClient instance can be refreshed or not(If disabled none of the Eureka client properties will be refreshable). How can I configure this property?
|
eureka.client.region=us-east-1
Gets the region (used in AWS datacenters) where this instance resides.
|
eureka.client.register-with-eureka=true
Indicates whether or not this instance should register its information with eureka server for discovery by others. In some cases, you do not want your instances to be discovered whereas you just want do discover other instances.
|
eureka.client.registry-fetch-interval-seconds=30
Indicates how often(in seconds) to fetch the registry information from the eureka server.
|
eureka.client.registry-refresh-single-vip-address=
Indicates whether the client is only interested in the registry information for a single VIP.
|
eureka.client.service-url=
Map of availability zone to list of fully qualified URLs to communicate with eureka server. Each value can be a single URL or a comma separated list of alternative locations. Typically the eureka server URLs carry protocol,host,port,context and version information if any. Example: https://ec2-256-156-243-129.compute-1.amazonaws.com:7001/eureka/ The changes are effective at runtime at the next service url refresh cycle as specified by eurekaServiceUrlPollIntervalSeconds.
|
eureka.client.should-enforce-registration-at-init=false
Indicates whether the client should enforce registration during initialization. Defaults to false.
|
eureka.client.should-unregister-on-shutdown=true
Indicates whether the client should explicitly unregister itself from the remote server on client shutdown.
|
eureka.client.tls.enabled=
|
eureka.client.tls.key-password=
|
eureka.client.tls.key-store=
|
eureka.client.tls.key-store-password=
|
eureka.client.tls.key-store-type=
|
eureka.client.tls.trust-store=
|
eureka.client.tls.trust-store-password=
|
eureka.client.tls.trust-store-type=
|
eureka.client.use-dns-for-fetching-service-urls=false
Indicates whether the eureka client should use the DNS mechanism to fetch a list of eureka servers to talk to. When the DNS name is updated to have additional servers, that information is used immediately after the eureka client polls for that information as specified in eurekaServiceUrlPollIntervalSeconds. Alternatively, the service urls can be returned serviceUrls, but the users should implement their own mechanism to return the updated list in case of changes. The changes are effective at runtime.
|
eureka.client.webclient.enabled=false
|
spring.cloud.config.discovery.enabled=false
Flag to indicate that config server discovery is enabled (config server URL will be looked up via discovery).
|
spring.cloud.config.discovery.service-id=configserver
Service id to locate config server.
|
Configuration Metadata
The collection of configuration properties listed in this section are automatically generated from the CAS source and components that contain the actual field definitions, types, descriptions, modules, etc. This metadata may not always be 100% accurate, or could be lacking details and sufficient explanations.
Be Selective
This section is meant as a guide only. Do NOT copy/paste the entire collection of settings into your CAS configuration; rather pick only the properties that you need. Do NOT enable settings unless you are certain of their purpose and do NOT copy settings into your configuration only to keep them as reference. All these ideas lead to upgrade headaches, maintenance nightmares and premature aging.
YAGNI
Note that for nearly ALL use cases, declaring and configuring properties listed here is sufficient. You should NOT have to explicitly massage a CAS XML/Java/etc configuration file to design an authentication handler, create attribute release policies, etc. CAS at runtime will auto-configure all required changes for you. If you are unsure about the meaning of a given CAS setting, do NOT turn it on without hesitation. Review the codebase or better yet, ask questions to clarify the intended behavior.
Naming Convention
Property names can be specified in very relaxed terms. For instance cas.someProperty
, cas.some-property
, cas.some_property
are all valid names. While all
forms are accepted by CAS, there are certain components (in CAS and other frameworks used) whose activation at runtime is conditional on a property value, where
this property is required to have been specified in CAS configuration using kebab case. This is both true for properties that are owned by CAS as well as those
that might be presented to the system via an external library or framework such as Spring Boot, etc.
When possible, properties should be stored in lower-case kebab format, such as cas.property-name=value
.
The only possible exception to this rule is when naming actuator endpoints; The name of the
actuator endpoints (i.e. ssoSessions
) MUST remain in camelCase mode.
Settings and properties that are controlled by the CAS platform directly always begin with the prefix cas
. All other settings are controlled and provided
to CAS via other underlying frameworks and may have their own schemas and syntax. BE CAREFUL with
the distinction. Unrecognized properties are rejected by CAS and/or frameworks upon which CAS depends. This means if you somehow misspell a property definition
or fail to adhere to the dot-notation syntax and such, your setting is entirely refused by CAS and likely the feature it controls will never be activated in the
way you intend.
Validation
Configuration properties are automatically validated on CAS startup to report issues with configuration binding, specially if defined CAS settings cannot be
recognized or validated by the configuration schema. The validation process is on by default and can be skipped on startup using a special system
property SKIP_CONFIG_VALIDATION
that should be set to true
. Additional validation processes are also handled
via Configuration Metadata and property migrations applied automatically on
startup by Spring Boot and family.
Indexed Settings
CAS settings able to accept multiple values are typically documented with an index, such as cas.some.setting[0]=value
. The index [0]
is meant to be
incremented by the adopter to allow for distinct multiple configuration blocks.
Authentication
Support for HTTP basic authentication will be automatically added if one of Eureka server URLs
in the configuration has credentials embedded in it (curl style, like http://user:password@localhost:8761/eureka
).
Troubleshooting
To enable additional logging, configure the log4j configuration file to add the following levels:
1
2
3
4
5
6
7
8
<Logger name="org.springframework.cloud" level="debug" additivity="false">
<AppenderRef ref="casConsole"/>
<AppenderRef ref="casFile"/>
</Logger>
<Logger name="com.netflix" level="debug" additivity="false">
<AppenderRef ref="casConsole"/>
<AppenderRef ref="casFile"/>
</Logger>