Skip to main content

KA-X001: Service selector matches no Pod template

Warning Cross-Resource

Why This Matters

A Service selector must match at least one Pod template in the same namespace for traffic routing to work. A dangling selector means the Service will have no endpoints, causing connection timeouts or refused connections at runtime.

How to Fix

Ensure a workload in the same namespace has labels matching the Service selector

Before (incorrect)

apiVersion: v1
kind: Service
metadata:
  name: my-svc
spec:
  selector:
    app: my-app

After (correct)

apiVersion: v1
kind: Service
metadata:
  name: my-svc
spec:
  selector:
    app: my-app
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-app
spec:
  template:
    metadata:
      labels:
        app: my-app

Rule Details

Rule Code
KA-X001
Severity
Warning
Category
Cross-Resource

Related Rules