Properly measuring and anticipating cost in Kubernetes is a complicated process. Network cost especially can be difficult to estimate properly with all of the complex factors that affect and determine how much you will be billed at the end of the month. The purpose of this article is to provide a comprehensive understanding of all of the different sources that make up your total network cost in Kubernetes and provide additional context for how it is calculated.
When evaluating the network cost generated by a cluster, it is important to take into account the underlying architecture of the cluster. The main concept to be aware of is whether or not your cluster is single or multi-zone.
A single zone cluster will have its Nodes hosted in a single region within a single “availability” or “failure” zone. A multi-zone cluster will still have its Nodes hosted in a single region but each Node will be distributed among different availability zones provided by that region. Provisioning your cluster with multi-zone architecture is considered best practice as it ensures that your Nodes won’t have a single point of failure, increasing the resilience and stability of your infrastructure. If a single availability zone fails, then your Pods can still continue to run on other Nodes hosted in a different zone. This feature is often enabled by default in some cloud vendors, such as Google Cloud Platform.
It is necessary to understand if your cluster is multi-zone because inter-zone data transfer is one component that makes up your overall network cost. Most cloud providers will charge for both ingress and egress traffic between availability zones. Any traffic between services on your cluster when each Pod is hosted in a different availability zone will incur these fees. This is important to be aware of as it means that traffic on your cluster, not just traffic that leaves your cluster can incur network fees. This can include traffic between microservices, Kafka clusters and even databases as long as they are between different availability zones. Currently, the main three cloud providers (AWS, Azure, GCP) all charge inter-zone network traffic at the same amount: $0.01 per GB.
Another cost to be aware of that contributes to your overall network cost is inter-region data transfer cost. Notably, this does not include egress traffic from your cluster to the Internet. But, it does include all egress traffic from your cluster to other VMs or services provided by your cloud provider in different regions. For example, if you had an AWS EKS cluster running in one region, and attempted to access data from an AWS S3 bucket in another region, that would incur an inter-region data transfer cost.
Inter-region cost is commonly priced based on the source and destination regions of the data transfer. For example, GCP will charge $0.02 per GB if the data is transferred between regions in North America. But if the data is transferred from North America to South America, $0.14 per GB is charged instead.
In Azure, the price is based on the source region and if the traffic is within the same continent or not. So, inter-region network traffic within North America is charged at $0.02 per GB and any traffic from North America to a region outside of the continent will be charged at $0.05 per GB instead.
In AWS, the price is based on the destination region and averages between $0.01 per GB and $0.02 per GB.
Because there are so many nuances between the way each vendor handles their network pricing, It’s very important to understand the exact pricing structure your cloud provider uses to estimate your cost accurately.
The final piece to be aware of that contributes to your total network cost is Internet egress data transfer cost. This is any outgoing network traffic from your cluster to the Internet. One detail to note when evaluating this cost is that all the major cloud providers do not charge anything for ingress traffic from the Internet to your cluster. The way that Internet egress data transfer is charged is generally dependent on the cluster region and fluctuates based on usage during a particular billing cycle. Also, each major cloud provider does not charge for a specified amount of data at the start of each billing cycle.
For example, Azure does not charge for the first 100 GB every month. Then, the price fluctuates for the next 10 TB, 40 TB, 100 TB and 350 TB every month. These price adjustments also change based on the source region of the cluster.
In AWS, they also do not charge for the first 100 GB every month. They also follow a similar price adjustment for tiers for the next 10 TB, 40 TB, 100 TB every month. There is a final tier for any data transferred after 150 TB. AWS also does not have as many region-specific adjustments for this pricing, although there are a few exceptions.
In GCP, they do not charge for the first 200 GiB every month. Their monthly usage tiers are from 200 GiB to 10240 GiB, 10240 GiB to 153600 GiB and then anything over 153600 GiB. The pricing for each tier also changes based on the source region. The following chart is based on the us-east1 region.
In conclusion, these are the main factors to be aware of when attempting to calculate the amount of network cost your cluster is generating. One final factor to keep in mind is that each cloud provider also offers different plans, such as Standard or Premium, which can also affect your network cost. Ultimately, because of how many variations can appear between the way each vendor handles their network cost calculation, the only way to accurately determine your network cost is going to rely on a more detailed understanding of the exact nature of your cloud provider, product plan, infrastructure and cluster activity. Hopefully, this article has helped you with building the foundational understanding of how network cost in Kubernetes is measured.