Skip to content

[FEATURE_REQUEST] Do not warn about dangling service linked to deployment or statefulset without a pod #179

Open
@tspearconquest

Description

@tspearconquest

Description of the problem/feature request
Service definitions with a label selector matching a deployment or statefulset definition without any pod definition are generating a dangling service warning in kube-linter because the dangling service check appears to only concern itself with pods.

Description of the existing behavior vs. expected behavior
Consider the following service definition:

apiVersion: v1
kind: Service
metadata:
  name: appnameA
  labels:
    app: appnameALabel
spec:
  ports:
  - name: http
    port: 8080
    targetPort: 8080
  selector:
    app: appnameALabel
  type: ClusterIP

And the following (partial) deployment definition:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: appnameA
  labels:
    app: appnameALabel
spec:
  replicas: 1
  selector:
    matchLabels:
      app: appnameALabel

When running kube-linter, we get the following:

kubernetes/60-services/appnameA-svc.yaml: (object: <no namespace>/appnameA /v1, Kind=Service) no pods found matching service labels (map[app:appnameALabel]) (check: dangling-service, remediation: Make sure your service's selector correctly matches the labels on one of your deployments.)

Additional context
The warning message is technically correct, there is no pod which matches the service label. However this is not a dangling service, and should not generate a warning. We currently annotate for this but we are looking to improve the kubernetes definitions and this is one that sticks out because it's doesn't seem to be a real problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs designIndicates that the proposed enhancement needs more thought on design

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions