2019-11-14 18:28:04 +00:00
|
|
|
package v1alpha1
|
|
|
|
|
|
|
|
import (
|
2020-09-16 13:46:04 +00:00
|
|
|
"github.com/traefik/traefik/v2/pkg/config/dynamic"
|
2019-11-14 18:28:04 +00:00
|
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
|
|
)
|
|
|
|
|
|
|
|
// +genclient
|
|
|
|
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
2021-03-03 14:32:04 +00:00
|
|
|
// +kubebuilder:storageversion
|
2019-11-14 18:28:04 +00:00
|
|
|
|
2022-06-24 10:40:08 +00:00
|
|
|
// TraefikService is the CRD implementation of a Traefik Service.
|
|
|
|
// TraefikService object allows to:
|
2022-07-19 16:38:09 +00:00
|
|
|
// - Apply weight to Services on load-balancing
|
|
|
|
// - Mirror traffic on services
|
2023-03-22 10:06:05 +00:00
|
|
|
// More info: https://doc.traefik.io/traefik/v2.10/routing/providers/kubernetes-crd/#kind-traefikservice
|
2019-11-14 18:28:04 +00:00
|
|
|
type TraefikService struct {
|
2022-06-24 10:40:08 +00:00
|
|
|
metav1.TypeMeta `json:",inline"`
|
|
|
|
// Standard object's metadata.
|
|
|
|
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
|
2019-11-14 18:28:04 +00:00
|
|
|
metav1.ObjectMeta `json:"metadata"`
|
|
|
|
|
2022-06-24 10:40:08 +00:00
|
|
|
Spec TraefikServiceSpec `json:"spec"`
|
2019-11-14 18:28:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
|
|
|
|
2022-06-24 10:40:08 +00:00
|
|
|
// TraefikServiceList is a collection of TraefikService resources.
|
2019-11-14 18:28:04 +00:00
|
|
|
type TraefikServiceList struct {
|
|
|
|
metav1.TypeMeta `json:",inline"`
|
2022-06-24 10:40:08 +00:00
|
|
|
// Standard object's metadata.
|
|
|
|
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
|
2019-11-14 18:28:04 +00:00
|
|
|
metav1.ListMeta `json:"metadata"`
|
|
|
|
|
2022-06-24 10:40:08 +00:00
|
|
|
// Items is the list of TraefikService.
|
2019-11-14 18:28:04 +00:00
|
|
|
Items []TraefikService `json:"items"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// +k8s:deepcopy-gen=true
|
|
|
|
|
2022-06-24 10:40:08 +00:00
|
|
|
// TraefikServiceSpec defines the desired state of a TraefikService.
|
|
|
|
type TraefikServiceSpec struct {
|
|
|
|
// Weighted defines the Weighted Round Robin configuration.
|
|
|
|
Weighted *WeightedRoundRobin `json:"weighted,omitempty"`
|
|
|
|
// Mirroring defines the Mirroring service configuration.
|
|
|
|
Mirroring *Mirroring `json:"mirroring,omitempty"`
|
2019-11-14 18:28:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// +k8s:deepcopy-gen=true
|
|
|
|
|
2022-06-24 10:40:08 +00:00
|
|
|
// Mirroring holds the mirroring service configuration.
|
2023-03-22 10:06:05 +00:00
|
|
|
// More info: https://doc.traefik.io/traefik/v2.10/routing/services/#mirroring-service
|
2019-11-14 18:28:04 +00:00
|
|
|
type Mirroring struct {
|
2021-03-03 14:32:04 +00:00
|
|
|
LoadBalancerSpec `json:",inline"`
|
|
|
|
|
2022-06-24 10:40:08 +00:00
|
|
|
// MaxBodySize defines the maximum size allowed for the body of the request.
|
|
|
|
// If the body is larger, the request is not mirrored.
|
|
|
|
// Default value is -1, which means unlimited size.
|
|
|
|
MaxBodySize *int64 `json:"maxBodySize,omitempty"`
|
|
|
|
// Mirrors defines the list of mirrors where Traefik will duplicate the traffic.
|
|
|
|
Mirrors []MirrorService `json:"mirrors,omitempty"`
|
2019-11-14 18:28:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// +k8s:deepcopy-gen=true
|
|
|
|
|
2022-06-24 10:40:08 +00:00
|
|
|
// MirrorService holds the mirror configuration.
|
2019-11-14 18:28:04 +00:00
|
|
|
type MirrorService struct {
|
2021-03-03 14:32:04 +00:00
|
|
|
LoadBalancerSpec `json:",inline"`
|
|
|
|
|
2022-06-24 10:40:08 +00:00
|
|
|
// Percent defines the part of the traffic to mirror.
|
|
|
|
// Supported values: 0 to 100.
|
2019-11-14 18:28:04 +00:00
|
|
|
Percent int `json:"percent,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// +k8s:deepcopy-gen=true
|
|
|
|
|
2022-06-24 10:40:08 +00:00
|
|
|
// WeightedRoundRobin holds the weighted round-robin configuration.
|
2023-03-22 10:06:05 +00:00
|
|
|
// More info: https://doc.traefik.io/traefik/v2.10/routing/services/#weighted-round-robin-service
|
2019-11-14 18:28:04 +00:00
|
|
|
type WeightedRoundRobin struct {
|
2022-06-24 10:40:08 +00:00
|
|
|
// Services defines the list of Kubernetes Service and/or TraefikService to load-balance, with weight.
|
|
|
|
Services []Service `json:"services,omitempty"`
|
|
|
|
// Sticky defines whether sticky sessions are enabled.
|
2023-03-22 10:06:05 +00:00
|
|
|
// More info: https://doc.traefik.io/traefik/v2.10/routing/providers/kubernetes-crd/#stickiness-and-load-balancing
|
2022-06-24 10:40:08 +00:00
|
|
|
Sticky *dynamic.Sticky `json:"sticky,omitempty"`
|
2019-11-14 18:28:04 +00:00
|
|
|
}
|