AWS - EKS - Cloud Map
- Cloud Map
- ref
Cloud Map
basic
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 .
AWS Cloud Map features
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- Rapid change propagation
- When are using API-based discovery, the updates on the resource locations and attributes are available within 5 seconds.
- 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
- 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
- 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%”
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
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" } } ] }
- 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
attribute-based service discovery
handling partial failure
Cloud map ecosystem
.
This post is licensed under CC BY 4.0 by the author.
Comments powered by Disqus.