Chapter 16. Implementing the HA CEP server
The high-availability (HA) CEP server runs on the Red Hat OpenShift Container Platform environment. It includes all necessary Drools rules and other code required to process events.
Prepare the source, build it, and then deploy it on Red Hat OpenShift Container Platform.
Alternatively, use a different process to deploy the HA CEP server where you can update the KJAR service at any time. For instructions about this process, see Chapter 17, Implementing the HA CEP server with a Maven repository for updating the KJAR service.
Prerequisites
-
You are logged into the project with administrator privilege using the
oc
command-line tool.
Procedure
-
Download the
rhpam-7.11.0-reference-implementation.zip
product deliverable file from the Software Downloads page of the Red Hat Customer Portal. -
Extract the contents of the file and then uncompress the
rhpam-7.11.0-openshift-drools-hacep-distribution.zip
file. -
Change to the
openshift-drools-hacep-distribution/sources
directory. -
Review and modify the server code based on the sample project in the
sample-hacep-project/sample-hacep-project-kjar
directory. The complex event processing logic is defined by the DRL rules in thesrc/main/resources/org/drools/cep
subdirectory. Build the project using the standard Maven command:
mvn clean install -DskipTests
- Enable the OpenShift operator for Red Hat AMQ Streams and then create an AMQ Streams (kafka) cluster in the project. For information about installing Red Hat AMQ Streams, see Using AMQ Streams on OpenShift.
To create the kafka topics that are required for operation of the server, remain in the
openshift-drools-hacep-distribution/sources
directory and run the following commands:oc apply -f kafka-topics/control.yaml oc apply -f kafka-topics/events.yaml oc apply -f kafka-topics/kiesessioninfos.yaml oc apply -f kafka-topics/snapshot.yaml
In order to enable application access to the ConfigMap that is used in the leader election, configure role-based access control. Change to the
springboot
directory and enter the following commands:oc create -f kubernetes/service-account.yaml oc create -f kubernetes/role.yaml oc create -f kubernetes/role-binding.yaml
For more information about configuring role-based access control in Red Hat OpenShift Container Platform, see Using RBAC to define and apply permissions in the Red Hat OpenShift Container Platform product documentation.
In the
springboot
directory, enter the following commands to create the image for deployment and push it into the repository configured for your OpenShift environment:oc new-build --binary --strategy=docker --name openshift-kie-springboot oc start-build openshift-kie-springboot --from-dir=. --follow
Enter the following command to detect the name of the image that was built:
oc get is/openshift-kie-springboot -o template --template='{{range .status.tags}}{{range .items}}{{.dockerImageReference}}{{end}}{{end}}'
-
Open the
kubernetes/deployment.yaml
file in a text editor. - Replace the existing image URL with the result of the previous command.
Remove all characters at the end of the line starting with the
@
symbol, then add:latest
to the line. For example:image: image-registry.openshift-image-registry.svc:5000/hacep/openshift-kie-springboot:latest
- Save the file.
Enter the following command to deploy the image:
oc apply -f kubernetes/deployment.yaml