Search⌘ K
AI Features

A Quick Example

Explore how to create and deploy a basic Kubernetes Service using the NodePort type. Understand how selectors route requests to pods, and see how services provide stable endpoints and load balance traffic across multiple replicas.

We'll cover the following...

Before we start talking about how a service works and all the different types of services we can have, let’s see a simple service in action to understand what it is doing.

YAML
apiVersion: v1
kind: Service
metadata:
name: hellok8s-svc
spec:
type: NodePort
selector:
app: hellok8s
ports:
- port: 4567
nodePort: 30001

By now, you should be getting used to the general manifest format. Most of this service definition is quite similar to the pods and deployment manifests we have seen.
We define a resource with the Service kind and give it the name ...