DEV Community

Ibrahim S
Ibrahim S

Posted on

ClusterIP - Kubernetes

ClusterIP --> The default service type, accessible only within the cluster. It's used for internal communication between services.
For example, communication between the front-end and back-end components of your application.

Create a 3 file

  1. nginx-pod.yml
  2. nginx-deployment.yml
  3. nginx-svc.yml
apiVersion: v1
kind: Pod
metadata:
  name: nginx-pod
spec:
  containers:
  - image: nginx
    name: nginx-ctr
Enter fullscreen mode Exit fullscreen mode

Execute the pod

kubectl apply -f nginx-pod.yml
kubectl get pods 
Enter fullscreen mode Exit fullscreen mode

Image description

Get the pod full details

kubectl get pods -o wide
Enter fullscreen mode Exit fullscreen mode

Image description

Create a deployment file

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  replicas: 2
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - image: nginx
        name: nginx-ctr
Enter fullscreen mode Exit fullscreen mode

Execute the deployment file

kubectl apply -f nginx-deployment.yml
kubectl get pods
Enter fullscreen mode Exit fullscreen mode

Image description

Create a service file

apiVersion: v1
kind: Service
metadata:
  name: nginx-svc
spec:
  selector:
    app: nginx
  ports:
    - name: nginx-port
      protocol: TCP
      port: 32767
      targetPort: 80
Enter fullscreen mode Exit fullscreen mode

Image description

Get the full information on pods

kubectl get all
Enter fullscreen mode Exit fullscreen mode

Image description

Get the pod IP address

kubectl get pods -o wide (or)
kubectl get endpoints
Enter fullscreen mode Exit fullscreen mode

Image description

POD → 1

Image description

POD → 2

Image description

Login to the container and change the Nginx file

kubectl -it exec nginx-deployment-7bb9945d7c-75nc5 -- /bin/sh
Enter fullscreen mode Exit fullscreen mode

Image description

Get the services IP

kubectl get svc
Enter fullscreen mode Exit fullscreen mode

Image description

Automatically load balancing selected

Image description

  • Accessible only within the cluster → ClusterIP → Internal load balancer.

  • Cluster IP service identifies pods using the selector → How pods are identified.

  • Target port helps in identifying pod port → how port is identified.

Quadratic AI

Quadratic AI – The Spreadsheet with AI, Code, and Connections

  • AI-Powered Insights: Ask questions in plain English and get instant visualizations
  • Multi-Language Support: Seamlessly switch between Python, SQL, and JavaScript in one workspace
  • Zero Setup Required: Connect to databases or drag-and-drop files straight from your browser
  • Live Collaboration: Work together in real-time, no matter where your team is located
  • Beyond Formulas: Tackle complex analysis that traditional spreadsheets can't handle

Get started for free.

Watch The Demo 📊✨

Top comments (0)

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

👋 Kindness is contagious

Explore a trove of insights in this engaging article, celebrated within our welcoming DEV Community. Developers from every background are invited to join and enhance our shared wisdom.

A genuine "thank you" can truly uplift someone’s day. Feel free to express your gratitude in the comments below!

On DEV, our collective exchange of knowledge lightens the road ahead and strengthens our community bonds. Found something valuable here? A small thank you to the author can make a big difference.

Okay