DevOps Week 7 - Complete Kubernetes Fundamentals Guide βΈοΈ Part 2
Master Kubernetes Services Deep Dive, Ingress, RBAC, OpenShift, Traffic Flow, Load Balancing, Security & Real-World DevOps Concepts π

πΉ Why Kubernetes Services Are Important? π€
In Kubernetes, Pods are temporary.
If a Pod crashes:
Kubernetes creates a new Pod with a new IP address
Because Pod IPs keep changing, applications cannot communicate reliably using direct Pod IPs.
This creates problems:
β Frontend cannot find backend
β Users lose connectivity
β Traffic routing becomes unstable
πΉ Solution: Kubernetes Services π
Kubernetes Services provide:
β
Stable networking
β
Service discovery
β
Load balancing
β
Reliable communication between Pods
A Service acts as:
Stable entry point for Pods
Even if Pod IPs change, the Service remains constant.
πΉ Real-Life Example π‘
Imagine: Employees in a company keep changing desks daily.
Instead of contacting employees directly, customers contact:
Reception Desk
The receptionist forwards requests to available employees.
Similarly:
Kubernetes Service routes traffic to available Pods
πΉ Application Deployment in Kubernetes π
The instructor first:
β
Created a sample Django/Python application
β
Built Docker image
β
Deployed application in Kubernetes
β
Created 2 Pod replicas
πΉ Why Multiple Replicas Are Important? π
Using multiple replicas helps in:
β
High availability
β
Load balancing
β
Better performance
β
Fault tolerance
If one Pod crashes, other Pods continue serving users.
πΉ Problem Without Services β οΈ
Suppose: Frontend application directly communicates with Pod IP.
If Pod gets deleted:
β IP changes
β Communication breaks
β Application stops working
This is why:
Direct Pod communication is not reliable
πΉ What is Service Discovery? π
Service Discovery means:
Automatically finding Pods inside Kubernetes
Kubernetes Services use:
β
Labels
β
Selectors
to identify Pods dynamically.
πΉ What are Labels? π·οΈ
Labels are key-value pairs attached to Kubernetes objects.
Example:
app: django
env: production
Labels help Kubernetes identify Pods.
πΉ What are Selectors? π―
Selectors are used by Services to:
Find matching Pods using labels
πΉ How Labels & Selectors Work Together? βοΈ
Example:
Pod Label:
app: django
Service Selector:
app: django
Now Service automatically connects to matching Pods.
πΉ Important Learning π‘
If labels are incorrect:
β Service cannot discover Pods
β Traffic routing fails
The instructor demonstrated this practically.
πΉ Kubernetes Service Types π
The video explains two major Service types:
β
NodePort |
β
LoadBalancer
πΉ NodePort Service π
NodePort exposes application using:
<Node-IP>:<Port>
This allows access from outside Kubernetes cluster.
πΉ How NodePort Works? βοΈ
Traffic Flow:
User β Worker Node IP β Service β Pod
Kubernetes opens a port on every worker node.
Example:
192.168.1.10:30007
πΉ Use Cases of NodePort π‘
Mostly used for:
β
Testing
β
Development
β
Internal applications
πΉ Limitations of NodePort β οΈ
β Not ideal for production internet exposure
β Requires node IP knowledge
β Limited scalability
πΉ LoadBalancer Service βοΈ
LoadBalancer exposes application publicly using cloud provider integrations.
Used mainly in:
AWS
Azure
GCP
πΉ How LoadBalancer Works? π
Traffic Flow:
Internet β Cloud Load Balancer β Service β Pods
Cloud provider automatically:
β
Creates public IP
β
Configures external load balancer
πΉ Benefits of LoadBalancer π
β
Public internet access
β
Production-ready
β
Automatic traffic distribution
β
Better scalability
πΉ Traffic Load Balancing in Kubernetes βοΈ
One of the biggest advantages of Services is:
Automatic traffic distribution
If multiple Pods exist: Kubernetes Service distributes requests across Pods.
πΉ Round Robin Load Balancing π
The instructor demonstrated:
Round Robin traffic distribution
Example:
Request 1 β Pod A
Request 2 β Pod B
Request 3 β Pod A
This improves:
β
Performance
β
Availability
β
Resource utilization
πΉ What is KubeShark? π¦
KubeShark is a Kubernetes traffic debugging and visualization tool.
It helps engineers:
β
Monitor traffic
β
Debug networking
β
Visualize request flow
β
Understand service communication
πΉ Why KubeShark is Useful? π
Normally, network traffic inside Kubernetes is difficult to understand.
KubeShark makes it easy by showing:
Real-time request & response flow
πΉ What Did the Instructor Demonstrate? π‘
Using KubeShark, the instructor showed:
β
Request origin
β
Traffic entering Service
β
Traffic routing to Pods
β
Load balancing behavior
πΉ Kubernetes Traffic Flow Explained π
Complete request flow:
User β Kubernetes Service β Selected Pod
If multiple Pods exist: Service automatically selects one Pod.
πΉ Real-Life Example π‘
Imagine: A restaurant has:
Multiple chefs (Pods)
One receptionist (Service)
Customers place orders at reception.
Reception distributes work among chefs equally.
This is exactly how:
Kubernetes Services perform load balancing
πΉ Why Services Are Critical in Production? π’
Without Services:
β Applications break when Pod IP changes
β Scaling becomes difficult
β Networking becomes unstable
Services provide:
β
Stability
β
Scalability
β
Reliable communication
β
Production-grade networking
πΉ Beginner-Friendly Summary π§
| Concept | Simple Meaning |
|---|---|
| Pod | Runs application |
| Service | Stable communication layer |
| Labels | Pod identification tags |
| Selectors | Used to find Pods |
| NodePort | Exposes app via node IP |
| LoadBalancer | Public internet access |
| KubeShark | Traffic monitoring tool |
πΉ Important kubectl Commands βοΈ
β View Services
kubectl get svc
β View Pods
kubectl get pods
β Describe Service
kubectl describe svc <service-name>
β Expose Deployment
kubectl expose deployment django-app --type=NodePort --port=80
π₯ Real-World Scenario Based Questions
β Why not use Pod IP directly?
β Answer:
Because Pod IPs are temporary and change whenever Pods restart or get recreated.
Services provide stable communication.
β How does Kubernetes achieve load balancing?
β Answer:
Kubernetes Services distribute incoming traffic across multiple Pods using round-robin method.
β What happens if labels donβt match selectors?
β Answer:
Service cannot discover Pods, so traffic routing fails.
β Why is LoadBalancer preferred in production?
β Answer:
Because it provides:
β
Public access
β
Scalability
β
Cloud integration
β
Better availability
β Why is KubeShark useful?
β Answer:
It helps DevOps engineers:
β
Visualize traffic
β
Debug networking
β
Monitor communication between services
πΉ What Problem Exists with Kubernetes Services? π€
Kubernetes Services are great for:
β
Service discovery
β
Internal communication
β
Basic load balancing
But in real production environments, they are not enough.
πΉ Limitations of Basic Kubernetes Services β οΈ
Basic Services cannot easily handle:
β Path-based routing
β Host-based routing
β Sticky sessions
β Advanced HTTPS/TLS management
β Centralized traffic management
πΉ Real-World Problem Example π‘
Imagine: Your company has:
Frontend application
API service
Admin dashboard
Payment service
If every application uses:
Separate LoadBalancer service
then:
β Multiple public IPs are created
β Cloud cost increases
β Management becomes difficult
πΉ Why LoadBalancer Services Become Expensive? π°
Cloud providers like:
AWS
Azure
GCP
charge money for every:
Public LoadBalancer IP
If a company has:
20 microservices
50 applications
then cost becomes very high.
πΉ Solution: Kubernetes Ingress π
Ingress provides:
β
Centralized routing
β
Single entry point
β
Advanced load balancing
β
HTTPS support
β
Domain-based routing
πΉ What is Kubernetes Ingress? π
Ingress is a Kubernetes resource used to:
Manage external access to applications inside the cluster
It acts like:
Smart traffic manager
for Kubernetes applications.
πΉ Real-Life Example π‘
Imagine a shopping mall.
Instead of every shop having:
β Separate gate
the mall uses:
One main entrance with security & routing
Visitors are guided to correct shops.
Similarly: Ingress routes users to correct services.
πΉ What Can Ingress Do? βοΈ
Ingress supports:
β
Host-based routing
β
Path-based routing
β
HTTPS/TLS
β
Load balancing
β
SSL termination
β
Reverse proxy functionality
πΉ What is Host-Based Routing? π
Traffic routing based on domain names.
Example:
api.myapp.com β API Service
admin.myapp.com β Admin Service
shop.myapp.com β Shopping Service
πΉ What is Path-Based Routing? π£οΈ
Traffic routing based on URL paths.
Example:
/api β Backend API
/admin β Admin dashboard
/products β Product service
πΉ What are Sticky Sessions? πͺ
Sticky sessions ensure:
User continuously connects to same backend server
Useful for:
Login sessions
Shopping carts
Stateful applications
πΉ Why Ingress is Important in Microservices? π’
Modern applications contain:
Many services
Multiple APIs
Separate frontend/backend systems
Ingress helps:
β
Manage traffic centrally
β
Simplify routing
β
Reduce infrastructure cost
πΉ Important Concept: Ingress Alone Does NOT Work β οΈ
This is the most important beginner concept.
Ingress resource only defines:
Routing rules
But it cannot actually handle traffic by itself.
πΉ What is an Ingress Controller? ποΈ
Ingress Controller is the actual component that:
β
Reads Ingress rules
β
Configures load balancer
β
Routes traffic properly
πΉ Real-Life Example π‘
Think of:
Ingress = Traffic rules document
Ingress Controller = Traffic police implementing rules
Without traffic police, rules cannot work.
πΉ Popular Ingress Controllers π
Common controllers include:
NGINX Ingress Controller
HAProxy
Traefik
F5
AWS ALB Controller
πΉ NGINX Ingress Controller π
The instructor used:
NGINX Ingress Controller
because it is:
β
Popular
β
Beginner friendly
β
Production-ready
β
Widely used in industry
πΉ How Ingress Works? π
Traffic Flow:
User β Ingress Controller β Ingress Rules β Kubernetes Service β Pods
πΉ Complete Workflow Explained π‘
Step 1: User opens website.
Step 2: Ingress Controller receives traffic.
Step 3: Ingress rules decide:
Where request should go
Step 4: Traffic forwarded to correct Kubernetes Service.
Step 5: Service sends traffic to Pods.
πΉ Practical Demo Covered in Video π§ͺ
The instructor demonstrated:
β
Creating Ingress resource
β
Installing NGINX Ingress Controller
β
Configuring routing rules
β
Exposing applications
β
Testing routing locally
Video link - https://youtu.be/47ck6bh6dfI?si=mDTEXUXP1N50AinI
πΉ Important Beginner Mistake β οΈ
Many beginners think:
Creating Ingress YAML is enough
But: β Without Ingress Controller, Ingress does not function.
πΉ Why Ingress Controller is Mandatory? π€
Because controller:
β
Watches Ingress resources
β
Applies routing configuration
β
Manages actual traffic flow
Without controller:
No traffic routing happens
πΉ Local Testing Using /etc/hosts π₯οΈ
The instructor also showed:
/etc/hosts file modification
for local domain testing.
Example:
127.0.0.1 myapp.local
This helps simulate:
β
Real domain names
β
Local testing environment
πΉ Kubernetes Ingress vs LoadBalancer βοΈ
| LoadBalancer | Ingress |
|---|---|
| Separate public IP for each service | Single entry point |
| Expensive | Cost efficient |
| Limited routing | Advanced routing |
| Basic load balancing | Enterprise features |
| Difficult to manage | Centralized management |
πΉ Why Companies Prefer Ingress? π’
Ingress provides:
β
Better scalability
β
Lower cloud cost
β
Centralized traffic management
β
HTTPS support
β
Production-ready architecture
πΉ Beginner-Friendly Architecture Flow βΈοΈ
Internet
β
Ingress Controller
β
Ingress Rules
β
Kubernetes Services
β
Pods
πΉ Important kubectl Commands βοΈ
β View Ingress Resources
kubectl get ingress
β Describe Ingress
kubectl describe ingress
β View Services
kubectl get svc
β View Pods
kubectl get pods
πΉ Example Ingress YAML π
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: my-ingress
spec:
rules:
- host: myapp.local
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: frontend-service
port:
number: 80
π₯ Real-World Scenario Based Questions
β Why not use LoadBalancer for every service?
β Answer:
Because:
β Cloud cost becomes very high
β Multiple public IPs are difficult to manage
Ingress provides centralized routing using single entry point.
β What happens if Ingress Controller is missing?
β Answer:
Ingress rules will exist, but traffic routing will not work.
Because controller is responsible for implementing rules.
β Why is Ingress important for microservices?
β Answer:
Because microservices architecture contains many services, Ingress helps manage:
β
Routing
β
Security
β
HTTPS
β
Traffic management centrally
β What is the difference between Ingress and Service?
β Answer:
| Service | Ingress |
|---|---|
| Internal communication | External traffic management |
| Basic load balancing | Advanced routing |
| Works inside cluster | Entry point for external users |
β Why is NGINX Ingress Controller popular?
β Answer:
Because it is:
β
Open-source
β
Fast
β
Reliable
β
Production-ready
β
Easy to configure
π₯ Interview Tip π
If interviewer asks:
Why Ingress is needed?
Best answer:
Ingress provides advanced routing, HTTPS security, and centralized traffic management while reducing cloud infrastructure cost.
πΉ What is RBAC in Kubernetes? π
RBAC stands for:
Role-Based Access Control
It is a security mechanism used in Kubernetes to:
Control who can access what inside the cluster
RBAC defines:
β
Who can access resources
β
What actions they can perform
β
Which resources they can manage
πΉ Why RBAC is Important? π€
In production environments, many people work on the same Kubernetes cluster.
Examples:
Developers
DevOps Engineers
Security Teams
QA Teams
Without RBAC:
β Anyone could delete Pods
β Anyone could change deployments
β Security risks become very high
πΉ Real-Life Example π‘
Imagine a company office.
Different employees have different permissions:
HR can access employee records
Finance team can access salary data
Security guards control entry gates
Not everyone gets:
Full admin access
Similarly, RBAC controls permissions inside Kubernetes.
πΉ What Does RBAC Control? βοΈ
RBAC controls actions like:
β
Creating Pods
β
Deleting Deployments
β
Viewing Logs
β
Accessing Secrets
β
Managing Namespaces
πΉ Core Components of Kubernetes RBAC π§©
RBAC mainly consists of:
Users / Service Accounts
Roles / ClusterRoles
RoleBindings / ClusterRoleBindings
These components work together to manage permissions.
πΉ Users & Service Accounts π€
These are identities requesting access.
Examples:
Developers
CI/CD pipelines
Applications
Automation tools
πΉ Difference Between User and Service Account βοΈ
| User | Service Account |
|---|---|
| Human identity | Application identity |
| Used by developers/admins | Used by Pods/apps |
| External authentication | Managed inside Kubernetes |
πΉ Important Beginner Concept β οΈ
Kubernetes does:
NOT manage users directly
Instead, authentication is handled using external systems like:
AWS IAM
Okta
Keycloak
Azure AD
πΉ What is a Role? π‘οΈ
A Role defines:
What actions are allowed
inside a specific namespace.
Example: A Role may allow:
β
View Pods
β
Read logs
β Cannot delete deployments
πΉ Real-Life Example of Role π‘
Think of:
Role = Job responsibilities
Example:
Manager permissions
Employee permissions
Intern permissions
πΉ What is a ClusterRole? π
ClusterRole works across:
Entire Kubernetes cluster
Unlike Roles, ClusterRoles are not limited to one namespace.
πΉ Difference Between Role and ClusterRole βοΈ
| Role | ClusterRole |
|---|---|
| Namespace-specific | Cluster-wide |
| Limited scope | Full cluster scope |
| Smaller permissions | Larger permissions |
πΉ What is RoleBinding? π
RoleBinding connects:
User/Service Account β Role
It assigns permissions to users.
Without RoleBinding:
β Roles are useless
πΉ Real-Life Example π‘
Imagine:
Role = Office ID card permissions
RoleBinding = Assigning ID card to employee
πΉ What is ClusterRoleBinding? π
ClusterRoleBinding connects:
User β ClusterRole
across the entire Kubernetes cluster.
πΉ How RBAC Works? π
Complete Flow:
User β RoleBinding β Role β Permissions β Kubernetes Resources
πΉ Example RBAC Workflow π‘
Developer wants to:
View Pods in development namespace
RBAC checks:
β
Does user have Role?
β
Is RoleBinding configured?
β
Does Role allow action?
If yes:
β
Access granted
Otherwise:
β Access denied
πΉ Why Companies Use RBAC? π’
RBAC helps organizations:
β
Improve security
β
Prevent accidental deletions
β
Control team permissions
β
Follow compliance rules
β
Separate responsibilities
πΉ What is OpenShift? βοΈ
OpenShift is:
Enterprise Kubernetes platform by Red Hat
It provides:
β
Kubernetes management
β
Security features
β
CI/CD integrations
β
Monitoring tools
πΉ OpenShift Sandbox for Beginners π
The instructor demonstrated:
Free 30-day OpenShift Sandbox
This gives learners:
β
Real Kubernetes environment
β
Hands-on practice
β
Production-like experience
without requiring cloud setup.
πΉ Benefits of OpenShift Sandbox π‘
Beginners can:
β
Practice Kubernetes
β
Deploy applications
β
Learn RBAC
β
Monitor workloads
β
Explore dashboards
πΉ OpenShift Dashboard π₯οΈ
The instructor also explored:
β
Deployments
β
Events
β
Pods
β
Monitoring tools
β
Resource usage
through the OpenShift UI dashboard.
πΉ CLI Login Using Token π
OpenShift allows login using:
CLI display token
This helps users securely connect to the cluster.
πΉ Why Learning RBAC is Important for DevOps Engineers? π
RBAC is used daily in production environments.
DevOps Engineers manage:
β
Team access
β
Deployment permissions
β
Security policies
β
CI/CD authentication
πΉ Beginner-Friendly RBAC Architecture βΈοΈ
User / Service Account
β
RoleBinding
β
Role
β
Kubernetes Resources
πΉ Example Role YAML π
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
namespace: dev
name: pod-reader
rules:
- apiGroups: [""]
resources: ["pods"]
verbs: ["get", "watch", "list"]
πΉ Example RoleBinding YAML π
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: read-pods
namespace: dev
subjects:
- kind: User
name: developer1
roleRef:
kind: Role
name: pod-reader
apiGroup: rbac.authorization.k8s.io
πΉ Important kubectl Commands βοΈ
β View Roles
kubectl get roles
β View RoleBindings
kubectl get rolebindings
β View ClusterRoles
kubectl get clusterroles
β View ClusterRoleBindings
kubectl get clusterrolebindings
β Check User Permissions
kubectl auth can-i create pods
π₯ Real-World Scenario Based Questions
β Why is RBAC important in Kubernetes?
β Answer:
RBAC improves security by controlling who can access and modify Kubernetes resources.
β What happens if RBAC is not configured?
β Answer:
Anyone with access may:
β Delete workloads
β Modify configurations
β Access sensitive data
This creates major security risks.
β Why does Kubernetes use external authentication providers?
β Answer:
Kubernetes focuses on cluster management, so authentication is delegated to systems like:
AWS IAM
Okta
Keycloak
β Difference between Role and ClusterRole?
β Answer:
| Role | ClusterRole |
|---|---|
| Namespace level | Cluster-wide |
| Limited scope | Global permissions |
β What is the purpose of RoleBinding?
β Answer:
RoleBinding assigns Roles to users or service accounts.
Without binding, permissions are not applied.
π₯ Interview Tip π
If interviewer asks:
What is RBAC?
Best answer:
RBAC is a Kubernetes security mechanism that controls which users or applications can perform specific actions on cluster resources.
π Continue Your Learning Journey
Thank you for taking the time to read this article.
Technology is evolving rapidly, and continuous learning is one of the most valuable investments you can make in your career. Whether you're exploring DevOps, Cloud Computing, Artificial Intelligence, Cybersecurity, Software Development, Data Science, or Career Growth, the resources below can help you deepen your knowledge and stay ahead in the industry.
π Recommended Learning Platforms
π Coursera
Learn from world-renowned universities and industry leaders including Google, IBM, Stanford, Microsoft, Meta, and many more.
β Professional Certificates β Career-focused Learning Paths β AI & Machine Learning Programs β Cloud & DevOps Certifications β Business & Leadership Courses
π https://imp.i384100.net/k0KvbV
π» Udemy
One of the largest online learning platforms with practical, hands-on courses covering:
β DevOps & Kubernetes β Docker & Cloud Computing β AWS, Azure & GCP β Programming & Development β Cybersecurity & Ethical Hacking
π https://trk.udemy.com/MAL2MY
π DataCamp
A great platform for anyone interested in:
β Python Programming β SQL & Databases β Data Analytics β Machine Learning β Artificial Intelligence
Interactive learning paths and hands-on projects make it ideal for beginners and professionals alike.
π https://datacamp.pxf.io/nX4kER
π edX
Access high-quality courses and certifications from leading institutions such as:
β Harvard University β MIT β Berkeley β Microsoft
Perfect for learners seeking university-level education online.
π https://edx.sjv.io/POvVeN
π¨ Domestika
Enhance your creative skills with courses on:
β Graphic Design β Video Editing β Animation β Digital Marketing β Content Creation
π https://domestika.sjv.io/dynKAW
π οΈ Recommended Tools & Resources
π₯ AppSumo
Discover exclusive lifetime deals on:
β AI Tools β Productivity Software β Developer Utilities β Marketing Platforms β Business Applications
A must-have resource for developers, creators, freelancers, and entrepreneurs looking to save money while accessing premium tools.
π https://appsumo.8odi.net/L04a33
π Shopify
Looking to start an online business or launch an eCommerce store?
Shopify provides everything you need to build, manage, and scale an online business.
β Online Store Builder β Payment Integration β Inventory Management β Marketing Tools
π https://shopify.pxf.io/Vxv09k
π WordPress, WooCommerce & Jetpack
Create professional websites, blogs, and online stores with one of the most trusted web ecosystems in the world.
Ideal for:
β Personal Blogs β Portfolio Websites β Business Websites β eCommerce Stores
π https://automattic.pxf.io/Z6vR5W
π Language Learning Resources
π£οΈ Preply
Learn English and other languages through personalized one-on-one tutoring sessions with experts from around the world.
π https://preply.sjv.io/o4gBDY
π British Council English Online
Improve your professional communication skills and English fluency through structured learning programs.
π https://englishonline.sjv.io/9VOGa4
π§ Rosetta Stone
One of the most recognized language-learning platforms for immersive language acquisition.
π https://aff.rosettastone.com/X4OyqG
π§ͺ Science & Educational Resources
π¬ MEL Science
Interactive science kits and educational experiences designed to make STEM learning engaging and practical.
π https://imp.i328067.net/bk2beg
π Carson Dellosa Education
Educational materials and learning resources for students, teachers, and lifelong learners.
π https://carsondellosaeducation.sjv.io/E0JbjW
β€οΈ Support My Work
Creating detailed technical content, tutorials, guides, and learning resources takes significant time and effort.
If you find my articles helpful and would like to support my work, you can do so through the following platforms:
β Become a GitHub Sponsor
Support my open-source contributions, technical content, and community projects.
π https://github.com/sponsors/hritikranjan1
β Buy Me a Chai
Enjoying my content? Consider buying me a chai and supporting future tutorials, guides, and educational resources.
π https://www.chai4.me/hritikranjan
π¨βπ» Connect With Me
Hritik Ranjan
π‘ AI Enthusiast βοΈ DevOps Learner π Cybersecurity Advocate π» Software Developer
Connect & Follow
π GitHub: https://github.com/hritikranjan1
π LinkedIn: https://linkedin.com/in/hritikranjan1
π’ Found This Article Helpful?
If this article added value to your learning journey:
β
Share it with your network
β
Bookmark it for future reference
β
Follow for more DevOps, AI, Cloud, Cybersecurity, and Software Engineering content
Thank you for reading and being part of this learning journey.
Keep Learning. Keep Building. Keep Growing. π






