Skip to main content

k8s_openapi/v1_36/api/scheduling/v1alpha2/
pod_group_template.rs

1// Generated from definition io.k8s.api.scheduling.v1alpha2.PodGroupTemplate
2
3/// PodGroupTemplate represents a template for a set of pods with a scheduling policy.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct PodGroupTemplate {
6    /// DisruptionMode defines the mode in which a given PodGroup can be disrupted. One of Pod, PodGroup. This field is available only when the WorkloadAwarePreemption feature gate is enabled.
7    pub disruption_mode: Option<std::string::String>,
8
9    /// Name is a unique identifier for the PodGroupTemplate within the Workload. It must be a DNS label. This field is immutable.
10    pub name: std::string::String,
11
12    /// Priority is the value of priority of pod groups created from this template. Various system components use this field to find the priority of the pod group. When Priority Admission Controller is enabled, it prevents users from setting this field. The admission controller populates this field from PriorityClassName. The higher the value, the higher the priority. This field is available only when the WorkloadAwarePreemption feature gate is enabled.
13    pub priority: Option<i32>,
14
15    /// PriorityClassName indicates the priority that should be considered when scheduling a pod group created from this template. If no priority class is specified, admission control can set this to the global default priority class if it exists. Otherwise, pod groups created from this template will have the priority set to zero. This field is available only when the WorkloadAwarePreemption feature gate is enabled.
16    pub priority_class_name: Option<std::string::String>,
17
18    /// ResourceClaims defines which ResourceClaims may be shared among Pods in the group. Pods consume the devices allocated to a PodGroup's claim by defining a claim in its own Spec.ResourceClaims that matches the PodGroup's claim exactly. The claim must have the same name and refer to the same ResourceClaim or ResourceClaimTemplate.
19    ///
20    /// This is an alpha-level field and requires that the DRAWorkloadResourceClaims feature gate is enabled.
21    ///
22    /// This field is immutable.
23    pub resource_claims: Option<std::vec::Vec<crate::api::scheduling::v1alpha2::PodGroupResourceClaim>>,
24
25    /// SchedulingConstraints defines optional scheduling constraints (e.g. topology) for this PodGroupTemplate. This field is only available when the TopologyAwareWorkloadScheduling feature gate is enabled.
26    pub scheduling_constraints: Option<crate::api::scheduling::v1alpha2::PodGroupSchedulingConstraints>,
27
28    /// SchedulingPolicy defines the scheduling policy for this PodGroupTemplate.
29    pub scheduling_policy: crate::api::scheduling::v1alpha2::PodGroupSchedulingPolicy,
30}
31
32impl crate::DeepMerge for PodGroupTemplate {
33    fn merge_from(&mut self, other: Self) {
34        crate::DeepMerge::merge_from(&mut self.disruption_mode, other.disruption_mode);
35        crate::DeepMerge::merge_from(&mut self.name, other.name);
36        crate::DeepMerge::merge_from(&mut self.priority, other.priority);
37        crate::DeepMerge::merge_from(&mut self.priority_class_name, other.priority_class_name);
38        crate::merge_strategies::list::map(
39            &mut self.resource_claims,
40            other.resource_claims,
41            &[|lhs, rhs| lhs.name == rhs.name],
42            |current_item, other_item| {
43                crate::DeepMerge::merge_from(current_item, other_item);
44            },
45        );
46        crate::DeepMerge::merge_from(&mut self.scheduling_constraints, other.scheduling_constraints);
47        crate::DeepMerge::merge_from(&mut self.scheduling_policy, other.scheduling_policy);
48    }
49}
50
51impl<'de> crate::serde::Deserialize<'de> for PodGroupTemplate {
52    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
53        #[allow(non_camel_case_types)]
54        enum Field {
55            Key_disruption_mode,
56            Key_name,
57            Key_priority,
58            Key_priority_class_name,
59            Key_resource_claims,
60            Key_scheduling_constraints,
61            Key_scheduling_policy,
62            Other,
63        }
64
65        impl<'de> crate::serde::Deserialize<'de> for Field {
66            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
67                struct Visitor;
68
69                impl crate::serde::de::Visitor<'_> for Visitor {
70                    type Value = Field;
71
72                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
73                        f.write_str("field identifier")
74                    }
75
76                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
77                        Ok(match v {
78                            "disruptionMode" => Field::Key_disruption_mode,
79                            "name" => Field::Key_name,
80                            "priority" => Field::Key_priority,
81                            "priorityClassName" => Field::Key_priority_class_name,
82                            "resourceClaims" => Field::Key_resource_claims,
83                            "schedulingConstraints" => Field::Key_scheduling_constraints,
84                            "schedulingPolicy" => Field::Key_scheduling_policy,
85                            _ => Field::Other,
86                        })
87                    }
88                }
89
90                deserializer.deserialize_identifier(Visitor)
91            }
92        }
93
94        struct Visitor;
95
96        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
97            type Value = PodGroupTemplate;
98
99            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
100                f.write_str("PodGroupTemplate")
101            }
102
103            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
104                let mut value_disruption_mode: Option<std::string::String> = None;
105                let mut value_name: Option<std::string::String> = None;
106                let mut value_priority: Option<i32> = None;
107                let mut value_priority_class_name: Option<std::string::String> = None;
108                let mut value_resource_claims: Option<std::vec::Vec<crate::api::scheduling::v1alpha2::PodGroupResourceClaim>> = None;
109                let mut value_scheduling_constraints: Option<crate::api::scheduling::v1alpha2::PodGroupSchedulingConstraints> = None;
110                let mut value_scheduling_policy: Option<crate::api::scheduling::v1alpha2::PodGroupSchedulingPolicy> = None;
111
112                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
113                    match key {
114                        Field::Key_disruption_mode => value_disruption_mode = crate::serde::de::MapAccess::next_value(&mut map)?,
115                        Field::Key_name => value_name = crate::serde::de::MapAccess::next_value(&mut map)?,
116                        Field::Key_priority => value_priority = crate::serde::de::MapAccess::next_value(&mut map)?,
117                        Field::Key_priority_class_name => value_priority_class_name = crate::serde::de::MapAccess::next_value(&mut map)?,
118                        Field::Key_resource_claims => value_resource_claims = crate::serde::de::MapAccess::next_value(&mut map)?,
119                        Field::Key_scheduling_constraints => value_scheduling_constraints = crate::serde::de::MapAccess::next_value(&mut map)?,
120                        Field::Key_scheduling_policy => value_scheduling_policy = crate::serde::de::MapAccess::next_value(&mut map)?,
121                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
122                    }
123                }
124
125                Ok(PodGroupTemplate {
126                    disruption_mode: value_disruption_mode,
127                    name: value_name.unwrap_or_default(),
128                    priority: value_priority,
129                    priority_class_name: value_priority_class_name,
130                    resource_claims: value_resource_claims,
131                    scheduling_constraints: value_scheduling_constraints,
132                    scheduling_policy: value_scheduling_policy.unwrap_or_default(),
133                })
134            }
135        }
136
137        deserializer.deserialize_struct(
138            "PodGroupTemplate",
139            &[
140                "disruptionMode",
141                "name",
142                "priority",
143                "priorityClassName",
144                "resourceClaims",
145                "schedulingConstraints",
146                "schedulingPolicy",
147            ],
148            Visitor,
149        )
150    }
151}
152
153impl crate::serde::Serialize for PodGroupTemplate {
154    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
155        let mut state = serializer.serialize_struct(
156            "PodGroupTemplate",
157            2 +
158            self.disruption_mode.as_ref().map_or(0, |_| 1) +
159            self.priority.as_ref().map_or(0, |_| 1) +
160            self.priority_class_name.as_ref().map_or(0, |_| 1) +
161            self.resource_claims.as_ref().map_or(0, |_| 1) +
162            self.scheduling_constraints.as_ref().map_or(0, |_| 1),
163        )?;
164        if let Some(value) = &self.disruption_mode {
165            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "disruptionMode", value)?;
166        }
167        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "name", &self.name)?;
168        if let Some(value) = &self.priority {
169            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "priority", value)?;
170        }
171        if let Some(value) = &self.priority_class_name {
172            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "priorityClassName", value)?;
173        }
174        if let Some(value) = &self.resource_claims {
175            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "resourceClaims", value)?;
176        }
177        if let Some(value) = &self.scheduling_constraints {
178            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "schedulingConstraints", value)?;
179        }
180        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "schedulingPolicy", &self.scheduling_policy)?;
181        crate::serde::ser::SerializeStruct::end(state)
182    }
183}
184
185#[cfg(feature = "schemars")]
186impl crate::schemars::JsonSchema for PodGroupTemplate {
187    fn schema_name() -> std::borrow::Cow<'static, str> {
188        "io.k8s.api.scheduling.v1alpha2.PodGroupTemplate".into()
189    }
190
191    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
192        crate::schemars::json_schema!({
193            "description": "PodGroupTemplate represents a template for a set of pods with a scheduling policy.",
194            "type": "object",
195            "properties": {
196                "disruptionMode": {
197                    "description": "DisruptionMode defines the mode in which a given PodGroup can be disrupted. One of Pod, PodGroup. This field is available only when the WorkloadAwarePreemption feature gate is enabled.",
198                    "type": "string",
199                },
200                "name": {
201                    "description": "Name is a unique identifier for the PodGroupTemplate within the Workload. It must be a DNS label. This field is immutable.",
202                    "type": "string",
203                },
204                "priority": {
205                    "description": "Priority is the value of priority of pod groups created from this template. Various system components use this field to find the priority of the pod group. When Priority Admission Controller is enabled, it prevents users from setting this field. The admission controller populates this field from PriorityClassName. The higher the value, the higher the priority. This field is available only when the WorkloadAwarePreemption feature gate is enabled.",
206                    "type": "integer",
207                    "format": "int32",
208                },
209                "priorityClassName": {
210                    "description": "PriorityClassName indicates the priority that should be considered when scheduling a pod group created from this template. If no priority class is specified, admission control can set this to the global default priority class if it exists. Otherwise, pod groups created from this template will have the priority set to zero. This field is available only when the WorkloadAwarePreemption feature gate is enabled.",
211                    "type": "string",
212                },
213                "resourceClaims": {
214                    "description": "ResourceClaims defines which ResourceClaims may be shared among Pods in the group. Pods consume the devices allocated to a PodGroup's claim by defining a claim in its own Spec.ResourceClaims that matches the PodGroup's claim exactly. The claim must have the same name and refer to the same ResourceClaim or ResourceClaimTemplate.\n\nThis is an alpha-level field and requires that the DRAWorkloadResourceClaims feature gate is enabled.\n\nThis field is immutable.",
215                    "type": "array",
216                    "items": (__gen.subschema_for::<crate::api::scheduling::v1alpha2::PodGroupResourceClaim>()),
217                },
218                "schedulingConstraints": ({
219                    let mut schema_obj = __gen.subschema_for::<crate::api::scheduling::v1alpha2::PodGroupSchedulingConstraints>();
220                    schema_obj.ensure_object().insert("description".into(), "SchedulingConstraints defines optional scheduling constraints (e.g. topology) for this PodGroupTemplate. This field is only available when the TopologyAwareWorkloadScheduling feature gate is enabled.".into());
221                    schema_obj
222                }),
223                "schedulingPolicy": ({
224                    let mut schema_obj = __gen.subschema_for::<crate::api::scheduling::v1alpha2::PodGroupSchedulingPolicy>();
225                    schema_obj.ensure_object().insert("description".into(), "SchedulingPolicy defines the scheduling policy for this PodGroupTemplate.".into());
226                    schema_obj
227                }),
228            },
229            "required": [
230                "name",
231                "schedulingPolicy",
232            ],
233        })
234    }
235}
236
237#[cfg(feature = "schemars08")]
238impl crate::schemars08::JsonSchema for PodGroupTemplate {
239    fn schema_name() -> std::string::String {
240        "io.k8s.api.scheduling.v1alpha2.PodGroupTemplate".into()
241    }
242
243    fn json_schema(__gen: &mut crate::schemars08::gen::SchemaGenerator) -> crate::schemars08::schema::Schema {
244        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
245            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
246                description: Some("PodGroupTemplate represents a template for a set of pods with a scheduling policy.".into()),
247                ..Default::default()
248            })),
249            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Object))),
250            object: Some(std::boxed::Box::new(crate::schemars08::schema::ObjectValidation {
251                properties: [
252                    (
253                        "disruptionMode".into(),
254                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
255                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
256                                description: Some("DisruptionMode defines the mode in which a given PodGroup can be disrupted. One of Pod, PodGroup. This field is available only when the WorkloadAwarePreemption feature gate is enabled.".into()),
257                                ..Default::default()
258                            })),
259                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::String))),
260                            ..Default::default()
261                        }),
262                    ),
263                    (
264                        "name".into(),
265                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
266                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
267                                description: Some("Name is a unique identifier for the PodGroupTemplate within the Workload. It must be a DNS label. This field is immutable.".into()),
268                                ..Default::default()
269                            })),
270                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::String))),
271                            ..Default::default()
272                        }),
273                    ),
274                    (
275                        "priority".into(),
276                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
277                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
278                                description: Some("Priority is the value of priority of pod groups created from this template. Various system components use this field to find the priority of the pod group. When Priority Admission Controller is enabled, it prevents users from setting this field. The admission controller populates this field from PriorityClassName. The higher the value, the higher the priority. This field is available only when the WorkloadAwarePreemption feature gate is enabled.".into()),
279                                ..Default::default()
280                            })),
281                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Integer))),
282                            format: Some("int32".into()),
283                            ..Default::default()
284                        }),
285                    ),
286                    (
287                        "priorityClassName".into(),
288                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
289                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
290                                description: Some("PriorityClassName indicates the priority that should be considered when scheduling a pod group created from this template. If no priority class is specified, admission control can set this to the global default priority class if it exists. Otherwise, pod groups created from this template will have the priority set to zero. This field is available only when the WorkloadAwarePreemption feature gate is enabled.".into()),
291                                ..Default::default()
292                            })),
293                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::String))),
294                            ..Default::default()
295                        }),
296                    ),
297                    (
298                        "resourceClaims".into(),
299                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
300                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
301                                description: Some("ResourceClaims defines which ResourceClaims may be shared among Pods in the group. Pods consume the devices allocated to a PodGroup's claim by defining a claim in its own Spec.ResourceClaims that matches the PodGroup's claim exactly. The claim must have the same name and refer to the same ResourceClaim or ResourceClaimTemplate.\n\nThis is an alpha-level field and requires that the DRAWorkloadResourceClaims feature gate is enabled.\n\nThis field is immutable.".into()),
302                                ..Default::default()
303                            })),
304                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Array))),
305                            array: Some(std::boxed::Box::new(crate::schemars08::schema::ArrayValidation {
306                                items: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(__gen.subschema_for::<crate::api::scheduling::v1alpha2::PodGroupResourceClaim>()))),
307                                ..Default::default()
308                            })),
309                            ..Default::default()
310                        }),
311                    ),
312                    (
313                        "schedulingConstraints".into(),
314                        {
315                            let mut schema_obj = __gen.subschema_for::<crate::api::scheduling::v1alpha2::PodGroupSchedulingConstraints>().into_object();
316                            schema_obj.metadata = Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
317                                description: Some("SchedulingConstraints defines optional scheduling constraints (e.g. topology) for this PodGroupTemplate. This field is only available when the TopologyAwareWorkloadScheduling feature gate is enabled.".into()),
318                                ..Default::default()
319                            }));
320                            crate::schemars08::schema::Schema::Object(schema_obj)
321                        },
322                    ),
323                    (
324                        "schedulingPolicy".into(),
325                        {
326                            let mut schema_obj = __gen.subschema_for::<crate::api::scheduling::v1alpha2::PodGroupSchedulingPolicy>().into_object();
327                            schema_obj.metadata = Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
328                                description: Some("SchedulingPolicy defines the scheduling policy for this PodGroupTemplate.".into()),
329                                ..Default::default()
330                            }));
331                            crate::schemars08::schema::Schema::Object(schema_obj)
332                        },
333                    ),
334                ].into(),
335                required: [
336                    "name".into(),
337                    "schedulingPolicy".into(),
338                ].into(),
339                ..Default::default()
340            })),
341            ..Default::default()
342        })
343    }
344}