Skip to content
Open
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
19 changes: 19 additions & 0 deletions apis/config/v1alpha1/backend_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,25 @@ var _ = Describe("Backend", Label("type"), func() {
Ω(backend.AddToParser(p)).ShouldNot(HaveOccurred())
Ω(p.String()).Should(ContainSubstring("option redispatch"))
})
It("should set health check port", func() {
backend := &configv1alpha1.Backend{
ObjectMeta: metav1.ObjectMeta{Name: "foo"},
Spec: configv1alpha1.BackendSpec{
Servers: []configv1alpha1.Server{
{
Name: "server",
Address: "10.0.0.4",
Port: 8080,
ServerParams: configv1alpha1.ServerParams{
Check: &configv1alpha1.Check{Enabled: true, Port: ptr.To(int64(80))},
},
},
},
},
}
Ω(backend.AddToParser(p)).ShouldNot(HaveOccurred())
Ω(p.String()).Should(ContainSubstring("server server 10.0.0.4:8080 check port 80"))
})
It("should set hash-type", func() {
backend := &configv1alpha1.Backend{
ObjectMeta: metav1.ObjectMeta{Name: "foo"},
Expand Down
7 changes: 7 additions & 0 deletions apis/config/v1alpha1/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,7 @@ func (s *ServerTemplate) Model() (models.ServerTemplate, error) {

if s.Check != nil && s.Check.Enabled {
model.Check = models.ServerParamsCheckEnabled
model.HealthCheckPort = s.Check.Port

if s.Check.Inter != nil {
model.Inter = ptr.To(s.Check.Inter.Milliseconds())
Expand Down Expand Up @@ -652,6 +653,7 @@ func (s *Server) Model() (models.Server, error) {

if s.Check != nil && s.Check.Enabled {
model.Check = models.ServerParamsCheckEnabled
model.HealthCheckPort = s.Check.Port

if s.Check.Inter != nil {
model.Inter = ptr.To(s.Check.Inter.Milliseconds())
Expand Down Expand Up @@ -703,6 +705,11 @@ type Check struct {
// Enable enables health checks on a server. If not set, no health checking is performed, and the server is always
// considered available.
Enabled bool `json:"enabled"`
// Port specifies a port for health checks that differs from the server port.
// +kubebuilder:validation:Maximum=65535
// +kubebuilder:validation:Minimum=1
// +optional
Port *int64 `json:"port,omitempty"`
// Inter sets the interval between two consecutive health checks. If left unspecified, the delay defaults to 2000 ms.
// +optional
Inter *metav1.Duration `json:"inter,omitempty"`
Expand Down
5 changes: 5 additions & 0 deletions apis/config/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ _Appears in:_
| Field | Description | Default | Validation |
| --- | --- | --- | --- |
| `enabled` _boolean_ | Enable enables health checks on a server. If not set, no health checking is performed, and the server is always<br />considered available. | | |
| `port` _integer_ | Port specifies a port for health checks that differs from the server port. | | Maximum: 65535 <br />Minimum: 1 <br />Optional: \{\} <br /> |
| `inter` _[Duration](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#duration-v1-meta)_ | Inter sets the interval between two consecutive health checks. If left unspecified, the delay defaults to 2000 ms. | | Optional: \{\} <br /> |
| `rise` _integer_ | Rise specifies the number of consecutive successful health checks after a server will be considered as operational.<br />This value defaults to 2 if unspecified. | | Optional: \{\} <br /> |
| `fall` _integer_ | Fall specifies the number of consecutive unsuccessful health checks after a server will be considered as dead.<br />This value defaults to 3 if unspecified. | | Optional: \{\} <br /> |
Expand Down
14 changes: 14 additions & 0 deletions helm/haproxy-operator/crds/config.haproxy.com_backends.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1401,6 +1401,13 @@ spec:
This value defaults to 3 if unspecified.
format: int64
type: integer
port:
description: Port specifies a port for health checks
that differs from the server port.
format: int64
maximum: 65535
minimum: 1
type: integer
inter:
description: Inter sets the interval between two consecutive
health checks. If left unspecified, the delay defaults
Expand Down Expand Up @@ -1841,6 +1848,13 @@ spec:
This value defaults to 3 if unspecified.
format: int64
type: integer
port:
description: Port specifies a port for health checks
that differs from the server port.
format: int64
maximum: 65535
minimum: 1
type: integer
inter:
description: Inter sets the interval between two consecutive
health checks. If left unspecified, the delay defaults
Expand Down
14 changes: 14 additions & 0 deletions helm/haproxy-operator/crds/config.haproxy.com_listens.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1882,6 +1882,13 @@ spec:
This value defaults to 3 if unspecified.
format: int64
type: integer
port:
description: Port specifies a port for health checks
that differs from the server port.
format: int64
maximum: 65535
minimum: 1
type: integer
inter:
description: Inter sets the interval between two consecutive
health checks. If left unspecified, the delay defaults
Expand Down Expand Up @@ -2322,6 +2329,13 @@ spec:
This value defaults to 3 if unspecified.
format: int64
type: integer
port:
description: Port specifies a port for health checks
that differs from the server port.
format: int64
maximum: 65535
minimum: 1
type: integer
inter:
description: Inter sets the interval between two consecutive
health checks. If left unspecified, the delay defaults
Expand Down