0
0
GCPcloud~30 mins

GKE Ingress with Load Balancer in GCP - Mini Project: Build & Apply

Choose your learning style9 modes available
GKE Ingress with Load Balancer
📖 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
Need a 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
Need a 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.

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: webapp-ingress
  annotations:
    kubernetes.io/ingress.class: "gce"
spec:
  rules:
  - http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: webapp-service
            port:
              number: 80
GCP
Need a hint?

Create a YAML file named webapp-ingress.yaml with the exact Ingress resource content and apply it using kubectl apply -f webapp-ingress.yaml.

4
Verify the Load Balancer IP
Run kubectl get ingress webapp-ingress to display the Ingress resource details and print the external IP address of the Load Balancer.
GCP
Need a hint?

Use kubectl get ingress webapp-ingress to see the external IP address under the ADDRESS column.