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:

  1. Introduction

  2. Prerequisites

  3. Creating the ReplicationController

  4. Exposing the Pods Using Services

    • ClusterIP

    • NodePort

    • LoadBalancer

  5. Accessing the Application

  6. Output Commands & Snapshots

  7. 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 configured

  • Basic 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 labels

  • Exposed 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!

0
Subscribe to my newsletter

Read articles from BHASHWANTH PALUKURI directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

BHASHWANTH PALUKURI
BHASHWANTH PALUKURI