Prerequisites
- A running GKE cluster
kubectlconfigured to point at your GKE cluster- An existing
gke-deployment.yamlthat successfully deploys your container

Why You Need a Service
A Kubernetes Service- Provides a stable IP or DNS name for your Pods
- Handles load balancing across Pod replicas
- Supports multiple types of exposure (ClusterIP, NodePort, LoadBalancer)
A Service decouples the network policy from your Pods. Even if your Pods get rescheduled or replaced, the Service IP/DNS remains constant.
Comparing Service Types
| Service Type | Description | Use Case |
|---|---|---|
| ClusterIP | Internal access within the cluster | Microservices communication |
| NodePort | Opens a port on each node’s IP | Quick testing, on-prem clusters |
| LoadBalancer | Provisions a cloud load balancer (GCP, AWS, Azure) | Exposing applications to the public internet automatically |
Updating gke-deployment.yaml
Add the following Service manifest below your existing Deployment spec in gke-deployment.yaml:
kubectl get svc my-app-service to retrieve the external IP:
http://34.68.12.34.
Provisioning a LoadBalancer can incur additional GCP costs. Be sure to delete unused Services when you’re done.