Deploying Scalable NGINX Applications on Kubernetes Using ReplicationController and Services with Bhashwanth & Chinnu

๐งโ๐ป Blog Title:
"Kubernetes Services in Action: Deploying and Exposing NGINX with ReplicationController (ft. Bhashwanth & Chinnu)"
๐ Table of Contents:
Introduction
Prerequisites
Creating the ReplicationController
Exposing the Pods Using Services
ClusterIP
NodePort
LoadBalancer
Accessing the Application
Output Commands & Snapshots
Conclusion
1. Introduction
This guide walks you through how to:
Deploy a ReplicationController
Expose your Pods using ClusterIP, NodePort, and LoadBalancer
Use Kubernetes concepts in a fun way by naming components after Tollywood-style names โ Bhashwanth and Chinnu.
2. Prerequisites
Kubernetes cluster (minikube or cloud-based like EKS, AKS, GKE)
kubectl
configuredBasic YAML understanding
Directory structure:
bashCopyEditReplication/
โโโ clusterip-service.yml
โโโ nodeport-service.yml
โโโ loadbalancer-service.yml
โโโ replication-controller.yml
3. ReplicationController YAML
๐ replication-controller.yml
:
yamlCopyEditapiVersion: v1
kind: ReplicationController
metadata:
name: bhashwanth-controller
labels:
app: bhashwanth
spec:
replicas: 3
selector:
actor: chinnu
template:
metadata:
labels:
actor: chinnu
spec:
containers:
- name: chinnu-container
image: nginx
ports:
- containerPort: 80
nodeSelector:
service: worker-1
๐ฏ This creates 3 nginx pods labeled with actor: chinnu
.
4. Exposing Pods with Services
๐ก A. ClusterIP Service
๐ clusterip-service.yml
yamlCopyEditapiVersion: v1
kind: Service
metadata:
name: bhashwanth-clusterip-service
labels:
actor: bhashwanth
spec:
type: ClusterIP
selector:
actor: chinnu
ports:
- port: 80
targetPort: 80
โ๏ธ Internal access only.
๐ต B. NodePort Service
๐ nodeport-service.yml
yamlCopyEditapiVersion: v1
kind: Service
metadata:
name: bhashwanth-nodeport-service
labels:
actor: bhashwanth
spec:
type: NodePort
selector:
actor: chinnu
ports:
- port: 80
targetPort: 80
nodePort: 30005
๐ Access app via:
cppCopyEdithttp://<Node-IP>:30005
๐ข C. LoadBalancer Service
๐ loadbalancer-service.yml
yamlCopyEditapiVersion: v1
kind: Service
metadata:
name: bhashwanth-loadbalancer-service
labels:
actor: bhashwanth
spec:
type: LoadBalancer
selector:
actor: chinnu
ports:
- port: 80
targetPort: 80
๐ Automatically creates an external LoadBalancer (on supported cloud providers).
5. Apply All Configurations
bashCopyEditkubectl apply -f replication-controller.yml
kubectl apply -f clusterip-service.yml
kubectl apply -f nodeport-service.yml
kubectl apply -f loadbalancer-service.yml
โ Verify Resources:
bashCopyEditkubectl get rc
kubectl get pods
kubectl get svc
6. Output Example
bashCopyEditkubectl get pods
NAME READY STATUS RESTARTS AGE
bhashwanth-controller-abc 1/1 Running 0 20s
...
kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
bhashwanth-clusterip-service ClusterIP 10.96.0.1 <none> 80/TCP 1m
bhashwanth-nodeport-service NodePort 10.96.0.2 <none> 80:30005/TCP 1m
bhashwanth-loadbalancer-service LoadBalancer 10.96.0.3 <pending> 80:xxxxx/TCP 1m
7. Conclusion
You've now:
Created a ReplicationController for nginx
Managed Pods with
chinnu
labelsExposed the app via ClusterIP, NodePort, and LoadBalancer
Understood practical K8s service types using a fun name twist
๐ Now you're ready to scale your K8s deployment like a blockbuster hit!
Subscribe to my newsletter
Read articles from BHASHWANTH PALUKURI directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
