k8s_traefik_api/
ingressroutes.rs

1// WARNING: generated by kopium - manual changes will be overwritten
2// kopium command: kopium ingressroutes.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/// IngressRouteSpec defines the desired state of IngressRoute.
17#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, TypedBuilder, Default, PartialEq, JsonSchema)]
18#[kube(group = "traefik.io", version = "v1alpha1", kind = "IngressRoute", plural = "ingressroutes")]
19#[kube(namespaced)]
20#[kube(derive="Default")]
21#[kube(derive="PartialEq")]
22pub struct IngressRouteSpec {
23    /// EntryPoints defines the list of entry point names to bind to.
24    /// Entry points have to be configured in the static configuration.
25    /// More info: https://doc.traefik.io/traefik/v3.3/routing/entrypoints/
26    /// Default: all.
27    #[serde(default, skip_serializing_if = "Option::is_none", rename = "entryPoints")]
28    #[builder(default, setter(strip_option))]
29    pub entry_points: Option<Vec<String>>,
30    /// Routes defines the list of routes.
31    #[builder(default)]
32    pub routes: Vec<IngressRouteRoutes>,
33    /// TLS defines the TLS configuration.
34    /// More info: https://doc.traefik.io/traefik/v3.3/routing/routers/#tls
35    #[serde(default, skip_serializing_if = "Option::is_none")]
36    #[builder(default, setter(strip_option))]
37    pub tls: Option<IngressRouteTls>,
38}
39
40/// Route holds the HTTP route configuration.
41#[derive(Serialize, Deserialize, Clone, Debug, TypedBuilder, Default, PartialEq, JsonSchema)]
42pub struct IngressRouteRoutes {
43    /// Kind defines the kind of the route.
44    /// Rule is the only supported kind.
45    /// If not defined, defaults to Rule.
46    #[serde(default, skip_serializing_if = "Option::is_none")]
47    #[builder(default, setter(strip_option))]
48    pub kind: Option<IngressRouteRoutesKind>,
49    /// Match defines the router's rule.
50    /// More info: https://doc.traefik.io/traefik/v3.3/routing/routers/#rule
51    #[serde(rename = "match")]
52    pub r#match: String,
53    /// Middlewares defines the list of references to Middleware resources.
54    /// More info: https://doc.traefik.io/traefik/v3.3/routing/providers/kubernetes-crd/#kind-middleware
55    #[serde(default, skip_serializing_if = "Option::is_none")]
56    #[builder(default, setter(strip_option))]
57    pub middlewares: Option<Vec<IngressRouteRoutesMiddlewares>>,
58    /// Observability defines the observability configuration for a router.
59    /// More info: https://doc.traefik.io/traefik/v3.2/routing/routers/#observability
60    #[serde(default, skip_serializing_if = "Option::is_none")]
61    #[builder(default, setter(strip_option))]
62    pub observability: Option<IngressRouteRoutesObservability>,
63    /// Priority defines the router's priority.
64    /// More info: https://doc.traefik.io/traefik/v3.3/routing/routers/#priority
65    #[serde(default, skip_serializing_if = "Option::is_none")]
66    #[builder(default, setter(strip_option))]
67    pub priority: Option<i64>,
68    /// Services defines the list of Service.
69    /// It can contain any combination of TraefikService and/or reference to a Kubernetes Service.
70    #[serde(default, skip_serializing_if = "Option::is_none")]
71    #[builder(default, setter(strip_option))]
72    pub services: Option<Vec<IngressRouteRoutesServices>>,
73    /// Syntax defines the router's rule syntax.
74    /// More info: https://doc.traefik.io/traefik/v3.3/routing/routers/#rulesyntax
75    #[serde(default, skip_serializing_if = "Option::is_none")]
76    #[builder(default, setter(strip_option))]
77    pub syntax: Option<String>,
78}
79
80/// Route holds the HTTP route configuration.
81#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
82pub enum IngressRouteRoutesKind {
83    Rule,
84}
85
86/// MiddlewareRef is a reference to a Middleware resource.
87#[derive(Serialize, Deserialize, Clone, Debug, TypedBuilder, Default, PartialEq, JsonSchema)]
88pub struct IngressRouteRoutesMiddlewares {
89    /// Name defines the name of the referenced Middleware resource.
90    pub name: String,
91    /// Namespace defines the namespace of the referenced Middleware resource.
92    #[serde(default, skip_serializing_if = "Option::is_none")]
93    #[builder(default, setter(strip_option))]
94    pub namespace: Option<String>,
95}
96
97/// Observability defines the observability configuration for a router.
98/// More info: https://doc.traefik.io/traefik/v3.2/routing/routers/#observability
99#[derive(Serialize, Deserialize, Clone, Debug, TypedBuilder, Default, PartialEq, JsonSchema)]
100pub struct IngressRouteRoutesObservability {
101    #[serde(default, skip_serializing_if = "Option::is_none", rename = "accessLogs")]
102    #[builder(default, setter(strip_option))]
103    pub access_logs: Option<bool>,
104    #[serde(default, skip_serializing_if = "Option::is_none")]
105    #[builder(default, setter(strip_option))]
106    pub metrics: Option<bool>,
107    #[serde(default, skip_serializing_if = "Option::is_none")]
108    #[builder(default, setter(strip_option))]
109    pub tracing: Option<bool>,
110}
111
112/// Service defines an upstream HTTP service to proxy traffic to.
113#[derive(Serialize, Deserialize, Clone, Debug, TypedBuilder, Default, PartialEq, JsonSchema)]
114pub struct IngressRouteRoutesServices {
115    /// Healthcheck defines health checks for ExternalName services.
116    #[serde(default, skip_serializing_if = "Option::is_none", rename = "healthCheck")]
117    #[builder(default, setter(strip_option))]
118    pub health_check: Option<IngressRouteRoutesServicesHealthCheck>,
119    /// Kind defines the kind of the Service.
120    #[serde(default, skip_serializing_if = "Option::is_none")]
121    #[builder(default, setter(strip_option))]
122    pub kind: Option<IngressRouteRoutesServicesKind>,
123    /// Name defines the name of the referenced Kubernetes Service or TraefikService.
124    /// The differentiation between the two is specified in the Kind field.
125    pub name: String,
126    /// Namespace defines the namespace of the referenced Kubernetes Service or TraefikService.
127    #[serde(default, skip_serializing_if = "Option::is_none")]
128    #[builder(default, setter(strip_option))]
129    pub namespace: Option<String>,
130    /// NativeLB controls, when creating the load-balancer,
131    /// whether the LB's children are directly the pods IPs or if the only child is the Kubernetes Service clusterIP.
132    /// The Kubernetes Service itself does load-balance to the pods.
133    /// By default, NativeLB is false.
134    #[serde(default, skip_serializing_if = "Option::is_none", rename = "nativeLB")]
135    #[builder(default, setter(strip_option))]
136    pub native_lb: Option<bool>,
137    /// NodePortLB controls, when creating the load-balancer,
138    /// whether the LB's children are directly the nodes internal IPs using the nodePort when the service type is NodePort.
139    /// It allows services to be reachable when Traefik runs externally from the Kubernetes cluster but within the same network of the nodes.
140    /// By default, NodePortLB is false.
141    #[serde(default, skip_serializing_if = "Option::is_none", rename = "nodePortLB")]
142    #[builder(default, setter(strip_option))]
143    pub node_port_lb: Option<bool>,
144    /// PassHostHeader defines whether the client Host header is forwarded to the upstream Kubernetes Service.
145    /// By default, passHostHeader is true.
146    #[serde(default, skip_serializing_if = "Option::is_none", rename = "passHostHeader")]
147    #[builder(default, setter(strip_option))]
148    pub pass_host_header: Option<bool>,
149    /// Port defines the port of a Kubernetes Service.
150    /// This can be a reference to a named port.
151    #[serde(default, skip_serializing_if = "Option::is_none")]
152    #[builder(default, setter(strip_option))]
153    pub port: Option<IntOrString>,
154    /// ResponseForwarding defines how Traefik forwards the response from the upstream Kubernetes Service to the client.
155    #[serde(default, skip_serializing_if = "Option::is_none", rename = "responseForwarding")]
156    #[builder(default, setter(strip_option))]
157    pub response_forwarding: Option<IngressRouteRoutesServicesResponseForwarding>,
158    /// Scheme defines the scheme to use for the request to the upstream Kubernetes Service.
159    /// It defaults to https when Kubernetes Service port is 443, http otherwise.
160    #[serde(default, skip_serializing_if = "Option::is_none")]
161    #[builder(default, setter(strip_option))]
162    pub scheme: Option<String>,
163    /// ServersTransport defines the name of ServersTransport resource to use.
164    /// It allows to configure the transport between Traefik and your servers.
165    /// Can only be used on a Kubernetes Service.
166    #[serde(default, skip_serializing_if = "Option::is_none", rename = "serversTransport")]
167    #[builder(default, setter(strip_option))]
168    pub servers_transport: Option<String>,
169    /// Sticky defines the sticky sessions configuration.
170    /// More info: https://doc.traefik.io/traefik/v3.3/routing/services/#sticky-sessions
171    #[serde(default, skip_serializing_if = "Option::is_none")]
172    #[builder(default, setter(strip_option))]
173    pub sticky: Option<IngressRouteRoutesServicesSticky>,
174    /// Strategy defines the load balancing strategy between the servers.
175    /// RoundRobin is the only supported value at the moment.
176    #[serde(default, skip_serializing_if = "Option::is_none")]
177    #[builder(default, setter(strip_option))]
178    pub strategy: Option<String>,
179    /// Weight defines the weight and should only be specified when Name references a TraefikService object
180    /// (and to be precise, one that embeds a Weighted Round Robin).
181    #[serde(default, skip_serializing_if = "Option::is_none")]
182    #[builder(default, setter(strip_option))]
183    pub weight: Option<i64>,
184}
185
186/// Healthcheck defines health checks for ExternalName services.
187#[derive(Serialize, Deserialize, Clone, Debug, TypedBuilder, Default, PartialEq, JsonSchema)]
188pub struct IngressRouteRoutesServicesHealthCheck {
189    /// FollowRedirects defines whether redirects should be followed during the health check calls.
190    /// Default: true
191    #[serde(default, skip_serializing_if = "Option::is_none", rename = "followRedirects")]
192    #[builder(default, setter(strip_option))]
193    pub follow_redirects: Option<bool>,
194    /// Headers defines custom headers to be sent to the health check endpoint.
195    #[serde(default, skip_serializing_if = "Option::is_none")]
196    #[builder(default, setter(strip_option))]
197    pub headers: Option<BTreeMap<String, String>>,
198    /// Hostname defines the value of hostname in the Host header of the health check request.
199    #[serde(default, skip_serializing_if = "Option::is_none")]
200    #[builder(default, setter(strip_option))]
201    pub hostname: Option<String>,
202    /// Interval defines the frequency of the health check calls.
203    /// Default: 30s
204    #[serde(default, skip_serializing_if = "Option::is_none")]
205    #[builder(default, setter(strip_option))]
206    pub interval: Option<IntOrString>,
207    /// Method defines the healthcheck method.
208    #[serde(default, skip_serializing_if = "Option::is_none")]
209    #[builder(default, setter(strip_option))]
210    pub method: Option<String>,
211    /// Mode defines the health check mode.
212    /// If defined to grpc, will use the gRPC health check protocol to probe the server.
213    /// Default: http
214    #[serde(default, skip_serializing_if = "Option::is_none")]
215    #[builder(default, setter(strip_option))]
216    pub mode: Option<String>,
217    /// Path defines the server URL path for the health check endpoint.
218    #[serde(default, skip_serializing_if = "Option::is_none")]
219    #[builder(default, setter(strip_option))]
220    pub path: Option<String>,
221    /// Port defines the server URL port for the health check endpoint.
222    #[serde(default, skip_serializing_if = "Option::is_none")]
223    #[builder(default, setter(strip_option))]
224    pub port: Option<i64>,
225    /// Scheme replaces the server URL scheme for the health check endpoint.
226    #[serde(default, skip_serializing_if = "Option::is_none")]
227    #[builder(default, setter(strip_option))]
228    pub scheme: Option<String>,
229    /// Status defines the expected HTTP status code of the response to the health check request.
230    #[serde(default, skip_serializing_if = "Option::is_none")]
231    #[builder(default, setter(strip_option))]
232    pub status: Option<i64>,
233    /// Timeout defines the maximum duration Traefik will wait for a health check request before considering the server unhealthy.
234    /// Default: 5s
235    #[serde(default, skip_serializing_if = "Option::is_none")]
236    #[builder(default, setter(strip_option))]
237    pub timeout: Option<IntOrString>,
238}
239
240/// Service defines an upstream HTTP service to proxy traffic to.
241#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
242pub enum IngressRouteRoutesServicesKind {
243    Service,
244    TraefikService,
245}
246
247/// ResponseForwarding defines how Traefik forwards the response from the upstream Kubernetes Service to the client.
248#[derive(Serialize, Deserialize, Clone, Debug, TypedBuilder, Default, PartialEq, JsonSchema)]
249pub struct IngressRouteRoutesServicesResponseForwarding {
250    /// FlushInterval defines the interval, in milliseconds, in between flushes to the client while copying the response body.
251    /// A negative value means to flush immediately after each write to the client.
252    /// This configuration is ignored when ReverseProxy recognizes a response as a streaming response;
253    /// for such responses, writes are flushed to the client immediately.
254    /// Default: 100ms
255    #[serde(default, skip_serializing_if = "Option::is_none", rename = "flushInterval")]
256    #[builder(default, setter(strip_option))]
257    pub flush_interval: Option<String>,
258}
259
260/// Sticky defines the sticky sessions configuration.
261/// More info: https://doc.traefik.io/traefik/v3.3/routing/services/#sticky-sessions
262#[derive(Serialize, Deserialize, Clone, Debug, TypedBuilder, Default, PartialEq, JsonSchema)]
263pub struct IngressRouteRoutesServicesSticky {
264    /// Cookie defines the sticky cookie configuration.
265    #[serde(default, skip_serializing_if = "Option::is_none")]
266    #[builder(default, setter(strip_option))]
267    pub cookie: Option<IngressRouteRoutesServicesStickyCookie>,
268}
269
270/// Cookie defines the sticky cookie configuration.
271#[derive(Serialize, Deserialize, Clone, Debug, TypedBuilder, Default, PartialEq, JsonSchema)]
272pub struct IngressRouteRoutesServicesStickyCookie {
273    /// HTTPOnly defines whether the cookie can be accessed by client-side APIs, such as JavaScript.
274    #[serde(default, skip_serializing_if = "Option::is_none", rename = "httpOnly")]
275    #[builder(default, setter(strip_option))]
276    pub http_only: Option<bool>,
277    /// MaxAge defines the number of seconds until the cookie expires.
278    /// When set to a negative number, the cookie expires immediately.
279    /// When set to zero, the cookie never expires.
280    #[serde(default, skip_serializing_if = "Option::is_none", rename = "maxAge")]
281    #[builder(default, setter(strip_option))]
282    pub max_age: Option<i64>,
283    /// Name defines the Cookie name.
284    #[serde(default, skip_serializing_if = "Option::is_none")]
285    #[builder(default, setter(strip_option))]
286    pub name: Option<String>,
287    /// Path defines the path that must exist in the requested URL for the browser to send the Cookie header.
288    /// When not provided the cookie will be sent on every request to the domain.
289    /// More info: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#pathpath-value
290    #[serde(default, skip_serializing_if = "Option::is_none")]
291    #[builder(default, setter(strip_option))]
292    pub path: Option<String>,
293    /// SameSite defines the same site policy.
294    /// More info: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite
295    #[serde(default, skip_serializing_if = "Option::is_none", rename = "sameSite")]
296    #[builder(default, setter(strip_option))]
297    pub same_site: Option<String>,
298    /// Secure defines whether the cookie can only be transmitted over an encrypted connection (i.e. HTTPS).
299    #[serde(default, skip_serializing_if = "Option::is_none")]
300    #[builder(default, setter(strip_option))]
301    pub secure: Option<bool>,
302}
303
304/// TLS defines the TLS configuration.
305/// More info: https://doc.traefik.io/traefik/v3.3/routing/routers/#tls
306#[derive(Serialize, Deserialize, Clone, Debug, TypedBuilder, Default, PartialEq, JsonSchema)]
307pub struct IngressRouteTls {
308    /// CertResolver defines the name of the certificate resolver to use.
309    /// Cert resolvers have to be configured in the static configuration.
310    /// More info: https://doc.traefik.io/traefik/v3.3/https/acme/#certificate-resolvers
311    #[serde(default, skip_serializing_if = "Option::is_none", rename = "certResolver")]
312    #[builder(default, setter(strip_option))]
313    pub cert_resolver: Option<String>,
314    /// Domains defines the list of domains that will be used to issue certificates.
315    /// More info: https://doc.traefik.io/traefik/v3.3/routing/routers/#domains
316    #[serde(default, skip_serializing_if = "Option::is_none")]
317    #[builder(default, setter(strip_option))]
318    pub domains: Option<Vec<IngressRouteTlsDomains>>,
319    /// Options defines the reference to a TLSOption, that specifies the parameters of the TLS connection.
320    /// If not defined, the `default` TLSOption is used.
321    /// More info: https://doc.traefik.io/traefik/v3.3/https/tls/#tls-options
322    #[serde(default, skip_serializing_if = "Option::is_none")]
323    #[builder(default, setter(strip_option))]
324    pub options: Option<IngressRouteTlsOptions>,
325    /// SecretName is the name of the referenced Kubernetes Secret to specify the certificate details.
326    #[serde(default, skip_serializing_if = "Option::is_none", rename = "secretName")]
327    #[builder(default, setter(strip_option))]
328    pub secret_name: Option<String>,
329    /// Store defines the reference to the TLSStore, that will be used to store certificates.
330    /// Please note that only `default` TLSStore can be used.
331    #[serde(default, skip_serializing_if = "Option::is_none")]
332    #[builder(default, setter(strip_option))]
333    pub store: Option<IngressRouteTlsStore>,
334}
335
336/// Domain holds a domain name with SANs.
337#[derive(Serialize, Deserialize, Clone, Debug, TypedBuilder, Default, PartialEq, JsonSchema)]
338pub struct IngressRouteTlsDomains {
339    /// Main defines the main domain name.
340    #[serde(default, skip_serializing_if = "Option::is_none")]
341    #[builder(default, setter(strip_option))]
342    pub main: Option<String>,
343    /// SANs defines the subject alternative domain names.
344    #[serde(default, skip_serializing_if = "Option::is_none")]
345    #[builder(default, setter(strip_option))]
346    pub sans: Option<Vec<String>>,
347}
348
349/// Options defines the reference to a TLSOption, that specifies the parameters of the TLS connection.
350/// If not defined, the `default` TLSOption is used.
351/// More info: https://doc.traefik.io/traefik/v3.3/https/tls/#tls-options
352#[derive(Serialize, Deserialize, Clone, Debug, TypedBuilder, Default, PartialEq, JsonSchema)]
353pub struct IngressRouteTlsOptions {
354    /// Name defines the name of the referenced TLSOption.
355    /// More info: https://doc.traefik.io/traefik/v3.3/routing/providers/kubernetes-crd/#kind-tlsoption
356    pub name: String,
357    /// Namespace defines the namespace of the referenced TLSOption.
358    /// More info: https://doc.traefik.io/traefik/v3.3/routing/providers/kubernetes-crd/#kind-tlsoption
359    #[serde(default, skip_serializing_if = "Option::is_none")]
360    #[builder(default, setter(strip_option))]
361    pub namespace: Option<String>,
362}
363
364/// Store defines the reference to the TLSStore, that will be used to store certificates.
365/// Please note that only `default` TLSStore can be used.
366#[derive(Serialize, Deserialize, Clone, Debug, TypedBuilder, Default, PartialEq, JsonSchema)]
367pub struct IngressRouteTlsStore {
368    /// Name defines the name of the referenced TLSStore.
369    /// More info: https://doc.traefik.io/traefik/v3.3/routing/providers/kubernetes-crd/#kind-tlsstore
370    pub name: String,
371    /// Namespace defines the namespace of the referenced TLSStore.
372    /// More info: https://doc.traefik.io/traefik/v3.3/routing/providers/kubernetes-crd/#kind-tlsstore
373    #[serde(default, skip_serializing_if = "Option::is_none")]
374    #[builder(default, setter(strip_option))]
375    pub namespace: Option<String>,
376}
377