Skip to main content
reliability · kubernetes

StatefulSets that name no governing service in serviceName

resource types
1
rule IDs covered
3
severity
medium

What does ZopNight detect here?

ZopNight flags an EKS, GKE or AKS StatefulSet whose `spec.serviceName` is empty. The governing headless Service is what gives each pod a stable DNS name of the form `web-0.nginx.default.svc.cluster.local`, so without it peers and clients cannot address individual replicas, and the field cannot be added later without recreating the StatefulSet.

Signal and threshold

How ZopNight evaluates StatefulSets that name no governing service in serviceName.
Field Value
Rule IDsRC-1760 · RC-1860 · RC-1960
Categoryreliability
Severitymedium
Metricspec.serviceName
Thresholdempty or unset
SourceZopNight
Permissions usedlist statefulsets.apps · list services

Stable pod identity depends on a governing service

Each StatefulSet pod gets a predictable hostname, <statefulset>-<ordinal>, such as web-0. The DNS record that makes that name reachable comes from a headless Service. The StatefulSets concept page describes the domain it manages as <service>.<namespace>.svc.cluster.local, with each pod getting <pod>.<service domain>, where the governing service is the one named in serviceName. The same page is explicit that StatefulSets currently need a headless Service for their pods’ network identity and that you are responsible for creating it.

Clustered software leans on those names. Database replicas, consensus members and brokers often find each other by stable per-pod addresses, so a StatefulSet without a governing service can start its pods and still fail to form a cluster.

Checking your StatefulSets

Terminal window
kubectl get statefulsets -A -o json | jq -r '
.items[] | select((.spec.serviceName // "") == "")
| "\(.metadata.namespace)/\(.metadata.name)"'

For those that do set it, confirm the named Service exists and is headless:

Terminal window
kubectl get service <service-name> -n <namespace> -o jsonpath='{.spec.clusterIP}'

A headless Service prints None.

An empty field is the only trigger

ZopNight reads the serviceName value collected for each StatefulSet and fires when it is empty or absent. It does not look up the Service itself, so a StatefulSet naming a Service that was later deleted, or one that is not headless, passes this check. There is no threshold or waiting period.

Why the fix means recreating the object

The Kubernetes API server treats serviceName as immutable once a StatefulSet exists, alongside the selector, volume claim templates and pod management policy. You cannot patch it in, which is why the check is worth catching early. The API reference also says the service must exist before the StatefulSet, so create it first.

A reliability gap without a price tag

The finding carries no saving. The risk is clustered applications that cannot discover their peers, and clients hard-coded to per-pod names that will not resolve.

Adding the headless service

  1. Create a Service with clusterIP: None whose selector matches the StatefulSet’s pod labels.
  2. Update the StatefulSet manifest to set serviceName to that Service.
  3. Delete the old object without its pods: kubectl delete statefulset <name> -n <namespace> --cascade=orphan.
  4. Apply the updated manifest. Existing PersistentVolumeClaims are not deleted with the StatefulSet, so the pods keep their data.
  5. Restart the pods one ordinal at a time, highest first, and check each resolves under the new domain before moving on.

See it fire on your bill.

Connect an account read-only. The first findings land in minutes.

472 rule families across 353 resource types on 22 platforms. Every threshold, metric, and IAM action is documented on these pages before you grant anything.

472 rule families documented
353 resource types covered
read-only default access level
Multi-cloud automation· Production-ready in 30 min· SOC 2 · ISO 27001· 20–60% off the bill, first month· 4 platforms · 1 console· Multi-cloud automation· Production-ready in 30 min· SOC 2 · ISO 27001· 20–60% off the bill, first month· 4 platforms · 1 console·