Deploy Docker app on Kubernetes or directly on EC2 instances?

9/15/2020

Assume I have a web application (Apache httpd server) deployed in AWS using EC2 instances (VM). Application deployment is performed using EC2 userdata.

Alternatively I could dockerize my web application. Deploy a Kubernetes cluster on EC2 instances using EKS, or custom setup. We could also use AWS Fargate for serverless feature.

What are the pros and cons to use second approach with Kubernetes here?

-- scoulomb
amazon-ec2
amazon-eks
amazon-web-services
docker
kubernetes

2 Answers

9/16/2020

Kubernetes is a container orchestrator for managing the lifecycles of containerized workloads. There is a lot of operational overhead in running a Kubernetes cluster, whether hosted or on premise.

Kubernetes benefits medium-to-large scale containerized workloads. For a single monolithic app, the negatives outweigh the benefits of using Kubernetes by a large margin.

For your use case, a hosted application service would be recommended. If you prefer having more control, rolling your own EC2 infrastructure would be the next best recommendation.

To say Kubernetes is easier for developers is a false statement. In actuality, Kubernetes is a very complex and costly system to operate effectively. There is a lot of operational overhead to run a Kubernetes cluster securely and effectively.

You will need to maintain nodes, use costly load balancer to expose traffic, implement designs to handle persistent data and session management.

Also, containers do not magical remove operational tasks. They are still prone to vulnerabilities and a workflow must exist to update your app’s container image with an updated base image on a regular basis.

Another challenge is containers are designed to be ephemeral, which means state changes must be persisted to attached volumes, and session management must be externalized. All this adds up to even more complexity and overhead.

-- Shane Rainville
Source: StackOverflow

9/15/2020

EC2 - more responsibilty for Developers

If you as a developer deploy your application to EC2 machines, you usually also is responsible for maintaining and patching the EC2 instances. The problem is that this is things that developers not usually are good at, and commonly not are so interested in. It is not their expertise to monitor and patch Linux machines or troubleshoot networking.

Kubernetes - less responsibility for Developers

With Kubernetes, you as a developer are responsible only for the application container and that your app is healthy. But another team, e.g. a platform team may be responsible for the underlying infrastructure, e.g. EC2 instances and Networking. Or as with Fargate, the cloud provider can be responsible for this.

Cognitive Load

Making the Developers responsible for less, but still having APIs for self-service deployment, makes them very efficient.

Need for a Platform Team

But when starting to use Kubernetes as a platform, you are taking on more complexity. You need to be a large enough organization for this. Unless you use higher level services like e.g. Google Cloud Run.

A good talk about all this is Kubernetes is Not Your Platform, It's Just the Foundation

-- Jonas
Source: StackOverflow