Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 36 additions & 13 deletions api/v2/apisixupstream_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type ApisixUpstreamSpec struct {
// ExternalNodes contains external nodes the Upstream should use
// If this field is set, the upstream will use these nodes directly without any further resolves
// +kubebuilder:validation:Optional
// +kubebuilder:validation:MinItems=1
ExternalNodes []ApisixUpstreamExternalNode `json:"externalNodes,omitempty" yaml:"externalNodes,omitempty"`

ApisixUpstreamConfig `json:",inline" yaml:",inline"`
Expand Down Expand Up @@ -81,6 +82,7 @@ type ApisixUpstreamConfig struct {
// The scheme used to talk with the upstream.
// Now value can be http, grpc.
// +kubebuilder:validation:Optional
// +kubebuilder:validation:Enum=http;https;grpc;grpcs;
Scheme string `json:"scheme,omitempty" yaml:"scheme,omitempty"`

// How many times that the proxy (Apache APISIX) should do when
Expand All @@ -92,6 +94,7 @@ type ApisixUpstreamConfig struct {
// +kubebuilder:validation:Optional
Timeout *UpstreamTimeout `json:"timeout,omitempty" yaml:"timeout,omitempty"`

// Deprecated: this is no longer support on standalone mode.
// The health check configurations for the upstream.
// +kubebuilder:validation:Optional
HealthCheck *HealthCheck `json:"healthCheck,omitempty" yaml:"healthCheck,omitempty"`
Expand All @@ -108,13 +111,15 @@ type ApisixUpstreamConfig struct {
// Configures the host when the request is forwarded to the upstream.
// Can be one of pass, node or rewrite.
// +kubebuilder:validation:Optional
// +kubebuilder:validation:Enum=pass;node;rewrite;
PassHost string `json:"passHost,omitempty" yaml:"passHost,omitempty"`

// Specifies the host of the Upstream request. This is only valid if
// the pass_host is set to rewrite
// +kubebuilder:validation:Optional
UpstreamHost string `json:"upstreamHost,omitempty" yaml:"upstreamHost,omitempty"`

// Deprecated: this is no longer support on standalone mode.
// Discovery is used to configure service discovery for upstream.
// +kubebuilder:validation:Optional
Discovery *Discovery `json:"discovery,omitempty" yaml:"discovery,omitempty"`
Expand Down Expand Up @@ -145,7 +150,9 @@ type LoadBalancer struct {

// HealthCheck describes the upstream health check parameters.
type HealthCheck struct {
Active *ActiveHealthCheck `json:"active" yaml:"active"`
// +kubebuilder:validation:Required
Active *ActiveHealthCheck `json:"active" yaml:"active"`
// +kubebuilder:validation:Optional
Passive *PassiveHealthCheck `json:"passive,omitempty" yaml:"passive,omitempty"`
}

Expand All @@ -159,17 +166,23 @@ type ApisixUpstreamSubset struct {

// Discovery defines Service discovery related configuration.
type Discovery struct {
ServiceName string `json:"serviceName" yaml:"serviceName"`
Type string `json:"type" yaml:"type"`
Args map[string]string `json:"args,omitempty" yaml:"args,omitempty"`
ServiceName string `json:"serviceName" yaml:"serviceName"`
Type string `json:"type" yaml:"type"`
// +kubebuilder:validation:Optional
Args map[string]string `json:"args,omitempty" yaml:"args,omitempty"`
}

// ActiveHealthCheck defines the active kind of upstream health check.
type ActiveHealthCheck struct {
Type string `json:"type,omitempty" yaml:"type,omitempty"`
Timeout time.Duration `json:"timeout,omitempty" yaml:"timeout,omitempty"`
Concurrency int `json:"concurrency,omitempty" yaml:"concurrency,omitempty"`
Host string `json:"host,omitempty" yaml:"host,omitempty"`
// +kubebuilder:validation:Optional
// +kubebuilder:validation:Enum=http;https;tcp;
Type string `json:"type,omitempty" yaml:"type,omitempty"`
Timeout time.Duration `json:"timeout,omitempty" yaml:"timeout,omitempty"`
// +kubebuilder:validation:Minimum=0
Concurrency int `json:"concurrency,omitempty" yaml:"concurrency,omitempty"`
Host string `json:"host,omitempty" yaml:"host,omitempty"`
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=65535
Port int32 `json:"port,omitempty" yaml:"port,omitempty"`
HTTPPath string `json:"httpPath,omitempty" yaml:"httpPath,omitempty"`
StrictTLS *bool `json:"strictTLS,omitempty" yaml:"strictTLS,omitempty"`
Expand Down Expand Up @@ -205,17 +218,27 @@ type ActiveHealthCheckUnhealthy struct {
// PassiveHealthCheckHealthy defines the conditions to judge whether
// an upstream node is healthy with the passive manner.
type PassiveHealthCheckHealthy struct {
// +kubebuilder:validation:Optional
// +kubebuilder:validation:MinItems=1
HTTPCodes []int `json:"httpCodes,omitempty" yaml:"httpCodes,omitempty"`
Successes int `json:"successes,omitempty" yaml:"successes,omitempty"`
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=254
Successes int `json:"successes,omitempty" yaml:"successes,omitempty"`
}

// PassiveHealthCheckUnhealthy defines the conditions to judge whether
// an upstream node is unhealthy with the passive manager.
type PassiveHealthCheckUnhealthy struct {
HTTPCodes []int `json:"httpCodes,omitempty" yaml:"httpCodes,omitempty"`
HTTPFailures int `json:"httpFailures,omitempty" yaml:"http_failures,omitempty"`
TCPFailures int `json:"tcpFailures,omitempty" yaml:"tcpFailures,omitempty"`
Timeouts int `json:"timeout,omitempty" yaml:"timeout,omitempty"`
// +kubebuilder:validation:Optional
// +kubebuilder:validation:MinItems=1
HTTPCodes []int `json:"httpCodes,omitempty" yaml:"httpCodes,omitempty"`
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=254
HTTPFailures int `json:"httpFailures,omitempty" yaml:"http_failures,omitempty"`
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=254
TCPFailures int `json:"tcpFailures,omitempty" yaml:"tcpFailures,omitempty"`
Timeouts int `json:"timeout,omitempty" yaml:"timeout,omitempty"`
}

func init() {
Expand Down
16 changes: 16 additions & 0 deletions api/v2/shared_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,22 @@ const (
ExternalTypeService ApisixUpstreamExternalType = "Service"
)

const (
// HealthCheckHTTP represents the HTTP kind health check.
HealthCheckHTTP = "http"
// HealthCheckHTTPS represents the HTTPS kind health check.
HealthCheckHTTPS = "https"
// HealthCheckTCP represents the TCP kind health check.
HealthCheckTCP = "tcp"

// HealthCheckMaxConsecutiveNumber is the max number for
// the consecutive success/failure in upstream health check.
HealthCheckMaxConsecutiveNumber = 254
// ActiveHealthCheckMinInterval is the minimum interval for
// the active health check.
ActiveHealthCheckMinInterval = time.Second
)

var schemeToPortMaps = map[string]int{
SchemeHTTP: 80,
SchemeHTTPS: 443,
Expand Down
Loading
Loading