@@ -206,6 +206,108 @@ type Upstream struct {
206206 Timeout * Timeout `json:"timeout,omitempty" yaml:"timeout,omitempty"`
207207 Type UpstreamType `json:"type,omitempty" yaml:"type,omitempty"`
208208 UpstreamHost string `json:"upstream_host,omitempty" yaml:"upstream_host,omitempty"`
209+
210+ Checks * UpstreamHealthCheck `json:"checks,omitempty" yaml:"checks,omitempty"`
211+ TLS * ClientTLS `json:"tls,omitempty" yaml:"tls,omitempty"`
212+ // for Service Discovery
213+ DiscoveryType string `json:"discovery_type,omitempty" yaml:"discovery_type,omitempty"`
214+ DiscoveryArgs map [string ]string `json:"discovery_args,omitempty" yaml:"discovery_args,omitempty"`
215+ }
216+
217+ // UpstreamHealthCheck defines the active and/or passive health check for an Upstream,
218+ // with the upstream health check feature, pods can be kicked out or joined in quickly,
219+ // if the feedback of Kubernetes liveness/readiness probe is long.
220+ // +k8s:deepcopy-gen=true
221+ type UpstreamHealthCheck struct {
222+ Active * UpstreamActiveHealthCheck `json:"active" yaml:"active"`
223+ Passive * UpstreamPassiveHealthCheck `json:"passive,omitempty" yaml:"passive,omitempty"`
224+ }
225+
226+ // ClientTLS is tls cert and key use in mTLS
227+ // +k8s:deepcopy-gen=true
228+ type ClientTLS struct {
229+ Cert string `json:"client_cert,omitempty" yaml:"client_cert,omitempty"`
230+ Key string `json:"client_key,omitempty" yaml:"client_key,omitempty"`
231+ }
232+
233+ // UpstreamActiveHealthCheck defines the active kind of upstream health check.
234+ // +k8s:deepcopy-gen=true
235+ type UpstreamActiveHealthCheck struct {
236+ Type string `json:"type,omitempty" yaml:"type,omitempty"`
237+ Timeout int `json:"timeout,omitempty" yaml:"timeout,omitempty"`
238+ Concurrency int `json:"concurrency,omitempty" yaml:"concurrency,omitempty"`
239+ Host string `json:"host,omitempty" yaml:"host,omitempty"`
240+ Port int32 `json:"port,omitempty" yaml:"port,omitempty"`
241+ HTTPPath string `json:"http_path,omitempty" yaml:"http_path,omitempty"`
242+ HTTPSVerifyCert bool `json:"https_verify_certificate,omitempty" yaml:"https_verify_certificate,omitempty"`
243+ HTTPRequestHeaders []string `json:"req_headers,omitempty" yaml:"req_headers,omitempty"`
244+ Healthy UpstreamActiveHealthCheckHealthy `json:"healthy,omitempty" yaml:"healthy,omitempty"`
245+ Unhealthy UpstreamActiveHealthCheckUnhealthy `json:"unhealthy,omitempty" yaml:"unhealthy,omitempty"`
246+ }
247+
248+ // UpstreamPassiveHealthCheck defines the passive kind of upstream health check.
249+ // +k8s:deepcopy-gen=true
250+ type UpstreamPassiveHealthCheck struct {
251+ Type string `json:"type,omitempty" yaml:"type,omitempty"`
252+ Healthy UpstreamPassiveHealthCheckHealthy `json:"healthy,omitempty" yaml:"healthy,omitempty"`
253+ Unhealthy UpstreamPassiveHealthCheckUnhealthy `json:"unhealthy,omitempty" yaml:"unhealthy,omitempty"`
254+ }
255+
256+ // UpstreamActiveHealthCheckHealthy defines the conditions to judge whether
257+ // an upstream node is healthy with the active manner.
258+ // +k8s:deepcopy-gen=true
259+ type UpstreamActiveHealthCheckHealthy struct {
260+ UpstreamPassiveHealthCheckHealthy `json:",inline" yaml:",inline"`
261+
262+ Interval int `json:"interval,omitempty" yaml:"interval,omitempty"`
263+ }
264+
265+ // UpstreamPassiveHealthCheckHealthy defines the conditions to judge whether
266+ // an upstream node is healthy with the passive manner.
267+ // +k8s:deepcopy-gen=true
268+ type UpstreamPassiveHealthCheckHealthy struct {
269+ HTTPStatuses []int `json:"http_statuses,omitempty" yaml:"http_statuses,omitempty"`
270+ Successes int `json:"successes,omitempty" yaml:"successes,omitempty"`
271+ }
272+
273+ // UpstreamPassiveHealthCheckUnhealthy defines the conditions to judge whether
274+ // an upstream node is unhealthy with the passive manager.
275+ // +k8s:deepcopy-gen=true
276+ type UpstreamPassiveHealthCheckUnhealthy struct {
277+ HTTPStatuses []int `json:"http_statuses,omitempty" yaml:"http_statuses,omitempty"`
278+ HTTPFailures int `json:"http_failures,omitempty" yaml:"http_failures,omitempty"`
279+ TCPFailures int `json:"tcp_failures,omitempty" yaml:"tcp_failures,omitempty"`
280+ Timeouts int `json:"timeouts,omitempty" yaml:"timeouts,omitempty"`
281+ }
282+
283+ // UpstreamActiveHealthCheckUnhealthy defines the conditions to judge whether
284+ // an upstream node is unhealthy with the active manager.
285+ // +k8s:deepcopy-gen=true
286+ type UpstreamActiveHealthCheckUnhealthy struct {
287+ UpstreamPassiveHealthCheckUnhealthy `json:",inline" yaml:",inline"`
288+
289+ Interval int `json:"interval,omitempty" yaml:"interval,omitempty"`
290+ }
291+
292+ // TrafficSplitConfig is the config of traffic-split plugin.
293+ // +k8s:deepcopy-gen=true
294+ type TrafficSplitConfig struct {
295+ Rules []TrafficSplitConfigRule `json:"rules"`
296+ }
297+
298+ // TrafficSplitConfigRule is the rule config in traffic-split plugin config.
299+ // +k8s:deepcopy-gen=true
300+ type TrafficSplitConfigRule struct {
301+ WeightedUpstreams []TrafficSplitConfigRuleWeightedUpstream `json:"weighted_upstreams"`
302+ }
303+
304+ // TrafficSplitConfigRuleWeightedUpstream is the weighted upstream config in
305+ // the traffic split plugin rule.
306+ // +k8s:deepcopy-gen=true
307+ type TrafficSplitConfigRuleWeightedUpstream struct {
308+ UpstreamID string `json:"upstream_id,omitempty"`
309+ Upstream * Upstream `json:"upstream,omitempty"`
310+ Weight int `json:"weight"`
209311}
210312
211313// +k8s:deepcopy-gen=true
@@ -431,15 +533,14 @@ func NewDefaultService() *Service {
431533
432534func NewDefaultUpstream () * Upstream {
433535 return & Upstream {
434- Type : Roundrobin ,
435- Nodes : make (UpstreamNodes , 0 ),
436- Scheme : SchemeHTTP ,
437536 Metadata : Metadata {
438- Desc : "Created by apisix-ingress-controller, DO NOT modify it manually" ,
439537 Labels : map [string ]string {
440538 "managed-by" : "apisix-ingress-controller" ,
441539 },
442540 },
541+ Nodes : make (UpstreamNodes , 0 ),
542+ Scheme : SchemeHTTP ,
543+ Type : Roundrobin ,
443544 }
444545}
445546
0 commit comments