Kubernetes Networking

Kubernetes networking is the set of protocols and mechanisms used to facilitate communication between the various components of a Kubernetes cluster. In a Kubernetes cluster, each pod is assigned its own IP address, and pods can communicate with each other using this IP address.

Kubernetes Service:

Kubernetes Service provides the IP Address, a single DNS name, and a Load Balancer to a set of Pods. A Service identifies its member Pods with label and selector.

Types of Service:

  1. ClusterIP: ClusterIP is the default Service type in Kubernetes. In this Service, Kubernetes creates a stable IP Address that is accessible from all the nodes in the cluster. The scope of this service is confined to the cluster only.

  2. NodePort: This type of service exposes the pods on a specific port of each node in the cluster. When you create a NodePort service in Kubernetes, a unique port is assigned to the service. This port can be any number between 30000 and 32767 and is chosen by Kubernetes when the service is created. NodePort services are commonly used during development and testing.

  3. LoadBalancer: The LoadBalancer Service is a standard way for exposing our Nodes to the outside world or the internet. when the LoadBalancer service is created the traffic that is sent to the service is distributed among the pods that are part of the service.

Ingress Controller:

An Ingress Controller is a Kubernetes resource that allows you to expose HTTP and HTTPS routes from outside the cluster to services within the cluster. This can be used to provide access to web applications running in the cluster. In other words, it enables exposing multiple services under a single IP address and routing traffic to them based on the request URL or domain name.

Kubernetes Network Policy:

Kubernetes Network Policy is a feature that allows you to define rules for how pods can communicate with each other. This can be used to enforce security policies, such as restricting communication between certain pods or allowing only certain types of traffic.

Container Network Interface(CNI):

CNI is a standard interface for configuring networking for containers, including those running in Kubernetes. There are many CNI plugins available that can be used to implement different networking solutions, such as using a virtual overlay network or integrating with existing network infrastructure.

DNS:

DNS (Domain Name System) is a hierarchical naming system that is used to map domain names to IP addresses. In Kubernetes, DNS is used to resolve the names of Kubernetes resources, such as pods and services, to their corresponding IP addresses.