Accessing Kubernetes service on port 80
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
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.

