Skip to content

Commit 88ea12e

Browse files
committed
Adding v1 types for Gateway, GatewayClass, and HTTPRoute
1 parent 10e80d4 commit 88ea12e

File tree

187 files changed

+18412
-5352
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

187 files changed

+18412
-5352
lines changed

apis/v1/doc.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
Copyright 2020 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
// Package v1 contains API Schema definitions for the gateway.networking.k8s.io
18+
// API group.
19+
//
20+
// +kubebuilder:object:generate=true
21+
// +groupName=gateway.networking.k8s.io
22+
package v1

apis/v1/gateway_types.go

Lines changed: 1079 additions & 0 deletions
Large diffs are not rendered by default.

apis/v1/gatewayclass_types.go

Lines changed: 269 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,269 @@
1+
/*
2+
Copyright 2020 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
)
22+
23+
// +genclient
24+
// +genclient:nonNamespaced
25+
// +kubebuilder:object:root=true
26+
// +kubebuilder:resource:categories=gateway-api,scope=Cluster,shortName=gc
27+
// +kubebuilder:storageversion
28+
// +kubebuilder:subresource:status
29+
// +kubebuilder:printcolumn:name="Controller",type=string,JSONPath=`.spec.controllerName`
30+
// +kubebuilder:printcolumn:name="Accepted",type=string,JSONPath=`.status.conditions[?(@.type=="Accepted")].status`
31+
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`
32+
// +kubebuilder:printcolumn:name="Description",type=string,JSONPath=`.spec.description`,priority=1
33+
34+
// GatewayClass describes a class of Gateways available to the user for creating
35+
// Gateway resources.
36+
//
37+
// It is recommended that this resource be used as a template for Gateways. This
38+
// means that a Gateway is based on the state of the GatewayClass at the time it
39+
// was created and changes to the GatewayClass or associated parameters are not
40+
// propagated down to existing Gateways. This recommendation is intended to
41+
// limit the blast radius of changes to GatewayClass or associated parameters.
42+
// If implementations choose to propagate GatewayClass changes to existing
43+
// Gateways, that MUST be clearly documented by the implementation.
44+
//
45+
// Whenever one or more Gateways are using a GatewayClass, implementations SHOULD
46+
// add the `gateway-exists-finalizer.gateway.networking.k8s.io` finalizer on the
47+
// associated GatewayClass. This ensures that a GatewayClass associated with a
48+
// Gateway is not deleted while in use.
49+
//
50+
// GatewayClass is a Cluster level resource.
51+
type GatewayClass struct {
52+
metav1.TypeMeta `json:",inline"`
53+
metav1.ObjectMeta `json:"metadata,omitempty"`
54+
55+
// Spec defines the desired state of GatewayClass.
56+
Spec GatewayClassSpec `json:"spec"`
57+
58+
// Status defines the current state of GatewayClass.
59+
//
60+
// Implementations MUST populate status on all GatewayClass resources which
61+
// specify their controller name.
62+
//
63+
// +kubebuilder:default={conditions: {{type: "Accepted", status: "Unknown", message: "Waiting for controller", reason: "Waiting", lastTransitionTime: "1970-01-01T00:00:00Z"}}}
64+
Status GatewayClassStatus `json:"status,omitempty"`
65+
}
66+
67+
const (
68+
// GatewayClassFinalizerGatewaysExist should be added as a finalizer to the
69+
// GatewayClass whenever there are provisioned Gateways using a
70+
// GatewayClass.
71+
GatewayClassFinalizerGatewaysExist = "gateway-exists-finalizer.gateway.networking.k8s.io"
72+
)
73+
74+
// GatewayClassSpec reflects the configuration of a class of Gateways.
75+
type GatewayClassSpec struct {
76+
// ControllerName is the name of the controller that is managing Gateways of
77+
// this class. The value of this field MUST be a domain prefixed path.
78+
//
79+
// Example: "example.net/gateway-controller".
80+
//
81+
// This field is not mutable and cannot be empty.
82+
//
83+
// Support: Core
84+
//
85+
// +kubebuilder:validation:XValidation:message="Value is immutable",rule="self == oldSelf"
86+
ControllerName GatewayController `json:"controllerName"`
87+
88+
// ParametersRef is a reference to a resource that contains the configuration
89+
// parameters corresponding to the GatewayClass. This is optional if the
90+
// controller does not require any additional configuration.
91+
//
92+
// ParametersRef can reference a standard Kubernetes resource, i.e. ConfigMap,
93+
// or an implementation-specific custom resource. The resource can be
94+
// cluster-scoped or namespace-scoped.
95+
//
96+
// If the referent cannot be found, the GatewayClass's "InvalidParameters"
97+
// status condition will be true.
98+
//
99+
// Support: Implementation-specific
100+
//
101+
// +optional
102+
ParametersRef *ParametersReference `json:"parametersRef,omitempty"`
103+
104+
// Description helps describe a GatewayClass with more details.
105+
//
106+
// +kubebuilder:validation:MaxLength=64
107+
// +optional
108+
Description *string `json:"description,omitempty"`
109+
}
110+
111+
// ParametersReference identifies an API object containing controller-specific
112+
// configuration resource within the cluster.
113+
type ParametersReference struct {
114+
// Group is the group of the referent.
115+
Group Group `json:"group"`
116+
117+
// Kind is kind of the referent.
118+
Kind Kind `json:"kind"`
119+
120+
// Name is the name of the referent.
121+
//
122+
// +kubebuilder:validation:MinLength=1
123+
// +kubebuilder:validation:MaxLength=253
124+
Name string `json:"name"`
125+
126+
// Namespace is the namespace of the referent.
127+
// This field is required when referring to a Namespace-scoped resource and
128+
// MUST be unset when referring to a Cluster-scoped resource.
129+
//
130+
// +optional
131+
Namespace *Namespace `json:"namespace,omitempty"`
132+
}
133+
134+
// GatewayClassConditionType is the type for status conditions on
135+
// Gateway resources. This type should be used with the
136+
// GatewayClassStatus.Conditions field.
137+
type GatewayClassConditionType string
138+
139+
// GatewayClassConditionReason defines the set of reasons that explain why a
140+
// particular GatewayClass condition type has been raised.
141+
type GatewayClassConditionReason string
142+
143+
const (
144+
// This condition indicates whether the GatewayClass has been accepted by
145+
// the controller requested in the `spec.controller` field.
146+
//
147+
// This condition defaults to Unknown, and MUST be set by a controller when
148+
// it sees a GatewayClass using its controller string. The status of this
149+
// condition MUST be set to True if the controller will support provisioning
150+
// Gateways using this class. Otherwise, this status MUST be set to False.
151+
// If the status is set to False, the controller SHOULD set a Message and
152+
// Reason as an explanation.
153+
//
154+
// Possible reasons for this condition to be true are:
155+
//
156+
// * "Accepted"
157+
//
158+
// Possible reasons for this condition to be False are:
159+
//
160+
// * "InvalidParameters"
161+
// * "UnsupportedVersion"
162+
//
163+
// Possible reasons for this condition to be Unknown are:
164+
//
165+
// * "Pending"
166+
//
167+
// Controllers should prefer to use the values of GatewayClassConditionReason
168+
// for the corresponding Reason, where appropriate.
169+
GatewayClassConditionStatusAccepted GatewayClassConditionType = "Accepted"
170+
171+
// This reason is used with the "Accepted" condition when the condition is
172+
// true.
173+
GatewayClassReasonAccepted GatewayClassConditionReason = "Accepted"
174+
175+
// This reason is used with the "Accepted" condition when the
176+
// GatewayClass was not accepted because the parametersRef field
177+
// was invalid, with more detail in the message.
178+
GatewayClassReasonInvalidParameters GatewayClassConditionReason = "InvalidParameters"
179+
180+
// This reason is used with the "Accepted" condition when the
181+
// requested controller has not yet made a decision about whether
182+
// to admit the GatewayClass. It is the default Reason on a new
183+
// GatewayClass.
184+
GatewayClassReasonPending GatewayClassConditionReason = "Pending"
185+
186+
// Deprecated: Use "Pending" instead.
187+
GatewayClassReasonWaiting GatewayClassConditionReason = "Waiting"
188+
)
189+
190+
const (
191+
// This condition indicates whether the GatewayClass supports the version(s)
192+
// of Gateway API CRDs present in the cluster. This condition MUST be set by
193+
// a controller when it marks a GatewayClass "Accepted".
194+
//
195+
// The version of a Gateway API CRD is defined by the
196+
// gateway.networking.k8s.io/bundle-version annotation on the CRD. If
197+
// implementations detect any Gateway API CRDs that either do not have this
198+
// annotation set, or have it set to a version that is not recognized or
199+
// supported by the implementation, this condition MUST be set to false.
200+
//
201+
// Implementations MAY choose to either provide "best effort" support when
202+
// an unrecognized CRD version is present. This would be communicated by
203+
// setting the "Accepted" condition to true and the "SupportedVersion"
204+
// condition to false.
205+
//
206+
// Alternatively, implementations MAY choose not to support CRDs with
207+
// unrecognized versions. This would be communicated by setting the
208+
// "Accepted" condition to false with the reason "UnsupportedVersions".
209+
//
210+
// Possible reasons for this condition to be true are:
211+
//
212+
// * "SupportedVersion"
213+
//
214+
// Possible reasons for this condition to be False are:
215+
//
216+
// * "UnsupportedVersion"
217+
//
218+
// Controllers should prefer to use the values of GatewayClassConditionReason
219+
// for the corresponding Reason, where appropriate.
220+
GatewayClassConditionStatusSupportedVersion GatewayClassConditionType = "SupportedVersion"
221+
222+
// This reason is used with the "SupportedVersion" condition when the
223+
// condition is true.
224+
GatewayClassReasonSupportedVersion GatewayClassConditionReason = "SupportedVersion"
225+
226+
// This reason is used with the "SupportedVersion" or "Accepted" condition
227+
// when the condition is false. A message SHOULD be included in this
228+
// condition that includes the detected CRD version(s) present in the
229+
// cluster and the CRD version(s) that are supported by the GatewayClass.
230+
GatewayClassReasonUnsupportedVersion GatewayClassConditionReason = "UnsupportedVersion"
231+
)
232+
233+
// GatewayClassStatus is the current status for the GatewayClass.
234+
type GatewayClassStatus struct {
235+
// Conditions is the current status from the controller for
236+
// this GatewayClass.
237+
//
238+
// Controllers should prefer to publish conditions using values
239+
// of GatewayClassConditionType for the type of each Condition.
240+
//
241+
// +optional
242+
// +listType=map
243+
// +listMapKey=type
244+
// +kubebuilder:validation:MaxItems=8
245+
// +kubebuilder:default={{type: "Accepted", status: "Unknown", message: "Waiting for controller", reason: "Pending", lastTransitionTime: "1970-01-01T00:00:00Z"}}
246+
Conditions []metav1.Condition `json:"conditions,omitempty"`
247+
248+
// SupportedFeatures is the set of features the GatewayClass support.
249+
// It MUST be sorted in ascending alphabetical order.
250+
// +optional
251+
// +listType=set
252+
// <gateway:experimental>
253+
// +kubebuilder:validation:MaxItems=64
254+
SupportedFeatures []SupportedFeature `json:"supportedFeatures,omitempty"`
255+
}
256+
257+
// +kubebuilder:object:root=true
258+
259+
// GatewayClassList contains a list of GatewayClass
260+
type GatewayClassList struct {
261+
metav1.TypeMeta `json:",inline"`
262+
metav1.ListMeta `json:"metadata,omitempty"`
263+
Items []GatewayClass `json:"items"`
264+
}
265+
266+
// SupportedFeature is used to describe distinct features that are covered by
267+
// conformance tests.
268+
// +kubebuilder:validation:Enum=Gateway;GatewayPort8080;GatewayStaticAddresses;HTTPRoute;HTTPRouteDestinationPortMatching;HTTPRouteHostRewrite;HTTPRouteMethodMatching;HTTPRoutePathRedirect;HTTPRoutePathRewrite;HTTPRoutePortRedirect;HTTPRouteQueryParamMatching;HTTPRouteRequestMirror;HTTPRouteRequestMultipleMirrors;HTTPRouteResponseHeaderModification;HTTPRouteSchemeRedirect;Mesh;ReferenceGrant;TLSRoute
269+
type SupportedFeature string

0 commit comments

Comments
 (0)