k8s_gateway_api/gatewayclass.rs
1use crate::*;
2use k8s_openapi::apimachinery::pkg::apis::meta::v1 as metav1;
3
4// GatewayClass describes a class of Gateways available to the user for creating
5// Gateway resources.
6//
7// It is recommended that this resource be used as a template for Gateways. This
8// means that a Gateway is based on the state of the GatewayClass at the time it
9// was created and changes to the GatewayClass or associated parameters are not
10// propagated down to existing Gateways. This recommendation is intended to
11// limit the blast radius of changes to GatewayClass or associated parameters.
12// If implementations choose to propagate GatewayClass changes to existing
13// Gateways, that MUST be clearly documented by the implementation.
14//
15// Whenever one or more Gateways are using a GatewayClass, implementations MUST
16// add the `gateway-exists-finalizer.gateway.networking.k8s.io` finalizer on the
17// associated GatewayClass. This ensures that a GatewayClass associated with a
18// Gateway is not deleted while in use.
19//
20// GatewayClass is a Cluster level resource.
21#[derive(
22 Clone, Debug, kube::CustomResource, serde::Deserialize, serde::Serialize, schemars::JsonSchema,
23)]
24#[kube(
25 group = "gateway.networking.k8s.io",
26 version = "v1beta1",
27 kind = "GatewayClass",
28 status = "GatewayClassStatus"
29)]
30#[serde(rename_all = "camelCase")]
31pub struct GatewayClassSpec {
32 /// ControllerName is the name of the controller that is managing Gateways
33 /// of this class. The value of this field MUST be a domain prefixed path.
34 ///
35 /// Example: "example.net/gateway-controller".
36 ///
37 /// This field is not mutable and cannot be empty.
38 pub controller_name: GatewayController,
39
40 /// ParametersRef is a reference to a resource that contains the
41 /// configuration parameters corresponding to the GatewayClass. This is
42 /// optional if the controller does not require any additional
43 /// configuration.
44 ///
45 /// ParametersRef can reference a standard Kubernetes resource, i.e.
46 /// ConfigMap, or an implementation-specific custom resource. The resource
47 /// can be cluster-scoped or namespace-scoped.
48 ///
49 /// If the referent cannot be found, the GatewayClass's "InvalidParameters"
50 /// status condition will be true.
51 ///
52 /// Support: Custom
53 pub paramters_ref: Option<ParametersReference>,
54
55 /// Description helps describe a GatewayClass with more details.
56 pub description: Option<String>,
57}
58
59/// ParametersReference identifies an API object containing controller-specific
60/// configuration resource within the cluster.
61#[derive(
62 Clone, Debug, Eq, PartialEq, serde::Deserialize, serde::Serialize, schemars::JsonSchema,
63)]
64pub struct ParametersReference {
65 /// Group is the group of the referent.
66 pub group: Group,
67
68 /// Kind is the kind of the referent.
69 pub kind: Kind,
70
71 /// Name is the name of the referent.
72 pub name: String,
73
74 /// Namespace is the namespace of the referent.
75 ///
76 /// This field is required when referring to a Namespace-scoped resource and
77 /// MUST be unset when referring to a Cluster-scoped resource.
78 pub namespace: Option<String>,
79}
80
81/// GatewayClassConditionType is the type for status conditions on
82/// Gateway resources. This type should be used with the
83/// GatewayClassStatus.Conditions field.
84pub type GatewayClassConditionType = String;
85
86/// GatewayClassConditionReason defines the set of reasons that explain why a
87/// particular GatewayClass condition type has been raised.
88pub type GatewayClassConditionReason = String;
89
90/// GatewayClassStatus is the current status for the GatewayClass.
91#[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize, schemars::JsonSchema)]
92pub struct GatewayClassStatus {
93 /// Conditions is the current status from the controller for this
94 /// GatewayClass.
95 ///
96 /// Controllers should prefer to publish conditions using values of
97 /// GatewayClassConditionType for the type of each Condition.
98 pub conditions: Option<Vec<metav1::Condition>>,
99}