Skip to content

Instantly share code, notes, and snippets.

@Andrew-Chen-Wang
Forked from mbstacy/EKSvsEC2.md
Created February 7, 2023 20:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Andrew-Chen-Wang/708da48b275d29b918bd5833ec934c7c to your computer and use it in GitHub Desktop.
Save Andrew-Chen-Wang/708da48b275d29b918bd5833ec934c7c 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.

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