Skip to content
This repository was archived by the owner on Jun 26, 2024. It is now read-only.

Commit 6c47359

Browse files
committed
add support for RabbitMQ operator backed-services
Signed-off-by: Predrag Knezevic <[email protected]>
1 parent 2969ffd commit 6c47359

File tree

6 files changed

+88
-4
lines changed

6 files changed

+88
-4
lines changed

config/rbac/kustomization.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ resources:
1515
- crunchy_postgres_clusterrole.yaml
1616
- percona_mysql_clusterrole.yaml
1717
- cloud_native_postgres_clusterrole.yaml
18+
- rabbitmq_operator_clusterrole.yaml
1819
# Comment the following 4 lines if you want to disable
1920
# the auth proxy (https://github.com/brancz/kube-rbac-proxy)
2021
# which protects your /metrics endpoint.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRole
3+
metadata:
4+
name: rabbitmq-operator-viewer-role
5+
labels:
6+
servicebinding.io/controller: "true"
7+
rules:
8+
- apiGroups:
9+
- rabbitmq.com
10+
resources:
11+
- rabbitmqclusters
12+
verbs:
13+
- get
14+
- list

controllers/crd/crd_controller.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ var bindingAnnotations = map[schema.GroupVersionKind]map[string]string{
6969
"service.binding": "path={.metadata.name}-{.spec.bootstrap.initdb.owner},objectType=Secret",
7070
"service.binding/database": "path={.spec.bootstrap.initdb.database}",
7171
},
72+
schema.GroupVersionKind{Group: "rabbitmq.com", Version: "v1beta1", Kind: "RabbitmqCluster"}: {
73+
"servicebinding.io/provisioned-service": "true",
74+
},
7275
}
7376

7477
// CrdReconciler reconciles a CustomResourceDefinition resources

pkg/util/util_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ func TestService(t *testing.T) {
1515
var _ = Describe("Merge Map", func() {
1616

1717
It("should merge two maps", func() {
18-
m1 := map[string]string {
18+
m1 := map[string]string{
1919
"foo": "bar",
2020
}
21-
m2 := map[string]string {
21+
m2 := map[string]string{
2222
"bar": "foo",
2323
}
2424
m3 := MergeMaps(m1, m2)
@@ -30,15 +30,15 @@ var _ = Describe("Merge Map", func() {
3030

3131
It("should return src map if dst is uninitialized", func() {
3232
var m1 map[string]string
33-
m2 := map[string]string {
33+
m2 := map[string]string{
3434
"bar": "foo",
3535
}
3636
m3 := MergeMaps(m1, m2)
3737
Expect(m3).To(Equal(m2))
3838
})
3939
It("should return dst map if src is uninitialized", func() {
4040
var m1 map[string]string
41-
m2 := map[string]string {
41+
m2 := map[string]string{
4242
"bar": "foo",
4343
}
4444
m3 := MergeMaps(m2, m1)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from olm import Operator
2+
from behave import given
3+
4+
5+
class RabbitMqOperator(Operator):
6+
7+
def __init__(self, name="rabbitmq-cluster-operator"):
8+
self.name = name
9+
10+
11+
@given(u'RabbitMQ operator is running')
12+
def install(_context):
13+
operator = RabbitMqOperator()
14+
operator.openshift.operators_namespace = "rabbitmq-system"
15+
if not operator.is_running():
16+
operator.openshift.apply_yaml_file("https://github.com/rabbitmq/cluster-operator/releases/download/v1.9.0/cluster-operator.yml")
17+
operator.is_running(wait=True)
18+
print("RabbitMQ operator is running")

test/acceptance/features/supportExistingOperatorBackedServices.feature

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,3 +290,51 @@ Feature: Support a number of existing operator-backed services out of the box
290290
app
291291
"""
292292
And File "/bindings/$scenario_id/password" exists in application pod
293+
294+
Scenario: Bind test application to RabbitMQ instance provisioned by RabbitMq operator
295+
Given RabbitMQ operator is running
296+
* Generic test application is running
297+
* The Custom Resource is present
298+
"""
299+
apiVersion: rabbitmq.com/v1beta1
300+
kind: RabbitmqCluster
301+
metadata:
302+
name: hello-world
303+
"""
304+
When Service Binding is applied
305+
"""
306+
apiVersion: binding.operators.coreos.com/v1alpha1
307+
kind: ServiceBinding
308+
metadata:
309+
name: $scenario_id
310+
spec:
311+
services:
312+
- group: rabbitmq.com
313+
version: v1beta1
314+
kind: RabbitmqCluster
315+
name: hello-world
316+
application:
317+
name: $scenario_id
318+
group: apps
319+
version: v1
320+
resource: deployments
321+
"""
322+
Then Service Binding is ready
323+
And Kind RabbitmqCluster with apiVersion rabbitmq.com/v1beta1 is listed in bindable kinds
324+
And Content of file "/bindings/$scenario_id/type" in application pod is
325+
"""
326+
rabbitmq
327+
"""
328+
And Content of file "/bindings/$scenario_id/host" in application pod is
329+
"""
330+
hello-world.$NAMESPACE.svc
331+
"""
332+
And Content of file "/bindings/$scenario_id/port" in application pod is
333+
"""
334+
5672
335+
"""
336+
And File "/bindings/$scenario_id/username" exists in application pod
337+
"""
338+
root
339+
"""
340+
And File "/bindings/$scenario_id/password" exists in application pod

0 commit comments

Comments
 (0)