Kubernetes Networking — Part 2

Kubernetes Networking — Part 2 In the first part of this series of posts, we provided a basic explanation of how networking works in Kubernetes. In this second part of the Kubernetes Networking Blog Posts series, we’ll be exploring the typi

Source comparison and review notes
  • Automated pair-review warning (AI bilingual content review): The Spanish source contains the full model-comparison table and a first-part link to https://madsblog.net/2024/10/28/kubernetes-modelo-de-networking-en-la-nube-parte-1/; the English source omits both despite saying it follows Part 1.

In the first part of this series of posts, we provided a basic explanation of how networking works in Kubernetes.

In this second part of the Kubernetes Networking Blog Posts series, we’ll be exploring the typical networking models in various Kubernetes implementations.


Typical Kubernetes Networking Models

There are different variants of the implementation of the Networking Model in Kubernetes. Any of these implementations must have the following characteristics:

  • Each Pod must have a unique IP across the cluster.
  • Pods must communicate with other Pods on all nodes without using NAT.
  • Kubelet must be able to communicate with all Pods on the node.

There are three types of implementations:

  • Fully integrated model (flat).
  • Bridge model (Island).
  • Air-gapped model.

These three implementations vary in:

  • How Pods communicate with services outside Kubernetes on the corporate network.
  • How Pods communicate with other clusters in the organization.
  • Whether NAT is required for outbound-to-external communication.
  • Whether the IPs of the Pods can be reused in another cluster of the corporate network.

As you may have noticed, each of the Cloud Providers can implement one or more of these models, giving several deployment options.


Fully Integrated Model (Flat)

One of the main advantages of this model is that Cloud Providers can tightly integrate Kubernetes deployment with Software-Defined Networks (SDNs).

The key to the operation of this model is that the IP addresses of the Pods are routed within the network where the Cluster is located. The underlying network knows which node the Pods are on. This can be handled by Routes in GCP or Effective Routes in Azure.

Some deployments use an isolated, separate CIDR for Pods, but it’s not a mandatory condition. In some implementations, the Pods take the IPs from the same network where the Cluster is located.

In this deployment, Pods do not need NAT to communicate with other applications outside the Cluster.


Deployment in Different Cloud Providers:

  • GKE uses this model with VPC-native Clusters. Services and Pods ranges are assigned as secondary ranges of the nodes’ VPC. For external traffic, SNAT can be used to map the IP of the Pod to that of the node.
  • AKS uses this model in Azure CNI and Azure CNI Dynamic configurations. In Azure CNI, IPs from the same network as the Clusters are used, and in Dynamic, we can assign a separate Subnet in the VNET for this purpose, allowing different NSG implementations.
  • EKS uses this model when using the Amazon VPC Container Networking Interface (CNI) Plugin. It allows assigning IPs to Pods directly from an address space in a VPC. This subnet can be the one where the nodes are located or a dedicated subnet, similar to the variation in AKS.

Advantages:

  • Better telemetry and debugging.
  • Simplifies configuring Firewall rules.
  • Better compatibility.
  • Service Mesh support.

Disadvantages:

  • Extensive use of IP addresses as large quantities will be needed for Pods.
  • SDN requirements: Requires deep integration with the underlying network. Difficult to implement in Self-Managed/On-premises.

Bridge Model (Island)

This model is commonly used On-Premises, where it is not possible to make a tight integration with the underlying network. With this model, Pods can communicate with resources outside the Cluster through a Gateway or Proxy. Pods within the Cluster can communicate freely.


Proxy/Gateway Deployment Models:

  • Use Nodes as Gateways: SNAT is used for Outbound. For communication to the Services, the Services such as NodePort or LoadBalancer can be used.
  • Use Proxy VMs: VMs must have two NICs, one in the network of the nodes and the other in the Enterprise Network.

Deployment in Different Cloud Providers:

  • GKE and EKS do not use this model.
  • By default, AKS uses this model when using Kubenet. UDRs are used for Pod-to-Pod traffic with IP Forwarding at the level of the node NICs. For outbound traffic, SNAT is used.

Advantages:

  • CIDRs can be reused in other clusters, although it is a bit risky for external communication. It should be carefully planned and equally recommended to reserve a single network-wide range for Pods and use this range for all clusters.
  • Easier security: since the Pods are not exposed to the rest of the network.

Disadvantages:

  • Inaccurate telemetry and difficult debugging: traffic is only recorded with the IP of the Nodes.
  • More difficult to configure firewalls: only the IP of the Nodes can be used.
  • Service Mesh incompatibility.

Air-Gapped Model

This model is mostly used for clusters that do not need access to the corporate network, relying only on Public APIs. In this model, the Cluster cannot communicate with other resources using private IPs. Pods within the Cluster can communicate freely.

This model is not commonly used, but an isolated network can be achieved in any deployment. You only need to deploy the Cluster on a separate network with no connectivity to other services on the corporate network.


Advantages:

  • All internal ranges can be reused.
  • Safety by total isolation.

Disadvantages:

  • No private communication.

Mateo Di Loreto

If you like what i do and want to support my content you can Buy Me a Coffe

Thanks for reading. The learning continues in the next article.