Skip to main content

Command Palette

Search for a command to run...

🎯Day 34 - Working with Services in Kubernetes

Published
2 min read
🎯Day 34 - Working with Services in Kubernetes
S
Hi, I’m Sarika 👋 I’m a QA Engineer with 2+ years of experience in software testing. I have hands-on experience in: * Functional & Regression Testing * API Testing using Postman * Database validation using SQL * Cross-browser testing Currently, I’m focusing on: * Automation Testing using Selenium & Playwright (Java) * Building real-world testing frameworks * End-to-End testing (UI + API + DB) This blog is where I share: * What I learn daily * Real testing scenarios * Practical examples (not just theory) * Interview-focused concepts 🚀 Learning | Building | Sharing Follow me on LinkedIn: https://www.linkedin.com/in/sarika-kamble-3153b3218/

🎯What are Services in K8s

In Kubernetes, Services are objects that provide stable network identities to Pods and abstract away the details of Pod IP addresses. Services allow Pods to receive traffic from other Pods, Services, and external clients.

🎯Task-1:

  • Create a Service for your todo-app Deployment from Day-32

  • Create a Service definition for your todo-app Deployment in a YAML file.

apiVersion: v1
kind: Service
metadata:
  name: node-app-service
  namespace: node-app-deployment
  labels:
    app: node-app
spec:
  type: NodePort
  selector:
    app: node-app
  ports:
    - port: 80
      targetPort: 8000
      nodePort: 30003
  • Apply the Service definition to your K8s (minikube) cluster using the kubectl apply -f service.yml -n <namespace-name> command.

  • Verify that the Service is working by accessing the todo-app using the Service's IP and Port in your Namespace.

🎯Task-2:

  • Create a ClusterIP Service for accessing the todo-app from within the cluster

  • Create a ClusterIP Service definition for your todo-app Deployment in a YAML file.

      apiVersion: v1
      kind: Service
      metadata:
        name : node-app-service
        namespace: node-app-deployment
      spec:
        selector:
          app: node-app
        ports:
          - port: 8000
            targetPort: 8000
        type: ClusterIP
    
  • Apply the ClusterIP Service definition to your K8s (minikube) cluster using the kubectl apply -f cluster-ip-service.yml -n <namespace-name> command.

  • Verify that the ClusterIP Service is working by accessing the todo-app from another Pod in the cluster in your Namespace.

🎯Task-3:

  • Create a LoadBalancer Service for accessing the todo-app from outside the cluster

  • Create a LoadBalancer Service definition for your todo-app Deployment in a YAML file.

       apiVersion: v1
      kind: Service
      metadata:
        name : node-app
        namespace: node-app-deployment
      spec:
        selector:
          app: node-app
        ports:
          - port: 8000
            targetPort: 8000
        type: LoadBalancer
    
    • Apply the LoadBalancer Service definition to your K8s (minikube) cluster using the kubectl apply -f load-balancer-service.yml -n <namespace-name> command.

  • Verify that the LoadBalancer Service is working by accessing the todo-app from outside the cluster in your Namespace.

📚Happy Learning :)

More from this blog

S

Sarika Tech Journey

42 posts