Kubernetes Service Checker

Paste a Service and the workload it is meant to reach, and find out whether it will actually have endpoints. A Service that selects nothing is accepted, reports healthy, and refuses every connection, with no warning anywhere.

Paste below, or drop a file anywhere on this panel

Or drop a file anywhere on this panel. Nothing is uploaded: the analysis runs in this tab.

The answer appears here

Paste on the left and press Check wiring. Nothing leaves this tab.

Examples

Real input you can load into the tool above. Each one shows a different thing going wrong, because that is what the tool is for.

Selector does not match

The commonest reason a Service returns connection refused with nothing in the logs

apiVersion: v1
kind: Service
metadata:
  name: api
spec:
  selector:
    app: api
  ports:
    - port: 80
      targetPort: 8080
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: api
spec:
  template:
    metadata:
      labels:
        app: web

A working Service

Selector and pod labels agreeing, which is what the failing case should look like

apiVersion: v1
kind: Service
metadata:
  name: api
spec:
  selector:
    app: api
  ports:
    - port: 80
      targetPort: 8080
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: api
spec:
  template:
    metadata:
      labels:
        app: api

Common mistakes

These are the ones that fail silently. The config is accepted, nothing raises an error, and the consequence arrives later.

  1. Debugging DNS when the endpoints are empty

    A Service with no matching pods resolves fine and refuses connections. The symptom looks like networking and the cause is a label typo.

    Instead:kubectl get endpoints <service> first. Empty means the selector matched nothing.

  2. Expecting a Service to route to a not-ready pod

    Only pods passing their readiness probe are added to endpoints. A failing probe removes the pod silently, which looks like intermittent failure.

    Instead:Check readiness before checking anything else in the network path.

  3. Using a headless Service by accident

    clusterIP: None gives DNS records per pod and no load balancing or virtual IP. Set unintentionally, clients connect to one pod forever.

    Instead:Leave clusterIP unset unless you specifically want per-pod DNS.

What it catches

All of it is determinable from the manifests, which is why it is worth knowing before you apply rather than after the pager goes off.

The labels people copy from the wrong block

A Service selects pods, and pod labels live at spec.template.metadata.labels. A Deployment also has its own metadata.labels, and the two are usually written to look identical. Copy the wrong one and you get a Service with no endpoints, no error from kubectl, and a connection refused that looks like the application is down. This is reported by name, not as a generic no-match.

Which key is wrong, not just that something is

A selector is an exact AND across every key, so one wrong value is the same as no match at all. When a workload satisfies three of four labels, the report says which key differs, what the pod has, and what the selector wanted.

Named ports, which fail hard

A numeric targetPort is informational and works whether or not a container declared it. A named one is resolved by the kubelet against the containers' port names, so a name nothing declares means the endpoint is never created. The two are treated differently because Kubernetes treats them differently.

Namespaces, and selectors that are too broad

A Service never selects pods in another namespace. If the only match is elsewhere, the report says so rather than reporting nothing. It also flags a selector matching two workloads at once, which is right for a blue/green cutover and a surprise the rest of the time.

How a Service actually finds its pods

There is no link between a Service and a Deployment. They never reference each other, and nothing validates that they agree. The only connection is that both mention the same labels, and if they stop agreeing, the two objects carry on existing happily while no traffic flows between them.

Three label blocks, and only one of them matters here

A Deployment manifest contains labels in three places and they do different jobs. The Service selector matches the third one, the pod template. Copying from the first is the classic failure, and because the blocks are usually written with the same values, everything looks correct in review.

kind: Deployment
metadata:
  labels:            <- the Deployment's own labels. Not this one.
    app: api
spec:
  selector:
    matchLabels:     <- how the Deployment finds its ReplicaSet. Not this one.
      app: api
  template:
    metadata:
      labels:        <- the POD labels. A Service matches THIS.
        app: api

The selector is an exact AND, with no expressions

Every key in the selector must be present on the pod with exactly that value. There is no partial match and no ordering, and unlike a Deployment's own selector there are no matchExpressions: a Service selector is equality-only. So adding one key to a selector without adding it to the pod template silently disconnects the Service.

selector:            pod labels:          result
  app: api             app: api             match
  tier: web            tier: web

  app: api             app: api             no match
  tier: web            tier: backend        (tier differs)

  app: api             app: api             no match
  version: v2                               (version absent)

What happens when nothing matches

Nothing. The Service is created, gets a ClusterIP, resolves in DNS, and appears in kubectl get svc looking exactly like a working one. It simply has no endpoints, so every connection to it is refused immediately. There is no warning at apply time and no event, which is why this is worth checking from the manifests rather than after deploying.

kubectl get endpoints api

NAME   ENDPOINTS   AGE
api    <none>      4m

that <none> is the whole diagnosis, and nothing else shows it

port, targetPort and containerPort are three different numbers

port is what the Service listens on. targetPort is the port on the pod it forwards to, and defaults to the same value as port when omitted, which is a common source of surprise. containerPort is only documentation: a container can listen on a port it never declared, and traffic still arrives. That last point cuts both ways, because it means a wrong targetPort produces a connection refused that is indistinguishable from a selector problem.

spec:
  ports:
    - port: 80         clients connect here
      targetPort: 8080 forwarded to this port on the pod

targetPort omitted -> defaults to the value of port, not to
                      whatever the container happens to declare

And it stops at the namespace boundary

A selector only ever considers pods in the Service's own namespace. There is no way to select across one. Reaching a service in another namespace is done through DNS, using the full name, or with an ExternalName Service as an alias.

api.other-namespace.svc.cluster.local

More kubernetes tools

Kubernetes YAML Generator Answer a few questions, get a manifest Kubernetes YAML Validator Is this YAML valid, and where is it wrong? Kubernetes Rollout & Probe Timing Restart loops, capacity dips and stuck drains Kubernetes Network Policy Viewer What can reach what, and what just broke Kubernetes Manifest Diff What actually changed Kubernetes Resource Calculator What these manifests actually reserve Kubernetes RBAC Viewer Who can actually do what Kubernetes Deployment Generator See the capacity dip before you deploy Kubernetes Service Generator port, targetPort, and which one you meant Kubernetes StatefulSet Generator Stable names, and volumes that outlive you Kubernetes QoS Class Calculator And where you sit in the eviction order Kubernetes Node Capacity Planner Allocatable is not capacity Kubernetes Max Pods per Node Calculator The ENI limit, not the 110 default Kubernetes Label Selector Tester Which key failed, not just that one did Kubernetes Taint & Toleration Tester Tolerations permit, they do not attract Kubernetes Resource Name Validator RFC 1123 subdomain, label, or 1035 Kubernetes Label & Annotation Validator Why your image tag is not a legal label Kubernetes CrashLoopBackOff Guide The status is a timer, not a cause Kubernetes TLS Certificate Decoder When it expires, and what it covers Kubernetes ServiceAccount Token Decoder Bound or legacy, and when it dies Kubernetes imagePullSecret Generator The registry URL nobody gets right Kubernetes cert-manager Certificates Issuer scope, and the rate limit that costs a week Kubernetes Flux HelmRelease Generator With the source it cannot work without Kubernetes Helm Chart Generator Chart.yaml, values, and working templates Kubernetes Argo CD Application Generator The defaults that are off, turned on Kubernetes Ingress Generator pathType, and the TLS secret that fails quietly Kubernetes HPA Generator Why it says unknown and never scales Kubernetes SecurityContext Generator Pod level, container level, and which wins Kubernetes Probe Generator How long it gets to start before liveness kills it Kubernetes PVC Generator Access modes your storage can actually do Kubernetes ResourceQuota Generator And the LimitRange that stops it breaking deploys Kubernetes CronJob Generator The fields that decide whether it runs Kubernetes NetworkPolicy Generator With the DNS rule already in it Kubernetes RBAC Generator And what it actually grants Kubernetes PodDisruptionBudget Generator Can this budget ever be satisfied? Kubernetes API Deprecation Checker What breaks on the next upgrade Kubernetes Kubeconfig Viewer Read it without handing it to anyone Kubernetes Quantity Parser What 512Mi, 100m and 1e3 actually mean Kubernetes Multi-Document YAML Splitter One file per object, in apply order Kubernetes .env to ConfigMap & Secret Split the credentials out on the way Kubernetes Secret Decoder See what is actually in there Kubernetes Ingress to Gateway API Which annotations silently stop working Kubernetes Manifest Visualizer What points at what, and what points at nothing Kubernetes Patch Tester Which --type, and what it deletes Kubernetes kubectl JSONPath Tester kubectl's dialect, not generic JSONPath Kubernetes Node Affinity Tester Required excludes, preferred only scores Kubernetes Helm Values Diff A missing key is a third value Kubernetes Pod and Service CIDR Fixed at cluster creation Kubernetes Secret Encoder base64 is not encryption Kubernetes API Version Checker Will this apply on that cluster Kubernetes Go Template Tester Go truthiness is not JavaScript's Kubernetes Cluster Cost Estimator At your rates, not a price table Kubernetes Kustomize Build Transformers run in kustomize's order Kubernetes Helm Chart Validator version is SemVer, appVersion is not

Elsewhere on the site