Skip to content

Instantly share code, notes, and snippets.

@mbstacy
Last active December 2, 2024 05:11
Show Gist options
  • Save mbstacy/50e5cfa5c4faad560c513595977ad096 to your computer and use it in GitHub Desktop.
Save mbstacy/50e5cfa5c4faad560c513595977ad096 to your computer and use it in GitHub Desktop.
EKS vs EC2 Kubernetes Costs

Kubernetes Cost Comparison EC2 vs EKS

EKS Kubernetes

AWS EKS service provides the Kubernetes control plane. Price for EKS Service is $0.20 per hour / cluster.

EKS Use Case Monthly Cost

Three clusters with four worker nodes.

  1. EKS Service

    1. ((0.20 * 24 * 365)/12) = $146/month per cluseter
    2. 3 clusters = $438/month
  2. Kubernetes Node costs

    • On-demand Cost
      • m5.xlarge 4 cpu 16 GiB x4 = 16 cpu 64 GB
        1. ((0.192 *24 *365)/12) = $140.16/mo per node
        2. Total = $560.64 4 nodes
        3. Clusters x 3 = $560.64 x3 = $1681.92
    • Spot Instances (Example uses us-west-2 spot instance prices)
      • m5.xlarge 4 cpu 16 GiB x4 = 16 cpu 64 GB
        1. ((0.068 * 24 * 365)/12 = $49.64/mo
        2. Total = $198.56 4 nodes
        3. Clusters x 3 = $198.56 x3 = $595.68

EC2 Kubernetes

The cost of EC2 is reflected in the Node costs. The control plane distributed across an odd number of node instances(odd number for quorum).

  1. Kubernetes Node costs
    • On-demand Cost
      • m5.xlarge 4 cpu 16 GiB x4 = 16 cpu 64 GB
        1. ((0.192 *24 *365)/12) = $140.16/mo per node
        2. Total = $560.64 4 nodes
        3. Clusters x 3 = $560.64 x3 = $1681.92
    • Spot Instances (Example uses us-west-2 spot instance prices)
      • m5.xlarge 4 cpu 16 GiB x4 = 16 cpu 64 GB
        1. ((0.068 * 24 * 365)/12 = $49.64/mo
        2. Total = $198.56 4 nodes
        3. Clusters x 3 = $198.56 x3 = $595.68

Summary

The main difference in cost is the set costs of the EKS cluster. In our use case above we have three clusters which is an additional $438/month.

  1. EKS Use Case Summary
    1. On-demand: 3 cluster = $438 + $1681.92 = $2119.92 ($706.64/cluster)
    2. Spot: 3 clusters = $438 + $595.68 = $1033.68 ($344.56/cluster)
  2. EC2
    1. On-demand: 3 clusters = $1681.92 ($560.64/cluster)
    2. Spot: 3 clusters = $595.68 ($198.56/cluster)

Cluster Setup

The initial cluster setup through Rancher can be accomplished quickly. Additional time for cluster setup is dependent on what cluster operation is needed. EC2 requires the setup of a node template. The template consists of instance type, Spot/On-demand, IAM role that has the appropriate policies. The AWS Load balancer needs to be setup with target group pointing to appropriate cluster node instances.

Spot instances require nodes have the ability to terminate without losing stateful set storage. Create external EC2 EBS volumes which is a persistant storage volume. This will be important if DB stateful storage is need vs AWS RDS Service. The IAM role should include a policy that grants nodes the ability to attach/detach external volumes.

@MuhammedBuyukkinaci
Copy link

Nice work !
Thanks for detailed explanation.

@vherman7
Copy link

vherman7 commented Mar 8, 2023

3 Clusters x 0.10 USD per hour x 730 hours per month = 219.00 USD
https://calculator.aws/#/addService/EKS

what about security compliance running control plane on ec2?

@jordanburke
Copy link

Great write up. One call out:

The cost of EC2 is reflected in the Node costs. The control plane distributed across an odd number of node instances (odd number for quorum).

In the EC2 case, wouldn't this mean there are less resources for the worker nodes/pods if you do not have dedicated control planes? In the EKS instance, the control plane is offloaded to AWS's infrastructure and not your nodes/pools. This means there are no resources used in the cluster pool for control plane, and you do not have to worry about worker nodes going down impacting any control plane services.

I'm only calling this out because I have a standalone Kubernetes cluster on EC2 and have seen some stability issues when I have run the control plane on worker nodes, and have since moved to dedicated control plane nodes, increasing my cost. I'm now looking at EKS to potentially compensate for that cost and stability.

@P-Y-R-O-B-O-T
Copy link

Nice, didn't find this good comparison anywhere else

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment