@@ -109,6 +109,37 @@ func (r *Reconciler) addProxySidecar(
109109 // Add proxy sidecar container
110110 podSpec .Containers = append (podSpec .Containers , r .buildProxySidecarContainer (instance ))
111111
112+ // Update RabbitMQ container's readiness probe and ports to match backend configuration
113+ // The RabbitMQ cluster operator sets a probe on port 5671 and exposes ports by default,
114+ // but with the proxy enabled, RabbitMQ only listens on localhost:5673
115+ for i , container := range podSpec .Containers {
116+ if container .Name == "rabbitmq" {
117+ // Override the readiness probe to check the backend port
118+ podSpec .Containers [i ].ReadinessProbe = & corev1.Probe {
119+ ProbeHandler : corev1.ProbeHandler {
120+ TCPSocket : & corev1.TCPSocketAction {
121+ Host : "127.0.0.1" ,
122+ Port : intstr .FromInt32 (int32 (rabbitmqBackendPort )),
123+ },
124+ },
125+ InitialDelaySeconds : 10 ,
126+ TimeoutSeconds : 5 ,
127+ PeriodSeconds : 10 ,
128+ SuccessThreshold : 1 ,
129+ FailureThreshold : 3 ,
130+ }
131+
132+ // Note: We don't override container ports here because:
133+ // 1. Ports are just metadata declarations, not actual network configuration
134+ // 2. What RabbitMQ actually listens on is controlled by our listener config
135+ // 3. Overriding ports can cause conflicts with cluster operator defaults
136+
137+ Log .Info ("Updated RabbitMQ container readiness probe for proxy mode" ,
138+ "readinessProbePort" , rabbitmqBackendPort )
139+ break
140+ }
141+ }
142+
112143 // Add volume for proxy script
113144 if podSpec .Volumes == nil {
114145 podSpec .Volumes = []corev1.Volume {}
@@ -137,6 +168,10 @@ func (r *Reconciler) addProxySidecar(
137168 })
138169 }
139170
171+ // Note: rabbitmq-tls volume is automatically added by the cluster operator when
172+ // cluster.Spec.TLS.SecretName is set (which we keep for inter-node TLS).
173+ // The proxy container will mount this volume via buildProxySidecarContainer().
174+
140175 // Add rabbitmq-tls-ca volume if CA is in a separate secret
141176 if instance .Spec .TLS .CaSecretName != "" && instance .Spec .TLS .CaSecretName != instance .Spec .TLS .SecretName {
142177 caVolumeExists := false
@@ -317,10 +352,23 @@ func (r *Reconciler) removeProxySidecar(cluster *rabbitmqv2.RabbitmqCluster) {
317352 }
318353 podSpec .Containers = newContainers
319354
320- // Remove proxy-script volume
355+ // Restore RabbitMQ container's readiness probe to default
356+ // When proxy is removed, RabbitMQ listens on standard ports again
357+ // Setting probe to nil allows the cluster operator to restore its default
358+ if removed {
359+ for i , container := range podSpec .Containers {
360+ if container .Name == "rabbitmq" {
361+ podSpec .Containers [i ].ReadinessProbe = nil
362+ Log .Info ("Restored RabbitMQ container readiness probe to default" )
363+ break
364+ }
365+ }
366+ }
367+
368+ // Remove proxy-script and rabbitmq-tls-ca volumes
321369 newVolumes := []corev1.Volume {}
322370 for _ , vol := range podSpec .Volumes {
323- if vol .Name != "proxy-script" {
371+ if vol .Name != "proxy-script" && vol . Name != "rabbitmq-tls-ca" {
324372 newVolumes = append (newVolumes , vol )
325373 }
326374 }
@@ -404,15 +452,18 @@ func (r *Reconciler) configureRabbitMQBackendPort(
404452 tlsStatus = "with TLS"
405453 }
406454
407- // Configure RabbitMQ to listen on localhost:5673 without TLS
455+ // Configure RabbitMQ to listen on localhost:5673 without TLS for AMQP
408456 // The proxy will handle TLS termination (if enabled) on 0.0.0.0:5671 or 0.0.0.0:5672
457+ // Override the default listeners set by the cluster operator
409458 additionalConfig := fmt .Sprintf (`
410459# Proxy sidecar configuration
411- # RabbitMQ listens on localhost:%d without TLS (proxy handles encryption)
460+ # RabbitMQ listens on localhost:%d without TLS for AMQP (proxy handles client encryption)
412461# External clients connect to proxy on port %d %s
413- # Disable all default listeners to prevent bypassing the proxy and port conflicts
414- listeners.tcp = none
415- listeners.ssl = none
462+ # Override default AMQP listeners set by cluster operator
463+ # Management and Prometheus SSL listeners remain active
464+ listeners.ssl.default = none
465+ listeners.tcp.default = none
466+ # Configure AMQP to listen on localhost only (proxy forwards to this)
416467listeners.tcp.1 = 127.0.0.1:%d
417468` , rabbitmqBackendPort , listenPort , tlsStatus , rabbitmqBackendPort )
418469
0 commit comments