Quick answers (at a glance)
Inspect Services
List Services in the current namespace:kubernetes Service. The TYPE column shows this is a ClusterIP Service.
Examine Service details
Describe the Service to see detailed fields, includingTargetPort, labels, and Endpoints:
describe output:
- TargetPort is
6443. - The Service has two labels:
component=apiserverprovider=kubernetes
- Endpoints shows
10.53.180.9:6443— a single IP:port, so the Service currently has one endpoint.
What are Endpoints?
When a Service routes traffic to Pods, Kubernetes matches the Serviceselector to Pod labels. The collection of Pod IPs and ports identified by that selector are called Endpoints. If the selector matches multiple Pods, Endpoints will list each IP:port. If no Pods match, Endpoints will be empty and the Service won’t forward traffic.
The following diagram illustrates a Service selecting Pods (based on labels) and creating Endpoints for them.

- If a Service selector is incorrect (matches no Pod labels), Endpoints will be empty and the Service will not forward traffic.
- If a Pod accidentally has labels that match an existing Service, that Pod will become an endpoint for that Service.
kubernetes Service has a single endpoint.
Check for Deployments
List Deployments in thedefault namespace:
simple-webapp-deployment.
Describe the Deployment to see the Pod template and image used:
kodekloud/simple-webapp:red.
Is the web UI reachable?
Not yet. Attempting to access the web app UI before creating a Service results in a “Bad Gateway” or connection failure because no Service is exposing the Pods.Create a Service to expose the web application
You can create aNodePort Service that exposes the Deployment’s Pods so the UI is reachable from a node IP and port.
Example Service manifest:
http://<node-ip>:30080.
Tip: if you need to test from inside the cluster, you can curl the Service ClusterIP and port or use a pod to curl the NodePort from another node.
Generate Service YAML imperatively (dry-run)
Usekubectl to generate manifests without creating resources by using --dry-run=client -o yaml. These commands print YAML you can edit and apply:
If you are unsure about the fields required in a Service manifest, consult the Kubernetes Service documentation for examples of ClusterIP, NodePort, and LoadBalancer Services.
Links and references
- Kubernetes Services (official docs)
- kubectl reference
- Kubernetes Concepts: Services, Load Balancing, and Networking