Skip to content

Commit

Permalink
Adds fields for PassiveHealthCheck on IngressGateway
Browse files Browse the repository at this point in the history
  • Loading branch information
missylbytes committed Aug 29, 2023
1 parent c4cbc32 commit c0dce33
Show file tree
Hide file tree
Showing 4 changed files with 189 additions and 1 deletion.
73 changes: 73 additions & 0 deletions charts/consul/templates/crd-ingressgateways.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,40 @@ spec:
while waiting for a connection to be established.
format: int32
type: integer
passiveHealthCheck:
description: PassiveHealthCheck configuration determines how upstream
proxy instances will be monitored for removal from the load
balancing pool.
properties:
baseEjectionTime:
description: The base time that a host is ejected for. The
real time is equal to the base time multiplied by the number
of times the host has been ejected and is capped by max_ejection_time
(Default 300s). Defaults to 30000ms or 30s.
type: string
enforcingConsecutive5xx:
description: EnforcingConsecutive5xx is the % chance that
a host will be actually ejected when an outlier status is
detected through consecutive 5xx. This setting can be used
to disable ejection or to ramp it up slowly.
format: int32
type: integer
interval:
description: Interval between health check analysis sweeps.
Each sweep may remove hosts or return hosts to the pool.
type: string
maxEjectionPercent:
description: The maximum % of an upstream cluster that can
be ejected due to outlier detection. Defaults to 10% but
will eject at least one host regardless of the value.
format: int32
type: integer
maxFailures:
description: MaxFailures is the count of consecutive failures
that results in a host being removed from the pool.
format: int32
type: integer
type: object
type: object
listeners:
description: Listeners declares what ports the ingress gateway should
Expand Down Expand Up @@ -160,6 +194,45 @@ spec:
service is located. Partitioning is a Consul Enterprise
feature.
type: string
passiveHealthCheck:
description: PassiveHealthCheck configuration determines
how upstream proxy instances will be monitored for removal
from the load balancing pool.
properties:
baseEjectionTime:
description: The base time that a host is ejected
for. The real time is equal to the base time multiplied
by the number of times the host has been ejected
and is capped by max_ejection_time (Default 300s).
Defaults to 30000ms or 30s.
type: string
enforcingConsecutive5xx:
description: EnforcingConsecutive5xx is the % chance
that a host will be actually ejected when an outlier
status is detected through consecutive 5xx. This
setting can be used to disable ejection or to ramp
it up slowly.
format: int32
type: integer
interval:
description: Interval between health check analysis
sweeps. Each sweep may remove hosts or return hosts
to the pool.
type: string
maxEjectionPercent:
description: The maximum % of an upstream cluster
that can be ejected due to outlier detection. Defaults
to 10% but will eject at least one host regardless
of the value.
format: int32
type: integer
maxFailures:
description: MaxFailures is the count of consecutive
failures that results in a host being removed from
the pool.
format: int32
type: integer
type: object
requestHeaders:
description: Allow HTTP header manipulation to be configured.
properties:
Expand Down
7 changes: 6 additions & 1 deletion control-plane/api/v1alpha1/ingressgateway_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package v1alpha1
import (
"encoding/json"
"fmt"

"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/hashicorp/consul-k8s/control-plane/api/common"
Expand Down Expand Up @@ -77,6 +76,9 @@ type IngressServiceConfig struct {
// will be allowed at a single point in time. Use this to limit HTTP/2 traffic,
// since HTTP/2 has many requests per connection.
MaxConcurrentRequests *uint32 `json:"maxConcurrentRequests,omitempty"`
// PassiveHealthCheck configuration determines how upstream proxy instances will
// be monitored for removal from the load balancing pool.
PassiveHealthCheck *PassiveHealthCheck `json:"passiveHealthCheck,omitempty"`
}

type GatewayTLSConfig struct {
Expand Down Expand Up @@ -364,6 +366,7 @@ func (in IngressService) toConsul() capi.IngressService {
MaxConnections: in.MaxConnections,
MaxPendingRequests: in.MaxPendingRequests,
MaxConcurrentRequests: in.MaxConcurrentRequests,
PassiveHealthCheck: in.PassiveHealthCheck.toConsul(),
}
}

Expand Down Expand Up @@ -457,6 +460,7 @@ func (in *IngressServiceConfig) validate(path *field.Path) field.ErrorList {
if in.MaxPendingRequests != nil && *in.MaxPendingRequests <= 0 {
errs = append(errs, field.Invalid(path.Child("maxpendingrequests"), *in.MaxPendingRequests, "MaxPendingRequests must be > 0"))
}

return errs
}

Expand All @@ -468,5 +472,6 @@ func (in *IngressServiceConfig) toConsul() *capi.IngressServiceConfig {
MaxConnections: in.MaxConnections,
MaxPendingRequests: in.MaxPendingRequests,
MaxConcurrentRequests: in.MaxConcurrentRequests,
PassiveHealthCheck: in.PassiveHealthCheck.toConsul(),
}
}
37 changes: 37 additions & 0 deletions control-plane/api/v1alpha1/ingressgateway_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package v1alpha1

import (
"k8s.io/utils/pointer"
"testing"
"time"

Expand Down Expand Up @@ -70,6 +71,17 @@ func TestIngressGateway_MatchesConsul(t *testing.T) {
MaxConnections: &defaultMaxConnections,
MaxPendingRequests: &defaultMaxPendingRequests,
MaxConcurrentRequests: &defaultMaxConcurrentRequests,
PassiveHealthCheck: &PassiveHealthCheck{
Interval: metav1.Duration{
Duration: 2 * time.Second,
},
MaxFailures: uint32(20),
EnforcingConsecutive5xx: pointer.Uint32(100),
MaxEjectionPercent: pointer.Uint32(10),
BaseEjectionTime: &metav1.Duration{
Duration: 10 * time.Second,
},
},
},
Listeners: []IngressListener{
{
Expand Down Expand Up @@ -170,6 +182,13 @@ func TestIngressGateway_MatchesConsul(t *testing.T) {
MaxConnections: &defaultMaxConnections,
MaxPendingRequests: &defaultMaxPendingRequests,
MaxConcurrentRequests: &defaultMaxConcurrentRequests,
PassiveHealthCheck: &capi.PassiveHealthCheck{
Interval: 2 * time.Second,
MaxFailures: uint32(20),
EnforcingConsecutive5xx: pointer.Uint32(100),
MaxEjectionPercent: pointer.Uint32(10),
BaseEjectionTime: pointer.Duration(10 * time.Second),
},
},
Listeners: []capi.IngressListener{
{
Expand Down Expand Up @@ -332,6 +351,17 @@ func TestIngressGateway_ToConsul(t *testing.T) {
MaxConnections: &defaultMaxConnections,
MaxPendingRequests: &defaultMaxPendingRequests,
MaxConcurrentRequests: &defaultMaxConcurrentRequests,
PassiveHealthCheck: &PassiveHealthCheck{
Interval: metav1.Duration{
Duration: 2 * time.Second,
},
MaxFailures: uint32(20),
EnforcingConsecutive5xx: pointer.Uint32(100),
MaxEjectionPercent: pointer.Uint32(10),
BaseEjectionTime: &metav1.Duration{
Duration: 10 * time.Second,
},
},
},
Listeners: []IngressListener{
{
Expand Down Expand Up @@ -431,6 +461,13 @@ func TestIngressGateway_ToConsul(t *testing.T) {
MaxConnections: &defaultMaxConnections,
MaxPendingRequests: &defaultMaxPendingRequests,
MaxConcurrentRequests: &defaultMaxConcurrentRequests,
PassiveHealthCheck: &capi.PassiveHealthCheck{
Interval: 2 * time.Second,
MaxFailures: uint32(20),
EnforcingConsecutive5xx: pointer.Uint32(100),
MaxEjectionPercent: pointer.Uint32(10),
BaseEjectionTime: pointer.Duration(10 * time.Second),
},
},
Listeners: []capi.IngressListener{
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,40 @@ spec:
while waiting for a connection to be established.
format: int32
type: integer
passiveHealthCheck:
description: PassiveHealthCheck configuration determines how upstream
proxy instances will be monitored for removal from the load
balancing pool.
properties:
baseEjectionTime:
description: The base time that a host is ejected for. The
real time is equal to the base time multiplied by the number
of times the host has been ejected and is capped by max_ejection_time
(Default 300s). Defaults to 30000ms or 30s.
type: string
enforcingConsecutive5xx:
description: EnforcingConsecutive5xx is the % chance that
a host will be actually ejected when an outlier status is
detected through consecutive 5xx. This setting can be used
to disable ejection or to ramp it up slowly.
format: int32
type: integer
interval:
description: Interval between health check analysis sweeps.
Each sweep may remove hosts or return hosts to the pool.
type: string
maxEjectionPercent:
description: The maximum % of an upstream cluster that can
be ejected due to outlier detection. Defaults to 10% but
will eject at least one host regardless of the value.
format: int32
type: integer
maxFailures:
description: MaxFailures is the count of consecutive failures
that results in a host being removed from the pool.
format: int32
type: integer
type: object
type: object
listeners:
description: Listeners declares what ports the ingress gateway should
Expand Down Expand Up @@ -153,6 +187,45 @@ spec:
service is located. Partitioning is a Consul Enterprise
feature.
type: string
passiveHealthCheck:
description: PassiveHealthCheck configuration determines
how upstream proxy instances will be monitored for removal
from the load balancing pool.
properties:
baseEjectionTime:
description: The base time that a host is ejected
for. The real time is equal to the base time multiplied
by the number of times the host has been ejected
and is capped by max_ejection_time (Default 300s).
Defaults to 30000ms or 30s.
type: string
enforcingConsecutive5xx:
description: EnforcingConsecutive5xx is the % chance
that a host will be actually ejected when an outlier
status is detected through consecutive 5xx. This
setting can be used to disable ejection or to ramp
it up slowly.
format: int32
type: integer
interval:
description: Interval between health check analysis
sweeps. Each sweep may remove hosts or return hosts
to the pool.
type: string
maxEjectionPercent:
description: The maximum % of an upstream cluster
that can be ejected due to outlier detection. Defaults
to 10% but will eject at least one host regardless
of the value.
format: int32
type: integer
maxFailures:
description: MaxFailures is the count of consecutive
failures that results in a host being removed from
the pool.
format: int32
type: integer
type: object
requestHeaders:
description: Allow HTTP header manipulation to be configured.
properties:
Expand Down

0 comments on commit c0dce33

Please sign in to comment.