k8s_traefik_api/
traefikservices.rs

1// WARNING: generated by kopium - manual changes will be overwritten
2// kopium command: kopium traefikservices.traefik.io -A -b --derive=Default --derive=PartialEq --smart-derive-elision
3// kopium version: 0.21.2
4
5#[allow(unused_imports)]
6mod prelude {
7    pub use kube::CustomResource;
8    pub use typed_builder::TypedBuilder;
9    pub use schemars::JsonSchema;
10    pub use serde::{Serialize, Deserialize};
11    pub use std::collections::BTreeMap;
12    pub use k8s_openapi::apimachinery::pkg::util::intstr::IntOrString;
13}
14use self::prelude::*;
15
16/// TraefikServiceSpec defines the desired state of a TraefikService.
17#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, TypedBuilder, Default, PartialEq, JsonSchema)]
18#[kube(group = "traefik.io", version = "v1alpha1", kind = "TraefikService", plural = "traefikservices")]
19#[kube(namespaced)]
20#[kube(derive="Default")]
21#[kube(derive="PartialEq")]
22pub struct TraefikServiceSpec {
23    /// Mirroring defines the Mirroring service configuration.
24    #[serde(default, skip_serializing_if = "Option::is_none")]
25    #[builder(default, setter(strip_option))]
26    pub mirroring: Option<TraefikServiceMirroring>,
27    /// Weighted defines the Weighted Round Robin configuration.
28    #[serde(default, skip_serializing_if = "Option::is_none")]
29    #[builder(default, setter(strip_option))]
30    pub weighted: Option<TraefikServiceWeighted>,
31}
32
33/// Mirroring defines the Mirroring service configuration.
34#[derive(Serialize, Deserialize, Clone, Debug, TypedBuilder, Default, PartialEq, JsonSchema)]
35pub struct TraefikServiceMirroring {
36    /// Healthcheck defines health checks for ExternalName services.
37    #[serde(default, skip_serializing_if = "Option::is_none", rename = "healthCheck")]
38    #[builder(default, setter(strip_option))]
39    pub health_check: Option<TraefikServiceMirroringHealthCheck>,
40    /// Kind defines the kind of the Service.
41    #[serde(default, skip_serializing_if = "Option::is_none")]
42    #[builder(default, setter(strip_option))]
43    pub kind: Option<TraefikServiceMirroringKind>,
44    /// MaxBodySize defines the maximum size allowed for the body of the request.
45    /// If the body is larger, the request is not mirrored.
46    /// Default value is -1, which means unlimited size.
47    #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxBodySize")]
48    #[builder(default, setter(strip_option))]
49    pub max_body_size: Option<i64>,
50    /// MirrorBody defines whether the body of the request should be mirrored.
51    /// Default value is true.
52    #[serde(default, skip_serializing_if = "Option::is_none", rename = "mirrorBody")]
53    #[builder(default, setter(strip_option))]
54    pub mirror_body: Option<bool>,
55    /// Mirrors defines the list of mirrors where Traefik will duplicate the traffic.
56    #[serde(default, skip_serializing_if = "Option::is_none")]
57    #[builder(default, setter(strip_option))]
58    pub mirrors: Option<Vec<TraefikServiceMirroringMirrors>>,
59    /// Name defines the name of the referenced Kubernetes Service or TraefikService.
60    /// The differentiation between the two is specified in the Kind field.
61    pub name: String,
62    /// Namespace defines the namespace of the referenced Kubernetes Service or TraefikService.
63    #[serde(default, skip_serializing_if = "Option::is_none")]
64    #[builder(default, setter(strip_option))]
65    pub namespace: Option<String>,
66    /// NativeLB controls, when creating the load-balancer,
67    /// whether the LB's children are directly the pods IPs or if the only child is the Kubernetes Service clusterIP.
68    /// The Kubernetes Service itself does load-balance to the pods.
69    /// By default, NativeLB is false.
70    #[serde(default, skip_serializing_if = "Option::is_none", rename = "nativeLB")]
71    #[builder(default, setter(strip_option))]
72    pub native_lb: Option<bool>,
73    /// NodePortLB controls, when creating the load-balancer,
74    /// whether the LB's children are directly the nodes internal IPs using the nodePort when the service type is NodePort.
75    /// It allows services to be reachable when Traefik runs externally from the Kubernetes cluster but within the same network of the nodes.
76    /// By default, NodePortLB is false.
77    #[serde(default, skip_serializing_if = "Option::is_none", rename = "nodePortLB")]
78    #[builder(default, setter(strip_option))]
79    pub node_port_lb: Option<bool>,
80    /// PassHostHeader defines whether the client Host header is forwarded to the upstream Kubernetes Service.
81    /// By default, passHostHeader is true.
82    #[serde(default, skip_serializing_if = "Option::is_none", rename = "passHostHeader")]
83    #[builder(default, setter(strip_option))]
84    pub pass_host_header: Option<bool>,
85    /// Port defines the port of a Kubernetes Service.
86    /// This can be a reference to a named port.
87    #[serde(default, skip_serializing_if = "Option::is_none")]
88    #[builder(default, setter(strip_option))]
89    pub port: Option<IntOrString>,
90    /// ResponseForwarding defines how Traefik forwards the response from the upstream Kubernetes Service to the client.
91    #[serde(default, skip_serializing_if = "Option::is_none", rename = "responseForwarding")]
92    #[builder(default, setter(strip_option))]
93    pub response_forwarding: Option<TraefikServiceMirroringResponseForwarding>,
94    /// Scheme defines the scheme to use for the request to the upstream Kubernetes Service.
95    /// It defaults to https when Kubernetes Service port is 443, http otherwise.
96    #[serde(default, skip_serializing_if = "Option::is_none")]
97    #[builder(default, setter(strip_option))]
98    pub scheme: Option<String>,
99    /// ServersTransport defines the name of ServersTransport resource to use.
100    /// It allows to configure the transport between Traefik and your servers.
101    /// Can only be used on a Kubernetes Service.
102    #[serde(default, skip_serializing_if = "Option::is_none", rename = "serversTransport")]
103    #[builder(default, setter(strip_option))]
104    pub servers_transport: Option<String>,
105    /// Sticky defines the sticky sessions configuration.
106    /// More info: https://doc.traefik.io/traefik/v3.3/routing/services/#sticky-sessions
107    #[serde(default, skip_serializing_if = "Option::is_none")]
108    #[builder(default, setter(strip_option))]
109    pub sticky: Option<TraefikServiceMirroringSticky>,
110    /// Strategy defines the load balancing strategy between the servers.
111    /// RoundRobin is the only supported value at the moment.
112    #[serde(default, skip_serializing_if = "Option::is_none")]
113    #[builder(default, setter(strip_option))]
114    pub strategy: Option<String>,
115    /// Weight defines the weight and should only be specified when Name references a TraefikService object
116    /// (and to be precise, one that embeds a Weighted Round Robin).
117    #[serde(default, skip_serializing_if = "Option::is_none")]
118    #[builder(default, setter(strip_option))]
119    pub weight: Option<i64>,
120}
121
122/// Healthcheck defines health checks for ExternalName services.
123#[derive(Serialize, Deserialize, Clone, Debug, TypedBuilder, Default, PartialEq, JsonSchema)]
124pub struct TraefikServiceMirroringHealthCheck {
125    /// FollowRedirects defines whether redirects should be followed during the health check calls.
126    /// Default: true
127    #[serde(default, skip_serializing_if = "Option::is_none", rename = "followRedirects")]
128    #[builder(default, setter(strip_option))]
129    pub follow_redirects: Option<bool>,
130    /// Headers defines custom headers to be sent to the health check endpoint.
131    #[serde(default, skip_serializing_if = "Option::is_none")]
132    #[builder(default, setter(strip_option))]
133    pub headers: Option<BTreeMap<String, String>>,
134    /// Hostname defines the value of hostname in the Host header of the health check request.
135    #[serde(default, skip_serializing_if = "Option::is_none")]
136    #[builder(default, setter(strip_option))]
137    pub hostname: Option<String>,
138    /// Interval defines the frequency of the health check calls.
139    /// Default: 30s
140    #[serde(default, skip_serializing_if = "Option::is_none")]
141    #[builder(default, setter(strip_option))]
142    pub interval: Option<IntOrString>,
143    /// Method defines the healthcheck method.
144    #[serde(default, skip_serializing_if = "Option::is_none")]
145    #[builder(default, setter(strip_option))]
146    pub method: Option<String>,
147    /// Mode defines the health check mode.
148    /// If defined to grpc, will use the gRPC health check protocol to probe the server.
149    /// Default: http
150    #[serde(default, skip_serializing_if = "Option::is_none")]
151    #[builder(default, setter(strip_option))]
152    pub mode: Option<String>,
153    /// Path defines the server URL path for the health check endpoint.
154    #[serde(default, skip_serializing_if = "Option::is_none")]
155    #[builder(default, setter(strip_option))]
156    pub path: Option<String>,
157    /// Port defines the server URL port for the health check endpoint.
158    #[serde(default, skip_serializing_if = "Option::is_none")]
159    #[builder(default, setter(strip_option))]
160    pub port: Option<i64>,
161    /// Scheme replaces the server URL scheme for the health check endpoint.
162    #[serde(default, skip_serializing_if = "Option::is_none")]
163    #[builder(default, setter(strip_option))]
164    pub scheme: Option<String>,
165    /// Status defines the expected HTTP status code of the response to the health check request.
166    #[serde(default, skip_serializing_if = "Option::is_none")]
167    #[builder(default, setter(strip_option))]
168    pub status: Option<i64>,
169    /// Timeout defines the maximum duration Traefik will wait for a health check request before considering the server unhealthy.
170    /// Default: 5s
171    #[serde(default, skip_serializing_if = "Option::is_none")]
172    #[builder(default, setter(strip_option))]
173    pub timeout: Option<IntOrString>,
174}
175
176/// Mirroring defines the Mirroring service configuration.
177#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
178pub enum TraefikServiceMirroringKind {
179    Service,
180    TraefikService,
181}
182
183/// MirrorService holds the mirror configuration.
184#[derive(Serialize, Deserialize, Clone, Debug, TypedBuilder, Default, PartialEq, JsonSchema)]
185pub struct TraefikServiceMirroringMirrors {
186    /// Healthcheck defines health checks for ExternalName services.
187    #[serde(default, skip_serializing_if = "Option::is_none", rename = "healthCheck")]
188    #[builder(default, setter(strip_option))]
189    pub health_check: Option<TraefikServiceMirroringMirrorsHealthCheck>,
190    /// Kind defines the kind of the Service.
191    #[serde(default, skip_serializing_if = "Option::is_none")]
192    #[builder(default, setter(strip_option))]
193    pub kind: Option<TraefikServiceMirroringMirrorsKind>,
194    /// Name defines the name of the referenced Kubernetes Service or TraefikService.
195    /// The differentiation between the two is specified in the Kind field.
196    pub name: String,
197    /// Namespace defines the namespace of the referenced Kubernetes Service or TraefikService.
198    #[serde(default, skip_serializing_if = "Option::is_none")]
199    #[builder(default, setter(strip_option))]
200    pub namespace: Option<String>,
201    /// NativeLB controls, when creating the load-balancer,
202    /// whether the LB's children are directly the pods IPs or if the only child is the Kubernetes Service clusterIP.
203    /// The Kubernetes Service itself does load-balance to the pods.
204    /// By default, NativeLB is false.
205    #[serde(default, skip_serializing_if = "Option::is_none", rename = "nativeLB")]
206    #[builder(default, setter(strip_option))]
207    pub native_lb: Option<bool>,
208    /// NodePortLB controls, when creating the load-balancer,
209    /// whether the LB's children are directly the nodes internal IPs using the nodePort when the service type is NodePort.
210    /// It allows services to be reachable when Traefik runs externally from the Kubernetes cluster but within the same network of the nodes.
211    /// By default, NodePortLB is false.
212    #[serde(default, skip_serializing_if = "Option::is_none", rename = "nodePortLB")]
213    #[builder(default, setter(strip_option))]
214    pub node_port_lb: Option<bool>,
215    /// PassHostHeader defines whether the client Host header is forwarded to the upstream Kubernetes Service.
216    /// By default, passHostHeader is true.
217    #[serde(default, skip_serializing_if = "Option::is_none", rename = "passHostHeader")]
218    #[builder(default, setter(strip_option))]
219    pub pass_host_header: Option<bool>,
220    /// Percent defines the part of the traffic to mirror.
221    /// Supported values: 0 to 100.
222    #[serde(default, skip_serializing_if = "Option::is_none")]
223    #[builder(default, setter(strip_option))]
224    pub percent: Option<i64>,
225    /// Port defines the port of a Kubernetes Service.
226    /// This can be a reference to a named port.
227    #[serde(default, skip_serializing_if = "Option::is_none")]
228    #[builder(default, setter(strip_option))]
229    pub port: Option<IntOrString>,
230    /// ResponseForwarding defines how Traefik forwards the response from the upstream Kubernetes Service to the client.
231    #[serde(default, skip_serializing_if = "Option::is_none", rename = "responseForwarding")]
232    #[builder(default, setter(strip_option))]
233    pub response_forwarding: Option<TraefikServiceMirroringMirrorsResponseForwarding>,
234    /// Scheme defines the scheme to use for the request to the upstream Kubernetes Service.
235    /// It defaults to https when Kubernetes Service port is 443, http otherwise.
236    #[serde(default, skip_serializing_if = "Option::is_none")]
237    #[builder(default, setter(strip_option))]
238    pub scheme: Option<String>,
239    /// ServersTransport defines the name of ServersTransport resource to use.
240    /// It allows to configure the transport between Traefik and your servers.
241    /// Can only be used on a Kubernetes Service.
242    #[serde(default, skip_serializing_if = "Option::is_none", rename = "serversTransport")]
243    #[builder(default, setter(strip_option))]
244    pub servers_transport: Option<String>,
245    /// Sticky defines the sticky sessions configuration.
246    /// More info: https://doc.traefik.io/traefik/v3.3/routing/services/#sticky-sessions
247    #[serde(default, skip_serializing_if = "Option::is_none")]
248    #[builder(default, setter(strip_option))]
249    pub sticky: Option<TraefikServiceMirroringMirrorsSticky>,
250    /// Strategy defines the load balancing strategy between the servers.
251    /// RoundRobin is the only supported value at the moment.
252    #[serde(default, skip_serializing_if = "Option::is_none")]
253    #[builder(default, setter(strip_option))]
254    pub strategy: Option<String>,
255    /// Weight defines the weight and should only be specified when Name references a TraefikService object
256    /// (and to be precise, one that embeds a Weighted Round Robin).
257    #[serde(default, skip_serializing_if = "Option::is_none")]
258    #[builder(default, setter(strip_option))]
259    pub weight: Option<i64>,
260}
261
262/// Healthcheck defines health checks for ExternalName services.
263#[derive(Serialize, Deserialize, Clone, Debug, TypedBuilder, Default, PartialEq, JsonSchema)]
264pub struct TraefikServiceMirroringMirrorsHealthCheck {
265    /// FollowRedirects defines whether redirects should be followed during the health check calls.
266    /// Default: true
267    #[serde(default, skip_serializing_if = "Option::is_none", rename = "followRedirects")]
268    #[builder(default, setter(strip_option))]
269    pub follow_redirects: Option<bool>,
270    /// Headers defines custom headers to be sent to the health check endpoint.
271    #[serde(default, skip_serializing_if = "Option::is_none")]
272    #[builder(default, setter(strip_option))]
273    pub headers: Option<BTreeMap<String, String>>,
274    /// Hostname defines the value of hostname in the Host header of the health check request.
275    #[serde(default, skip_serializing_if = "Option::is_none")]
276    #[builder(default, setter(strip_option))]
277    pub hostname: Option<String>,
278    /// Interval defines the frequency of the health check calls.
279    /// Default: 30s
280    #[serde(default, skip_serializing_if = "Option::is_none")]
281    #[builder(default, setter(strip_option))]
282    pub interval: Option<IntOrString>,
283    /// Method defines the healthcheck method.
284    #[serde(default, skip_serializing_if = "Option::is_none")]
285    #[builder(default, setter(strip_option))]
286    pub method: Option<String>,
287    /// Mode defines the health check mode.
288    /// If defined to grpc, will use the gRPC health check protocol to probe the server.
289    /// Default: http
290    #[serde(default, skip_serializing_if = "Option::is_none")]
291    #[builder(default, setter(strip_option))]
292    pub mode: Option<String>,
293    /// Path defines the server URL path for the health check endpoint.
294    #[serde(default, skip_serializing_if = "Option::is_none")]
295    #[builder(default, setter(strip_option))]
296    pub path: Option<String>,
297    /// Port defines the server URL port for the health check endpoint.
298    #[serde(default, skip_serializing_if = "Option::is_none")]
299    #[builder(default, setter(strip_option))]
300    pub port: Option<i64>,
301    /// Scheme replaces the server URL scheme for the health check endpoint.
302    #[serde(default, skip_serializing_if = "Option::is_none")]
303    #[builder(default, setter(strip_option))]
304    pub scheme: Option<String>,
305    /// Status defines the expected HTTP status code of the response to the health check request.
306    #[serde(default, skip_serializing_if = "Option::is_none")]
307    #[builder(default, setter(strip_option))]
308    pub status: Option<i64>,
309    /// Timeout defines the maximum duration Traefik will wait for a health check request before considering the server unhealthy.
310    /// Default: 5s
311    #[serde(default, skip_serializing_if = "Option::is_none")]
312    #[builder(default, setter(strip_option))]
313    pub timeout: Option<IntOrString>,
314}
315
316/// MirrorService holds the mirror configuration.
317#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
318pub enum TraefikServiceMirroringMirrorsKind {
319    Service,
320    TraefikService,
321}
322
323/// ResponseForwarding defines how Traefik forwards the response from the upstream Kubernetes Service to the client.
324#[derive(Serialize, Deserialize, Clone, Debug, TypedBuilder, Default, PartialEq, JsonSchema)]
325pub struct TraefikServiceMirroringMirrorsResponseForwarding {
326    /// FlushInterval defines the interval, in milliseconds, in between flushes to the client while copying the response body.
327    /// A negative value means to flush immediately after each write to the client.
328    /// This configuration is ignored when ReverseProxy recognizes a response as a streaming response;
329    /// for such responses, writes are flushed to the client immediately.
330    /// Default: 100ms
331    #[serde(default, skip_serializing_if = "Option::is_none", rename = "flushInterval")]
332    #[builder(default, setter(strip_option))]
333    pub flush_interval: Option<String>,
334}
335
336/// Sticky defines the sticky sessions configuration.
337/// More info: https://doc.traefik.io/traefik/v3.3/routing/services/#sticky-sessions
338#[derive(Serialize, Deserialize, Clone, Debug, TypedBuilder, Default, PartialEq, JsonSchema)]
339pub struct TraefikServiceMirroringMirrorsSticky {
340    /// Cookie defines the sticky cookie configuration.
341    #[serde(default, skip_serializing_if = "Option::is_none")]
342    #[builder(default, setter(strip_option))]
343    pub cookie: Option<TraefikServiceMirroringMirrorsStickyCookie>,
344}
345
346/// Cookie defines the sticky cookie configuration.
347#[derive(Serialize, Deserialize, Clone, Debug, TypedBuilder, Default, PartialEq, JsonSchema)]
348pub struct TraefikServiceMirroringMirrorsStickyCookie {
349    /// HTTPOnly defines whether the cookie can be accessed by client-side APIs, such as JavaScript.
350    #[serde(default, skip_serializing_if = "Option::is_none", rename = "httpOnly")]
351    #[builder(default, setter(strip_option))]
352    pub http_only: Option<bool>,
353    /// MaxAge defines the number of seconds until the cookie expires.
354    /// When set to a negative number, the cookie expires immediately.
355    /// When set to zero, the cookie never expires.
356    #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxAge")]
357    #[builder(default, setter(strip_option))]
358    pub max_age: Option<i64>,
359    /// Name defines the Cookie name.
360    #[serde(default, skip_serializing_if = "Option::is_none")]
361    #[builder(default, setter(strip_option))]
362    pub name: Option<String>,
363    /// Path defines the path that must exist in the requested URL for the browser to send the Cookie header.
364    /// When not provided the cookie will be sent on every request to the domain.
365    /// More info: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#pathpath-value
366    #[serde(default, skip_serializing_if = "Option::is_none")]
367    #[builder(default, setter(strip_option))]
368    pub path: Option<String>,
369    /// SameSite defines the same site policy.
370    /// More info: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite
371    #[serde(default, skip_serializing_if = "Option::is_none", rename = "sameSite")]
372    #[builder(default, setter(strip_option))]
373    pub same_site: Option<String>,
374    /// Secure defines whether the cookie can only be transmitted over an encrypted connection (i.e. HTTPS).
375    #[serde(default, skip_serializing_if = "Option::is_none")]
376    #[builder(default, setter(strip_option))]
377    pub secure: Option<bool>,
378}
379
380/// ResponseForwarding defines how Traefik forwards the response from the upstream Kubernetes Service to the client.
381#[derive(Serialize, Deserialize, Clone, Debug, TypedBuilder, Default, PartialEq, JsonSchema)]
382pub struct TraefikServiceMirroringResponseForwarding {
383    /// FlushInterval defines the interval, in milliseconds, in between flushes to the client while copying the response body.
384    /// A negative value means to flush immediately after each write to the client.
385    /// This configuration is ignored when ReverseProxy recognizes a response as a streaming response;
386    /// for such responses, writes are flushed to the client immediately.
387    /// Default: 100ms
388    #[serde(default, skip_serializing_if = "Option::is_none", rename = "flushInterval")]
389    #[builder(default, setter(strip_option))]
390    pub flush_interval: Option<String>,
391}
392
393/// Sticky defines the sticky sessions configuration.
394/// More info: https://doc.traefik.io/traefik/v3.3/routing/services/#sticky-sessions
395#[derive(Serialize, Deserialize, Clone, Debug, TypedBuilder, Default, PartialEq, JsonSchema)]
396pub struct TraefikServiceMirroringSticky {
397    /// Cookie defines the sticky cookie configuration.
398    #[serde(default, skip_serializing_if = "Option::is_none")]
399    #[builder(default, setter(strip_option))]
400    pub cookie: Option<TraefikServiceMirroringStickyCookie>,
401}
402
403/// Cookie defines the sticky cookie configuration.
404#[derive(Serialize, Deserialize, Clone, Debug, TypedBuilder, Default, PartialEq, JsonSchema)]
405pub struct TraefikServiceMirroringStickyCookie {
406    /// HTTPOnly defines whether the cookie can be accessed by client-side APIs, such as JavaScript.
407    #[serde(default, skip_serializing_if = "Option::is_none", rename = "httpOnly")]
408    #[builder(default, setter(strip_option))]
409    pub http_only: Option<bool>,
410    /// MaxAge defines the number of seconds until the cookie expires.
411    /// When set to a negative number, the cookie expires immediately.
412    /// When set to zero, the cookie never expires.
413    #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxAge")]
414    #[builder(default, setter(strip_option))]
415    pub max_age: Option<i64>,
416    /// Name defines the Cookie name.
417    #[serde(default, skip_serializing_if = "Option::is_none")]
418    #[builder(default, setter(strip_option))]
419    pub name: Option<String>,
420    /// Path defines the path that must exist in the requested URL for the browser to send the Cookie header.
421    /// When not provided the cookie will be sent on every request to the domain.
422    /// More info: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#pathpath-value
423    #[serde(default, skip_serializing_if = "Option::is_none")]
424    #[builder(default, setter(strip_option))]
425    pub path: Option<String>,
426    /// SameSite defines the same site policy.
427    /// More info: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite
428    #[serde(default, skip_serializing_if = "Option::is_none", rename = "sameSite")]
429    #[builder(default, setter(strip_option))]
430    pub same_site: Option<String>,
431    /// Secure defines whether the cookie can only be transmitted over an encrypted connection (i.e. HTTPS).
432    #[serde(default, skip_serializing_if = "Option::is_none")]
433    #[builder(default, setter(strip_option))]
434    pub secure: Option<bool>,
435}
436
437/// Weighted defines the Weighted Round Robin configuration.
438#[derive(Serialize, Deserialize, Clone, Debug, TypedBuilder, Default, PartialEq, JsonSchema)]
439pub struct TraefikServiceWeighted {
440    /// Services defines the list of Kubernetes Service and/or TraefikService to load-balance, with weight.
441    #[serde(default, skip_serializing_if = "Option::is_none")]
442    #[builder(default, setter(strip_option))]
443    pub services: Option<Vec<TraefikServiceWeightedServices>>,
444    /// Sticky defines whether sticky sessions are enabled.
445    /// More info: https://doc.traefik.io/traefik/v3.3/routing/providers/kubernetes-crd/#stickiness-and-load-balancing
446    #[serde(default, skip_serializing_if = "Option::is_none")]
447    #[builder(default, setter(strip_option))]
448    pub sticky: Option<TraefikServiceWeightedSticky>,
449}
450
451/// Service defines an upstream HTTP service to proxy traffic to.
452#[derive(Serialize, Deserialize, Clone, Debug, TypedBuilder, Default, PartialEq, JsonSchema)]
453pub struct TraefikServiceWeightedServices {
454    /// Healthcheck defines health checks for ExternalName services.
455    #[serde(default, skip_serializing_if = "Option::is_none", rename = "healthCheck")]
456    #[builder(default, setter(strip_option))]
457    pub health_check: Option<TraefikServiceWeightedServicesHealthCheck>,
458    /// Kind defines the kind of the Service.
459    #[serde(default, skip_serializing_if = "Option::is_none")]
460    #[builder(default, setter(strip_option))]
461    pub kind: Option<TraefikServiceWeightedServicesKind>,
462    /// Name defines the name of the referenced Kubernetes Service or TraefikService.
463    /// The differentiation between the two is specified in the Kind field.
464    pub name: String,
465    /// Namespace defines the namespace of the referenced Kubernetes Service or TraefikService.
466    #[serde(default, skip_serializing_if = "Option::is_none")]
467    #[builder(default, setter(strip_option))]
468    pub namespace: Option<String>,
469    /// NativeLB controls, when creating the load-balancer,
470    /// whether the LB's children are directly the pods IPs or if the only child is the Kubernetes Service clusterIP.
471    /// The Kubernetes Service itself does load-balance to the pods.
472    /// By default, NativeLB is false.
473    #[serde(default, skip_serializing_if = "Option::is_none", rename = "nativeLB")]
474    #[builder(default, setter(strip_option))]
475    pub native_lb: Option<bool>,
476    /// NodePortLB controls, when creating the load-balancer,
477    /// whether the LB's children are directly the nodes internal IPs using the nodePort when the service type is NodePort.
478    /// It allows services to be reachable when Traefik runs externally from the Kubernetes cluster but within the same network of the nodes.
479    /// By default, NodePortLB is false.
480    #[serde(default, skip_serializing_if = "Option::is_none", rename = "nodePortLB")]
481    #[builder(default, setter(strip_option))]
482    pub node_port_lb: Option<bool>,
483    /// PassHostHeader defines whether the client Host header is forwarded to the upstream Kubernetes Service.
484    /// By default, passHostHeader is true.
485    #[serde(default, skip_serializing_if = "Option::is_none", rename = "passHostHeader")]
486    #[builder(default, setter(strip_option))]
487    pub pass_host_header: Option<bool>,
488    /// Port defines the port of a Kubernetes Service.
489    /// This can be a reference to a named port.
490    #[serde(default, skip_serializing_if = "Option::is_none")]
491    #[builder(default, setter(strip_option))]
492    pub port: Option<IntOrString>,
493    /// ResponseForwarding defines how Traefik forwards the response from the upstream Kubernetes Service to the client.
494    #[serde(default, skip_serializing_if = "Option::is_none", rename = "responseForwarding")]
495    #[builder(default, setter(strip_option))]
496    pub response_forwarding: Option<TraefikServiceWeightedServicesResponseForwarding>,
497    /// Scheme defines the scheme to use for the request to the upstream Kubernetes Service.
498    /// It defaults to https when Kubernetes Service port is 443, http otherwise.
499    #[serde(default, skip_serializing_if = "Option::is_none")]
500    #[builder(default, setter(strip_option))]
501    pub scheme: Option<String>,
502    /// ServersTransport defines the name of ServersTransport resource to use.
503    /// It allows to configure the transport between Traefik and your servers.
504    /// Can only be used on a Kubernetes Service.
505    #[serde(default, skip_serializing_if = "Option::is_none", rename = "serversTransport")]
506    #[builder(default, setter(strip_option))]
507    pub servers_transport: Option<String>,
508    /// Sticky defines the sticky sessions configuration.
509    /// More info: https://doc.traefik.io/traefik/v3.3/routing/services/#sticky-sessions
510    #[serde(default, skip_serializing_if = "Option::is_none")]
511    #[builder(default, setter(strip_option))]
512    pub sticky: Option<TraefikServiceWeightedServicesSticky>,
513    /// Strategy defines the load balancing strategy between the servers.
514    /// RoundRobin is the only supported value at the moment.
515    #[serde(default, skip_serializing_if = "Option::is_none")]
516    #[builder(default, setter(strip_option))]
517    pub strategy: Option<String>,
518    /// Weight defines the weight and should only be specified when Name references a TraefikService object
519    /// (and to be precise, one that embeds a Weighted Round Robin).
520    #[serde(default, skip_serializing_if = "Option::is_none")]
521    #[builder(default, setter(strip_option))]
522    pub weight: Option<i64>,
523}
524
525/// Healthcheck defines health checks for ExternalName services.
526#[derive(Serialize, Deserialize, Clone, Debug, TypedBuilder, Default, PartialEq, JsonSchema)]
527pub struct TraefikServiceWeightedServicesHealthCheck {
528    /// FollowRedirects defines whether redirects should be followed during the health check calls.
529    /// Default: true
530    #[serde(default, skip_serializing_if = "Option::is_none", rename = "followRedirects")]
531    #[builder(default, setter(strip_option))]
532    pub follow_redirects: Option<bool>,
533    /// Headers defines custom headers to be sent to the health check endpoint.
534    #[serde(default, skip_serializing_if = "Option::is_none")]
535    #[builder(default, setter(strip_option))]
536    pub headers: Option<BTreeMap<String, String>>,
537    /// Hostname defines the value of hostname in the Host header of the health check request.
538    #[serde(default, skip_serializing_if = "Option::is_none")]
539    #[builder(default, setter(strip_option))]
540    pub hostname: Option<String>,
541    /// Interval defines the frequency of the health check calls.
542    /// Default: 30s
543    #[serde(default, skip_serializing_if = "Option::is_none")]
544    #[builder(default, setter(strip_option))]
545    pub interval: Option<IntOrString>,
546    /// Method defines the healthcheck method.
547    #[serde(default, skip_serializing_if = "Option::is_none")]
548    #[builder(default, setter(strip_option))]
549    pub method: Option<String>,
550    /// Mode defines the health check mode.
551    /// If defined to grpc, will use the gRPC health check protocol to probe the server.
552    /// Default: http
553    #[serde(default, skip_serializing_if = "Option::is_none")]
554    #[builder(default, setter(strip_option))]
555    pub mode: Option<String>,
556    /// Path defines the server URL path for the health check endpoint.
557    #[serde(default, skip_serializing_if = "Option::is_none")]
558    #[builder(default, setter(strip_option))]
559    pub path: Option<String>,
560    /// Port defines the server URL port for the health check endpoint.
561    #[serde(default, skip_serializing_if = "Option::is_none")]
562    #[builder(default, setter(strip_option))]
563    pub port: Option<i64>,
564    /// Scheme replaces the server URL scheme for the health check endpoint.
565    #[serde(default, skip_serializing_if = "Option::is_none")]
566    #[builder(default, setter(strip_option))]
567    pub scheme: Option<String>,
568    /// Status defines the expected HTTP status code of the response to the health check request.
569    #[serde(default, skip_serializing_if = "Option::is_none")]
570    #[builder(default, setter(strip_option))]
571    pub status: Option<i64>,
572    /// Timeout defines the maximum duration Traefik will wait for a health check request before considering the server unhealthy.
573    /// Default: 5s
574    #[serde(default, skip_serializing_if = "Option::is_none")]
575    #[builder(default, setter(strip_option))]
576    pub timeout: Option<IntOrString>,
577}
578
579/// Service defines an upstream HTTP service to proxy traffic to.
580#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
581pub enum TraefikServiceWeightedServicesKind {
582    Service,
583    TraefikService,
584}
585
586/// ResponseForwarding defines how Traefik forwards the response from the upstream Kubernetes Service to the client.
587#[derive(Serialize, Deserialize, Clone, Debug, TypedBuilder, Default, PartialEq, JsonSchema)]
588pub struct TraefikServiceWeightedServicesResponseForwarding {
589    /// FlushInterval defines the interval, in milliseconds, in between flushes to the client while copying the response body.
590    /// A negative value means to flush immediately after each write to the client.
591    /// This configuration is ignored when ReverseProxy recognizes a response as a streaming response;
592    /// for such responses, writes are flushed to the client immediately.
593    /// Default: 100ms
594    #[serde(default, skip_serializing_if = "Option::is_none", rename = "flushInterval")]
595    #[builder(default, setter(strip_option))]
596    pub flush_interval: Option<String>,
597}
598
599/// Sticky defines the sticky sessions configuration.
600/// More info: https://doc.traefik.io/traefik/v3.3/routing/services/#sticky-sessions
601#[derive(Serialize, Deserialize, Clone, Debug, TypedBuilder, Default, PartialEq, JsonSchema)]
602pub struct TraefikServiceWeightedServicesSticky {
603    /// Cookie defines the sticky cookie configuration.
604    #[serde(default, skip_serializing_if = "Option::is_none")]
605    #[builder(default, setter(strip_option))]
606    pub cookie: Option<TraefikServiceWeightedServicesStickyCookie>,
607}
608
609/// Cookie defines the sticky cookie configuration.
610#[derive(Serialize, Deserialize, Clone, Debug, TypedBuilder, Default, PartialEq, JsonSchema)]
611pub struct TraefikServiceWeightedServicesStickyCookie {
612    /// HTTPOnly defines whether the cookie can be accessed by client-side APIs, such as JavaScript.
613    #[serde(default, skip_serializing_if = "Option::is_none", rename = "httpOnly")]
614    #[builder(default, setter(strip_option))]
615    pub http_only: Option<bool>,
616    /// MaxAge defines the number of seconds until the cookie expires.
617    /// When set to a negative number, the cookie expires immediately.
618    /// When set to zero, the cookie never expires.
619    #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxAge")]
620    #[builder(default, setter(strip_option))]
621    pub max_age: Option<i64>,
622    /// Name defines the Cookie name.
623    #[serde(default, skip_serializing_if = "Option::is_none")]
624    #[builder(default, setter(strip_option))]
625    pub name: Option<String>,
626    /// Path defines the path that must exist in the requested URL for the browser to send the Cookie header.
627    /// When not provided the cookie will be sent on every request to the domain.
628    /// More info: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#pathpath-value
629    #[serde(default, skip_serializing_if = "Option::is_none")]
630    #[builder(default, setter(strip_option))]
631    pub path: Option<String>,
632    /// SameSite defines the same site policy.
633    /// More info: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite
634    #[serde(default, skip_serializing_if = "Option::is_none", rename = "sameSite")]
635    #[builder(default, setter(strip_option))]
636    pub same_site: Option<String>,
637    /// Secure defines whether the cookie can only be transmitted over an encrypted connection (i.e. HTTPS).
638    #[serde(default, skip_serializing_if = "Option::is_none")]
639    #[builder(default, setter(strip_option))]
640    pub secure: Option<bool>,
641}
642
643/// Sticky defines whether sticky sessions are enabled.
644/// More info: https://doc.traefik.io/traefik/v3.3/routing/providers/kubernetes-crd/#stickiness-and-load-balancing
645#[derive(Serialize, Deserialize, Clone, Debug, TypedBuilder, Default, PartialEq, JsonSchema)]
646pub struct TraefikServiceWeightedSticky {
647    /// Cookie defines the sticky cookie configuration.
648    #[serde(default, skip_serializing_if = "Option::is_none")]
649    #[builder(default, setter(strip_option))]
650    pub cookie: Option<TraefikServiceWeightedStickyCookie>,
651}
652
653/// Cookie defines the sticky cookie configuration.
654#[derive(Serialize, Deserialize, Clone, Debug, TypedBuilder, Default, PartialEq, JsonSchema)]
655pub struct TraefikServiceWeightedStickyCookie {
656    /// HTTPOnly defines whether the cookie can be accessed by client-side APIs, such as JavaScript.
657    #[serde(default, skip_serializing_if = "Option::is_none", rename = "httpOnly")]
658    #[builder(default, setter(strip_option))]
659    pub http_only: Option<bool>,
660    /// MaxAge defines the number of seconds until the cookie expires.
661    /// When set to a negative number, the cookie expires immediately.
662    /// When set to zero, the cookie never expires.
663    #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxAge")]
664    #[builder(default, setter(strip_option))]
665    pub max_age: Option<i64>,
666    /// Name defines the Cookie name.
667    #[serde(default, skip_serializing_if = "Option::is_none")]
668    #[builder(default, setter(strip_option))]
669    pub name: Option<String>,
670    /// Path defines the path that must exist in the requested URL for the browser to send the Cookie header.
671    /// When not provided the cookie will be sent on every request to the domain.
672    /// More info: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#pathpath-value
673    #[serde(default, skip_serializing_if = "Option::is_none")]
674    #[builder(default, setter(strip_option))]
675    pub path: Option<String>,
676    /// SameSite defines the same site policy.
677    /// More info: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite
678    #[serde(default, skip_serializing_if = "Option::is_none", rename = "sameSite")]
679    #[builder(default, setter(strip_option))]
680    pub same_site: Option<String>,
681    /// Secure defines whether the cookie can only be transmitted over an encrypted connection (i.e. HTTPS).
682    #[serde(default, skip_serializing_if = "Option::is_none")]
683    #[builder(default, setter(strip_option))]
684    pub secure: Option<bool>,
685}
686