Post

AWS - EKS - Cloud Map


Cloud Map

Screen Shot 2021-04-04 at 15.54.07

basic

Screen Shot 2021-04-04 at 15.51.38

Companies are increasingly building their applications as microservices (many separate services that each do a single job).

  • Microservices often allow companies to iterate and deploy more quickly.
  • Many of these microservice-based modern applications are built using various types of cloud resources and deployed on dynamically changing infrastructure.

had to use configuration files to manage the location of the application resource.

  • but dependencies in a microservices-based application can quickly become too complex to easily manage through configuration files.
  • many applications are built using containers that scale dynamically, reacting on the changes in traffic load.
  • That increases the application responsiveness, now the application components need to discover and connect to the upstream services at runtime.
  • This problem of connectivity in dynamically changing infrastructures and microservices is commonly addressed by service discovery .

Screen Shot 2021-04-04 at 15.52.55

Screen Shot 2021-04-04 at 15.53.23

product-page-diagram_skymap_before-after

AWS Cloud Map features

  1. Discover resources via API calls or DNS queries
    • Cloud Map allows the applications to discover any web-based service via AWS SDK, API calls, or DNS queries.
    • Over DNS, Cloud Map provides resource locations of IP addresses or IP:port combinations using either IPv4 or IPv6.
    • Using the discovery API, Cloud Map can return URLs or ARNs as well as IP addresses and IP:port combinations.
  2. Simplified service naming
    • AWS Cloud Map lets define simple custom names for services in the application.
    • This can include Amazon Elastic Container Service (ECS) tasks, Amazon EC2 instances, Amazon S3 buckets, Amazon DynamoDB tables, Amazon Simple Queue Service (SQS) queues, and any other cloud resource.
  3. Assign custom attributes
    • Cloud Map lets define custom attributes for each resource, such as location and deployment stage.
    • This provides the ability to customize the deployment across different regions or environments.
  4. Access control
    • Cloud Map is integrated with AWS Identity and Access Management (IAM) to ensure that only authenticated services can discover resources within the registry and retrieve the location and credential for those resources.
  5. Automatic health check
    • Amazon Route 53 health checks ensure that only healthy endpoints are returned on discovery queries.
    • This ensures that Cloud Map always has an up-to-date registry of healthy resources.
  6. Deep integration with AWS container services
    • Services and tasks managed by Amazon Elastic Container Service (ECS) or Amazon Elastic Service for Kubernetes (EKS) can be automatically registered and updated in Cloud Map.
    • As ECS launches tasks for the service, it automatically registers them as resources with Cloud Map, and they are discoverable within five seconds.
  7. Rapid change propagation
    • When are using API-based discovery, the updates on the resource locations and attributes are available within 5 seconds.
  8. Fully managed
    • AWS Cloud Map eliminates the need to set up, update, and manage the own service discovery tools and software.

AWS Cloud Map in Action

  1. create a namespace, such as myapp.com.
    • decide whether want the applications to discover resources only via the AWS SDK and API calls, or if need optional discovery via DNS.
    • When enable DNS discovery for a namespace, need to provide IP addresses for all the resources that register.
    • If plan to register other cloud resources, such as DynamoDB tables by ARN or the URLs of the APIs deployed on Amazon API Gateway, need to select API discovery mode.
    1
    2
    
     aws servicediscovery create-public-dns-namespace \
         --name myapp.com
    
  2. create services.
    • A service represents the application components, such as users, auth, or payment and can be comprised of many dynamically changing resources.
    • specify a name for the service, then select the DNS discovery and health checking options.
    1
    2
    3
    
     aws servicediscovery create-service \
         --name frontend \
         --namespace-id %namespace_id%”
    
  3. register service instances with custom attributes:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    
     aws servicediscovery register-instance \
         --service-id %service_id% \
         --instance-id %id% \
         --attributes AWS_INSTANCE_IPV4=54.20.10.1,stage=beta,version=1.0,active=yes
    
     aws servicediscovery register-instance \
         --service-id %service_id% \
         --instance-id %id% \
         --attributes AWS_INSTANCE_IPV4=54.20.10.2,stage=beta,version=2.0,active=no
    
  4. Now, applications can make API calls to discover the service instances, optionally providing query parameters to filter the results:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    
     aws servicediscovery discover-instances \
         --namespace-name myapp.com \
         --service-name frontend \
         --query-parameters version=1.0,active=yes
     -->
     {
         "Instances": [
             {
             "InstanceId": "1",
             "NamespaceName": "myapp.com",
             "ServiceName": "users",
             "HealthStatus": "HEALTHY",
             "Attributes": {
                 "version":"1.0",
                 "active":"yes",
                 "stage":"beta",
                 "AWS_INSTANCE_IPV4": "54.20.10.2" }
             }
         ]
     }
    
  5. Amazon Elastic Container Service (ECS) and AWS Fargate are tightly integrated with AWS Cloud Map.
    • When create the service and enable service discovery, all the task instances are automatically registered in AWS Cloud Map on scale up, and deregistered on scale down.
    • ECS also ensures that only healthy task instances are returned on the discovery calls by publishing always up-to-date health information to AWS Cloud Map.
    • For Amazon Elastic Container Service for Kubernetes (EKS), can automatically publish the external IPs of the services running in EKS in AWS Cloud Map. To do this, we’ve released an update to an open source project, ExternalDNS, to make Kubernetes resources discoverable via AWS Cloud Map. You can find out more details about Kubernetes External DNS here.

Registry cloud resources

Screen Shot 2021-04-04 at 15.55.19

Screen Shot 2021-04-04 at 15.56.14

Screen Shot 2021-04-04 at 15.56.30

Screen Shot 2021-04-04 at 15.57.08

Screen Shot 2021-04-04 at 15.57.45

Screen Shot 2021-04-04 at 15.58.17

Screen Shot 2021-04-04 at 15.58.40

attribute-based service discovery

Screen Shot 2021-04-04 at 15.58.54

Screen Shot 2021-04-04 at 15.59.09

Screen Shot 2021-04-04 at 15.59.31

Screen Shot 2021-04-04 at 15.59.44

handling partial failure

Screen Shot 2021-04-04 at 16.00.02

Screen Shot 2021-04-04 at 16.00.38

Screen Shot 2021-04-04 at 16.00.51

Screen Shot 2021-04-04 at 16.01.23

Screen Shot 2021-04-04 at 16.01.59


Cloud map ecosystem

Screen Shot 2021-04-04 at 23.55.40

Screen Shot 2021-04-04 at 23.56.08

Screen Shot 2021-04-04 at 23.56.21

Screen Shot 2021-04-04 at 23.56.35

Screen Shot 2021-04-04 at 23.56.56

.

This post is licensed under CC BY 4.0 by the author.

Comments powered by Disqus.