Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
k8s:
- v1.24.1
rabbitmq-image:
- rabbitmq:3.9.0-management # minimum supported version
- rabbitmq:3.9.9-management # minimum supported version
- rabbitmq:3.10-management
- pivotalrabbitmq/rabbitmq:master-otp-min
- pivotalrabbitmq/rabbitmq:master-otp-max
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ under `site/kubernetes`.

## Supported Versions

The operator deploys RabbitMQ `3.10.2` by default, and supports versions from `3.9` upwards. The operator requires Kubernetes `1.19` or newer.
The operator deploys RabbitMQ `3.10.2` by default, and supports versions from `3.9.9` upwards. The operator requires Kubernetes `1.19` or newer.

## Versioning

Expand Down
13 changes: 9 additions & 4 deletions internal/resource/configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ package resource

import (
"fmt"
"strconv"
"strings"

"sigs.k8s.io/controller-runtime/pkg/client"
Expand All @@ -27,12 +28,12 @@ import (
const (
ServerConfigMapName = "server-conf"
defaultRabbitmqConf = `
queue_master_locator = min-masters
disk_free_limit.absolute = 2GB
cluster_partition_handling = pause_minority
cluster_formation.peer_discovery_backend = rabbit_peer_discovery_k8s
cluster_formation.k8s.host = kubernetes.default
cluster_formation.k8s.address_type = hostname
cluster_partition_handling = pause_minority
queue_master_locator = min-masters
disk_free_limit.absolute = 2GB`
cluster_formation.k8s.address_type = hostname`

defaultTLSConf = `
ssl_options.certfile = /etc/rabbitmq-tls/tls.crt
Expand Down Expand Up @@ -89,6 +90,10 @@ func (builder *ServerConfigMapBuilder) Update(object client.Object) error {
}
defaultSection := operatorConfiguration.Section("")

if _, err := defaultSection.NewKey("cluster_formation.target_cluster_size_hint", strconv.Itoa(int(*builder.Instance.Spec.Replicas))); err != nil {
return err
}

if _, err := defaultSection.NewKey("cluster_name", builder.Instance.Name); err != nil {
return err
}
Expand Down
29 changes: 22 additions & 7 deletions internal/resource/configmap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ package resource_test
import (
"bytes"
"fmt"
"k8s.io/utils/pointer"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
Expand All @@ -27,13 +28,14 @@ import (

func defaultRabbitmqConf(instanceName string) string {
return iniString(`
cluster_formation.peer_discovery_backend = rabbit_peer_discovery_k8s
cluster_formation.k8s.host = kubernetes.default
cluster_formation.k8s.address_type = hostname
cluster_partition_handling = pause_minority
queue_master_locator = min-masters
disk_free_limit.absolute = 2GB
cluster_name = ` + instanceName)
queue_master_locator = min-masters
disk_free_limit.absolute = 2GB
cluster_partition_handling = pause_minority
cluster_formation.peer_discovery_backend = rabbit_peer_discovery_k8s
cluster_formation.k8s.host = kubernetes.default
cluster_formation.k8s.address_type = hostname
cluster_formation.target_cluster_size_hint = 1
cluster_name = ` + instanceName)
}

var _ = Describe("GenerateServerConfigMap", func() {
Expand Down Expand Up @@ -143,6 +145,16 @@ var _ = Describe("GenerateServerConfigMap", func() {
Expect(configMap.Data).To(HaveKeyWithValue("operatorDefaults.conf", expectedConfiguration))
})

It("sets cluster size hint", func() {
builder.Instance.Spec.Rabbitmq.AdditionalConfig = ""
builder.Instance.Spec.Replicas = pointer.Int32Ptr(100)

Expect(configMapBuilder.Update(configMap)).To(Succeed())
operatorDefaultConf, err := ini.Load([]byte(configMap.Data["operatorDefaults.conf"]))
Expect(err).To(Not(HaveOccurred()))
Expect(operatorDefaultConf.Section("").KeysHash()).To(HaveKeyWithValue("cluster_formation.target_cluster_size_hint", "100"))
})

When("valid userDefinedConfiguration is provided", func() {
It("adds configurations in a new rabbitmq configuration", func() {
userDefinedConfiguration := "cluster_formation.peer_discovery_backend = my-backend\n" +
Expand Down Expand Up @@ -375,6 +387,7 @@ CONSOLE_LOG=new`
Name: "rabbit-tls",
},
Spec: rabbitmqv1beta1.RabbitmqClusterSpec{
Replicas: pointer.Int32Ptr(1),
TLS: rabbitmqv1beta1.TLSSpec{
SecretName: "some-secret",
DisableNonTLSListeners: true,
Expand Down Expand Up @@ -406,6 +419,7 @@ CONSOLE_LOG=new`
Name: "rabbit-tls",
},
Spec: rabbitmqv1beta1.RabbitmqClusterSpec{
Replicas: pointer.Int32Ptr(1),
TLS: rabbitmqv1beta1.TLSSpec{
SecretName: "some-secret",
DisableNonTLSListeners: true,
Expand Down Expand Up @@ -453,6 +467,7 @@ CONSOLE_LOG=new`
Name: "rabbit-tls",
},
Spec: rabbitmqv1beta1.RabbitmqClusterSpec{
Replicas: pointer.Int32Ptr(1),
TLS: rabbitmqv1beta1.TLSSpec{
SecretName: "some-secret",
CaSecretName: "some-mutual-secret",
Expand Down