Skip to content

Commit

Permalink
[Messaging] Add kubernetes deploy steps
Browse files Browse the repository at this point in the history
  • Loading branch information
avano authored and aldettinger committed Oct 17, 2023
1 parent d65f774 commit ec105f3
Show file tree
Hide file tree
Showing 4 changed files with 197 additions and 0 deletions.
42 changes: 42 additions & 0 deletions message-bridge/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,48 @@ $ java -jar target/quarkus-app/quarkus-run.jar
[io.quarkus] (main) camel-quarkus-examples-... started in 1.163s.
----

=== Running on Kubernetes

The quarkus-maven-plugin used in this example can generate the required resources for deploying the application on a Kubernetes cluster. The following steps assume you want to run the example on a minikube cluster. If you wish to deploy it on a different Kubernetes cluster, you can skip the minikube-specific commands.

First, configure and start minikube, and then configure your Docker to connect to its Docker daemon:

----
minikube start --cpus <cpu> --memory <memory> --addons ingress
eval $(minikube docker-env)
----

Next, deploy the message brokers and create a persistent volume claim:

----
kubectl create -f src/main/resources/resources.yml
----

After the broker pods are up and running, you can create the Docker image with the example and deploy it to the cluster:

----
mvn clean package -Pkubernetes -Dquarkus.kubernetes.deploy=true
----

NOTE: This works on minikube because you've previously configured your local Docker environment to use the Docker daemon inside minikube. However, on a different Kubernetes environment, you'll need to ensure that the image is accessible to the cluster through alternative methods.

TIP: You can omit -Dquarkus.kubernetes.deploy=true to disable automatic deployment. Instead, you can deploy it manually using the target/kubernetes/kubernetes.yml file.

Once the Ingress `camel-quarkus-examples-message-bridge` has been assigned an IP, you can start sending messages to the application:

----
curl -X POST -H "Content-Type: text/plain" http://$(oc get ingress camel-quarkus-examples-message-bridge -o jsonpath='{.status.loadBalancer.ingress[0].ip}')/message -d 'Hello'
----

==== Clean up

To remove the created resources, use the following commands:

----
kubectl delete -f target/kubernetes/kubernetes.yml
kubectl delete -f src/main/resources/resources.yml
----

=== Running on OpenShift

You can also deploy this example as an OpenShift pod using the capabilities of the quarkus-maven-plugin.
Expand Down
38 changes: 38 additions & 0 deletions message-bridge/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,44 @@
</dependencies>

<profiles>
<profile>
<id>kubernetes</id>
<activation>
<property>
<name>kubernetes</name>
</property>
</activation>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-kubernetes</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-container-image-jib</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>${quarkus.platform.group-id}</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>${quarkus.platform.version}</version>
<configuration>
<systemProperties>
<quarkus.profile>kubernetes</quarkus.profile>
<quarkus.container-image.build>true</quarkus.container-image.build>
<quarkus.kubernetes.ingress.expose>true</quarkus.kubernetes.ingress.expose>
<quarkus.kubernetes.pvc-volumes.storage.claim-name>message-bridge</quarkus.kubernetes.pvc-volumes.storage.claim-name>
<quarkus.kubernetes.mounts.storage.path>/storage</quarkus.kubernetes.mounts.storage.path>
<quarkus.kubernetes.image-pull-policy>IfNotPresent</quarkus.kubernetes.image-pull-policy>
</systemProperties>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>openshift</id>
<activation>
Expand Down
4 changes: 4 additions & 0 deletions message-bridge/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
quarkus.log.file.enable=true

ibm.mq.host=localhost
%kubernetes.ibm.mq.host=${MQ_SERVICE_HOST}
%openshift.ibm.mq.host=mq
ibm.mq.port=1414
ibm.mq.channel=DEV.APP.SVRCONN
Expand All @@ -26,6 +27,7 @@ ibm.mq.password=passw0rd
ibm.mq.queue=DEV.QUEUE.1

quarkus.artemis.amqConnectionFactory.url=tcp://localhost:61616
%kubernetes.quarkus.artemis.amqConnectionFactory.url=tcp://${ACTIVEMQ_SERVICE_HOST}:61616
%openshift.quarkus.artemis.amqConnectionFactory.url=tcp://activemq-artemis-broker:61616
quarkus.artemis.amqConnectionFactory.username=admin
quarkus.artemis.amqConnectionFactory.password=admin
Expand All @@ -37,6 +39,8 @@ quarkus.pooled-jms.max-connections=8

quarkus.transaction-manager.object-store.directory=target/narayana
%openshift.quarkus.transaction-manager.object-store.directory=/storage/narayana
%kubernetes.quarkus.transaction-manager.object-store.directory=/storage/narayana
dummy.resource.directory=target/DummyXAResource
%openshift.dummy.resource.directory=/storage/DummyXAResource
%kubernetes.dummy.resource.directory=/storage/DummyXAResource
quarkus.transaction-manager.enable-recovery=true
113 changes: 113 additions & 0 deletions message-bridge/src/main/resources/resources.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

apiVersion: apps/v1
kind: Deployment
metadata:
name: activemq-deployment
labels:
app.kubernetes.io/name: activemq
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: activemq
template:
metadata:
labels:
app.kubernetes.io/name: activemq
spec:
containers:
- name: activemq
image: quay.io/artemiscloud/activemq-artemis-broker
ports:
- containerPort: 61616
env:
- name: AMQ_USER
value: admin
- name: AMQ_PASSWORD
value: admin
---
apiVersion: v1
kind: Service
metadata:
labels:
app.kubernetes.io/name: activemq
name: activemq
spec:
ports:
- name: tcp
port: 61616
targetPort: 61616
selector:
app.kubernetes.io/name: activemq
type: ClusterIP
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: mq-deployment
labels:
app.kubernetes.io/name: ibmmq
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: ibmmq
template:
metadata:
labels:
app.kubernetes.io/name: ibmmq
spec:
containers:
- name: mq
image: icr.io/ibm-messaging/mq:9.3.2.1-r1
ports:
- containerPort: 1414
env:
- name: LICENSE
value: accept
- name: MQ_QMGR_NAME
value: QM1
- name: MQ_APP_PASSWORD
value: passw0rd
---
apiVersion: v1
kind: Service
metadata:
labels:
app.kubernetes.io/name: ibmmq
name: mq
spec:
ports:
- name: tcp
port: 1414
targetPort: 1414
selector:
app.kubernetes.io/name: ibmmq
type: ClusterIP
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: message-bridge
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi

0 comments on commit ec105f3

Please sign in to comment.