Skip to main content

KA-R011: Selector/template label mismatch

Error Reliability

Why This Matters

The resource has a mismatch between spec.selector.matchLabels and spec.template.metadata.labels. Every label in the selector must exist with the same value in the pod template labels. A mismatch causes the controller to fail to manage its pods, and Kubernetes will reject the resource at creation time.

How to Fix

Ensure all selector matchLabels appear in the template metadata labels

Before (incorrect)

spec:
  selector:
    matchLabels:
      app: myapp
  template:
    metadata:
      labels:
        app: other-app

After (correct)

spec:
  selector:
    matchLabels:
      app: myapp
  template:
    metadata:
      labels:
        app: myapp
        version: v1

Rule Details

Rule Code
KA-R011
Severity
Error
Category
Reliability

Related Rules