netflix-eureka-on-aws-fargate

June 22, 2020
aws fargate service-discovery netflix-eureka

Configuration for deploying Netflix Eureka in AWS Fargate

What is Netflix Eureka?

Service Discovery service from Netflix.

Why this article?

Service Discovery can be achieved with ECS Service Discovery feature. However I have asked to work on resolve the issues while deploying Eureka into AWS Fargate. I ran into multiple challenges, sharing the knowledge what I gained here.

Architecture

Architecture

Steps

Dockerfile

Fargate container IP address will not be the same as the Network Interface IP Address which gets attached to the Task. So we need to tweak the Dockerfile to get the Network Interface IP address and use it in Eureka.

FROM openjdk:8-jdk-alpine

RUN apk add --no-cache curl
RUN apk add --no-cache jq

WORKDIR /app
COPY target/eureka-server*.jar /app/eureka-server.jar
COPY src/main/resources/config/application*.* /app/
COPY docker-entrypoint.sh /app/

RUN chmod +x /app/docker-entrypoint.sh
ENTRYPOINT ["/app/docker-entrypoint.sh"]

docker-entrypoint.sh

#!/bin/sh

export ECS_INSTANCE_IP_ADDRESS=$(/usr/bin/curl --retry 5 --connect-timeout 3 -s http://169.254.170.2/v2/metadata | /usr/bin/jq .Containers[0].Networks[0].IPv4Addresses[0] -r)

exec java ${JAVA_OPTS} -Deureka.instance.ip-address=${ECS_INSTANCE_IP_ADDRESS} -Djava.security.egd=file:/dev/./urandom -jar /app/eureka-server.jar "$@"

terraform-access-denied-access-denied

Terraform Access Denied Access Denied
aws terraform s3 state

aws-firelens-overview

An overview of AWS Firelens
aws firelens