Skip to content
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

Update GEP-1762 with Gateway name limit recommendations #3070

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions apis/v1/gateway_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ import (

// Gateway represents an instance of a service-traffic handling infrastructure
// by binding Listeners to a set of IP addresses.
//
// It is recommended that the Gateway name field be limited to a maximum length
// of 63 characters. Gateway names may be used in label values on generated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like 63 is too long if 63 is the max length of some of the values we're trying to populate. Ideally wouldn't you want to translate foo-gateway to a generated contour-foo-gateway or similar? I'm also not sure if this belongs in the API spec or should just be in more user-facing guidelines documentation for using the API.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

63 is the max label value length, this shouldn't have any immediate bearing on generated resource names

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can move this to another guide instead though if that is preferred, maybe better here: https://gateway-api.sigs.k8s.io/api-types/gateway/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

63 is the max label value length, this shouldn't have any immediate bearing on generated resource names

🤦 did not read this closely enough, nevermind.

I can move this to another guide instead

We don't really have any strong guidance here as far as where user-facing tips like this belongs. Generally we reserve RFC language like SHOULD and MUST in the API Spec for implementation guidance, but it also feels weird to have "It is recommended" instead of "SHOULD" here. I can't really think of better solutions here, but interested in what @youngnick thinks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this is a good use case for SHOULD - in that we would prefer implementations be aware of the complexities here as well.

Let's change "It is recommended..." to "The Gateway name field SHOULD be no longer than 63 characters."

// in-cluster resources which have a length limit of 63 characters.
type Gateway struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions config/crd/standard/gateway.networking.k8s.io_gateways.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions geps/gep-1762/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ With this configuration, an implementation:

* MUST mark the Gateway as `Programmed` and provide an address in `Status.Addresses` where the Gateway can be reached on each configured port.
* MUST label all generated resources (Service, Deployment, etc) with `gateway.networking.k8s.io/gateway-name: my-gateway` (where `my-gateway` is the name of the Gateway resource).
* In the case that a Gateway resource name is longer than the maximum label value length of 63 characters, implementations MUST set the value of the label to the first 20 characters of the Gateway name with a `-` character appended and then the `sha1` checksum of the remainder of the name (40 characters long) appended.
robscott marked this conversation as resolved.
Show resolved Hide resolved
* For example for a Gateway with name `example-very-very-very-very-very-very-very-very-very-long-gateway-name` (70 characters long), the resulting label value would be `example-very-very-ve-65cb6f84bc9e50270d0a6c2f845fd98c6fe8d89f`.
* Cluster Operators creating Gateways are encouraged to limit Gateway names to a maximum of 63 characters to ensure the label value avoids this truncation/hashing and is human readable.
* MUST provision generated resources in the same namespace as the Gateway if they are namespace scoped resources.
* Cluster scoped resources are not recommended.
* SHOULD name all generated resources `my-gateway-example` (`<NAME>-<GATEWAY CLASS>`).
Expand Down
2 changes: 1 addition & 1 deletion pkg/generated/openapi/zz_generated.openapi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.