Skip to main content

require-service-selector

Require service selectors to be specified.

Examples

Correct manifest for this rule:

new Service({
spec: {
selector: { app: "nginx" },
ports: [{ port: 80 }]
}
});

Incorrect manifest for this rule:

new Service({
spec: {
ports: [{ port: 80 }]
}
});
new Service({
spec: {
selector: {},
ports: [{ port: 80 }]
}
});

Configuration

allow

Allow services that matches the patterns to not have selectors. This is useful when you want to maintain a list of endpoints that are not managed by Kubernetes. See Kubernetes documentation for more information.

Allow a specific namespace and name.

allow = [{ namespace = "foo", name = "bar" }]

Allow all names in a specific namespace.

allow = [{ namespace = "foo", name = "*" }]