0
0
Kubernetesdevops~30 mins

LoadBalancer service type in Kubernetes - Mini Project: Build & Apply

Choose your learning style9 modes available
Create a Kubernetes LoadBalancer Service
📖 Scenario: You have deployed a simple web application in Kubernetes using a Deployment. Now, you want to expose this application to the internet so users can access it from outside the cluster.
🎯 Goal: Learn how to create a Kubernetes Service of type LoadBalancer to expose your application externally.
📋 What You'll Learn
Create a Deployment named webapp running the nginx image with 2 replicas
Create a Service named webapp-service of type LoadBalancer
The Service should select pods with label app: webapp
The Service should expose port 80 and forward it to container port 80
Print the Service YAML manifest at the end
💡 Why This Matters
🌍 Real World
In real cloud environments, LoadBalancer Services provide a simple way to expose applications to the internet with a cloud provider's load balancer.
💼 Career
Understanding how to expose Kubernetes applications externally is essential for DevOps roles managing cloud-native applications.
Progress0 / 4 steps
1
Create the Deployment
Create a Deployment named webapp with 2 replicas using the nginx image. The pods should have the label app: webapp. Write the YAML manifest for this Deployment.
Kubernetes
Need a hint?

Use kind: Deployment and set replicas: 2. Add label app: webapp under template.metadata.labels.

2
Add the LoadBalancer Service configuration
Create a Service named webapp-service of type LoadBalancer. It should select pods with label app: webapp. Expose port 80 and forward it to container port 80. Write the YAML manifest for this Service below the Deployment manifest.
Kubernetes
Need a hint?

Use kind: Service and set type: LoadBalancer. Use selector: app: webapp and expose port 80.

3
Apply the manifests to the cluster
Use the kubectl apply -f command to apply the YAML manifest file named webapp.yaml that contains both the Deployment and Service manifests.
Kubernetes
Need a hint?

Use kubectl apply -f webapp.yaml to apply the manifest file.

4
Display the Service details
Use the kubectl get service webapp-service command to display the details of the LoadBalancer Service and show its external IP address.
Kubernetes
Need a hint?

Use kubectl get service webapp-service to see the external IP and ports.