System info:
Describe the bug
The mismatching-selector check appears to advertise ReplicationController support through its DeploymentLike scope, but ReplicationController objects are skipped during selector extraction.
DeploymentLike includes ReplicationController, but mismatching-selector calls extract.Selector(object.K8sObject). For ReplicationController, spec.selector is a plain map[string]string, while extract.Selector only handles special-cased DeploymentConfig / CronJob selectors or reflected Spec.Selector fields typed as *metav1.LabelSelector.
As a result, a ReplicationController with mismatched spec.selector and pod template labels is not reported.
To Reproduce
Steps to reproduce the behavior:
- Save the sample YAML below as
rc-mismatching-selector.yaml.
- Run:
kube-linter lint --include mismatching-selector --do-not-auto-add-defaults rc-mismatching-selector.yaml
- Observe that no
mismatching-selector finding is reported for the ReplicationController.
Sample YAML input
apiVersion: v1
kind: ReplicationController
metadata:
name: rc-selector-mismatch
spec:
selector:
app: api
tier: backend
template:
metadata:
labels:
app: api
tier: frontend
spec:
containers:
- name: app
image: nginx
Expected behavior
The mismatching-selector check should report that the ReplicationController selector does not match the pod template labels.
Either ReplicationController should be removed from the effective DeploymentLike scope for this check, or extract.Selector should convert ReplicationController.spec.selector into a metav1.LabelSelector{MatchLabels: ...} similar to how DeploymentConfig is handled.
Screenshots
Not applicable.
Additional context
The check is registered with scope.objectKinds: DeploymentLike, and DeploymentLike includes ReplicationController.
The issue seems to come from selector extraction rather than object-kind matching: extract.Selector does not currently handle selector maps from ReplicationController.
System info:
Describe the bug
The
mismatching-selectorcheck appears to advertiseReplicationControllersupport through itsDeploymentLikescope, butReplicationControllerobjects are skipped during selector extraction.DeploymentLikeincludesReplicationController, butmismatching-selectorcallsextract.Selector(object.K8sObject). ForReplicationController,spec.selectoris a plainmap[string]string, whileextract.Selectoronly handles special-casedDeploymentConfig/CronJobselectors or reflectedSpec.Selectorfields typed as*metav1.LabelSelector.As a result, a
ReplicationControllerwith mismatchedspec.selectorand pod template labels is not reported.To Reproduce
Steps to reproduce the behavior:
rc-mismatching-selector.yaml.mismatching-selectorfinding is reported for theReplicationController.Sample YAML input
Expected behavior
The
mismatching-selectorcheck should report that theReplicationControllerselector does not match the pod template labels.Either
ReplicationControllershould be removed from the effectiveDeploymentLikescope for this check, orextract.Selectorshould convertReplicationController.spec.selectorinto ametav1.LabelSelector{MatchLabels: ...}similar to howDeploymentConfigis handled.Screenshots
Not applicable.
Additional context
The check is registered with
scope.objectKinds: DeploymentLike, andDeploymentLikeincludesReplicationController.The issue seems to come from selector extraction rather than object-kind matching:
extract.Selectordoes not currently handle selector maps fromReplicationController.