Files
flagger/pkg/apis/smi/v1alpha2/traffic_split.go
Johnson Shi d82b2c219a fix: Require SMI TrafficSplit Service and Weight
In the SMI TrafficSplit spec, Weight and Service are
required values for TrafficSplit Backend.
In flagger's SMI v1alpha2 implementation,
Service and Weight have the omitempty json option.

During canary analysis, flagger initially creates
a SMI TrafficSplit custom resource in which the
canary backend service has a Weight of 0.
The omitempty option causes Go to omit Weight
when it sends the custom resource to Kubernetes.
This throws an error during canary analysis.

Signed-off-by: Johnson Shi <Johnson.Shi@microsoft.com>
2021-06-14 06:55:59 -07:00

48 lines
1.5 KiB
Go

package v1alpha2
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// +genclient
// +genclient:noStatus
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// TrafficSplit allows users to incrementally direct percentages of traffic
// between various services. It will be used by clients such as ingress
// controllers or service mesh sidecars to split the outgoing traffic to
// different destinations.
type TrafficSplit struct {
metav1.TypeMeta `json:",inline"`
// Standard object's metadata.
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
// +optional
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
// Specification of the desired behavior of the traffic split.
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status
// +optional
Spec TrafficSplitSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
}
// TrafficSplitSpec is the specification for a TrafficSplit
type TrafficSplitSpec struct {
Service string `json:"service,omitempty"`
Backends []TrafficSplitBackend `json:"backends,omitempty"`
}
// TrafficSplitBackend defines a backend
type TrafficSplitBackend struct {
Service string `json:"service"`
Weight int `json:"weight"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type TrafficSplitList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`
Items []TrafficSplit `json:"items"`
}