Day 34 - Unlocking Kubernetes Services: Enhance Your App Networking Journey! ๐ŸŒ๐Ÿ”—๐Ÿš€

Day 34 - Unlocking Kubernetes Services: Enhance Your App Networking Journey! ๐ŸŒ๐Ÿ”—๐Ÿš€

ยท

2 min read

๐Ÿš€ Day 34 of #90DaysOfDevOpsChallenge! Today, let's dive into Kubernetes Services! ๐ŸŽ‰ Learn how Services provide stable network identities to Pods, allowing them to receive traffic from other Pods, Services, and external clients. ๐Ÿ’กโœจ

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:

  1. Create a Service definition YAML file.

  2. Apply the Service definition to your K8s (minikube) cluster.

  3. Verify functionality by accessing the todo-app using the Service's IP and Port.๐Ÿ› ๏ธ๐Ÿ”—๐Ÿ–ฅ๏ธ

apiVersion: v1
kind: Service
metadata:
  name: todo-app-service
spec:
  selector:
    app: todo-app
  ports:
    - protocol: TCP
      port: 80
      targetPort: 8080

kubectl apply -f todo-app-service.yaml

Task 2๏ธโƒฃ: Create a ClusterIP Service for internal cluster access:

  1. Define a ClusterIP Service YAML file.

  2. Apply the ClusterIP Service to your K8s cluster.

  3. Verify functionality by accessing the todo-app from another Pod in the cluster.๐ŸŒ๐Ÿ”’๐Ÿ”ง

apiVersion: v1
kind: Service
metadata:
  name: todo-app-clusterip
spec:
  selector:
    app: todo-app
  ports:
    - protocol: TCP
      port: 80
      targetPort: 8080
  type: ClusterIP

kubectl apply -f clusterip-service.yaml

Task 3๏ธโƒฃ: Create a LoadBalancer Service for external access:

  1. Define a LoadBalancer Service YAML file.

  2. Apply the LoadBalancer Service to your K8s cluster.

  3. Verify functionality by accessing the todo-app from outside the cluster.๐ŸŒ๐Ÿ”—๐Ÿšช

apiVersion: v1
kind: Service
metadata:
  name: todo-app-loadbalancer
spec:
  selector:
    app: todo-app
  ports:
    - protocol: TCP
      port: 80
      targetPort: 8080
  type: LoadBalancer

kubectl apply -f loadbalancer-service.yaml

Happy Learning! ๐ŸŒŸ๐Ÿ“š #DevOps #Kubernetes #LearningJourney ๐Ÿš€๐Ÿ”

Did you find this article valuable?

Support Nilkanth Mistry by becoming a sponsor. Any amount is appreciated!

ย