Skip to content

Commit afbf562

Browse files
committed
feat(mesh): Define XMesh API and 'make generate'
Signed-off-by: Flynn <[email protected]>
1 parent 3fbfdf8 commit afbf562

File tree

21 files changed

+1499
-3
lines changed

21 files changed

+1499
-3
lines changed

apisx/v1alpha1/xmesh_types.go

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
/*
2+
Copyright 2025 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 v1alpha1
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
gatewayapiv1 "sigs.k8s.io/gateway-api/apis/v1"
22+
)
23+
24+
// +genclient
25+
// +genclient:nonNamespaced
26+
// +kubebuilder:object:root=true
27+
// +kubebuilder:resource:categories=gateway-api,scope=Cluster,shortName=mesh
28+
// +kubebuilder:subresource:status
29+
// +kubebuilder:storageversion
30+
// +kubebuilder:printcolumn:name="Accepted",type=string,JSONPath=`.status.conditions[?(@.type=="Accepted")].status`
31+
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`
32+
33+
// XMesh defines mesh-wide characteristics of a GAMMA-compliant service mesh.
34+
type XMesh struct {
35+
metav1.TypeMeta `json:",inline"`
36+
// +optional
37+
metav1.ObjectMeta `json:"metadata,omitempty"`
38+
39+
// Spec defines the desired state of XMesh.
40+
// +required
41+
Spec MeshSpec `json:"spec"`
42+
43+
// Status defines the current state of XMesh.
44+
//
45+
// <gateway:util:excludeFromCRD>
46+
// Implementations MUST populate status on all Mesh resources which
47+
// specify their controller name.
48+
// </gateway:util:excludeFromCRD>
49+
//
50+
// +kubebuilder:default={conditions: {{type: "Accepted", status: "Unknown", reason:"Pending", message:"Waiting for controller", lastTransitionTime: "1970-01-01T00:00:00Z"}}}
51+
// +optional
52+
Status MeshStatus `json:"status,omitempty"`
53+
}
54+
55+
// MeshSpec defines the desired state of an XMesh.
56+
type MeshSpec struct {
57+
// ControllerName is the name of the controller that is managing Gateways of
58+
// this class. The value of this field MUST be a domain prefixed path.
59+
//
60+
// Example: "example.com/awesome-mesh".
61+
//
62+
// This field is not mutable and cannot be empty.
63+
//
64+
// Support: Core
65+
//
66+
// +kubebuilder:validation:XValidation:message="Value is immutable",rule="self == oldSelf"
67+
// +required
68+
ControllerName gatewayapiv1.GatewayController `json:"controllerName"`
69+
70+
// ParametersRef is an optional reference to a resource that contains
71+
// implementation-specific for this Mesh. If no implementation-specific
72+
// parameters are needed, this field MUST be omitted.
73+
//
74+
// ParametersRef can reference a standard Kubernetes resource, i.e.
75+
// ConfigMap, or an implementation-specific custom resource. The resource
76+
// can be cluster-scoped or namespace-scoped.
77+
//
78+
// If the referent cannot be found, refers to an unsupported kind, or when
79+
// the data within that resource is malformed, the Mesh MUST be rejected
80+
// with the "Accepted" status condition set to "False" and an
81+
// "InvalidParameters" reason.
82+
//
83+
// Support: Implementation-specific
84+
//
85+
// +optional
86+
ParametersRef *gatewayapiv1.ParametersReference `json:"parametersRef,omitempty"`
87+
88+
// Description optionally provides a human-readable description of a Mesh.
89+
//
90+
// +kubebuilder:validation:MaxLength=64
91+
// +optional
92+
Description *string `json:"description,omitempty"`
93+
}
94+
95+
// MeshConditionType is the type for status conditions on Mesh resources.
96+
// This type should be used with the MeshStatus.Conditions field.
97+
type MeshConditionType string
98+
99+
// MeshConditionReason defines the set of reasons that explain why a
100+
// particular Mesh condition type has been raised.
101+
type MeshConditionReason string
102+
103+
const (
104+
// This condition indicates whether the Mesh has been accepted by the
105+
// controller requested in the `spec.controllerName` field.
106+
//
107+
// This condition defaults to Unknown, and MUST be set by a controller
108+
// when it sees a Mesh using its controller string. The status of this
109+
// condition MUST be set to True if the controller will accept the Mesh
110+
// resource. Otherwise, this status MUST be set to False. If the status is
111+
// set to False, the controller MUST set a Message and Reason as an
112+
// explanation.
113+
//
114+
// Possible reasons for this condition to be true are:
115+
//
116+
// * "Accepted"
117+
//
118+
// Possible reasons for this condition to be False are:
119+
//
120+
// * "InvalidParameters"
121+
//
122+
// Possible reasons for this condition to be Unknown are:
123+
//
124+
// * "Pending"
125+
//
126+
// Controllers should prefer to use the values of MeshConditionReason for
127+
// the corresponding Reason, where appropriate.
128+
MeshConditionStatusAccepted MeshConditionType = "Accepted"
129+
MeshConditionStatusUnknown MeshConditionType = "Unknown"
130+
131+
// This reason is used with the "Accepted" condition when the condition is
132+
// true.
133+
MeshConditionReasonAccepted MeshConditionReason = "Accepted"
134+
135+
// This reason is used with the "Accepted" condition when the Mesh
136+
// was not accepted because the parametersRef field refers to
137+
// * a namespaced resource but the Namespace field is not set, or
138+
// * a cluster-scoped resource but the Namespace field is set, or
139+
// * a nonexistent object, or
140+
// * an unsupported resource or kind, or
141+
// * an existing resource but the data within that resource is malformed.
142+
MeshConditionReasonInvalidParameters MeshConditionReason = "InvalidParameters"
143+
144+
// This reason is used with the "Unknown" condition when the
145+
// requested controller has not yet made a decision about whether
146+
// to accept the Mesh. It is the default Reason on a new Mesh.
147+
MeshConditionReasonPending MeshConditionReason = "Pending"
148+
)
149+
150+
// MeshStatus is the current status for the Mesh.
151+
type MeshStatus struct {
152+
// Conditions is the current status from the controller for
153+
// this Mesh.
154+
//
155+
// Controllers should prefer to publish conditions using values
156+
// of MeshConditionType for the type of each Condition.
157+
//
158+
// +optional
159+
// +listType=map
160+
// +listMapKey=type
161+
// +kubebuilder:validation:MaxItems=8
162+
// +kubebuilder:default={{type: "Accepted", status: "Unknown", reason:"Pending", message:"Waiting for controller", lastTransitionTime: "1970-01-01T00:00:00Z"},{type: "Programmed", status: "Unknown", reason:"Pending", message:"Waiting for controller", lastTransitionTime: "1970-01-01T00:00:00Z"}}
163+
Conditions []metav1.Condition `json:"conditions,omitempty"`
164+
165+
// SupportedFeatures is the set of features the Mesh support.
166+
// It MUST be sorted in ascending alphabetical order by the Name key.
167+
// +optional
168+
// +listType=map
169+
// +listMapKey=name
170+
// +kubebuilder:validation:MaxItems=64
171+
SupportedFeatures []gatewayapiv1.SupportedFeature `json:"supportedFeatures,omitempty"`
172+
}
173+
174+
// +kubebuilder:object:root=true
175+
type XMeshList struct {
176+
metav1.TypeMeta `json:",inline"`
177+
metav1.ListMeta `json:"metadata,omitempty"`
178+
Items []XMesh `json:"items"`
179+
}

apisx/v1alpha1/zz_generated.deepcopy.go

Lines changed: 112 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apisx/v1alpha1/zz_generated.register.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

applyconfiguration/apisx/v1alpha1/meshspec.go

Lines changed: 62 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)