diff --git a/apis/config/v1alpha1/backend_types_test.go b/apis/config/v1alpha1/backend_types_test.go
index b83bac1..f70b35b 100644
--- a/apis/config/v1alpha1/backend_types_test.go
+++ b/apis/config/v1alpha1/backend_types_test.go
@@ -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"},
diff --git a/apis/config/v1alpha1/common_types.go b/apis/config/v1alpha1/common_types.go
index 92333fb..4a525a5 100644
--- a/apis/config/v1alpha1/common_types.go
+++ b/apis/config/v1alpha1/common_types.go
@@ -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())
@@ -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())
@@ -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"`
diff --git a/apis/config/v1alpha1/zz_generated.deepcopy.go b/apis/config/v1alpha1/zz_generated.deepcopy.go
index 6cdeffb..7f5e741 100644
--- a/apis/config/v1alpha1/zz_generated.deepcopy.go
+++ b/apis/config/v1alpha1/zz_generated.deepcopy.go
@@ -405,6 +405,11 @@ func (in *CertificateListElement) DeepCopy() *CertificateListElement {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Check) DeepCopyInto(out *Check) {
*out = *in
+ if in.Port != nil {
+ in, out := &in.Port, &out.Port
+ *out = new(int64)
+ **out = **in
+ }
if in.Inter != nil {
in, out := &in.Inter, &out.Inter
*out = new(v1.Duration)
diff --git a/docs/api-reference.md b/docs/api-reference.md
index 7b1184d..e0809eb 100644
--- a/docs/api-reference.md
+++ b/docs/api-reference.md
@@ -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
considered available. | | |
+| `port` _integer_ | Port specifies a port for health checks that differs from the server port. | | Maximum: 65535
Minimum: 1
Optional: \{\}
|
| `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: \{\}
|
| `rise` _integer_ | Rise specifies the number of consecutive successful health checks after a server will be considered as operational.
This value defaults to 2 if unspecified. | | Optional: \{\}
|
| `fall` _integer_ | Fall specifies the number of consecutive unsuccessful health checks after a server will be considered as dead.
This value defaults to 3 if unspecified. | | Optional: \{\}
|
diff --git a/helm/haproxy-operator/crds/config.haproxy.com_backends.yaml b/helm/haproxy-operator/crds/config.haproxy.com_backends.yaml
index 874fdc1..534bbf3 100644
--- a/helm/haproxy-operator/crds/config.haproxy.com_backends.yaml
+++ b/helm/haproxy-operator/crds/config.haproxy.com_backends.yaml
@@ -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
@@ -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
diff --git a/helm/haproxy-operator/crds/config.haproxy.com_listens.yaml b/helm/haproxy-operator/crds/config.haproxy.com_listens.yaml
index 2d76f6e..be8cdb2 100644
--- a/helm/haproxy-operator/crds/config.haproxy.com_listens.yaml
+++ b/helm/haproxy-operator/crds/config.haproxy.com_listens.yaml
@@ -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
@@ -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