Skip to content

Commit 9bc475b

Browse files
committed
SSL Completed
1 parent 6ca6fe5 commit 9bc475b

File tree

12 files changed

+291
-116
lines changed

12 files changed

+291
-116
lines changed

README.adoc

Lines changed: 60 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,7 @@
11
# AMQ Broker Operator Helm Enhancement
22

33
The aim is to automate the creation of the AMQ Broker Custom Resources and at the same time enhance the broker.xml with a configuration that is not yet available in the operator.
4-
The helm chart keeps in sync the custom resources and the broker.xml.
5-
6-
. Install Operator to specific namespace on the cluster
7-
.. This can be provided by the cluster-admin as namespaced installation and should give the right role to manage the AMQ Broker CRD.
8-
+
9-
NOTE: You cannot create more than one broker deployment in a given OpenShift project by deploying multiple broker Custom Resource (CR) instances. However, when you have created a broker deployment in a project, you can deploy multiple CR instances for addresses. https://access.redhat.com/documentation/en-us/red_hat_amq/7.7/html-single/deploying_amq_broker_on_openshift/index#con-br-operator-deployment-notes_broker-ocp[Reference].
10-
. [pre-install hook] Restore AMQ Broker Operator
11-
. [install/upgrade] Create kind: ActiveMQArtemis
12-
. [install/upgrade] Deploy custom broker xml.
13-
. [post-install hook] Shutdown the AMQ Broker Operator
14-
. [post-install hook] Adopt the AMQ Broker resource to Helm:
15-
+
16-
[source,yaml]
17-
------
18-
annotations:
19-
meta.helm.sh/release-name: release-name
20-
meta.helm.sh/release-namespace: namespace-name
21-
labels:
22-
app.kubernetes.io/managed-by: Helm
23-
------
24-
. [post install] Adjust AMQ Broker Stateful set to use the custom broker xml. Possible 3 ways:
25-
.. Set BROKER_XML environment variable with your custom broker.xml.
26-
.. Mount ConfigMap resources hosting any custom configuration file.
27-
.. Use S2I procedure with more customization requirements. footnote:[ActiveMQArtemis allows you to override the amq broker images]
28-
. [test] Verify the installation is correct.
29-
30-
NOTE: A pre-hook install image requires oc client `quay.io/openshift/origin-cli:4.6` and running with edit role on the specific namespace.
31-
32-
## Important
33-
34-
* In AMQ Broker 7.7, if you want to configure any of the following items, you must add the appropriate configuration to the main CR instance before deploying the CR for the first time.
35-
** Address settings
36-
** The size of the Persistent Volume Claim (PVC) required by each broker in a deployment for persistent storage
37-
** Limits and requests for memory and CPU for each broker in a deployment
38-
* During an active scaling event, any further changes that you apply are queued by the Operator and executed only when scaling is complete. For example, suppose that you scale the size of your deployment down from four brokers to one. Then, while scaledown is taking place, you also change the values of the broker administrator user name and password. In this case, the Operator queues the user name and password changes until the deployment is running with one active broker.
39-
* All CR changes – apart from changing the size of your deployment, or changing the value of the expose attribute for acceptors, connectors, or the console – cause existing brokers to be restarted. If you have multiple brokers in your deployment, only one broker restarts at a time.
40-
41-
* To configure address and queue settings for broker deployments on OpenShift Container Platform, you add configuration to an addressSettings section of the main Custom Resource (CR) instance for the broker deployment. This contrasts with standalone deployments on Linux or Windows, for which you add configuration to an address-settings element in the broker.xml configuration file.
42-
* The format used for the names of configuration items differs between OpenShift Container Platform and standalone broker deployments. For OpenShift Container Platform deployments, configuration item names are in camel case, for example, defaultQueueRoutingType. By contrast, configuration item names for standalone deployments are in lower case and use a dash (-) separator, for example, default-queue-routing-type.
43-
44-
The following table shows some further examples of this naming difference.
45-
46-
.Naming difference
47-
[cols="5,5",options=header]
48-
|===
49-
50-
| Configuration item for standalone broker deployment
51-
| Configuration item for OpenShift broker deployment
52-
53-
| address-full-policy
54-
| addressFullPolicy
55-
56-
| auto-create-queues
57-
| autoCreateQueues
58-
59-
| default-queue-routing-type
60-
| defaultQueueRoutingType
61-
62-
| last-value-queue
63-
| lastValueQueue
64-
65-
|===
66-
67-
* Addresses are created by the AMQ Broker Operator using Artemis Jolokia and MBean.
68-
4+
The helm chart keeps in sync the custom resources and the custom broker.xml.
695

706
## Prerequisites
717

@@ -101,26 +37,75 @@ The following table shows some further examples of this naming difference.
10137
| DONE
10238

10339
| SSL Selfsigned Implementation
104-
| TODO
40+
| DONE
10541

106-
| Make sure that the operator creates the Addresses and probably we are able to reuse it. `<address-setting match="None">`
107-
| TODO
42+
| Test with External Client Implementation
43+
| DONE
44+
45+
| Keystore and Truststore Password
46+
| DONE
47+
48+
| SSL Custom CA Implementation, NOTE: if you create the certificate early it should work
49+
| https://github.com/openlab-red/amq-broker-operator-helm/issues/2[#2]
50+
51+
| User Management
52+
| https://github.com/openlab-red/amq-broker-operator-helm/issues/3[#3]
10853

10954
| Bridge and Diverts Implementation
110-
| TODO
55+
| https://github.com/openlab-red/amq-broker-operator-helm/issues/1[#1]
11156

11257
| Network Policy
113-
| TODO
114-
115-
| Test with External Client Implementation
116-
| TODO
58+
| https://github.com/openlab-red/amq-broker-operator-helm/issues/4[#4]
11759

118-
| SSL Custom CA Implementation
60+
| Make sure that the operator creates all the Addresses
11961
| TODO
12062

12163
| High Availability and How scale down controller actives without the operator.
12264
| TODO
12365

12466
| Migrate one standalone broker
12567
| TODO
126-
|===
68+
|===
69+
70+
## Pseudo Code
71+
72+
. Install Operator to specific namespace on the cluster
73+
.. This can be provided by the cluster-admin as namespaced installation and should give the right role to manage the AMQ Broker CRD.
74+
+
75+
NOTE: You cannot create more than one broker deployment in a given OpenShift project by deploying multiple broker Custom Resource (CR) instances. However, when you have created a broker deployment in a project, you can deploy multiple CR instances for addresses. https://access.redhat.com/documentation/en-us/red_hat_amq/7.7/html-single/deploying_amq_broker_on_openshift/index#con-br-operator-deployment-notes_broker-ocp[Reference].
76+
. [pre-install hook] Restore AMQ Broker Operator
77+
. [install/upgrade] Create kind: ActiveMQArtemis and ActiveMQArtemisAddress
78+
. [install/upgrade] Create Config Map with custom broker xml.
79+
. [post-install hook] Shutdown the AMQ Broker Operator
80+
. [post-install hook] Adoptthe AMQ Broker resource to Helm:
81+
+
82+
[source,yaml]
83+
------
84+
annotations:
85+
meta.helm.sh/release-name: release-name
86+
meta.helm.sh/release-namespace: namespace-name
87+
labels:
88+
app.kubernetes.io/managed-by: Helm
89+
------
90+
. [post install] Adjust AMQ Broker Stateful set to use the custom broker xml.
91+
.. Set BROKER_XML environment variable with your custom broker.xml.
92+
. [test] Verify the installation is correct.
93+
94+
NOTE: A *-hook install image requires oc client `quay.io/openshift/origin-cli:4.6` and running with edit role on the specific namespace.
95+
96+
## Important
97+
98+
* In AMQ Broker 7.7, if you want to configure any of the following items, you must add the appropriate configuration to the main CR instance before deploying the CR for the first time.
99+
** Address settings
100+
** The size of the Persistent Volume Claim (PVC) required by each broker in a deployment for persistent storage
101+
** Limits and requests for memory and CPU for each broker in a deployment
102+
* During an active scaling event, any further changes that you apply are queued by the Operator and executed only when scaling is complete. For example, suppose that you scale the size of your deployment down from four brokers to one. Then, while scaledown is taking place, you also change the values of the broker administrator user name and password. In this case, the Operator queues the user name and password changes until the deployment is running with one active broker.
103+
* All CR changes – apart from changing the size of your deployment, or changing the value of the expose attribute for acceptors, connectors, or the console – cause existing brokers to be restarted. If you have multiple brokers in your deployment, only one broker restarts at a time.
104+
* To configure address and queue settings for broker deployments on OpenShift Container Platform, you add configuration to an addressSettings section of the main Custom Resource (CR) instance for the broker deployment. This contrasts with standalone deployments on Linux or Windows, for which you add configuration to an address-settings element in the broker.xml configuration file.
105+
* The format used for the names of configuration items differs between OpenShift Container Platform and standalone broker deployments. For OpenShift Container Platform deployments, configuration item names are in camel case, for example, defaultQueueRoutingType. By contrast, configuration item names for standalone deployments are in lower case and use a dash (-) separator, for example, default-queue-routing-type.
106+
* Addresses are created by the AMQ Broker Operator using Artemis Jolokia and MBean.
107+
108+
## Reference
109+
110+
* https://access.redhat.com/documentation/en-us/red_hat_amq/7.7/html-single/deploying_amq_broker_on_openshift/index#con-br-configuring-broker-certificate-for-hostname-verification_broker-ocp
111+

amq-broker/templates/_helpers.tpl

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,38 @@ Route <broker-name>-<acceptor-name>-<replica>-svc-rte
7171
svc.cluster.local
7272
*/}}
7373
{{- define "amq-broker.gen-certs" -}}
74-
{{- $altNames := list ( printf "%s-*-svc-rte-%s.%s" (include "amq-broker.fullname" .) .Release.Namespace .Values.clusterDomain ) ( printf "%s-*-svc.%s.svc" (include "amq-broker.fullname" .) .Release.Namespace ) -}}
74+
{{- $cn:= printf "%s-*-svc-rte-%s.%s" (include "amq-broker.fullname" .) .Release.Namespace .Values.clusterDomain -}}
75+
{{- $altNames := list $cn ( printf "%s-*-svc.%s.svc" (include "amq-broker.fullname" .) .Release.Namespace ) -}}
7576
{{- $ca := genCA "amq-broker-ca" 365 -}}
76-
{{- $cert := genSignedCert ( include "amq-broker.fullname" . ) nil $altNames 365 $ca -}}
77+
{{- $cert := genSignedCert $cn nil $altNames 365 $ca -}}
7778
tls.crt: {{ $cert.Cert | b64enc }}
7879
tls.key: {{ $cert.Key | b64enc }}
7980
ca.crt: {{ $ca.Cert | b64enc }}
8081
{{- end -}}
82+
83+
84+
{{/*
85+
Generate acceptors broker.xml
86+
*/}}
87+
{{- define "amq-broker.acceptors" -}}
88+
{{- $fullName := ( include "amq-broker.fullname" . ) -}}
89+
{{ range .Values.acceptors }}
90+
{{- $acceptor := . -}}
91+
{{- with $ }}
92+
<acceptor name="{{ $acceptor.name }}">tcp://${BROKER_IP}:{{ $acceptor.port }}?protocols=
93+
{{- if eq $acceptor.protocols "all" -}}
94+
AMQP,CORE,HORNETQ,MQTT,OPENWIRE,STOMP
95+
{{- else -}}
96+
{{- upper $acceptor.protocols -}}
97+
{{- end -}}
98+
{{- if $acceptor.sslEnabled -}}
99+
;sslEnabled=true;keyStorePath=/etc/{{ $fullName }}-all-secret-volume/broker.ks;keyStorePassword={{ .Values.keyStorePassword }};trustStorePath=/etc/{{ $fullName }}-all-secret-volume/client.ts;trustStorePassword={{ .Values.trustStorePassword }};
100+
{{- else -}}
101+
;
102+
{{- end -}}
103+
tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;useEpoll=true;amqpCredits=1000;amqpMinCredits=300</acceptor>
104+
{{- end -}}
105+
{{- end }}
106+
{{- end }}
107+
108+

amq-broker/templates/activeamqartemis.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ spec:
1212
adminPassword: {{ .Values.adminPassword }}
1313
adminUser: {{ .Values.adminUser }}
1414
console:
15-
expose: true
16-
sslEnabled: false
15+
{{- toYaml .Values.console | nindent 4 }}
1716
deploymentPlan:
1817
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
1918
journalType: nio

amq-broker/templates/configmap.yaml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,12 @@ data:
4444
<critical-analyzer-policy>HALT</critical-analyzer-policy>
4545
4646
<connectors>
47+
<!-- Connector used to be announced through cluster connections and notifications -->
4748
<connector name="artemis">tcp://${BROKER_IP}:61616</connector>
4849
</connectors>
4950
5051
<acceptors>
51-
{{- range .Values.acceptors }}
52-
{{ if eq .protocols "all" }}
53-
<acceptor name="{{ .name }}">tcp://${BROKER_IP}:{{ .port }}?protocols=AMQP,CORE,HORNETQ,MQTT,OPENWIRE,STOMP;tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;useEpoll=true;amqpCredits=1000;amqpMinCredits=300</acceptor>
54-
{{ else }}
55-
<acceptor name="{{ .name }}">tcp://${BROKER_IP}:{{ .port }}?protocols={{ upper .protocols }};tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;useEpoll=true;amqpCredits=1000;amqpMinCredits=300</acceptor>
56-
{{ end }}
57-
{{- end }}
58-
<!-- acceptor name="all">tcp://${BROKER_IP}:61617?protocols=AMQP,CORE,HORNETQ,MQTT,OPENWIRE,STOMP;sslEnabled=true;keyStorePath=/etc/tls-secret-volume/broker.ks;keyStorePassword=changeit;trustStorePath=/etc/tls-secret-volume/client.ts;trustStorePassword=changeit;sslProvider=JDK;tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;useEpoll=true;amqpCredits=1000;amqpMinCredits=300</acceptor -->
52+
{{- include "amq-broker.acceptors" . | nindent 16 }}
5953
<acceptor name="scaleDown">tcp://${BROKER_IP}:61616?protocols=CORE;tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;useEpoll=true;amqpCredits=1000;amqpMinCredits=300</acceptor>
6054
</acceptors>
6155

amq-broker/templates/post-install.yaml

Lines changed: 79 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,45 @@ spec:
1919
spec:
2020
serviceAccountName: {{ include "amq-broker.serviceAccountName" . }}
2121
restartPolicy: Never
22+
initContainers:
23+
- name: keytool
24+
image: "{{ .Values.keytool.image.repository }}:{{ .Values.keytool.image.tag }}"
25+
imagePullPolicy: "{{ .Values.keytool.image.pullPolicy }}"
26+
command:
27+
- /bin/bash
28+
- '-c'
29+
- |
30+
#!/bin/bash
31+
32+
{{ range .Values.acceptors }}
33+
{{- $acceptor := . -}}
34+
{{- with $ }}
35+
{{- if $acceptor.sslEnabled -}}
36+
37+
cd /opt/pki/{{ $acceptor.name }}
38+
mkdir -p ../java/{{ $acceptor.name }}
39+
40+
RANDFILE=/tmp/.rnd openssl pkcs12 -export -in tls.crt -inkey tls.key -chain -CAfile ca.crt -name broker -password pass:{{ .Values.keyStorePassword | quote }} -out ../java/{{ $acceptor.name }}/broker.ks
41+
42+
keytool -keystore ../java/{{ $acceptor.name }}/client.ts -storepass {{ .Values.trustStorePassword | quote }} -noprompt -alias broker -import -file tls.crt
43+
44+
{{- end }}
45+
{{- end }}
46+
{{- end }}
47+
exit 0
48+
volumeMounts:
49+
{{ range .Values.acceptors }}
50+
{{- if .sslEnabled -}}
51+
- name: {{ .name }}
52+
mountPath: /opt/pki/{{ .name }}
53+
{{- end }}
54+
{{- end }}
55+
- name: pki
56+
mountPath: /opt/pki
2257
containers:
2358
- name: post-install
24-
image: "quay.io/openshift/origin-cli:4.6"
59+
image: "{{ .Values.oc.image.repository }}:{{ .Values.oc.image.tag }}"
60+
imagePullPolicy: "{{ .Values.oc.image.pullPolicy }}"
2561
command:
2662
- /bin/bash
2763
- '-c'
@@ -30,6 +66,34 @@ spec:
3066
3167
export AMQ_BROKER={{ include "amq-broker.fullname" . }}-ss
3268
69+
{{ range .Values.acceptors }}
70+
{{- $acceptor := . -}}
71+
{{- with $ }}
72+
{{- if $acceptor.sslEnabled -}}
73+
74+
cd /opt/pki/java/{{ $acceptor.name }}
75+
76+
export BROKER_KS=$(base64 broker.ks -w0)
77+
export CLIENT_TS=$(base64 client.ts -w0)
78+
79+
oc patch secret {{ include "amq-broker.fullname" . }}-{{ $acceptor.name }}-secret -p "
80+
data:
81+
broker.ks: |
82+
${BROKER_KS}
83+
client.ts: |
84+
${CLIENT_TS}
85+
"
86+
87+
oc secrets link sa/amq-broker-operator {{ include "amq-broker.fullname" . }}-{{ $acceptor.name }}-secret
88+
89+
{{- end }}
90+
{{- end }}
91+
{{- end }}
92+
93+
# TODO: Wait until the operator finish to apply all the changes (broker and addresses)
94+
# Reconcile
95+
sleep 1m
96+
3397
# Wait the rollout of AMQ Broker Statefulset
3498
oc rollout status sts/$AMQ_BROKER -w
3599
@@ -46,11 +110,21 @@ spec:
46110
volumeMounts:
47111
- name: kustomize
48112
mountPath: /opt/config
113+
- name: pki
114+
mountPath: /opt/pki
49115
volumes:
116+
- name: pki
117+
emptyDir: {}
50118
- name: kustomize
51119
configMap:
52120
name: {{ include "amq-broker.fullname" . }}
53-
54-
55-
56-
121+
{{ range .Values.acceptors }}
122+
{{- $acceptor := . -}}
123+
{{- with $ }}
124+
{{- if $acceptor.sslEnabled -}}
125+
- name: {{ $acceptor.name }}
126+
secret:
127+
secretName: {{ include "amq-broker.fullname" . }}-{{ $acceptor.name }}-secret
128+
{{- end }}
129+
{{- end }}
130+
{{- end }}

amq-broker/templates/pre-install.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,20 @@ spec:
2121
restartPolicy: Never
2222
containers:
2323
- name: pre-install
24-
image: "quay.io/openshift/origin-cli:4.6"
24+
image: "{{ .Values.oc.image.repository }}:{{ .Values.oc.image.tag }}"
2525
command:
2626
- /bin/bash
2727
- '-c'
2828
- |
2929
#!/bin/bash
3030
31+
export AMQ_BROKER={{ include "amq-broker.fullname" . }}-ss
32+
3133
# Scale Up the Operator
3234
oc scale --replicas=1 deployments/amq-broker-operator
3335
34-
oc rollout status deployments/amq-broker-operator -w
36+
oc rollout status deployments/amq-broker-operator -w --timeout=1m
37+
3538
3639
3740

amq-broker/templates/edit-rolebinding.yaml renamed to amq-broker/templates/rolebinding.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.serviceAccount.create -}}
12
apiVersion: rbac.authorization.k8s.io/v1
23
kind: RoleBinding
34
metadata:
@@ -13,4 +14,5 @@ roleRef:
1314
name: edit
1415
subjects:
1516
- kind: ServiceAccount
16-
name: {{ include "amq-broker.serviceAccountName" . }}
17+
name: {{ include "amq-broker.serviceAccountName" . }}
18+
{{- end }}

0 commit comments

Comments
 (0)