Skip to content

Commit 831d139

Browse files
committed
Divert Message #1 and minor fixes
1 parent 39e62ee commit 831d139

File tree

7 files changed

+255
-7
lines changed

7 files changed

+255
-7
lines changed

README.adoc

Lines changed: 75 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ oc label secret/mycluster-amq-broker-all-secret app.kubernetes.io/managed-by=Hel
112112
`oc extract secret/mycluster-amq-broker-all-secret --keys=client.ts`
113113
114114
. Extract AMQ Endpoint
115-
115+
+
116116
`export AMQ_ENDPOINT=$(oc get route mycluster-amq-broker-all-0-svc-rte --no-headers -o custom-columns=:.spec.host)`
117117
118118
. Launch Artemis Producer Command
@@ -127,12 +127,13 @@ Producer ActiveMQQueue[TEST], thread=0 Started to calculate elapsed time ...
127127
Producer ActiveMQQueue[TEST], thread=0 Produced: 10 messages
128128
Producer ActiveMQQueue[TEST], thread=0 Elapsed time in second : 0 s
129129
Producer ActiveMQQueue[TEST], thread=0 Elapsed time in milli second : 79 milli seconds
130+
130131
-------
131132
132133
. Launch Artemis Consumer Command
133134
+
134135
[source,bash]
135-
-------
136+
-----
136137
./artemis consumer --user amq --password amq --message-count 10 --url="tcp://${AMQ_ENDPOINT}:443?sslEnabled=true;trustStorePath=./client.ts;trustStorePassword=password"
137138

138139
Connection brokerURL = tcp://mycluster-amq-broker-all-0-svc-rte-dxc.apps-crc.testing:443?sslEnabled=true;trustStorePath=./client.ts;trustStorePassword=password
@@ -143,12 +144,83 @@ Consumer ActiveMQQueue[TEST], thread=0 Elapsed time in second : 0 s
143144
Consumer ActiveMQQueue[TEST], thread=0 Elapsed time in milli second : 17 milli seconds
144145
Consumer ActiveMQQueue[TEST], thread=0 Consumed: 10 messages
145146
Consumer ActiveMQQueue[TEST], thread=0 Consumer thread finished
146-
-------
147+
-----
148+
149+
## Bridge Scenario [WIP]
150+
151+
. Create two OpenShift project.
152+
+
153+
[source,bash]
154+
-----
155+
oc new-project brk1
156+
oc new-project brk2
157+
-----
158+
159+
. Install AMQ Broker Operator for both the projects.
160+
161+
. Create a NetworkPolicy to allow connection from brk1 to brk2.
162+
+
163+
[source,yaml]
164+
-----
165+
apiVersion: networking.k8s.io/v1
166+
kind: NetworkPolicy
167+
metadata:
168+
name: mycluster1-amq-broker-all
169+
labels:
170+
app.kubernetes.io/name: amq-broker
171+
app.kubernetes.io/instance: mycluster2
172+
spec:
173+
podSelector:
174+
matchLabels:
175+
app.kubernetes.io/name: amq-broker
176+
app.kubernetes.io/instance: mycluster2
177+
ingress:
178+
- from:
179+
- namespaceSelector:
180+
matchLabels:
181+
app.kubernetes.io/instance: mycluster
182+
ports:
183+
- port: 61617
184+
protocol: TCP
185+
-----
186+
187+
. Label brk1 namespace with `app.kubernetes.io/instance: mycluster`
188+
+
189+
`oc label namespace brk1 app.kubernetes.io/instance=mycluster`
190+
191+
. Install AMQ Broker Helm Chart on brk2
192+
+
193+
`helm upgrade --install mycluster2 amq-broker -n brk2`
194+
195+
. In case of SSL Connector to brk2, create a secret on brk1 to able to connect to brk2.
196+
+
197+
[source,bash]
198+
-----
199+
mkdir brk2-pki
200+
201+
oc extract secret/mycluster2-amq-broker-all-secret --to=brk2-pki -n brk2
202+
203+
oc create secret generic mycluster2-amq-broker-all-brk2-secret --from-file=brk2-pki/ -n brk1
204+
-----
205+
206+
. Install AMQ Broker Helm Chart on brk1
207+
+
208+
`helm upgrade --install mycluster amq-broker -n brk1`
209+
210+
. Launch Helm Test to test the bridge connection
211+
+
212+
`helm test mycluster1 -n brk1`
147213
148214
## Uninstall it
149215
150216
`helm uninstall mycluster --no-hooks`
151217
218+
## Failed Status
219+
220+
In case of failed installation due to missing role rights, AMQ Broker operator, tests failed or others, please make sure to clean up all the pending resources.
221+
222+
`oc delete all -lapp.kubernetes.io/name=amq-broker`
223+
152224
## Progress
153225
154226
.Progress

amq-broker/templates/_helpers.tpl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,24 @@ tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;useEpoll=true;amqpCredits
105105
{{- end }}
106106
{{- end }}
107107

108+
{{/*
109+
Generate connectors broker.xml
110+
TODO: Read the connector ssl secret automatically
111+
*/}}
112+
{{- define "amq-broker.connectors" -}}
113+
{{- $fullName := ( include "amq-broker.fullname" . ) -}}
114+
{{ range .Values.connectors }}
115+
{{- $connector := . -}}
116+
{{- with $ }}
117+
<connector name="{{ $connector.name }}">{{ $connector.type }}://{{ $connector.host }}:{{ $connector.port }}
118+
{{- if $connector.sslEnabled -}}
119+
;sslEnabled=true;keyStorePath=/etc/{{ $connector.sslSecret }}-volume/broker.ks;keyStorePassword={{ .Values.pki.keyStorePassword }};trustStorePath=/etc/{{ $connector.sslSecret }}-volume/client.ts;trustStorePassword={{ .Values.pki.trustStorePassword }}
120+
{{- else -}}
121+
;
122+
{{- end -}}
123+
</connector>
124+
{{- end -}}
125+
{{- end }}
126+
{{- end }}
127+
108128

amq-broker/templates/activemqartemisaddress.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{{- range .Values.addresses }}
22
{{- $address := . -}}
33
{{- with $ }}
4+
---
45
apiVersion: broker.amq.io/v2alpha2
56
kind: ActiveMQArtemisAddress
67
metadata:

amq-broker/templates/configmap.yaml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ data:
4646
<connectors>
4747
<!-- Connector used to be announced through cluster connections and notifications -->
4848
<connector name="artemis">tcp://${BROKER_IP}:61616</connector>
49+
50+
{{- include "amq-broker.connectors" . | nindent 16 }}
4951
</connectors>
5052
5153
<acceptors>
@@ -188,16 +190,28 @@ data:
188190
<diverts>
189191
{{- range .Values.diverts }}
190192
<divert name="{{ .name }}">
193+
<routing-name>{{ .name }}</routing-name>
191194
<address>{{ .address }}</address>
192195
<forwarding-address>{{ .forwardingAddress }}</forwarding-address>
193196
<exclusive>{{ .exclusive }}</exclusive>
197+
{{- if .filter }}
198+
<filter>{{ .filter }}</filter>
199+
{{- end }}
194200
</divert>
195201
{{- end }}
196202
</diverts>
197203
198204
<bridges>
199205
{{- range .Values.bridges }}
200-
206+
<bridge name="{{ .name }}">
207+
<queue-name>{{ .queueName }}</queue-name>
208+
<forwarding-address>{{ .forwardingAddress }}</forwarding-address>
209+
<user>{{ .user }}</user>
210+
<password>{{ .password }}</password>
211+
<static-connectors>
212+
<connector-ref>{{ .connectorRef }}</connector-ref>
213+
</static-connectors>
214+
</bridge>
201215
{{- end}}
202216
</bridges>
203217
</core>
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{{- range $index, $acceptor := .Values.acceptors }}
2+
{{- with $ }}
3+
---
4+
apiVersion: v1
5+
kind: Pod
6+
metadata:
7+
name: {{ include "amq-broker.fullname" . }}-{{ $acceptor.name }}-divert-consumer
8+
labels:
9+
{{- include "amq-broker.labels" . | nindent 4 }}
10+
annotations:
11+
"helm.sh/hook": test
12+
"helm.sh/hook-delete-policy": hook-succeeded
13+
"helm.sh/hook-weight": "{{ $index }}"
14+
spec:
15+
containers:
16+
- name: artemis-consumer
17+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
18+
imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
19+
env:
20+
- name: ARTEMIS_USER
21+
value: {{ default "" .Values.adminUser | quote }}
22+
- name: ARTEMIS_PASSWORD
23+
value: {{ default "" .Values.adminPassword | quote }}
24+
{{- if $acceptor.expose }}
25+
- name: ARTEMIS_HOST
26+
value: {{ include "amq-broker.fullname" . }}-{{ $acceptor.name }}-0-svc
27+
{{ else }}
28+
- name: ARTEMIS_HOST
29+
value: {{ include "amq-broker.fullname" . }}-hdls-svc
30+
{{- end }}
31+
{{- if eq $acceptor.protocols "all" }}
32+
- name: ARTEMIS_PROTOCOL
33+
value: "core"
34+
{{ else }}
35+
- name: ARTEMIS_PROTOCOL
36+
value: {{ $acceptor.protocols }}
37+
{{- end }}
38+
command:
39+
- /bin/bash
40+
- '-c'
41+
- |
42+
#!/bin/bash
43+
44+
/opt/amq/bin/artemis consumer --user ${ARTEMIS_USER} --password ${ARTEMIS_PASSWORD} --message-count 10 --protocol=${ARTEMIS_PROTOCOL} --destination={{ ( index .Values.diverts 0 ).forwardingAddress }} --url="tcp://${ARTEMIS_HOST}:{{ $acceptor.port }}
45+
{{- if $acceptor.sslEnabled -}}
46+
?sslEnabled=true;trustStorePath=/opt/pki/{{ .name }}/client.ts;trustStorePassword={{ .Values.pki.trustStorePassword }}"
47+
{{- else -}}
48+
"
49+
{{ end }}
50+
{{- if $acceptor.sslEnabled }}
51+
volumeMounts:
52+
- name: {{ $acceptor.name }}
53+
mountPath: /opt/pki/{{ .name }}
54+
volumes:
55+
- name: {{ $acceptor.name }}
56+
secret:
57+
secretName: {{ include "amq-broker.fullname" . }}-{{ $acceptor.name }}-secret
58+
{{- end }}
59+
restartPolicy: Never
60+
{{- end }}
61+
{{- end }}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{{- range $index, $acceptor := .Values.acceptors }}
2+
{{- with $ }}
3+
---
4+
apiVersion: v1
5+
kind: Pod
6+
metadata:
7+
name: {{ include "amq-broker.fullname" . }}-{{ $acceptor.name }}-divert-producer
8+
labels:
9+
{{- include "amq-broker.labels" . | nindent 4 }}
10+
annotations:
11+
"helm.sh/hook": test
12+
"helm.sh/hook-delete-policy": hook-succeeded
13+
"helm.sh/hook-weight": "{{ sub $index 1 }}"
14+
spec:
15+
containers:
16+
- name: artemis-producer
17+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
18+
imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
19+
env:
20+
- name: ARTEMIS_USER
21+
value: {{ default "" .Values.adminUser | quote }}
22+
- name: ARTEMIS_PASSWORD
23+
value: {{ default "" .Values.adminPassword | quote }}
24+
{{- if $acceptor.expose }}
25+
- name: ARTEMIS_HOST
26+
value: {{ include "amq-broker.fullname" . }}-{{ $acceptor.name }}-0-svc
27+
{{ else }}
28+
- name: ARTEMIS_HOST
29+
value: {{ include "amq-broker.fullname" . }}-hdls-svc
30+
{{- end }}
31+
{{- if eq $acceptor.protocols "all" }}
32+
- name: ARTEMIS_PROTOCOL
33+
value: "core"
34+
{{ else }}
35+
- name: ARTEMIS_PROTOCOL
36+
value: {{ $acceptor.protocols }}
37+
{{- end }}
38+
command:
39+
- /bin/bash
40+
- '-c'
41+
- |
42+
#!/bin/bash
43+
44+
/opt/amq/bin/artemis producer --user ${ARTEMIS_USER} --password ${ARTEMIS_PASSWORD} --message-count 10 --protocol=${ARTEMIS_PROTOCOL} --destination={{ ( index .Values.diverts 0 ).address }} --url="tcp://${ARTEMIS_HOST}:{{ $acceptor.port }}
45+
{{- if $acceptor.sslEnabled -}}
46+
?sslEnabled=true;trustStorePath=/opt/pki/{{ .name }}/client.ts;trustStorePassword={{ .Values.pki.trustStorePassword }}"
47+
{{- else -}}
48+
"
49+
{{ end }}
50+
{{- if $acceptor.sslEnabled }}
51+
volumeMounts:
52+
- name: {{ $acceptor.name }}
53+
mountPath: /opt/pki/{{ .name }}
54+
volumes:
55+
- name: {{ $acceptor.name }}
56+
secret:
57+
secretName: {{ include "amq-broker.fullname" . }}-{{ $acceptor.name }}-secret
58+
{{- end }}
59+
restartPolicy: Never
60+
{{- end }}
61+
{{- end }}

amq-broker/values.yaml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,15 @@ acceptors:
6666
protocols: amqp
6767
port: 5672
6868

69-
connectors: []
69+
connectors:
70+
- port: 61617
71+
host: mycluster2-amq-broker-all-0-svc.brk2.svc.cluster.local
72+
needClientAuth: false
73+
name: bridge
74+
type: tcp
75+
# Requires secret created in Advanced.
76+
sslEnabled: true
77+
sslSecret: mycluster2-amq-broker-all-brk2-secret
7078

7179
addressSettings:
7280
addressSetting:
@@ -83,14 +91,21 @@ addresses:
8391
- addressName: com.my.queue
8492
queueName: com.my.queue
8593
routingType: anycast
94+
- addressName: divert.test.address
95+
queueName: divert.test.address
96+
routingType: anycast
97+
- addressName: divert.test.forwarding
98+
queueName: divert.test.forwarding
99+
routingType: anycast
100+
86101

87102
securitySettings:
88103
users:
89104
- name: test
90105
password: test
91106
role: guest
92107
securitySetting:
93-
- match: 'ch.rtc.igt.#'
108+
- match: 'com.my.queue.#'
94109
createNonDurableQueue: admin
95110
deleteNonDurableQueue: admin
96111
createDurableQueue: admin
@@ -104,7 +119,11 @@ securitySettings:
104119

105120
bridges: []
106121

107-
diverts: []
122+
diverts:
123+
- name: divert.test
124+
address: divert.test.address
125+
forwardingAddress: divert.test.forwarding
126+
exclusive: true
108127

109128
clusterDomain: apps.dev.openlab.red
110129

0 commit comments

Comments
 (0)