📖 Scenario: You are managing a Kubernetes cluster on Google Cloud Platform (GCP). You want to expose your application to the internet using a Load Balancer. To do this, you will create an Ingress resource in Google Kubernetes Engine (GKE) that automatically provisions a Google Cloud Load Balancer.This project will guide you step-by-step to create a simple web application deployment, configure a service, set up an Ingress resource, and verify the Load Balancer is working.
🎯 Goal: Build a GKE Ingress resource that exposes a web application through a Google Cloud Load Balancer. You will create a deployment, a service, and an ingress resource with the correct annotations and rules.
📋 What You'll Learn
Create a Kubernetes deployment named webapp with the image nginx:1.23 and 2 replicas
Create a service named webapp-service of type NodePort exposing port 80
Create an Ingress resource named webapp-ingress that routes HTTP traffic to webapp-service
Use the annotation kubernetes.io/ingress.class: "gce" to specify the GCP Load Balancer
Print the Ingress resource details to verify the Load Balancer IP
💡 Why This Matters
🌍 Real World
In real projects, exposing applications securely and reliably to the internet is essential. GKE Ingress with Load Balancer automates this process on Google Cloud.
💼 Career
Understanding how to configure GKE Ingress and Load Balancers is a key skill for cloud engineers and DevOps professionals working with Kubernetes on GCP.
Progress0 / 4 steps
1
Create the Deployment
Create a Kubernetes deployment named webapp with 2 replicas using the image nginx:1.23. Use the command kubectl create deployment webapp --image=nginx:1.23 --replicas=2.
GCP
Hint
Use kubectl create deployment with the exact name webapp, image nginx:1.23, and replicas set to 2.
2
Create the Service
Create a service named webapp-service of type NodePort that exposes port 80 and targets the webapp deployment. Use the command kubectl expose deployment webapp --name=webapp-service --type=NodePort --port=80.
GCP
Hint
Use kubectl expose deployment with the exact service name webapp-service, type NodePort, and port 80.
3
Create the Ingress Resource
Create an Ingress resource named webapp-ingress with the annotation kubernetes.io/ingress.class: "gce" that routes HTTP traffic to the webapp-service on port 80. Use the following YAML manifest and apply it with kubectl apply -f webapp-ingress.yaml.
5. You want to expose two services, frontend and backend, on the same IP but different paths using GKE Ingress with a Load Balancer. Which YAML snippet correctly configures this?