What is a Service?

last updated May 10, 2019

There are 2 hard problems in computer science: cache invalidation, naming things, and off-by-1 errors. -- Leon Bambrick

A Kubernetes Service is an object which describes how to access your applications. You can think of a Service a bit like a DNS name, a firewall rule, and a load balancer all in-one - because it is! Services "select" applications to point at via their selector tag - you'll notice this matches our definition on the DeploymentIn Kubernetes, a Deployment is an object which describes how an application is deployed. A Deployment defines the images to launch, how to configure them, and how they should be deployedRead More... example page.

apiVersion: v1
kind: Service
name: nginx-http
type: ClusterIP
- name: tcp
port: 80
app: nginx

Once defined, all pods in the same NamespaceA Namespace is a logical group for application environments - staging, qa, production - a namespace isolates containers within it from containers outside.Read More... as this pod can automatically access the NGINX server via the address: http://nginx-http. Many services can select the same pods, and pods can be exposed by multiple services (for example, we're only exposing port 80 here - another service might expose the 443 port later).

Services have a number of "types" of Kubernetes Services:

  • ClusterIP: This type of service is only reachable from inside the cluster and is the default type.

  • NodePort: This service type selects a static port number on the Node, potentially allowing access to the service from the internet.

  • LoadBalancer: A LoadBalancer service requires a Cloud Provider plugin which will create an actual Cloud LoadBalancer resource for you. Kubernetes then actively manages the LoadBalancer, ensuring it points at the right nodes and the right ports!