-
Notifications
You must be signed in to change notification settings - Fork 817
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
Add CRD validation via OpenAPIv3 Schema #100
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,99 @@ spec: | |
shortNames: | ||
- gs | ||
singular: gameserver | ||
validation: | ||
openAPIV3Schema: | ||
required: | ||
- spec | ||
properties: | ||
spec: | ||
required: | ||
- containerPort | ||
- template | ||
properties: | ||
template: | ||
type: object | ||
required: | ||
- spec | ||
properties: | ||
spec: | ||
type: object | ||
required: | ||
- containers | ||
properties: | ||
containers: | ||
type: array | ||
items: | ||
type: object | ||
required: | ||
- image | ||
properties: | ||
name: | ||
type: string | ||
minLength: 0 | ||
maxLength: 63 | ||
pattern: "^[a-z0-9]([-a-z0-9]*[a-z0-9])?$" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You'll be surprised it's not, I have just tried with a
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Apparently so! Sounds like it's time to file a PR on the Kubernetes documentation. |
||
image: | ||
type: string | ||
minLength: 1 | ||
minItems: 1 | ||
container: | ||
title: The container name running the gameserver | ||
description: if there is more than one container, specify which one is the game server | ||
type: string | ||
minLength: 0 | ||
maxLength: 63 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same questions as above |
||
pattern: "^[a-z0-9]([-a-z0-9]*[a-z0-9])?$" | ||
portPolicy: | ||
title: the port policy that will be applied to the game server | ||
description: | | ||
portPolicy has two options: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Love all these titles and descriptions!! 👍 |
||
- "dynamic" (default) the system allocates a free hostPort for the gameserver, for game clients to connect to | ||
- "static", user defines the hostPort that the game client will connect to. Then onus is on the user to ensure that the | ||
port is available. When static is the policy specified, `hostPort` is required to be populated | ||
type: string | ||
enum: | ||
- dynamic | ||
- static | ||
protocol: | ||
title: Protocol being used. Defaults to UDP. TCP is the only other option | ||
type: string | ||
enum: | ||
- UDP | ||
- TCP | ||
containerPort: | ||
title: The port that is being opened on the game server process | ||
type: integer | ||
minimum: 0 | ||
maximum: 65535 | ||
hostPort: | ||
title: The port exposed on the host | ||
description: Only required when `portPolicy` is "static". Overwritten when portPolicy is "dynamic". | ||
type: integer | ||
minimum: 0 | ||
maximum: 65535 | ||
health: | ||
type: object | ||
title: Health checking for the running game server | ||
properties: | ||
disabled: | ||
title: Disable health checking. defaults to false, but can be set to true | ||
type: boolean | ||
initialDelaySeconds: | ||
title: Number of seconds after the container has started before health check is initiated. Defaults to 5 seconds | ||
type: integer | ||
minimum: 0 | ||
maximum: 2147483648 | ||
periodSeconds: | ||
title: How long before the server is considered not healthy | ||
type: integer | ||
minimum: 0 | ||
maximum: 2147483648 | ||
failureThreshold: | ||
title: Minimum consecutive failures for the health probe to be considered failed after having succeeded. | ||
type: integer | ||
minimum: 1 | ||
maximum: 2147483648 | ||
--- | ||
apiVersion: extensions/v1beta1 | ||
kind: Deployment | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious where 63 comes from -
Looking at the names doc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from here: https://github.com/kubernetes/kubernetes/blob/53a9d106c4aabcd550cc32ae4e8004f32fb0ae7b/pkg/api/validation/validation.go#L280
:) I was also surprised.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found the latest version here:
https://github.com/kubernetes/kubernetes/blob/master/pkg/apis/core/validation/validation.go#L2854
https://github.com/kubernetes/apimachinery/blob/master/pkg/api/validation/objectmeta.go
But looks like the docs are wrong. Wow, 63 chars is not a huge amount.