Accessing Kubernetes service on port 80
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
Kubernetes has emerged as a leading platform for automating deployment, scaling, and operations of application containers. One of the key functionalities in Kubernetes is its ability to handle application networking using Services. In this article, we'll explore accessing a Kubernetes Service configured on port 80, a common requirement for web applications.
Understanding Kubernetes Services
Kubernetes services are an abstraction which define a logical set of Pods and a policy by which to access them. Services enable seamless communication in a dynamic environment where IP addresses of Pods can frequently change.
Types of Services
Kubernetes supports several types of services:
- ClusterIP (default): Exposes the Service on a cluster-internal IP. It is accessible only from within the cluster.
- NodePort: Exposes the Service on each Node's IP at a static port.
- LoadBalancer: Exposes the Service externally using a cloud provider's load balancer.
- ExternalName: Maps the service to the contents of the `externalName` field (e.g., foo.bar.example.com).
Each of these plays a different role based on the required exposure of the application.
Configuring a Service on Port 80
Exposing services on port 80 is common for web applications. We'll cover the configuration needed for ClusterIP, NodePort, and LoadBalancer services to achieve this.
1. ClusterIP Example
- protocol: TCP
- protocol: TCP
- protocol: TCP
- ClusterIP: Use `kubectl port-forward` to access the service locally or deploy a proxy Pod in the cluster.
- NodePort: Access through the external IP of any node followed by the `NodePort` (e.g., `http://node-ip:30000\`).
- LoadBalancer: Access through the external IP addressed by the cloud provider's load balancer (e.g., DNS or IP).
- Ensure your firewall settings allow traffic on the desired ports.
- Be mindful of security and authentication when exposing services externally.
- Remember that each type has specific cloud provider requirements and configuration nuances.
Related reading
- Accessing Local Kafka from within Services deployed in Local Docker For Mac (incl. Kubernetes extension)
- Accessing Local Kafka from within Services deployed in Local Docker For Mac incl. Kubernetes extension
- Active-Passive Jenkins Setup in Kubernetes
- Add Helm chart dependency repository as git url
- Accessing RDS from within a Docker container not getting through security group?
- Accessing Tensorboard on AWS
- Accessing Terraform variables within user_data provider template file
- Accessing the application properties in logback.xml

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.