Day 34 - Unlocking Kubernetes Services: Enhance Your App Networking Journey! ๐๐๐
๐ 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:
Create a Service definition YAML file.
Apply the Service definition to your K8s (minikube) cluster.
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:
Define a ClusterIP Service YAML file.
Apply the ClusterIP Service to your K8s cluster.
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:
Define a LoadBalancer Service YAML file.
Apply the LoadBalancer Service to your K8s cluster.
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 ๐๐