valid-pod-selector
Rec
Enabled in recommended preset.Require deployment selector to equal or be a subset of the pod template labels.
Examples
✅ Correct manifest for this rule:
new Deployment({
spec: {
selector: { matchLabels: { app: "nginx" } },
template: {
metadata: { labels: { app: "nginx" } }
}
}
});
new Deployment({
spec: {
selector: { matchLabels: { app: "nginx" } },
template: {
metadata: { labels: { app: "nginx", tier: "backend" } }
}
}
});
❌ Incorrect manifest for this rule:
new Deployment({
spec: {
selector: { matchLabels: { app: "nginx" } },
template: {
metadata: { labels: { app: "mysql" } }
}
}
});