kubesphere.io/api@v0.0.0-20231107125330-c9a03957060c/servicemesh/v1alpha2/strategy_types.go (about) 1 /* 2 Copyright 2019 The KubeSphere authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package v1alpha2 18 19 import ( 20 "istio.io/api/networking/v1alpha3" 21 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions" 22 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 23 ) 24 25 // EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! 26 // NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. 27 28 const ( 29 ResourceKindStrategy = "Strategy" 30 ResourceSingularStrategy = "strategy" 31 ResourcePluralStrategy = "strategies" 32 ) 33 34 type strategyType string 35 36 const ( 37 // Canary strategy type 38 CanaryType strategyType = "Canary" 39 40 // BlueGreen strategy type 41 BlueGreenType strategyType = "BlueGreen" 42 43 // Mirror strategy type 44 Mirror strategyType = "Mirror" 45 ) 46 47 type StrategyPolicy string 48 49 const ( 50 // apply strategy only until workload is ready 51 PolicyWaitForWorkloadReady StrategyPolicy = "WaitForWorkloadReady" 52 53 // apply strategy immediately no matter workload status is 54 PolicyImmediately StrategyPolicy = "Immediately" 55 56 // pause strategy 57 PolicyPause StrategyPolicy = "Paused" 58 ) 59 60 // StrategySpec defines the desired state of Strategy 61 type StrategySpec struct { 62 // Strategy type 63 Type strategyType `json:"type,omitempty"` 64 65 // Principal version, the one as reference version 66 // label version value 67 // +optional 68 PrincipalVersion string `json:"principal,omitempty"` 69 70 // Governor version, the version takes control of all incoming traffic 71 // label version value 72 // +optional 73 GovernorVersion string `json:"governor,omitempty"` 74 75 // Label selector for virtual services. 76 // +optional 77 Selector *metav1.LabelSelector `json:"selector,omitempty"` 78 79 // Template describes the virtual service that will be created. 80 Template VirtualServiceTemplateSpec `json:"template,omitempty"` 81 82 // strategy policy, how the strategy will be applied 83 // by the strategy controller 84 StrategyPolicy StrategyPolicy `json:"strategyPolicy,omitempty"` 85 } 86 87 // VirtualServiceTemplateSpec 88 type VirtualServiceTemplateSpec struct { 89 90 // Metadata of the virtual services created from this template 91 // +optional 92 metav1.ObjectMeta `json:"metadata,omitempty"` 93 94 // Spec indicates the behavior of a virtual service. 95 // +optional 96 Spec v1alpha3.VirtualService `json:"spec,omitempty"` 97 } 98 99 // StrategyStatus defines the observed state of Strategy 100 type StrategyStatus struct { 101 // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster 102 // Important: Run "make" to regenerate code after modifying this file 103 104 // The latest available observations of an object's current state. 105 // +optional 106 Conditions []StrategyCondition `json:"conditions,omitempty"` 107 108 // Represents time when the strategy was acknowledged by the controller. 109 // It is represented in RFC3339 form and is in UTC. 110 // +optional 111 StartTime *metav1.Time `json:"startTime,omitempty"` 112 113 // Represents time when the strategy was completed. 114 // It is represented in RFC3339 form and is in UTC. 115 // +optional 116 CompletionTime *metav1.Time `json:"completionTime,omitempty"` 117 } 118 119 type StrategyConditionType string 120 121 // These are valid conditions of a strategy. 122 const ( 123 // StrategyComplete means the strategy has been delivered to istio. 124 StrategyComplete StrategyConditionType = "Complete" 125 126 // StrategyFailed means the strategy has failed its delivery to istio. 127 StrategyFailed StrategyConditionType = "Failed" 128 ) 129 130 // StrategyCondition describes current state of a strategy. 131 type StrategyCondition struct { 132 // Type of strategy condition, Complete or Failed. 133 Type StrategyConditionType `json:"type,omitempty"` 134 135 // Status of the condition, one of True, False, Unknown 136 Status apiextensions.ConditionStatus `json:"status,omitempty"` 137 138 // Last time the condition was checked. 139 // +optional 140 LastProbeTime metav1.Time `json:"lastProbeTime,omitempty"` 141 142 // Last time the condition transit from one status to another 143 // +optional 144 LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"` 145 146 // reason for the condition's last transition 147 Reason string `json:"reason,omitempty"` 148 149 // Human readable message indicating details about last transition. 150 // +optinal 151 Message string `json:"message,omitempty"` 152 } 153 154 // +genclient 155 // +kubebuilder:object:root=true 156 157 // Strategy is the Schema for the strategies API 158 // +kubebuilder:printcolumn:name="Type",type="string",JSONPath=".spec.type",description="type of strategy" 159 // +kubebuilder:printcolumn:name="Hosts",type="string",JSONPath=".spec.template.spec.hosts",description="destination hosts" 160 // +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="CreationTimestamp is a timestamp representing the server time when this object was created. It is not guaranteed to be set in happens-before order across separate operations. Clients may not set this value. It is represented in RFC3339 form and is in UTC. Populated by the system. Read-only. Null for lists. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata" 161 // +k8s:openapi-gen=true 162 type Strategy struct { 163 metav1.TypeMeta `json:",inline"` 164 metav1.ObjectMeta `json:"metadata,omitempty"` 165 166 Spec StrategySpec `json:"spec,omitempty"` 167 Status StrategyStatus `json:"status,omitempty"` 168 } 169 170 // +kubebuilder:object:root=true 171 172 // StrategyList contains a list of Strategy 173 type StrategyList struct { 174 metav1.TypeMeta `json:",inline"` 175 metav1.ListMeta `json:"metadata,omitempty"` 176 Items []Strategy `json:"items"` 177 } 178 179 func init() { 180 SchemeBuilder.Register(&Strategy{}, &StrategyList{}) 181 }