-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implicit ServiceSpec union? #141
Comments
@ari-becker: Just to make sure I understand: do you mean that there is an API invariant that the Kubernetes server is enforcing that is not codified in the OpenAPI specification? Specifically:
|
Yes. If
I just tested this, and the API server does accept a manifest for a Service of type ExternalName which defines ports. In practice, these ports are ignored, as ExternalName is used to manually insert CNAME records into Kubernetes's cluster DNS. With that said, I can understand a user defining a port for a Service of type ExternalName as a means of documenting usage for downstream users. |
@ari-becker: I think my inclination here is to either:
The main reason why is that we're slowly trying to generalize the I do agree, though, that this sounds like the obvious more strongly-typed representation would be a Dhall union with at least two alternatives (one alternative for |
@Gabriel439 Asking Kubernetes upstream to fix the OpenAPI spec is non-trivial. The spec itself is a computer-generated ~ 5 MB document, which seems to be generated from the JSON tags on the Golang structs of the API objects, see e.g. ServiceSpec (at least that's my best guess without spending much more time in the codebase). For better or worse, these are long-stabilized APIs whose validations are unlikely to be changed at this point. I'm wondering about a different approach - keep moving towards a generalized |
not providing ports is also supported for headless services by the way, not just ExternalNames |
Trying to run
kubectl apply
on:results in the following error:
The Service "foo" is invalid: spec.ports: Required value
. Puttingports: []
results in the same error.The
ports
field inServiceSpec
is anOptional (List ServicePort.Type)
only because ofExternalName
Services (example taken from linked documentation):Similarly,
externalName
is a required field for anExternalName
ServiceSpec
but should not be specified at all for other kinds ofServiceSpec
.Ran into this issue when the super-configuration that was generating a
Kubernetes.Service.Type
had an optional field that was being mapped to the Kubernetes Service's.spec.ports
, where the field wasn't specified and the default was an empty optional.Related: dhall-lang/dhall-lang#691
The text was updated successfully, but these errors were encountered: