/
canarypolicy_types.go
109 lines (88 loc) · 3.08 KB
/
canarypolicy_types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
package v1
import (
"github.com/petomalina/krane/pkg/apis/networking/v1alpha3"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
type BaselineMode string
const (
BaselineModeNew BaselineMode = "NEW"
BaselineModeOld = "OLD"
)
// CanaryPolicySpec defines the desired state of CanaryPolicy
// +k8s:openapi-gen=true
type CanaryPolicySpec struct {
// Base is the original deployment that the canary will use
// to copy baseline
Base string `json:"base,omitempty"`
// VirtualService is a name of bindable virtualservice that
// will be used for traffic splitting
VirtualService string `json:"virtualService,omitempty"`
// Service is a name of the service to be weight-routed during
// the canary phase
Service string `json:"service,omitempty"`
// Mode is used to determine if baseline uses original
// or canary configuration
BaselineMode BaselineMode `json:"baselineMode,omitempty"`
// DestinationRule is a rule that will be created when a new
// canary will be deployed
DestinationRule v1alpha3.DestinationRuleSpec
// Ports is a list of ports to be be open for the canary when
// baseline and canary deployments are created
Ports []corev1.ServicePort
TestSpec TestSpec `json:"test,omitempty"`
JudgeSpec JudgeSpec `json:"judge,omitempty"`
}
type JudgeSpecBoundary struct {
Time string `json:"time,omitempty"`
}
type TestSpecBoundary struct {
Time string `json:"time,omitempty"`
Requests int `json:"requests,omitempty"`
}
// +k8s:openapi-gen=true
type TestSpec struct {
Image string `json:"image,omitempty"`
Cmd []string `json:"cmd,omitempty"`
Boundary TestSpecBoundary `json:"boundary,omitempty"`
}
type ThresholdMetric struct {
Metric string `json:"metric,omitempty"`
Value string `json:"value,omitempty"`
}
type DiffMetric struct {
Metric string `json:"metric,omitempty"`
Container string `json:"container,omitempty"`
Diff float64 `json:"diff,omitempty"`
}
// +k8s:openapi-gen=true
type JudgeSpec struct {
Image string `json:"image,omitempty"`
Cmd []string `json:"cmd,omitempty"`
DiffMetrics []DiffMetric `json:"diffMetrics,omitempty"`
ThresholdMetrics []ThresholdMetric `json:"thresholdMetrics,omitempty"`
Boundary JudgeSpecBoundary `json:"boundary,omitempty"`
}
// CanaryPolicyStatus defines the observed state of CanaryPolicy
// +k8s:openapi-gen=true
type CanaryPolicyStatus struct {
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// CanaryPolicy is the Schema for the canarypolicies API
// +k8s:openapi-gen=true
type CanaryPolicy struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec CanaryPolicySpec `json:"spec,omitempty"`
Status CanaryPolicyStatus `json:"status,omitempty"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// CanaryPolicyList contains a list of CanaryPolicy
type CanaryPolicyList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []CanaryPolicy `json:"items"`
}
func init() {
SchemeBuilder.Register(&CanaryPolicy{}, &CanaryPolicyList{})
}