Skip to content

CDK8s+: Support headless services without ports #2827

@sweco-sedalh

Description

@sweco-sedalh

Description of the bug:

We use a headless service (clusterIP: "None") just for the reverse DNS lookup (PTR), so have no need to specify ports. I imagine that that is a reasonably common usecase.

However, the current CDK8+ Service requires ports to be specified. Therefore I'd want that validation to be ignored when given a headless service.

An added bonus would be explicit support for headless services, by making the type of clusterIP be string | "None" | undefined or string | ServiceClusterIP | undefined (where ServiceClusterIP is an enum with a single value HEADLESS that resolves to "None" in the generated manifest).

Reproduction Steps:

Create a headless service:

new Service(this, "headless-svc", {
  clusterIP: "None",
  selector: deployment,
});

Error Log:

Error: Failed serializing construct at path 'app/traefik-headless-svc/Resource' with name 'traefik-headless': Error: A service must be configured with a port

Environment:

  • Framework Version:
  • OS:

Other:


This is 🐛 Bug Report

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds-triagePriority and effort undetermined yet

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions