You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
In Kubernetes, pods are ephemeral — they can be created, destroyed, and rescheduled at any time. Services provide a stable network endpoint for accessing a set of pods, while Ingress provides HTTP/HTTPS routing for external traffic. On GKE, both integrate deeply with Google Cloud Load Balancing.
A Service is an abstraction that defines a logical set of pods and a policy for accessing them. Services provide stable IP addresses and DNS names that do not change as pods come and go.
| Type | Description | Use Case |
|---|---|---|
| ClusterIP | Internal-only IP, accessible within the cluster | Service-to-service communication |
| NodePort | Exposes the service on each node's IP at a static port | Testing, limited external access |
| LoadBalancer | Creates a Google Cloud Network Load Balancer | Direct external access to a service |
| ExternalName | Maps to an external DNS name | Accessing external services by name |
| Headless | No ClusterIP — returns pod IPs directly via DNS | StatefulSet discovery, custom load balancing |
apiVersion: v1
kind: Service
metadata:
name: backend-api
spec:
type: ClusterIP
selector:
app: backend-api
ports:
- port: 80
targetPort: 8080
protocol: TCP
When you create a Service of type LoadBalancer on GKE, it automatically provisions a Google Cloud Network Load Balancer:
apiVersion: v1
kind: Service
metadata:
name: web-frontend
spec:
type: LoadBalancer
selector:
app: web-frontend
ports:
- port: 80
targetPort: 8080
protocol: TCP
Ingress provides HTTP/HTTPS routing from outside the cluster to services inside the cluster. On GKE, the Ingress controller creates a Google Cloud HTTP(S) Load Balancer.
| Feature | Description |
|---|---|
| Path-based routing | Route /api to one service, /web to another |
| Host-based routing | Route api.example.com to one service, web.example.com to another |
| TLS termination | Terminate HTTPS at the load balancer with managed certificates |
| Health checks | Automatic health check configuration for backends |
| Cloud CDN | Enable content caching at Google's edge |
| Cloud Armor | WAF and DDoS protection |
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.