Services for Network Access
Expose your applications inside and outside the cluster using various Kubernetes Service types.
Services for Network Access is a free Docker & DevOps Fundamentals lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Docker & DevOps Fundamentals learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
What is a Kubernetes Service?
In Kubernetes, Pods are the smallest deployable units. They are designed to be ephemeral, meaning they can be created, deleted, or replaced at any time, often receiving new IP addresses.
This dynamic nature makes it hard for other applications to reliably find and communicate with them. This is where Services come in!

Providing Stable Network Access
A Kubernetes Service acts as a stable network endpoint for a set of Pods. Think of it as a permanent address that doesn't change, even if the Pods behind it do.
- Services provide a consistent IP address and DNS name.
- They can load balance traffic across multiple Pods.
- They ensure continuous availability as Pods scale or restart.
Connecting Pods to Services
How does a Service know which Pods to route traffic to? It uses labels and selectors.
When you create Pods, you assign them labels (key-value pairs like app: my-app). A Service then specifies a selector that matches these labels, creating a dynamic link.
Internal Access with ClusterIP
The ClusterIP is the default and most common Service type. It assigns a stable internal IP address within the Kubernetes cluster. This IP is only reachable from other Pods or Nodes inside the cluster.
It's perfect for backend services (like a database or an API) that only need to communicate with other services within your application.
Defining a ClusterIP Service
Here's a simple YAML definition for a ClusterIP Service. Notice the selector matching the label app: my-backend, and how port maps to targetPort.
apiVersion: v1
kind: Service
metadata:
name: my-backend-service
spec:
selector:
app: my-backend
ports:
- protocol: TCP
port: 80
targetPort: 8080 # Port your application listens on
type: ClusterIPExternal Access with NodePort
A NodePort Service exposes your application on a static port on each Node's IP address. This makes your service accessible from outside the cluster using any Node's IP and the specified port.
The nodePort value is typically in the range 30000-32767. It's useful for simple external access or development environments.
Defining a NodePort Service
To expose your service externally via a NodePort, you set type: NodePort. You can optionally specify a nodePort, or Kubernetes will choose one for you.
apiVersion: v1
kind: Service
metadata:
name: my-frontend-service
spec:
selector:
app: my-frontend
ports:
- protocol: TCP
port: 80
targetPort: 80 # Port your application listens on
nodePort: 30080 # Optional: specific port on the Node
type: NodePortCloud Load Balancers
The LoadBalancer Service type is designed for cloud environments. When you create this type of Service, your cloud provider (like AWS, GCP, Azure) automatically provisions an external load balancer.
This load balancer gets a public IP address and routes external traffic directly to your Pods, often with advanced features like SSL termination.
Defining a LoadBalancer Service
For public-facing applications in a cloud Kubernetes cluster, LoadBalancer is the go-to choice. It simplifies external access management greatly.
apiVersion: v1
kind: Service
metadata:
name: my-web-app-lb
spec:
selector:
app: my-web-app
ports:
- protocol: TCP
port: 80
targetPort: 80
type: LoadBalancerChoose the Right Service
Your team is deploying a new application to Kubernetes. Consider the following scenarios:
- A backend API that only needs to be accessed by other services within the cluster.
- A frontend web server that needs to be accessible from the internet, and you are deploying on a cloud provider (AWS, GCP, Azure).
Which Service type is best suited for the frontend web server?
Recap: Services for Network Access
We learned that Kubernetes Services provide stable network access to dynamic Pods. They are essential for your applications to communicate reliably.
- ClusterIP: For internal cluster communication only.
- NodePort: Exposes a service on a static port on each Node's IP, accessible externally for specific use cases.
- LoadBalancer: Integrates with cloud providers to provision an external load balancer for public access.
Choosing the right Service type is crucial for controlling how your applications are exposed.
Frequently asked questions
Is the “Services for Network Access” lesson free?
Yes — the full text of “Services for Network Access” is free to read here on the web, and the Docker & DevOps Fundamentals course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Docker & DevOps Fundamentals course, upgrade to CoddyKit PRO.
What will I learn in “Services for Network Access”?
Expose your applications inside and outside the cluster using various Kubernetes Service types. You practise Docker & DevOps Fundamentals with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Docker & DevOps Fundamentals?
No prior experience is required. Docker & DevOps Fundamentals on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Services for Network Access” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Docker & DevOps Fundamentals lesson?
Yes. Every Docker & DevOps Fundamentals lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Deployments for Stateless Apps
- Services for Network Access
- ConfigMaps & Secrets
- Ingress and External Routing