KUBERNETES SERVICES | DISCOVERY | LOAD BALANCING | NETWORKING

Kubernetes services are critical components in production scenarios.
- Services are created for each deployment in Kubernetes.
- Services are important for managing multiple replicas of a pod for concurrent users.

Creating multiple replicas in Kubernetes helps distribute the load and handle more requests.
- Number of replicas depends on the number of users and connections a pod can handle.
- Kubernetes has auto-healing capability to create new replicas when a pod goes down.

Load balancing and service concept in Kubernetes
- In Kubernetes, load balancing is used to distribute traffic evenly among multiple replicas of an application.
- Instead of accessing specific IP addresses, users are advised to access a service, which handles the load balancing.

Instead of giving each user project a specific IP address, create a load balancer service using Kubernetes.
- Using a service instead of IP addresses prevents issues when Pods or Ports change.
- The service acts as a load balancer and can be accessed using the service name.

Service discovery is an advantage of Kubernetes services.
- Service discovery allows pods to be accessed using a service.
- Labels and selectors are used in service discovery to track and manage pods.

Kubernetes service uses labels and selectors for service discovery mechanism.
- Labels are tags that are attached to deployments, replica sets, and pods in Kubernetes.
- Service discovery mechanism in Kubernetes tracks pods using labels instead of IP addresses.

Exposing application to the world
- Kubernetes cluster allows access to the application only through SSH
- Not practical in real-world scenarios, need a simpler way for users to access the application

A Kubernetes service can expose your application outside the cluster.
- A Kubernetes service allows end users to access the application from anywhere.
- There are three types of Kubernetes services: cluster IP, node port, and load balancer.

Different types of service in Kubernetes
- Load balancer service type won't work on local Kubernetes clusters
- To access the application, use LoadBalancer on cloud or NodePort for internal access

Kubernetes load balancer creates a public IP address for accessing the application.
- The load balancer requests AWS for an elastic load balancer IP address.
- The Cloud control manager generates the public IP address using AWS implementation.

Kubernetes services offer load balancing, service discovery, and application exposure.
- Load balancing mechanism is needed to manage traffic between pods.
- Service discovery mechanism is needed to handle changing IP addresses and auto-healing capabilities.

Different types of load balancing in Kubernetes
- Load balancers allow global access to services
- Various load balancing modes in Kubernetes: NodePort mode for internal access, ClusterIP mode for network access
KUBERNETES SERVICES DEEP DIVE
Deep dive into Kubernetes services
- Practical session on load balancing, discovery, and application exposure
- Using KubeShark to understand traffic flow and communication between Kubernetes components

Creating a Kubernetes cluster using AWS and clearing existing resources.
- To create a Kubernetes cluster on AWS, you can use free coupons or resources.
- Clearing existing resources by deleting a deployment and a service.

Modifying the deployment with 2 replicas and adding labels
- Choosing 2 replicas to demonstrate load balancing
- Explaining the importance of labels and selectors in Kubernetes

Updating container Port, image, labels, and selectors in the deployment.yaml file.
- Create the deployment using 'kubectl apply -f deployment.yaml' command.
- Check the status of the deployment and view the created pods using 'kubectl get deploy' and 'kubectl get pods' commands.

Dynamic IP address allocation in Kubernetes can lead to traffic loss
- Kubernetes assigns IP addresses dynamically to pods, which can result in changes in IP address
- Using labels and selectors, Kubernetes services can identify pods consistently despite IP address changes

Using selector and label, a new pod is created to handle traffic
- To access the deployments, you can use MiniKube SSH with an IP address and curl command
- The application context root is '/demo', which needs to be added to the curl command

Exposing applications in Kubernetes can be done through worker node IP addresses or public IP addresses
- Internal applications can be accessed using worker node IP addresses
- External applications require a public IP address for access by anyone in the world

Kubernetes services have different types of exposure methods.
- NodePort exposes the application on the Node IP address.
- Service looks for pods using selectors and forwards traffic to them.

You can access your application using the cluster IP or the node IP address.
- The cluster IP is mapped with the node IP address and port 3007.
- Using the node IP address is not recommended as you can already access using the Pod IP addresses.

Accessing the application using the node IP address and port 3007.
- If accessing from the same laptop, you can access the application using the mini Cube IP address as they are in the same network.
- To access from other people's browsers, use the load balancer IP address as it becomes external traffic.

Load balancer generates external IP for services in Kubernetes.
- The IP address will not be allocated for miniCube, but for AWS, Azure, or GCP, it will generate the IP address.
- If you use MetalLB project in miniCube, it can generate a public IP address, but it's still a beta project.

Service Discovery concept explained
- Modify the selector in service configurations to understand the concept
- Use either Cube CTL edit or vim to modify the service and reapply it

Load balancing is achieved through the creation of services in Kubernetes
- Cubeshark is a recommended application for understanding traffic flow within the cluster
- To install Cubeshark, refer to the Cubeshark documentation and execute the provided commands

Demonstration of load balancing in Kubernetes services using KubeShark
- Ran curl command multiple times to test the load balancing
- Expected output was for requests to be evenly distributed between two parts (170.7 and 172.5)

Understanding the packet flow
- The request originates from IP address 192.168.64.1
- The packet flow involves sending requests to various IP addresses and hosts

KubeShark is a must-have tool for every DevOps engineer to understand traffic flow in Kubernetes.
- KubeShark provides a traffic viewer for Kubernetes, making it easier to understand Kubernetes concepts.
- You can use KubeShark to view the service map and see how services are connected, as well as view pods in different namespaces and analyze traffic based on TCP and HTTP requests.

Launch your GraphyLaunch your Graphy
100K+ creators trust Graphy to teach online
𝕏
Tech Guides 2024 Privacy policy Terms of use Contact us Refund policy