Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 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
2 changes: 1 addition & 1 deletion api/adc/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ type Upstream struct {

HashOn string `json:"hash_on,omitempty" yaml:"hash_on,omitempty"`
Key string `json:"key,omitempty" yaml:"key,omitempty"`
Nodes UpstreamNodes `json:"nodes" yaml:"nodes"`
Nodes UpstreamNodes `json:"nodes,omitempty" yaml:"nodes,omitempty"`
PassHost string `json:"pass_host,omitempty" yaml:"pass_host,omitempty"`
Retries *int64 `json:"retries,omitempty" yaml:"retries,omitempty"`
RetryTimeout *float64 `json:"retry_timeout,omitempty" yaml:"retry_timeout,omitempty"`
Expand Down
48 changes: 35 additions & 13 deletions api/v2/apisixupstream_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
)

// ApisixUpstreamSpec describes the specification of ApisixUpstream.
// +kubebuilder:validation:XValidation:rule="has(self.subsets) || (has(self.externalNodes)!=has(self.discovery))"
type ApisixUpstreamSpec struct {
// IngressClassName is the name of an IngressClass cluster resource.
// controller implementations use this field to know whether they should be
Expand All @@ -29,6 +30,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 +83,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 Down Expand Up @@ -108,6 +111,7 @@ 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
Expand Down Expand Up @@ -145,7 +149,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 +165,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 +217,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
67 changes: 67 additions & 0 deletions config/crd/bases/apisix.apache.org_apisixupstreams.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ spec:
weight:
type: integer
type: object
minItems: 1
type: array
healthCheck:
description: The health check configurations for the upstream.
Expand All @@ -83,6 +84,7 @@ spec:
health check.
properties:
concurrency:
minimum: 0
type: integer
healthy:
description: |-
Expand All @@ -92,10 +94,13 @@ spec:
httpCodes:
items:
type: integer
minItems: 1
type: array
interval:
type: string
successes:
maximum: 254
minimum: 0
type: integer
type: object
host:
Expand All @@ -104,6 +109,8 @@ spec:
type: string
port:
format: int32
maximum: 65535
minimum: 0
type: integer
requestHeaders:
items:
Expand All @@ -119,6 +126,10 @@ spec:
format: int64
type: integer
type:
enum:
- http
- https
- tcp
type: string
unhealthy:
description: |-
Expand All @@ -128,12 +139,17 @@ spec:
httpCodes:
items:
type: integer
minItems: 1
type: array
httpFailures:
maximum: 254
minimum: 0
type: integer
interval:
type: string
tcpFailures:
maximum: 254
minimum: 0
type: integer
timeout:
type: integer
Expand All @@ -152,8 +168,11 @@ spec:
httpCodes:
items:
type: integer
minItems: 1
type: array
successes:
maximum: 254
minimum: 0
type: integer
type: object
type:
Expand All @@ -166,10 +185,15 @@ spec:
httpCodes:
items:
type: integer
minItems: 1
type: array
httpFailures:
maximum: 254
minimum: 0
type: integer
tcpFailures:
maximum: 254
minimum: 0
type: integer
timeout:
type: integer
Expand Down Expand Up @@ -207,6 +231,10 @@ spec:
description: |-
Configures the host when the request is forwarded to the upstream.
Can be one of pass, node or rewrite.
enum:
- pass
- node
- rewrite
type: string
portLevelSettings:
items:
Expand Down Expand Up @@ -239,6 +267,7 @@ spec:
upstream health check.
properties:
concurrency:
minimum: 0
type: integer
healthy:
description: |-
Expand All @@ -248,10 +277,13 @@ spec:
httpCodes:
items:
type: integer
minItems: 1
type: array
interval:
type: string
successes:
maximum: 254
minimum: 0
type: integer
type: object
host:
Expand All @@ -260,6 +292,8 @@ spec:
type: string
port:
format: int32
maximum: 65535
minimum: 0
type: integer
requestHeaders:
items:
Expand All @@ -275,6 +309,10 @@ spec:
format: int64
type: integer
type:
enum:
- http
- https
- tcp
type: string
unhealthy:
description: |-
Expand All @@ -284,12 +322,17 @@ spec:
httpCodes:
items:
type: integer
minItems: 1
type: array
httpFailures:
maximum: 254
minimum: 0
type: integer
interval:
type: string
tcpFailures:
maximum: 254
minimum: 0
type: integer
timeout:
type: integer
Expand All @@ -308,8 +351,11 @@ spec:
httpCodes:
items:
type: integer
minItems: 1
type: array
successes:
maximum: 254
minimum: 0
type: integer
type: object
type:
Expand All @@ -322,10 +368,15 @@ spec:
httpCodes:
items:
type: integer
minItems: 1
type: array
httpFailures:
maximum: 254
minimum: 0
type: integer
tcpFailures:
maximum: 254
minimum: 0
type: integer
timeout:
type: integer
Expand Down Expand Up @@ -356,6 +407,10 @@ spec:
description: |-
Configures the host when the request is forwarded to the upstream.
Can be one of pass, node or rewrite.
enum:
- pass
- node
- rewrite
type: string
port:
description: Port is a Kubernetes Service port, it should be
Expand All @@ -372,6 +427,11 @@ spec:
description: |-
The scheme used to talk with the upstream.
Now value can be http, grpc.
enum:
- http
- https
- grpc
- grpcs
type: string
subsets:
description: |-
Expand Down Expand Up @@ -438,6 +498,11 @@ spec:
description: |-
The scheme used to talk with the upstream.
Now value can be http, grpc.
enum:
- http
- https
- grpc
- grpcs
type: string
subsets:
description: |-
Expand Down Expand Up @@ -490,6 +555,8 @@ spec:
the pass_host is set to rewrite
type: string
type: object
x-kubernetes-validations:
- rule: has(self.subsets) || (has(self.externalNodes)!=has(self.discovery))
status:
description: ApisixStatus is the status report for Apisix ingress Resources
properties:
Expand Down
1 change: 1 addition & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ rules:
- ""
resources:
- namespaces
- pods
- secrets
- services
verbs:
Expand Down
Loading
Loading