1#[derive(Clone, Debug, Default, PartialEq)]
5pub struct ServiceSpec {
6 pub allocate_load_balancer_node_ports: Option<bool>,
8
9 pub cluster_ip: Option<std::string::String>,
11
12 pub cluster_ips: Option<std::vec::Vec<std::string::String>>,
16
17 pub external_ips: Option<std::vec::Vec<std::string::String>>,
19
20 pub external_name: Option<std::string::String>,
22
23 pub external_traffic_policy: Option<std::string::String>,
25
26 pub health_check_node_port: Option<i32>,
28
29 pub internal_traffic_policy: Option<std::string::String>,
31
32 pub ip_families: Option<std::vec::Vec<std::string::String>>,
36
37 pub ip_family_policy: Option<std::string::String>,
39
40 pub load_balancer_class: Option<std::string::String>,
42
43 pub load_balancer_ip: Option<std::string::String>,
45
46 pub load_balancer_source_ranges: Option<std::vec::Vec<std::string::String>>,
48
49 pub ports: Option<std::vec::Vec<crate::api::core::v1::ServicePort>>,
51
52 pub publish_not_ready_addresses: Option<bool>,
54
55 pub selector: Option<std::collections::BTreeMap<std::string::String, std::string::String>>,
57
58 pub session_affinity: Option<std::string::String>,
60
61 pub session_affinity_config: Option<crate::api::core::v1::SessionAffinityConfig>,
63
64 pub traffic_distribution: Option<std::string::String>,
66
67 pub type_: Option<std::string::String>,
69}
70
71impl crate::DeepMerge for ServiceSpec {
72 fn merge_from(&mut self, other: Self) {
73 crate::DeepMerge::merge_from(&mut self.allocate_load_balancer_node_ports, other.allocate_load_balancer_node_ports);
74 crate::DeepMerge::merge_from(&mut self.cluster_ip, other.cluster_ip);
75 crate::merge_strategies::list::atomic(&mut self.cluster_ips, other.cluster_ips);
76 crate::merge_strategies::list::atomic(&mut self.external_ips, other.external_ips);
77 crate::DeepMerge::merge_from(&mut self.external_name, other.external_name);
78 crate::DeepMerge::merge_from(&mut self.external_traffic_policy, other.external_traffic_policy);
79 crate::DeepMerge::merge_from(&mut self.health_check_node_port, other.health_check_node_port);
80 crate::DeepMerge::merge_from(&mut self.internal_traffic_policy, other.internal_traffic_policy);
81 crate::merge_strategies::list::atomic(&mut self.ip_families, other.ip_families);
82 crate::DeepMerge::merge_from(&mut self.ip_family_policy, other.ip_family_policy);
83 crate::DeepMerge::merge_from(&mut self.load_balancer_class, other.load_balancer_class);
84 crate::DeepMerge::merge_from(&mut self.load_balancer_ip, other.load_balancer_ip);
85 crate::merge_strategies::list::atomic(&mut self.load_balancer_source_ranges, other.load_balancer_source_ranges);
86 crate::merge_strategies::list::map(
87 &mut self.ports,
88 other.ports,
89 &[|lhs, rhs| lhs.port == rhs.port],
90 |current_item, other_item| {
91 crate::DeepMerge::merge_from(current_item, other_item);
92 },
93 );
94 crate::DeepMerge::merge_from(&mut self.publish_not_ready_addresses, other.publish_not_ready_addresses);
95 crate::merge_strategies::map::atomic(&mut self.selector, other.selector);
96 crate::DeepMerge::merge_from(&mut self.session_affinity, other.session_affinity);
97 crate::DeepMerge::merge_from(&mut self.session_affinity_config, other.session_affinity_config);
98 crate::DeepMerge::merge_from(&mut self.traffic_distribution, other.traffic_distribution);
99 crate::DeepMerge::merge_from(&mut self.type_, other.type_);
100 }
101}
102
103impl<'de> crate::serde::Deserialize<'de> for ServiceSpec {
104 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
105 #[allow(non_camel_case_types)]
106 enum Field {
107 Key_allocate_load_balancer_node_ports,
108 Key_cluster_ip,
109 Key_cluster_ips,
110 Key_external_ips,
111 Key_external_name,
112 Key_external_traffic_policy,
113 Key_health_check_node_port,
114 Key_internal_traffic_policy,
115 Key_ip_families,
116 Key_ip_family_policy,
117 Key_load_balancer_class,
118 Key_load_balancer_ip,
119 Key_load_balancer_source_ranges,
120 Key_ports,
121 Key_publish_not_ready_addresses,
122 Key_selector,
123 Key_session_affinity,
124 Key_session_affinity_config,
125 Key_traffic_distribution,
126 Key_type_,
127 Other,
128 }
129
130 impl<'de> crate::serde::Deserialize<'de> for Field {
131 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
132 struct Visitor;
133
134 impl crate::serde::de::Visitor<'_> for Visitor {
135 type Value = Field;
136
137 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
138 f.write_str("field identifier")
139 }
140
141 fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
142 Ok(match v {
143 "allocateLoadBalancerNodePorts" => Field::Key_allocate_load_balancer_node_ports,
144 "clusterIP" => Field::Key_cluster_ip,
145 "clusterIPs" => Field::Key_cluster_ips,
146 "externalIPs" => Field::Key_external_ips,
147 "externalName" => Field::Key_external_name,
148 "externalTrafficPolicy" => Field::Key_external_traffic_policy,
149 "healthCheckNodePort" => Field::Key_health_check_node_port,
150 "internalTrafficPolicy" => Field::Key_internal_traffic_policy,
151 "ipFamilies" => Field::Key_ip_families,
152 "ipFamilyPolicy" => Field::Key_ip_family_policy,
153 "loadBalancerClass" => Field::Key_load_balancer_class,
154 "loadBalancerIP" => Field::Key_load_balancer_ip,
155 "loadBalancerSourceRanges" => Field::Key_load_balancer_source_ranges,
156 "ports" => Field::Key_ports,
157 "publishNotReadyAddresses" => Field::Key_publish_not_ready_addresses,
158 "selector" => Field::Key_selector,
159 "sessionAffinity" => Field::Key_session_affinity,
160 "sessionAffinityConfig" => Field::Key_session_affinity_config,
161 "trafficDistribution" => Field::Key_traffic_distribution,
162 "type" => Field::Key_type_,
163 _ => Field::Other,
164 })
165 }
166 }
167
168 deserializer.deserialize_identifier(Visitor)
169 }
170 }
171
172 struct Visitor;
173
174 impl<'de> crate::serde::de::Visitor<'de> for Visitor {
175 type Value = ServiceSpec;
176
177 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
178 f.write_str("ServiceSpec")
179 }
180
181 fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
182 let mut value_allocate_load_balancer_node_ports: Option<bool> = None;
183 let mut value_cluster_ip: Option<std::string::String> = None;
184 let mut value_cluster_ips: Option<std::vec::Vec<std::string::String>> = None;
185 let mut value_external_ips: Option<std::vec::Vec<std::string::String>> = None;
186 let mut value_external_name: Option<std::string::String> = None;
187 let mut value_external_traffic_policy: Option<std::string::String> = None;
188 let mut value_health_check_node_port: Option<i32> = None;
189 let mut value_internal_traffic_policy: Option<std::string::String> = None;
190 let mut value_ip_families: Option<std::vec::Vec<std::string::String>> = None;
191 let mut value_ip_family_policy: Option<std::string::String> = None;
192 let mut value_load_balancer_class: Option<std::string::String> = None;
193 let mut value_load_balancer_ip: Option<std::string::String> = None;
194 let mut value_load_balancer_source_ranges: Option<std::vec::Vec<std::string::String>> = None;
195 let mut value_ports: Option<std::vec::Vec<crate::api::core::v1::ServicePort>> = None;
196 let mut value_publish_not_ready_addresses: Option<bool> = None;
197 let mut value_selector: Option<std::collections::BTreeMap<std::string::String, std::string::String>> = None;
198 let mut value_session_affinity: Option<std::string::String> = None;
199 let mut value_session_affinity_config: Option<crate::api::core::v1::SessionAffinityConfig> = None;
200 let mut value_traffic_distribution: Option<std::string::String> = None;
201 let mut value_type_: Option<std::string::String> = None;
202
203 while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
204 match key {
205 Field::Key_allocate_load_balancer_node_ports => value_allocate_load_balancer_node_ports = crate::serde::de::MapAccess::next_value(&mut map)?,
206 Field::Key_cluster_ip => value_cluster_ip = crate::serde::de::MapAccess::next_value(&mut map)?,
207 Field::Key_cluster_ips => value_cluster_ips = crate::serde::de::MapAccess::next_value(&mut map)?,
208 Field::Key_external_ips => value_external_ips = crate::serde::de::MapAccess::next_value(&mut map)?,
209 Field::Key_external_name => value_external_name = crate::serde::de::MapAccess::next_value(&mut map)?,
210 Field::Key_external_traffic_policy => value_external_traffic_policy = crate::serde::de::MapAccess::next_value(&mut map)?,
211 Field::Key_health_check_node_port => value_health_check_node_port = crate::serde::de::MapAccess::next_value(&mut map)?,
212 Field::Key_internal_traffic_policy => value_internal_traffic_policy = crate::serde::de::MapAccess::next_value(&mut map)?,
213 Field::Key_ip_families => value_ip_families = crate::serde::de::MapAccess::next_value(&mut map)?,
214 Field::Key_ip_family_policy => value_ip_family_policy = crate::serde::de::MapAccess::next_value(&mut map)?,
215 Field::Key_load_balancer_class => value_load_balancer_class = crate::serde::de::MapAccess::next_value(&mut map)?,
216 Field::Key_load_balancer_ip => value_load_balancer_ip = crate::serde::de::MapAccess::next_value(&mut map)?,
217 Field::Key_load_balancer_source_ranges => value_load_balancer_source_ranges = crate::serde::de::MapAccess::next_value(&mut map)?,
218 Field::Key_ports => value_ports = crate::serde::de::MapAccess::next_value(&mut map)?,
219 Field::Key_publish_not_ready_addresses => value_publish_not_ready_addresses = crate::serde::de::MapAccess::next_value(&mut map)?,
220 Field::Key_selector => value_selector = crate::serde::de::MapAccess::next_value(&mut map)?,
221 Field::Key_session_affinity => value_session_affinity = crate::serde::de::MapAccess::next_value(&mut map)?,
222 Field::Key_session_affinity_config => value_session_affinity_config = crate::serde::de::MapAccess::next_value(&mut map)?,
223 Field::Key_traffic_distribution => value_traffic_distribution = crate::serde::de::MapAccess::next_value(&mut map)?,
224 Field::Key_type_ => value_type_ = crate::serde::de::MapAccess::next_value(&mut map)?,
225 Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
226 }
227 }
228
229 Ok(ServiceSpec {
230 allocate_load_balancer_node_ports: value_allocate_load_balancer_node_ports,
231 cluster_ip: value_cluster_ip,
232 cluster_ips: value_cluster_ips,
233 external_ips: value_external_ips,
234 external_name: value_external_name,
235 external_traffic_policy: value_external_traffic_policy,
236 health_check_node_port: value_health_check_node_port,
237 internal_traffic_policy: value_internal_traffic_policy,
238 ip_families: value_ip_families,
239 ip_family_policy: value_ip_family_policy,
240 load_balancer_class: value_load_balancer_class,
241 load_balancer_ip: value_load_balancer_ip,
242 load_balancer_source_ranges: value_load_balancer_source_ranges,
243 ports: value_ports,
244 publish_not_ready_addresses: value_publish_not_ready_addresses,
245 selector: value_selector,
246 session_affinity: value_session_affinity,
247 session_affinity_config: value_session_affinity_config,
248 traffic_distribution: value_traffic_distribution,
249 type_: value_type_,
250 })
251 }
252 }
253
254 deserializer.deserialize_struct(
255 "ServiceSpec",
256 &[
257 "allocateLoadBalancerNodePorts",
258 "clusterIP",
259 "clusterIPs",
260 "externalIPs",
261 "externalName",
262 "externalTrafficPolicy",
263 "healthCheckNodePort",
264 "internalTrafficPolicy",
265 "ipFamilies",
266 "ipFamilyPolicy",
267 "loadBalancerClass",
268 "loadBalancerIP",
269 "loadBalancerSourceRanges",
270 "ports",
271 "publishNotReadyAddresses",
272 "selector",
273 "sessionAffinity",
274 "sessionAffinityConfig",
275 "trafficDistribution",
276 "type",
277 ],
278 Visitor,
279 )
280 }
281}
282
283impl crate::serde::Serialize for ServiceSpec {
284 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
285 let mut state = serializer.serialize_struct(
286 "ServiceSpec",
287 self.allocate_load_balancer_node_ports.as_ref().map_or(0, |_| 1) +
288 self.cluster_ip.as_ref().map_or(0, |_| 1) +
289 self.cluster_ips.as_ref().map_or(0, |_| 1) +
290 self.external_ips.as_ref().map_or(0, |_| 1) +
291 self.external_name.as_ref().map_or(0, |_| 1) +
292 self.external_traffic_policy.as_ref().map_or(0, |_| 1) +
293 self.health_check_node_port.as_ref().map_or(0, |_| 1) +
294 self.internal_traffic_policy.as_ref().map_or(0, |_| 1) +
295 self.ip_families.as_ref().map_or(0, |_| 1) +
296 self.ip_family_policy.as_ref().map_or(0, |_| 1) +
297 self.load_balancer_class.as_ref().map_or(0, |_| 1) +
298 self.load_balancer_ip.as_ref().map_or(0, |_| 1) +
299 self.load_balancer_source_ranges.as_ref().map_or(0, |_| 1) +
300 self.ports.as_ref().map_or(0, |_| 1) +
301 self.publish_not_ready_addresses.as_ref().map_or(0, |_| 1) +
302 self.selector.as_ref().map_or(0, |_| 1) +
303 self.session_affinity.as_ref().map_or(0, |_| 1) +
304 self.session_affinity_config.as_ref().map_or(0, |_| 1) +
305 self.traffic_distribution.as_ref().map_or(0, |_| 1) +
306 self.type_.as_ref().map_or(0, |_| 1),
307 )?;
308 if let Some(value) = &self.allocate_load_balancer_node_ports {
309 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "allocateLoadBalancerNodePorts", value)?;
310 }
311 if let Some(value) = &self.cluster_ip {
312 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "clusterIP", value)?;
313 }
314 if let Some(value) = &self.cluster_ips {
315 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "clusterIPs", value)?;
316 }
317 if let Some(value) = &self.external_ips {
318 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "externalIPs", value)?;
319 }
320 if let Some(value) = &self.external_name {
321 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "externalName", value)?;
322 }
323 if let Some(value) = &self.external_traffic_policy {
324 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "externalTrafficPolicy", value)?;
325 }
326 if let Some(value) = &self.health_check_node_port {
327 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "healthCheckNodePort", value)?;
328 }
329 if let Some(value) = &self.internal_traffic_policy {
330 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "internalTrafficPolicy", value)?;
331 }
332 if let Some(value) = &self.ip_families {
333 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "ipFamilies", value)?;
334 }
335 if let Some(value) = &self.ip_family_policy {
336 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "ipFamilyPolicy", value)?;
337 }
338 if let Some(value) = &self.load_balancer_class {
339 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "loadBalancerClass", value)?;
340 }
341 if let Some(value) = &self.load_balancer_ip {
342 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "loadBalancerIP", value)?;
343 }
344 if let Some(value) = &self.load_balancer_source_ranges {
345 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "loadBalancerSourceRanges", value)?;
346 }
347 if let Some(value) = &self.ports {
348 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "ports", value)?;
349 }
350 if let Some(value) = &self.publish_not_ready_addresses {
351 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "publishNotReadyAddresses", value)?;
352 }
353 if let Some(value) = &self.selector {
354 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "selector", value)?;
355 }
356 if let Some(value) = &self.session_affinity {
357 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "sessionAffinity", value)?;
358 }
359 if let Some(value) = &self.session_affinity_config {
360 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "sessionAffinityConfig", value)?;
361 }
362 if let Some(value) = &self.traffic_distribution {
363 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "trafficDistribution", value)?;
364 }
365 if let Some(value) = &self.type_ {
366 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "type", value)?;
367 }
368 crate::serde::ser::SerializeStruct::end(state)
369 }
370}
371
372#[cfg(feature = "schemars")]
373impl crate::schemars::JsonSchema for ServiceSpec {
374 fn schema_name() -> std::borrow::Cow<'static, str> {
375 "io.k8s.api.core.v1.ServiceSpec".into()
376 }
377
378 fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
379 crate::schemars::json_schema!({
380 "description": "ServiceSpec describes the attributes that a user creates on a service.",
381 "type": "object",
382 "properties": {
383 "allocateLoadBalancerNodePorts": {
384 "description": "allocateLoadBalancerNodePorts defines if NodePorts will be automatically allocated for services with type LoadBalancer. Default is \"true\". It may be set to \"false\" if the cluster load-balancer does not rely on NodePorts. If the caller requests specific NodePorts (by specifying a value), those requests will be respected, regardless of this field. This field may only be set for services with type LoadBalancer and will be cleared if the type is changed to any other type.",
385 "type": "boolean",
386 },
387 "clusterIP": {
388 "description": "clusterIP is the IP address of the service and is usually assigned randomly. If an address is specified manually, is in-range (as per system configuration), and is not in use, it will be allocated to the service; otherwise creation of the service will fail. This field may not be changed through updates unless the type field is also being changed to ExternalName (which requires this field to be blank) or the type field is being changed from ExternalName (in which case this field may optionally be specified, as describe above). Valid values are \"None\", empty string (\"\"), or a valid IP address. Setting this to \"None\" makes a \"headless service\" (no virtual IP), which is useful when direct endpoint connections are preferred and proxying is not required. Only applies to types ClusterIP, NodePort, and LoadBalancer. If this field is specified when creating a Service of type ExternalName, creation will fail. This field will be wiped when updating a Service to type ExternalName. More info: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies",
389 "type": "string",
390 },
391 "clusterIPs": {
392 "description": "ClusterIPs is a list of IP addresses assigned to this service, and are usually assigned randomly. If an address is specified manually, is in-range (as per system configuration), and is not in use, it will be allocated to the service; otherwise creation of the service will fail. This field may not be changed through updates unless the type field is also being changed to ExternalName (which requires this field to be empty) or the type field is being changed from ExternalName (in which case this field may optionally be specified, as describe above). Valid values are \"None\", empty string (\"\"), or a valid IP address. Setting this to \"None\" makes a \"headless service\" (no virtual IP), which is useful when direct endpoint connections are preferred and proxying is not required. Only applies to types ClusterIP, NodePort, and LoadBalancer. If this field is specified when creating a Service of type ExternalName, creation will fail. This field will be wiped when updating a Service to type ExternalName. If this field is not specified, it will be initialized from the clusterIP field. If this field is specified, clients must ensure that clusterIPs[0] and clusterIP have the same value.\n\nThis field may hold a maximum of two entries (dual-stack IPs, in either order). These IPs must correspond to the values of the ipFamilies field. Both clusterIPs and ipFamilies are governed by the ipFamilyPolicy field. More info: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies",
393 "type": "array",
394 "items": {
395 "type": "string",
396 },
397 },
398 "externalIPs": {
399 "description": "externalIPs is a list of IP addresses for which nodes in the cluster will also accept traffic for this service. These IPs are not managed by Kubernetes. The user is responsible for ensuring that traffic arrives at a node with this IP. A common example is external load-balancers that are not part of the Kubernetes system.",
400 "type": "array",
401 "items": {
402 "type": "string",
403 },
404 },
405 "externalName": {
406 "description": "externalName is the external reference that discovery mechanisms will return as an alias for this service (e.g. a DNS CNAME record). No proxying will be involved. Must be a lowercase RFC-1123 hostname (https://tools.ietf.org/html/rfc1123) and requires `type` to be \"ExternalName\".",
407 "type": "string",
408 },
409 "externalTrafficPolicy": {
410 "description": "externalTrafficPolicy describes how nodes distribute service traffic they receive on one of the Service's \"externally-facing\" addresses (NodePorts, ExternalIPs, and LoadBalancer IPs). If set to \"Local\", the proxy will configure the service in a way that assumes that external load balancers will take care of balancing the service traffic between nodes, and so each node will deliver traffic only to the node-local endpoints of the service, without masquerading the client source IP. (Traffic mistakenly sent to a node with no endpoints will be dropped.) The default value, \"Cluster\", uses the standard behavior of routing to all endpoints evenly (possibly modified by topology and other features). Note that traffic sent to an External IP or LoadBalancer IP from within the cluster will always get \"Cluster\" semantics, but clients sending to a NodePort from within the cluster may need to take traffic policy into account when picking a node.",
411 "type": "string",
412 },
413 "healthCheckNodePort": {
414 "description": "healthCheckNodePort specifies the healthcheck nodePort for the service. This only applies when type is set to LoadBalancer and externalTrafficPolicy is set to Local. If a value is specified, is in-range, and is not in use, it will be used. If not specified, a value will be automatically allocated. External systems (e.g. load-balancers) can use this port to determine if a given node holds endpoints for this service or not. If this field is specified when creating a Service which does not need it, creation will fail. This field will be wiped when updating a Service to no longer need it (e.g. changing type). This field cannot be updated once set.",
415 "type": "integer",
416 "format": "int32",
417 },
418 "internalTrafficPolicy": {
419 "description": "InternalTrafficPolicy describes how nodes distribute service traffic they receive on the ClusterIP. If set to \"Local\", the proxy will assume that pods only want to talk to endpoints of the service on the same node as the pod, dropping the traffic if there are no local endpoints. The default value, \"Cluster\", uses the standard behavior of routing to all endpoints evenly (possibly modified by topology and other features).",
420 "type": "string",
421 },
422 "ipFamilies": {
423 "description": "IPFamilies is a list of IP families (e.g. IPv4, IPv6) assigned to this service. This field is usually assigned automatically based on cluster configuration and the ipFamilyPolicy field. If this field is specified manually, the requested family is available in the cluster, and ipFamilyPolicy allows it, it will be used; otherwise creation of the service will fail. This field is conditionally mutable: it allows for adding or removing a secondary IP family, but it does not allow changing the primary IP family of the Service. Valid values are \"IPv4\" and \"IPv6\". This field only applies to Services of types ClusterIP, NodePort, and LoadBalancer, and does apply to \"headless\" services. This field will be wiped when updating a Service to type ExternalName.\n\nThis field may hold a maximum of two entries (dual-stack families, in either order). These families must correspond to the values of the clusterIPs field, if specified. Both clusterIPs and ipFamilies are governed by the ipFamilyPolicy field.",
424 "type": "array",
425 "items": {
426 "type": "string",
427 },
428 },
429 "ipFamilyPolicy": {
430 "description": "IPFamilyPolicy represents the dual-stack-ness requested or required by this Service. If there is no value provided, then this field will be set to SingleStack. Services can be \"SingleStack\" (a single IP family), \"PreferDualStack\" (two IP families on dual-stack configured clusters or a single IP family on single-stack clusters), or \"RequireDualStack\" (two IP families on dual-stack configured clusters, otherwise fail). The ipFamilies and clusterIPs fields depend on the value of this field. This field will be wiped when updating a service to type ExternalName.",
431 "type": "string",
432 },
433 "loadBalancerClass": {
434 "description": "loadBalancerClass is the class of the load balancer implementation this Service belongs to. If specified, the value of this field must be a label-style identifier, with an optional prefix, e.g. \"internal-vip\" or \"example.com/internal-vip\". Unprefixed names are reserved for end-users. This field can only be set when the Service type is 'LoadBalancer'. If not set, the default load balancer implementation is used, today this is typically done through the cloud provider integration, but should apply for any default implementation. If set, it is assumed that a load balancer implementation is watching for Services with a matching class. Any default load balancer implementation (e.g. cloud providers) should ignore Services that set this field. This field can only be set when creating or updating a Service to type 'LoadBalancer'. Once set, it can not be changed. This field will be wiped when a service is updated to a non 'LoadBalancer' type.",
435 "type": "string",
436 },
437 "loadBalancerIP": {
438 "description": "Only applies to Service Type: LoadBalancer. This feature depends on whether the underlying cloud-provider supports specifying the loadBalancerIP when a load balancer is created. This field will be ignored if the cloud-provider does not support the feature. Deprecated: This field was under-specified and its meaning varies across implementations. Using it is non-portable and it may not support dual-stack. Users are encouraged to use implementation-specific annotations when available.",
439 "type": "string",
440 },
441 "loadBalancerSourceRanges": {
442 "description": "If specified and supported by the platform, this will restrict traffic through the cloud-provider load-balancer will be restricted to the specified client IPs. This field will be ignored if the cloud-provider does not support the feature.\" More info: https://kubernetes.io/docs/tasks/access-application-cluster/create-external-load-balancer/",
443 "type": "array",
444 "items": {
445 "type": "string",
446 },
447 },
448 "ports": {
449 "description": "The list of ports that are exposed by this service. More info: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies",
450 "type": "array",
451 "items": (__gen.subschema_for::<crate::api::core::v1::ServicePort>()),
452 },
453 "publishNotReadyAddresses": {
454 "description": "publishNotReadyAddresses indicates that any agent which deals with endpoints for this Service should disregard any indications of ready/not-ready. The primary use case for setting this field is for a StatefulSet's Headless Service to propagate SRV DNS records for its Pods for the purpose of peer discovery. The Kubernetes controllers that generate Endpoints and EndpointSlice resources for Services interpret this to mean that all endpoints are considered \"ready\" even if the Pods themselves are not. Agents which consume only Kubernetes generated endpoints through the Endpoints or EndpointSlice resources can safely assume this behavior.",
455 "type": "boolean",
456 },
457 "selector": {
458 "description": "Route service traffic to pods with label keys and values matching this selector. If empty or not present, the service is assumed to have an external process managing its endpoints, which Kubernetes will not modify. Only applies to types ClusterIP, NodePort, and LoadBalancer. Ignored if type is ExternalName. More info: https://kubernetes.io/docs/concepts/services-networking/service/",
459 "type": "object",
460 "additionalProperties": {
461 "type": "string",
462 },
463 },
464 "sessionAffinity": {
465 "description": "Supports \"ClientIP\" and \"None\". Used to maintain session affinity. Enable client IP based session affinity. Must be ClientIP or None. Defaults to None. More info: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies",
466 "type": "string",
467 },
468 "sessionAffinityConfig": ({
469 let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::SessionAffinityConfig>();
470 schema_obj.ensure_object().insert("description".into(), "sessionAffinityConfig contains the configurations of session affinity.".into());
471 schema_obj
472 }),
473 "trafficDistribution": {
474 "description": "TrafficDistribution offers a way to express preferences for how traffic is distributed to Service endpoints. Implementations can use this field as a hint, but are not required to guarantee strict adherence. If the field is not set, the implementation will apply its default routing strategy. If set to \"PreferClose\", implementations should prioritize endpoints that are topologically close (e.g., same zone). This is an alpha field and requires enabling ServiceTrafficDistribution feature.",
475 "type": "string",
476 },
477 "type": {
478 "description": "type determines how the Service is exposed. Defaults to ClusterIP. Valid options are ExternalName, ClusterIP, NodePort, and LoadBalancer. \"ClusterIP\" allocates a cluster-internal IP address for load-balancing to endpoints. Endpoints are determined by the selector or if that is not specified, by manual construction of an Endpoints object or EndpointSlice objects. If clusterIP is \"None\", no virtual IP is allocated and the endpoints are published as a set of endpoints rather than a virtual IP. \"NodePort\" builds on ClusterIP and allocates a port on every node which routes to the same endpoints as the clusterIP. \"LoadBalancer\" builds on NodePort and creates an external load-balancer (if supported in the current cloud) which routes to the same endpoints as the clusterIP. \"ExternalName\" aliases this service to the specified externalName. Several other fields do not apply to ExternalName services. More info: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types",
479 "type": "string",
480 },
481 },
482 })
483 }
484}