How to Migrate From ECS to EKS and the #1 Trick to Make EKS Easier
Tags: ecs, kubernetes, devops, cloud
Published: 2022-03-29 13:15:09

<!-- wp:paragraph -->
<p>Migrating from Amazon ECS to EKS is probably the last thing you want to spend your time on.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Yet, you’re here. So, it’s likely that ECS hasn’t been serving you fully. Or perhaps you’re curious if you should start planning the migration and how long will it take.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>I’ll try to answer most of your questions, starting from whether you should look at EKS at all to some practical migration and EKS management tips for when you’ve made your decision.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 id="why-migrate-from-ecs-to-eks">Why migrate from ECS to EKS?</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Companies that want to advance in Kubernetes are better off by using EKS. Giants like Amazon, HSBC, JP Morgan Chase, and Delivery Hero all use EKS because of the control and flexibility it offers.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":7481,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="https://cast.ai/wp-content/uploads/2022/03/image-7.png" alt="ecs vs eks" class="wp-image-7481"/></figure>
<!-- /wp:image -->

<!-- wp:heading {"level":3} -->
<h3 id="1-portability">1. Portability&nbsp;</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>While ECS is AWS-proprietary technology, EKS is basically a Kubernetes-as-a-platform service developed and maintained by AWS. EKS clusters are actually portable, you can recreate a similar experience on local environments, development environments, etc., using vanilla K8s. So, you can probably tell in which scenario you’ll face the risk of <a href="https://cast.ai/blog/vendor-lock-in-and-how-to-break-free/" target="_blank" rel="noreferrer noopener">cloud vendor lock-in</a>.</p>
<!-- /wp:paragraph -->

<!-- wp:quote {"className":"is-style-plain"} -->
<blockquote class="wp-block-quote is-style-plain"><p>​​If you’re building and running applications in ECS, you might encounter vendor lock-in issues in the long run. If you decide to use another provider, you’ll have to define the entire architecture to match it.&nbsp;</p></blockquote>
<!-- /wp:quote -->

<!-- wp:paragraph -->
<p>That’s why designing your application to run on EKS leaves you more flexibility. The abstraction layer of EKS helps you to package your containers and move them to another platform quickly. That way, you can run workloads on any other Kubernetes cluster - whether it’s on-prem or the cloud provider offering you the best deal.&nbsp;</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>On top of that, you can find solutions on the market that allow you to <a href="https://cast.ai/blog/how-to-spin-a-multi-cloud-application-with-cast-ai/" target="_blank" rel="noreferrer noopener">switch between different managed Kubernetes services</a> seamlessly.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Open source and community are two important points related to this.</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>With EKS, you have lots of tooling built on top of it and the community itself is growing rapidly. And you know what that means - you get plenty of support as many problems already have their solutions.&nbsp;</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Open source also allows you to choose your tooling, while in ECS, everything is very opinionated and there’s not much flexibility left at the end of the day.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3 id="2-networking-limitations">2. Networking limitations</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>​​Amazon ECS allows users to assign an elastic network interface (ENI) to a task using only one networking mode: <em>awsvpc</em>. Usually, you can get only 8-15 network interfaces per EC2 instance but ECS also supports containers with higher limits (as long as you meet specific prerequisites). In total, you can run up to 120 tasks per EC2 instance.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>In EKS, you get to enjoy greater flexibility in networking. You can share an ENI between multiple pods and place more pods per instance.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3 id="3-namespaces">3. Namespaces</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Namespaces come in handy because they isolate workloads running in the same Kubernetes cluster. For example, you can have a dev, staging, and production environment in one cluster. They can all share the resources of the cluster.&nbsp;</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Trouble is, you can’t use namespaces in ECS. The solution just doesn’t include them as a concept. In contrast to that, EKS allows you to use them just as you would in self-managed Kubernetes.&nbsp;</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3 id="4-no-configuration-flexibility">4. No configuration flexibility</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Many people choose ECS because it’s so simple. But there’s a price to pay for this - namely, limited configuration options. For example, you get no access to cluster nodes, which limits your troubleshooting capabilities.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>And if you use ECS with Fargate, prepare for even more limitations. For example, you don’t get the option to easily decouple environment-specific config from your container images for portability as you do in EKS.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 id="ecs-to-eks-glossary">ECS to EKS glossary</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Before migrating from ECS to EKS, you need to become familiar with a few terms that are common to Kubernetes:&nbsp;</p>
<!-- /wp:paragraph -->

<!-- wp:list -->
<ul><li>ECS vs. K8s building blocks - this is the best place to get started, reviewing the building blocks of <a href="https://aws.amazon.com/blogs/compute/building-blocks-of-amazon-ecs/" target="_blank" rel="noreferrer noopener">ECS</a> and <a href="https://kubernetes.io/docs/concepts/" target="_blank" rel="noreferrer noopener">Kubernetes</a> will help you understand the differences between these two.</li></ul>
<!-- /wp:list -->

<!-- wp:list -->
<ul><li>EKS Worker Node - this is the EC2 Instance that is running your workloads (Pods).</li><li>IaC - Infrastructure as Code - these are tools that allow you to define infrastructure in code that you usually commit into Git repositories. In addition to that, you get Git-like diff output whenever there is a mismatch between your code and the infrastructure in the cloud. Examples include <a href="https://www.pulumi.com/" target="_blank" rel="noreferrer noopener">Pulumi</a>, <a href="https://www.terraform.io/" target="_blank" rel="noreferrer noopener">Terraform</a>, and <a href="https://aws.amazon.com/cloudformation/" target="_blank" rel="noreferrer noopener">AWS CloudFormation</a></li><li><a href="https://helm.sh/" target="_blank" rel="noreferrer noopener">Helm</a> - the most popular packaging solution in the Kubernetes world.&nbsp;</li><li>ALB - Application Load Balancer.</li><li>NLB - Network Load Balancer.</li><li><a href="https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Internet_Gateway.html" target="_blank" rel="noreferrer noopener">Internet Gateway</a> - an internet gateway is a horizontally scaled, redundant, and highly available VPC component that allows communication between your VPC and the internet.</li><li><a href="https://docs.aws.amazon.com/vpc/latest/userguide/what-is-amazon-vpc.html" target="_blank" rel="noreferrer noopener">VPC</a> - Amazon Virtual Private Cloud (Amazon VPC) enables you to launch AWS resources into a virtual network that you've defined. This virtual network closely resembles a traditional network that you'd operate in your own data center, with the benefits of using the scalable infrastructure of AWS.&nbsp;</li></ul>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p>ECS comes with its own terminology that you’re probably familiar with. Here’s how different ECS concepts translate into the world of EKS.</p>
<!-- /wp:paragraph -->

<!-- wp:list -->
<ul><li>ECS Task Definition &lt;&gt; EKS Kubernetes Deployment YAML</li><li>ECS Task &lt;&gt; EKS Kubernetes Pod</li><li>ECS Cluster &lt;&gt; EKS Cluster</li></ul>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p>If you need more guidance here, some good sources to check out are the <a href="https://ecsworkshop.com/introduction/ecs_basics/cluster/" target="_blank" rel="noreferrer noopener">ECS Workshop</a> and <a href="https://www.eksworkshop.com/010_introduction/eks/" target="_blank" rel="noreferrer noopener">EKS Workshop</a>.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 id="what-you-get-with-eks">What you get with EKS</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>You might not need pods for every workload you’re running. But you can’t deny that they offer unparalleled control over pod placement and resource sharing. This is really valuable when you’re dealing with most service-based architectures.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>EKS offers far more flexibility for managing the underlying resources. You can run your clusters on EC2 instances, Fargate, and even on-premises (via EKS Anywhere).</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>If you’re familiar with Kubernetes and want to get your hands on the flexibility and features it provides, go for EKS.&nbsp;</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 id="how-to-migrate-from-ecs-to-eks">How to migrate from ECS to EKS</h2>
<!-- /wp:heading -->

<!-- wp:image {"id":7484,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="https://cast.ai/wp-content/uploads/2022/03/image-8.png" alt="ecs architecture" class="wp-image-7484"/></figure>
<!-- /wp:image -->

<!-- wp:image -->
<figure class="wp-block-image"><img src="https://lh5.googleusercontent.com/3F3LGy3ozwDd6Je9_6PxZrf1cDbi0cKsRbj4W_LkWRFX7sYTnN8ZrQiEMfMjffWCkOz2kjug1P2nQe7LolqeHjSU6UHXJs5UtI2m5aCsMDMHlAcKK5yYr8mSS-7Mf4P2HqaAH5hm" alt="Kubernetes architecture"/></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>AWS has some good tips on <a href="https://aws.amazon.com/blogs/containers/migrating-from-self-managed-kubernetes-to-amazon-eks-here-are-some-key-considerations/" target="_blank" rel="noreferrer noopener">migrating to EKS</a>.&nbsp;</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>But we found some other things you need to take care of before your ECS to EKS migration.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3 id="1-rewrite-ecs-task-definition-files-to-k8s-deployment-yamls">1. Rewrite ECS Task Definition files to K8s deployment YAMLs</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>First things first, you need to rewrite your ECS <a href="https://ecsworkshop.com/introduction/ecs_basics/task_definition/#:~:text=To%20prepare%20your%20application%20to,a%20blueprint%20for%20your%20application." target="_blank" rel="noreferrer noopener">Task Definition files</a> to Kubernetes <a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/" target="_blank" rel="noreferrer noopener">deployment YAMLs</a>. This part is unavoidable and relates to one of the biggest differences between ECS and EKS (or vanilla Kubernetes).</p>
<!-- /wp:paragraph -->

<!-- wp:image -->
<figure class="wp-block-image"><img src="https://lh5.googleusercontent.com/3QsyND5y3G5q6W1Gox0Lkt4YPYkaT-bfe-5y8w50H4y9Dbn-llZs0OmYdWgwB-0E6p8xyDGDFgXxAZmPQ7nUwXAOYj_tZ5AMfcvPYYiwBifbz3b4CEmXlk9SjZpQ0giw-UUxrTUh" alt="ECS to EKS migration"/></figure>
<!-- /wp:image -->

<!-- wp:heading {"level":3} -->
<h3 id="2-spin-up-your-environment">2. Spin up your environment</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>You also need to spin up the respective environment versions you have on EKS. People typically choose to use Infrastructure as Code (IaC) for that - using Terraform, CloudFormation, or Pulumi. Good news: the most popular IaC tools support EKS.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Assuming that you’re already familiar with Docker and have application images packaged and available for use:</p>
<!-- /wp:paragraph -->

<!-- wp:list -->
<ul><li>You could use the features of Terraform (or an alternative IaC tool), such as <a href="https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/deployment_v1" target="_blank" rel="noreferrer noopener">kubernetes provider</a> to ship your Deployment YAMLs as part of the IaC flow.&nbsp;</li><li>You could also make use of <a href="https://registry.terraform.io/providers/hashicorp/helm/latest/docs" target="_blank" rel="noreferrer noopener">Helm Provider</a> if your application packages use Helm.</li><li>Alternatively, you could use CloudFormation which allows <a href="https://aws.amazon.com/blogs/infrastructure-and-automation/using-aws-cloudformation-to-deploy-software-into-amazon-eks-clusters/" target="_blank" rel="noreferrer noopener">deploying workloads to EKS clusters</a> as well, assuming your applications are packaged using Helm.</li></ul>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p>You can get the above working in many more ways - and each has its pros and cons. But this simple solution is enough for now.&nbsp;</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3 id="3-configure-your-ci-cd-pipelines">3. Configure your CI/CD pipelines&nbsp;</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>You need to do this to deploy your applications into the EKS cluster.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3 id="4-networking">4. Networking</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Both ECS and EKS support similar networking capabilities: ALB &amp; NLB. You can use the basic constructs of networking that you’re currently familiar with in ECS. <a href="https://aws.amazon.com/blogs/opensource/kubernetes-ingress-aws-alb-ingress-controller/" target="_blank" rel="noreferrer noopener">This article</a> might come in handy if you’re looking for more details about ingress with ALB.&nbsp;</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3 id="5-run-some-tests">5. Run some tests</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Run your test suite against your new configuration to make sure that everything works properly.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3 id="6-switch-your-traffic-to-the-eks-cluster">6. Switch your traffic to the EKS cluster</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>This might vary depending on your configuration, but to give you an idea of what needs to be done:</p>
<!-- /wp:paragraph -->

<!-- wp:list -->
<ul><li>You could switch the IP your domain points to, for it to point to the Load Balancer used by your EKS cluster. This is how you make sure that your application traffic now points to the EKS cluster.</li><li>For stateful applications, you need to think about other things as well, such as ensuring that the K8s-based application transitions to being the main user of the database (smooth switch from ECS using the database for writing to the EKS app using the database for writing).</li></ul>
<!-- /wp:list -->

<!-- wp:heading -->
<h2 id="make-your-eks-journey-easier-with-automation">Make your EKS journey easier with automation</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Configuring and running EKS doesn’t have to be hard. This is what all the managed Kubernetes tools are here for.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>For example, CAST AI comes with opinionated Kubernetes implementation that helps you manage all the infrastructure complexities:</p>
<!-- /wp:paragraph -->

<!-- wp:list -->
<ul><li>Focus on high-level work that interests you most.&nbsp;</li><li>Creating and managing CAST Al components is easy - you can do it through API and Terraform to automate infrastructure lifecycle management.&nbsp;</li><li>You get to streamline autoscaling with a headroom policy to accommodate sudden spikes in demand.</li><li>And automate spot instance use to cut costs even more. If the spot availability shrinks, your workloads are automatically moved to on-demand instances and never go down.&nbsp;</li><li>All in all, you get to benefit from automated cloud cost optimization - the platform chooses the most cost-effective AWS instance types and sizes, and delivers detailed cost reports.</li></ul>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p>If you’d like to see how this works in real life, here’s how the e-commerce agency Snow Commerce moved to EKS and now rolls out apps seamlessly with a fully automated environment.</p>
<!-- /wp:paragraph -->

<!-- wp:group {"align":"wide","style":{"spacing":{"padding":{"right":"0rem","left":"0rem"}}},"layout":{"inherit":true}} -->
<div class="wp-block-group alignwide" style="padding-right:0rem;padding-left:0rem"><!-- wp:heading {"textAlign":"center"} -->
<h2 class="has-text-align-center">See how CAST AI works in real life</h2>
<!-- /wp:heading -->

<!-- wp:acf/case-studies-list {"id":"block_623300b8b853e","name":"acf/case-studies-list","data":{"load_latest":"0","_load_latest":"field_case-studies-list_load_latest","case_studies":["2641"],"_case_studies":"field_case-studies-list_case_studies"},"align":"wide","mode":"auto","wpClassName":"wp-block-acf-case-studies-list alignwide"} /--></div>
<!-- /wp:group -->