├── .gitignore ├── README.md ├── all-in-one-template.json ├── amq.json ├── pom.xml ├── rider-auto-backend ├── .gitignore ├── README.md ├── pom.xml └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── fusesource │ │ │ └── camel │ │ │ └── impl │ │ │ └── BackEndImpl.java │ └── resources │ │ ├── META-INF │ │ └── spring │ │ │ └── camel-context.xml │ │ └── log4j.properties │ └── test │ └── java │ └── org │ └── fusesource │ └── camel │ └── kubetest │ └── KubernetesIntegrationKT.java ├── rider-auto-common ├── .gitignore ├── pom.xml └── src │ ├── data │ ├── message1.xml │ └── message2.csv │ └── main │ ├── java │ └── org │ │ └── fusesource │ │ └── camel │ │ └── model │ │ └── Order.java │ └── resources │ ├── features.xml │ ├── log4j.properties │ └── org │ └── fusesource │ └── camel │ └── model │ └── jaxb.index ├── rider-auto-file ├── .gitignore ├── README.md ├── pom.xml └── src │ ├── main │ ├── fabric8 │ │ └── vagrant-pv.yaml │ ├── java │ │ └── org │ │ │ └── fusesource │ │ │ └── examples │ │ │ └── kube │ │ │ └── RiderAutoJsonModelProcessor.java │ └── resources │ │ ├── META-INF │ │ └── spring │ │ │ └── camel-context.xml │ │ └── log4j.properties │ └── test │ └── java │ └── org │ └── fusesource │ └── camel │ └── kubetest │ └── KubernetesIntegrationKT.java ├── rider-auto-normalizer ├── .gitignore ├── README.md ├── pom.xml └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── fusesource │ │ │ └── camel │ │ │ └── util │ │ │ └── OrderConverter.java │ └── resources │ │ ├── META-INF │ │ ├── services │ │ │ └── org │ │ │ │ └── apache │ │ │ │ └── camel │ │ │ │ └── TypeConverter │ │ └── spring │ │ │ └── camel-context.xml │ │ └── log4j.properties │ └── test │ └── java │ └── org │ └── fusesource │ └── camel │ └── kubetest │ └── KubernetesIntegrationKT.java ├── rider-auto-ose-installer ├── README.md └── pom.xml ├── rider-auto-rest ├── README.md ├── pom.xml └── src │ └── main │ ├── fabric8 │ ├── horizontal-pod-autoscaler.yml │ └── project-limits.yml │ ├── java │ └── org │ │ └── fusesource │ │ ├── camel │ │ └── route │ │ │ ├── RestResponseDTO.java │ │ │ └── RestRouteBuilder.java │ │ └── examples │ │ └── kube │ │ └── RiderAutoJsonModelProcessor.java │ └── resources │ ├── META-INF │ └── spring │ │ └── camel-context.xml │ └── log4j.properties └── rider-auto-ws ├── .gitignore ├── README.md ├── pom.xml └── src ├── data ├── message1.xml └── message2.csv ├── main ├── java │ └── org │ │ └── fusesource │ │ ├── camel │ │ └── ws │ │ │ └── OrderEndpoint.java │ │ └── examples │ │ └── kube │ │ └── RiderAutoJsonModelProcessor.java └── resources │ ├── META-INF │ └── spring │ │ └── camel-context.xml │ └── log4j.properties └── test ├── java └── org │ └── fusesource │ └── camel │ └── kubetest │ └── KubernetesIntegrationKT.java └── soapui └── OrderService-soapui-project.xml /.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | .settings 3 | .project 4 | .classpath 5 | *.iml 6 | .idea 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Fuse integration Services on OpenShift 2 | ======================================= 3 | 4 | With the recently released functionality in Fuse integration services on OpenShift we're able to run our integration 5 | services in a microservice style architecture in docker containers. We've been architecting services for Fuse 6 | like this for a long time, but now we can take advantage of the automation, process isolation, and packaging benefits 7 | of Docker which is crucial for a microservices style deployment. 8 | 9 | Note, this project is currently focused on using the productized (Red Hat supported) versions of the FIS (Fuse integration services) libraries and frameworks from the [http://fabric8.io](http://fabric8.io) project. The following versions of community projects can be expected in the productized release (please check the Red Hat documentation for official guidance on versions) 10 | 11 | Project | Version | 12 | -------------------------------------------|:-------------------------:| 13 | | [Apache Camel][camel] | 2.15.1.redhat-621084 | 14 | | [Apache ActiveMQ][activemq] | 5.11.0.redhat-621084 | 15 | | [Apache CXF][cxf] | 3.0.4.redhat-621084 | 16 | | [Apache Karaf maven plugin][karaf] | 4.0.2.redhat-621079 | 17 | | [JBoss Fuse][fuse] | 6.2.1.redhat-084 | 18 | | [Fabric8 - kubernetes-model][kube-model] | 1.0.22.redhat-079 | 19 | | [Fabric8 - kubernetes-client][kube-cli] | 1.3.26.redhat-079 | 20 | | [Fabric8][fabric8] | 2.2.0.redhat-079 | 21 | | [iPaaS Quickstarts][quickstart] | 2.2.0.redhat-079 | 22 | 23 | [camel]: http://camel.apache.org 24 | [activemq]: http://activemq.apache.org 25 | [karaf]: http://karaf.apache.org 26 | [fuse]: http://jboss.org/fuse 27 | [cxf]: http://cxf.apache.org 28 | [kube-model]: https://github.com/fabric8io/kubernetes-model 29 | [kube-cli]: http://github.com/fabric8io/kubernetes-client 30 | [fabric8]: http://fabric8.io 31 | [quickstart]: https://github.com/fabric8io/ipaas-quickstarts 32 | 33 | 34 | 35 | 36 | The Camel routes used in this example are explained by the following diagram: 37 | 38 | ![EIP Diagram](https://raw.github.com/FuseByExample/rider-auto-osgi/master/doc/EIP_Routes_Diagram.png) 39 | 40 | 41 | 42 | Setup 43 | ============================== 44 | 45 | You should probably set up the basic developer tools to be able to go through these steps, examples. We will also cover more ideal workflows with developer-local setup of docker and openshift, so would be good to install the "optional" tools as well! 46 | 47 | - Install JBoss Developer Studio 8.1.0 [https://www.jboss.org/products/devstudio.html] 48 | - Install Apache Maven 3.2.x [http://maven.apache.org] 49 | - Install JBoss Fuse 6.2.1 [https://www.jboss.org/products/fuse.html] 50 | - Have access to an OpenShift installation 51 | - (Optional, but recommended) Install the Red Hat [CDK Beta](https://access.redhat.com/downloads/content/293/ver=2/rhel---7/2.0.0/x86_64/product-software) for local development 52 | - (Optional, but recommended) Install the [native docker](https://docs.docker.com/engine/installation/binaries/#get-the-docker-binary) _client_ libs for your operating system 53 | - (Optional, but recommended) Install the [native openshift](https://github.com/openshift/origin/releases) _client_ libs for your operating system 54 | 55 | Java Build & Run 56 | ============================== 57 | 58 | ### Build this project 59 | 60 | > $ mvn clean install 61 | 62 | 63 | This project ends up building a few important things: 64 | 65 | * the project artifacts 66 | * builds the jars as Apache Karaf bundles (if wish to deploy into karaf -- not required though) 67 | * builds an Apache Karaf features file (if wish to deploy into karaf -- not required though) 68 | * kubernetes.json files for each module, found in `target/classes/kubernetes.json` of each sub-module 69 | * a single, comprehensive kubernetes.json that has all of the submodule descriptor files to install all in one found in `rider-auto-ose-installer/target/classes/kubernetes.json` 70 | 71 | ### To build and install the Docker microservices, please have a look at the docs for each module, or the all-in-one installer 72 | 73 | * All-in-one: [rider-auto-ose-installer](rider-auto-ose-installer/README.md) 74 | * [rider-auto-ws](rider-auto-ws/README.md) 75 | * [rider-auto-file](rider-auto-file/README.md) 76 | * [rider-auto-backend](rider-auto-backend/README.md) 77 | * [rider-auto-normalizer](rider-auto-normalizer/README.md) 78 | 79 | ## Deploy A-MQ 80 | This example uses JBoss A-MQ, so we need to have that running in the same project/namespace as the rider-auto apps (including this module). 81 | To deploy AMQ, follow the [instructions from the xPaaS AMQ documentation](https://docs.openshift.com/enterprise/3.1/using_images/xpaas_images/a_mq.html). On the CDK, you can do this: 82 | 83 | ### Create a template for JBoss A-MQ 84 | 85 | > oc create -f https://raw.githubusercontent.com/openshift/openshift-ansible/master/roles/openshift_examples/files/examples/v1.1/xpaas-templates/amq62-basic.json 86 | > oc process amq62-basic -v APPLICATION_NAME=broker -v MQ_USERNAME=admin -v MQ_PASSWORD=admin 87 | 88 | Or you can use the template i've included in the root of this project: 89 | 90 | > oc create -f amq.json 91 | 92 | ``` 93 | service "broker-amq-tcp" created 94 | deploymentconfig "broker-amq" created 95 | ``` 96 | 97 | Note: as a user of the CDK, you may need cluster-admin rights by using the config file in /var/lib/origin/openshift.local.config/master/admin.kubeconfig. If you copy this to your ~/.kube/config file or set the location to it in $KUBECONFIG environment variable, you should be granted full cluster-admin rights and should be able to create the AMQ image. It is best to first login to the vagrant from your host machine: 98 | 99 | > vagrant ssh 100 | 101 | Then sudo to root 102 | 103 | > sudo -s 104 | 105 | Then login to OpenShift using the "system:admin" superuser on a dedicated admin interface (10.0.2.15): 106 | 107 | > oc login -u system:admin https://10.0.2.15:8443 108 | 109 | Now you can create the AMQ service by running the following command (after copying and pasting the amq.json file to your root directory): 110 | 111 | > oc create -f amq.json 112 | 113 | Note that the user name and password need to be `admin/admin` as that's what the rider-auto-osgi project expects. 114 | 115 | ### Install on a local JBoss Fuse 6.2.1 116 | 117 | $ bin/fuse 118 | 119 | 1) Add this projects features.xml config to Fuse from the Console 120 | (makes it easier to install bundles with all required dependencies) 121 | 122 | > JBossFuse:karaf@root> features:addUrl mvn:org.fusesource.examples/rider-auto-common/5.0-SNAPSHOT/xml/features 123 | 124 | 2) Install the project. 125 | 126 | > JBossFuse:karaf@root> features:install rider-auto-osgi 127 | 128 | 3) To test the file processing, there are existing files in the 129 | rider-auto-common module. 130 | 131 | > $ cp rider-auto-common/src/data/message1.xml /target/placeorder 132 | 133 | To see what happened look at the log file, either from the console 134 | 135 | > JBossFuse:karaf@root> log:display 136 | 137 | or from the command line 138 | 139 | > $ tail -f data/log/fuse.log 140 | 141 | 4) To test the WS, use your favorite WS tool (e.g. SoapUI) against the following 142 | WSDL hosted by the rider-auto-ws bundle. 143 | * http://localhost:8182/cxf/order?wsdl 144 | 145 | Getting Help 146 | ============================ 147 | 148 | If you hit any problems please let the Fuse team know on the forums 149 | [https://community.jboss.org/en/jbossfuse] 150 | -------------------------------------------------------------------------------- /all-in-one-template.json: -------------------------------------------------------------------------------- 1 | { 2 | "apiVersion" : "v1", 3 | "kind" : "Template", 4 | "labels" : { }, 5 | "metadata" : { 6 | "annotations" : { 7 | "description" : "# How to install rider-auto\n\nThe rider-auto app consists of a set of microservices all packaged as Docker containers.\n\n\n## Create new OpenShift project\nFor this demo, we'll want to create a new OpenShift project and install all of the rider-auto microservices there.\n\n> oc new-project rider-auto\n\n## Install Persistent Volume\n\nThe rider-auto-file module will poll for new orders to start processing and it listens to a directory on a file system. In this example, we'll use Kubernetes [Persistent Volumes](http://kubernetes.io/v1.1/docs/user-guide/persistent-volumes.html) and map the location that Camel polls to a HostPath Persistent Volume which we can use to test out that everything works. For example, this is the yaml for the PV:\n \n```\nkind: PersistentVolume\napiVersion: v1\nmetadata:\n name: rider-auto-file-pv\n labels:\n type: local\nspec:\n capacity:\n storage: 100Ki\n accessModes:\n - ReadWriteOnce\n persistentVolumeReclaimPolicy: Recycle\n hostPath:\n path: \"/opt/camel\"\n```\n\n\nThis means that the path on disk \"/opt/camel\" will be the location that we can send files to and have the rider-auto-file pod pick it up and process it.\n\nTo install this HostPath PV, you'll need to be an admin user on the \"rider-auto\" project and try the following:\n\n\n> oc create -f rider-auto-file/src/main/fabric8/vagrant-pv.yaml\n\nAfter doing this, you should double check that it was created properly:\n\n> oc get pv\n\n```\n[root@localhost ~]# oc get pv\nNAME LABELS CAPACITY ACCESSMODES STATUS CLAIM REASON AGE\nrider-auto-file-pv type=local 100Ki RWO Available 4m\n```\n\n## Install AMQ\n\nThe microservices in this project communicate over JMS and use JBoss AMQ. To do this, we should boot up a broker in the `rider-auto` project. In the root of the project, we have a curated `amq.json` file that contains the broker.\n\n> oc create amq.json\n\n## Builder Docker containers\n\nTo run these microservices on openshift, you should build the docker images for each module. See the docs for each module for how to do that.\n\n## Install microservices\n\nFrom the root directory of `rider-auto-ose-installer` project, run:\n\n> mvn clean install fabric8:json fabric8:apply\n\n", 8 | "fabric8.rider-auto-backend/iconUrl" : "https://cdn.rawgit.com/fabric8io/fabric8/master/fabric8-maven-plugin/src/main/resources/icons/camel.svg", 9 | "fabric8.rider-auto-file/iconUrl" : "https://cdn.rawgit.com/fabric8io/fabric8/master/fabric8-maven-plugin/src/main/resources/icons/camel.svg", 10 | "fabric8.rider-auto-normalizer/iconUrl" : "https://cdn.rawgit.com/fabric8io/fabric8/master/fabric8-maven-plugin/src/main/resources/icons/camel.svg", 11 | "fabric8.rider-auto-ws/iconUrl" : "https://cdn.rawgit.com/fabric8io/fabric8/master/fabric8-maven-plugin/src/main/resources/icons/camel.svg" 12 | }, 13 | "labels" : { }, 14 | "name" : "rider-auto-ose-installer" 15 | }, 16 | "objects" : [ { 17 | "apiVersion" : "v1", 18 | "kind" : "Service", 19 | "metadata" : { 20 | "annotations" : { 21 | "prometheus.io/port" : "9779", 22 | "prometheus.io/scrape" : "true" 23 | }, 24 | "labels" : { 25 | "container" : "java", 26 | "component" : "rider-auto-backend", 27 | "provider" : "fabric8", 28 | "project" : "rider-auto-backend", 29 | "version" : "5.0-SNAPSHOT", 30 | "group" : "rider-auto" 31 | }, 32 | "name" : "rider-auto-backend" 33 | }, 34 | "spec" : { 35 | "clusterIP" : "None", 36 | "deprecatedPublicIPs" : [ ], 37 | "externalIPs" : [ ], 38 | "ports" : [ { 39 | "port" : 1 40 | } ], 41 | "selector" : { 42 | "container" : "java", 43 | "project" : "rider-auto-backend", 44 | "component" : "rider-auto-backend", 45 | "provider" : "fabric8", 46 | "group" : "rider-auto" 47 | } 48 | } 49 | }, { 50 | "apiVersion" : "v1", 51 | "kind" : "Service", 52 | "metadata" : { 53 | "annotations" : { 54 | "prometheus.io/port" : "9779", 55 | "prometheus.io/scrape" : "true" 56 | }, 57 | "labels" : { 58 | "container" : "java", 59 | "component" : "rider-auto-file", 60 | "provider" : "fabric8", 61 | "project" : "rider-auto-file", 62 | "version" : "5.0-SNAPSHOT", 63 | "group" : "rider-auto" 64 | }, 65 | "name" : "rider-auto-file" 66 | }, 67 | "spec" : { 68 | "clusterIP" : "None", 69 | "deprecatedPublicIPs" : [ ], 70 | "externalIPs" : [ ], 71 | "ports" : [ { 72 | "port" : 1 73 | } ], 74 | "selector" : { 75 | "container" : "java", 76 | "project" : "rider-auto-file", 77 | "component" : "rider-auto-file", 78 | "provider" : "fabric8", 79 | "group" : "rider-auto" 80 | } 81 | } 82 | }, { 83 | "apiVersion" : "v1", 84 | "kind" : "Service", 85 | "metadata" : { 86 | "annotations" : { 87 | "prometheus.io/port" : "9779", 88 | "prometheus.io/scrape" : "true" 89 | }, 90 | "labels" : { 91 | "container" : "java", 92 | "component" : "rider-auto-normalizer", 93 | "provider" : "fabric8", 94 | "project" : "rider-auto-normalizer", 95 | "version" : "5.0-SNAPSHOT", 96 | "group" : "rider-auto" 97 | }, 98 | "name" : "rider-auto-normalizer" 99 | }, 100 | "spec" : { 101 | "clusterIP" : "None", 102 | "deprecatedPublicIPs" : [ ], 103 | "externalIPs" : [ ], 104 | "ports" : [ { 105 | "port" : 1 106 | } ], 107 | "selector" : { 108 | "container" : "java", 109 | "project" : "rider-auto-normalizer", 110 | "component" : "rider-auto-normalizer", 111 | "provider" : "fabric8", 112 | "group" : "rider-auto" 113 | } 114 | } 115 | }, { 116 | "apiVersion" : "v1", 117 | "kind" : "Service", 118 | "metadata" : { 119 | "annotations" : { 120 | "prometheus.io/port" : "9779", 121 | "prometheus.io/scrape" : "true" 122 | }, 123 | "labels" : { 124 | "container" : "java", 125 | "component" : "rider-auto-ws", 126 | "provider" : "fabric8", 127 | "project" : "rider-auto-ws", 128 | "version" : "5.0-SNAPSHOT", 129 | "group" : "rider-auto" 130 | }, 131 | "name" : "rider-auto-ws" 132 | }, 133 | "spec" : { 134 | "deprecatedPublicIPs" : [ ], 135 | "externalIPs" : [ ], 136 | "ports" : [ { 137 | "port" : 80, 138 | "protocol" : "TCP", 139 | "targetPort" : 8183 140 | } ], 141 | "selector" : { 142 | "container" : "java", 143 | "project" : "rider-auto-ws", 144 | "component" : "rider-auto-ws", 145 | "provider" : "fabric8", 146 | "group" : "rider-auto" 147 | } 148 | } 149 | }, { 150 | "apiVersion" : "v1", 151 | "kind" : "PersistentVolumeClaim", 152 | "metadata" : { 153 | "annotations" : { }, 154 | "labels" : { 155 | "project" : "rider-auto-file", 156 | "component" : "rider-auto-file", 157 | "provider" : "fabric8", 158 | "group" : "rider-auto" 159 | }, 160 | "name" : "rider-auto-file-pvc" 161 | }, 162 | "spec" : { 163 | "accessModes" : [ "ReadWriteOnce" ], 164 | "resources" : { 165 | "limits" : { }, 166 | "requests" : { 167 | "storage" : "100Ki" 168 | } 169 | } 170 | } 171 | }, { 172 | "apiVersion" : "v1", 173 | "kind" : "ReplicationController", 174 | "metadata" : { 175 | "annotations" : { }, 176 | "labels" : { 177 | "container" : "java", 178 | "component" : "rider-auto-backend", 179 | "provider" : "fabric8", 180 | "project" : "rider-auto-backend", 181 | "version" : "5.0-SNAPSHOT", 182 | "group" : "rider-auto" 183 | }, 184 | "name" : "rider-auto-backend" 185 | }, 186 | "spec" : { 187 | "replicas" : 1, 188 | "selector" : { 189 | "container" : "java", 190 | "component" : "rider-auto-backend", 191 | "provider" : "fabric8", 192 | "project" : "rider-auto-backend", 193 | "version" : "5.0-SNAPSHOT", 194 | "group" : "rider-auto" 195 | }, 196 | "template" : { 197 | "metadata" : { 198 | "annotations" : { }, 199 | "labels" : { 200 | "container" : "java", 201 | "component" : "rider-auto-backend", 202 | "provider" : "fabric8", 203 | "project" : "rider-auto-backend", 204 | "version" : "5.0-SNAPSHOT", 205 | "group" : "rider-auto" 206 | } 207 | }, 208 | "spec" : { 209 | "containers" : [ { 210 | "args" : [ ], 211 | "command" : [ ], 212 | "env" : [ { 213 | "name" : "KUBERNETES_NAMESPACE", 214 | "valueFrom" : { 215 | "fieldRef" : { 216 | "fieldPath" : "metadata.namespace" 217 | } 218 | } 219 | } ], 220 | "image" : "fabric8/rider-auto-backend:5.0-SNAPSHOT", 221 | "name" : "rider-auto-backend", 222 | "ports" : [ { 223 | "containerPort" : 8778, 224 | "name" : "jolokia" 225 | } ], 226 | "securityContext" : { }, 227 | "volumeMounts" : [ ] 228 | } ], 229 | "imagePullSecrets" : [ ], 230 | "nodeSelector" : { }, 231 | "volumes" : [ ] 232 | } 233 | } 234 | } 235 | }, { 236 | "apiVersion" : "v1", 237 | "kind" : "ReplicationController", 238 | "metadata" : { 239 | "annotations" : { }, 240 | "labels" : { 241 | "container" : "java", 242 | "component" : "rider-auto-file", 243 | "provider" : "fabric8", 244 | "project" : "rider-auto-file", 245 | "version" : "5.0-SNAPSHOT", 246 | "group" : "rider-auto" 247 | }, 248 | "name" : "rider-auto-file" 249 | }, 250 | "spec" : { 251 | "replicas" : 1, 252 | "selector" : { 253 | "container" : "java", 254 | "component" : "rider-auto-file", 255 | "provider" : "fabric8", 256 | "project" : "rider-auto-file", 257 | "version" : "5.0-SNAPSHOT", 258 | "group" : "rider-auto" 259 | }, 260 | "template" : { 261 | "metadata" : { 262 | "annotations" : { }, 263 | "labels" : { 264 | "container" : "java", 265 | "component" : "rider-auto-file", 266 | "provider" : "fabric8", 267 | "project" : "rider-auto-file", 268 | "version" : "5.0-SNAPSHOT", 269 | "group" : "rider-auto" 270 | } 271 | }, 272 | "spec" : { 273 | "containers" : [ { 274 | "args" : [ ], 275 | "command" : [ ], 276 | "env" : [ { 277 | "name" : "KUBERNETES_NAMESPACE", 278 | "valueFrom" : { 279 | "fieldRef" : { 280 | "fieldPath" : "metadata.namespace" 281 | } 282 | } 283 | } ], 284 | "image" : "fabric8/rider-auto-file:5.0-SNAPSHOT", 285 | "name" : "rider-auto-file", 286 | "ports" : [ { 287 | "containerPort" : 8778, 288 | "name" : "jolokia" 289 | } ], 290 | "securityContext" : { }, 291 | "volumeMounts" : [ { 292 | "mountPath" : "/deployments/target/placeorder", 293 | "name" : "rider-auto-file-volume", 294 | "readOnly" : false 295 | } ] 296 | } ], 297 | "imagePullSecrets" : [ ], 298 | "nodeSelector" : { }, 299 | "volumes" : [ { 300 | "name" : "rider-auto-file-volume", 301 | "persistentVolumeClaim" : { 302 | "claimName" : "rider-auto-file-pvc", 303 | "readOnly" : false 304 | } 305 | } ] 306 | } 307 | } 308 | } 309 | }, { 310 | "apiVersion" : "v1", 311 | "kind" : "ReplicationController", 312 | "metadata" : { 313 | "annotations" : { }, 314 | "labels" : { 315 | "container" : "java", 316 | "component" : "rider-auto-normalizer", 317 | "provider" : "fabric8", 318 | "project" : "rider-auto-normalizer", 319 | "version" : "5.0-SNAPSHOT", 320 | "group" : "rider-auto" 321 | }, 322 | "name" : "rider-auto-normalizer" 323 | }, 324 | "spec" : { 325 | "replicas" : 1, 326 | "selector" : { 327 | "container" : "java", 328 | "component" : "rider-auto-normalizer", 329 | "provider" : "fabric8", 330 | "project" : "rider-auto-normalizer", 331 | "version" : "5.0-SNAPSHOT", 332 | "group" : "rider-auto" 333 | }, 334 | "template" : { 335 | "metadata" : { 336 | "annotations" : { }, 337 | "labels" : { 338 | "container" : "java", 339 | "component" : "rider-auto-normalizer", 340 | "provider" : "fabric8", 341 | "project" : "rider-auto-normalizer", 342 | "version" : "5.0-SNAPSHOT", 343 | "group" : "rider-auto" 344 | } 345 | }, 346 | "spec" : { 347 | "containers" : [ { 348 | "args" : [ ], 349 | "command" : [ ], 350 | "env" : [ { 351 | "name" : "KUBERNETES_NAMESPACE", 352 | "valueFrom" : { 353 | "fieldRef" : { 354 | "fieldPath" : "metadata.namespace" 355 | } 356 | } 357 | } ], 358 | "image" : "fabric8/rider-auto-normalizer:5.0-SNAPSHOT", 359 | "name" : "rider-auto-normalizer", 360 | "ports" : [ { 361 | "containerPort" : 8778, 362 | "name" : "jolokia" 363 | } ], 364 | "securityContext" : { }, 365 | "volumeMounts" : [ ] 366 | } ], 367 | "imagePullSecrets" : [ ], 368 | "nodeSelector" : { }, 369 | "volumes" : [ ] 370 | } 371 | } 372 | } 373 | }, { 374 | "apiVersion" : "v1", 375 | "kind" : "ReplicationController", 376 | "metadata" : { 377 | "annotations" : { }, 378 | "labels" : { 379 | "container" : "java", 380 | "component" : "rider-auto-ws", 381 | "provider" : "fabric8", 382 | "project" : "rider-auto-ws", 383 | "version" : "5.0-SNAPSHOT", 384 | "group" : "rider-auto" 385 | }, 386 | "name" : "rider-auto-ws" 387 | }, 388 | "spec" : { 389 | "replicas" : 1, 390 | "selector" : { 391 | "container" : "java", 392 | "component" : "rider-auto-ws", 393 | "provider" : "fabric8", 394 | "project" : "rider-auto-ws", 395 | "version" : "5.0-SNAPSHOT", 396 | "group" : "rider-auto" 397 | }, 398 | "template" : { 399 | "metadata" : { 400 | "annotations" : { }, 401 | "labels" : { 402 | "container" : "java", 403 | "component" : "rider-auto-ws", 404 | "provider" : "fabric8", 405 | "project" : "rider-auto-ws", 406 | "version" : "5.0-SNAPSHOT", 407 | "group" : "rider-auto" 408 | } 409 | }, 410 | "spec" : { 411 | "containers" : [ { 412 | "args" : [ ], 413 | "command" : [ ], 414 | "env" : [ { 415 | "name" : "KUBERNETES_NAMESPACE", 416 | "valueFrom" : { 417 | "fieldRef" : { 418 | "fieldPath" : "metadata.namespace" 419 | } 420 | } 421 | } ], 422 | "image" : "fabric8/rider-auto-ws:5.0-SNAPSHOT", 423 | "name" : "rider-auto-ws", 424 | "ports" : [ { 425 | "containerPort" : 8183, 426 | "name" : "soap" 427 | }, { 428 | "containerPort" : 8778, 429 | "name" : "jolokia" 430 | } ], 431 | "securityContext" : { }, 432 | "volumeMounts" : [ ] 433 | } ], 434 | "imagePullSecrets" : [ ], 435 | "nodeSelector" : { }, 436 | "volumes" : [ ] 437 | } 438 | } 439 | } 440 | } ], 441 | "parameters" : [ ] 442 | } -------------------------------------------------------------------------------- /amq.json: -------------------------------------------------------------------------------- 1 | { 2 | "kind": "List", 3 | "apiVersion": "v1", 4 | "metadata": {}, 5 | "items": [ 6 | { 7 | "apiVersion": "v1", 8 | "kind": "Service", 9 | "metadata": { 10 | "annotations": { 11 | "description": "The broker's OpenWire port." 12 | }, 13 | "labels": { 14 | "application": "broker", 15 | "template": "amq62-basic", 16 | "xpaas": "1.2.0" 17 | }, 18 | "name": "broker" 19 | }, 20 | "spec": { 21 | "ports": [ 22 | { 23 | "port": 61616, 24 | "targetPort": 61616 25 | } 26 | ], 27 | "selector": { 28 | "deploymentConfig": "broker-amq" 29 | } 30 | } 31 | }, 32 | { 33 | "apiVersion": "v1", 34 | "kind": "DeploymentConfig", 35 | "metadata": { 36 | "labels": { 37 | "application": "broker", 38 | "template": "amq62-basic", 39 | "xpaas": "1.2.0" 40 | }, 41 | "name": "broker-amq" 42 | }, 43 | "spec": { 44 | "replicas": 1, 45 | "selector": { 46 | "deploymentConfig": "broker-amq" 47 | }, 48 | "strategy": { 49 | "type": "Recreate" 50 | }, 51 | "template": { 52 | "metadata": { 53 | "labels": { 54 | "application": "broker", 55 | "deploymentConfig": "broker-amq" 56 | }, 57 | "name": "broker-amq" 58 | }, 59 | "spec": { 60 | "containers": [ 61 | { 62 | "env": [ 63 | { 64 | "name": "AMQ_USER", 65 | "value": "admin" 66 | }, 67 | { 68 | "name": "AMQ_PASSWORD", 69 | "value": "admin" 70 | }, 71 | { 72 | "name": "AMQ_TRANSPORTS", 73 | "value": "openwire" 74 | }, 75 | { 76 | "name": "AMQ_QUEUES", 77 | "value": "" 78 | }, 79 | { 80 | "name": "AMQ_TOPICS", 81 | "value": "" 82 | }, 83 | { 84 | "name": "AMQ_MESH_DISCOVERY_TYPE", 85 | "value": "kube" 86 | }, 87 | { 88 | "name": "AMQ_MESH_SERVICE_NAME", 89 | "value": "broker-amq-tcp" 90 | }, 91 | { 92 | "name": "AMQ_MESH_SERVICE_NAMESPACE", 93 | "valueFrom": { 94 | "fieldRef": { 95 | "fieldPath": "metadata.namespace" 96 | } 97 | } 98 | }, 99 | { 100 | "name": "AMQ_STORAGE_USAGE_LIMIT", 101 | "value": "100 gb" 102 | } 103 | ], 104 | "image": "jboss-amq-62", 105 | "imagePullPolicy": "Always", 106 | "name": "broker-amq", 107 | "ports": [ 108 | { 109 | "containerPort": 8778, 110 | "name": "jolokia", 111 | "protocol": "TCP" 112 | }, 113 | { 114 | "containerPort": 61616, 115 | "name": "tcp", 116 | "protocol": "TCP" 117 | } 118 | ], 119 | "readinessProbe": { 120 | "exec": { 121 | "command": [ 122 | "/bin/bash", 123 | "-c", 124 | "/opt/amq/bin/readinessProbe.sh" 125 | ] 126 | } 127 | } 128 | } 129 | ], 130 | "terminationGracePeriodSeconds": 60 131 | } 132 | }, 133 | "triggers": [ 134 | { 135 | "imageChangeParams": { 136 | "automatic": true, 137 | "containerNames": [ 138 | "broker-amq" 139 | ], 140 | "from": { 141 | "kind": "ImageStreamTag", 142 | "name": "jboss-amq-62:1.2", 143 | "namespace": "openshift" 144 | } 145 | }, 146 | "type": "ImageChange" 147 | }, 148 | { 149 | "type": "ConfigChange" 150 | } 151 | ] 152 | } 153 | } 154 | ] 155 | } 156 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 15 | 4.0.0 16 | 17 | org.fusesource.examples 18 | rider-auto-osgi 19 | 5.0-SNAPSHOT 20 | pom 21 | 22 | Rider Auto OSGi Example 23 | http://fusesource.com 24 | 25 | 26 | rider-auto-common 27 | rider-auto-file 28 | rider-auto-ws 29 | rider-auto-normalizer 30 | rider-auto-backend 31 | rider-auto-ose-installer 32 | rider-auto-rest 33 | 34 | 35 | 36 | 2.2.0.redhat-079 37 | 6.2.1.redhat-084 38 | 2.15.1.redhat-621084 39 | 5.11.0.redhat-621084 40 | 41 | 42 | fabric8/ 43 | ${fabric8.dockerUser}${project.artifactId}:${project.version} 44 | 0.13.6 45 | jboss-fuse-6/fis-java-openshift:1.0 46 | 8778 47 | 2.4.0.redhat-621084 48 | 4.0.2.redhat-621079 49 | 3.0.4 50 | 51 | 52 | 53 | 54 | 55 | io.fabric8 56 | fabric8-project-bom-with-platform-deps 57 | ${fabric8.version} 58 | pom 59 | import 60 | 61 | 62 | org.jboss.fuse.bom 63 | jboss-fuse-parent 64 | ${fuse.version} 65 | pom 66 | import 67 | 68 | 69 | org.fusesource.examples 70 | rider-auto-common 71 | ${project.version} 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | org.apache.maven.plugins 81 | maven-compiler-plugin 82 | 3.3 83 | 84 | 1.8 85 | 1.8 86 | 87 | 88 | 89 | org.apache.maven.plugins 90 | maven-surefire-plugin 91 | 2.4.3 92 | 93 | 94 | org.apache.camel 95 | camel-maven-plugin 96 | ${camel-version} 97 | 98 | 99 | org.apache.felix 100 | maven-bundle-plugin 101 | true 102 | 3.0.1 103 | 104 | 105 | org.codehaus.mojo 106 | build-helper-maven-plugin 107 | 1.10 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | fuse-releases 116 | JBoss Fuse Release Repository 117 | https://repository.jboss.org/nexus/content/repositories/fs-releases/ 118 | 119 | false 120 | 121 | 122 | true 123 | 124 | 125 | 126 | public jboss 127 | JBoss Release Repository 128 | https://repository.jboss.org/nexus/content/groups/public/ 129 | 130 | false 131 | 132 | 133 | true 134 | 135 | 136 | 137 | 138 | 139 | fuse-releases 140 | JBoss Fuse Release Repository 141 | https://repository.jboss.org/nexus/content/repositories/fs-releases/ 142 | 143 | false 144 | 145 | 146 | true 147 | 148 | 149 | 150 | public jboss 151 | JBoss Release Repository 152 | https://repository.jboss.org/nexus/content/groups/public/ 153 | 154 | false 155 | 156 | 157 | true 158 | 159 | 160 | 161 | 162 | 163 | -------------------------------------------------------------------------------- /rider-auto-backend/.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | .settings 3 | .project 4 | .classpath 5 | -------------------------------------------------------------------------------- /rider-auto-backend/README.md: -------------------------------------------------------------------------------- 1 | # Rider Auto Backend Module 2 | 3 | This module is a place holder for a "backend" system of record type module. It really just logs to the developer logs, but you could think of it as a holder for a database or legacy connector. 4 | 5 | 6 | ## Building 7 | 8 | You can build this module with Maven: 9 | 10 | > mvn clean install 11 | 12 | If you'd like to skip tests: 13 | 14 | > mvn clean install -Dtest=false -DfailIfNoTests=false 15 | 16 | ## Running locally 17 | You should be able to run this locally using mvn, and it should work as expected. We highly recommend you test your services out locally before packaging as Docker containers. For this service to run correctly, it's expecting a JBoss-AMQ to be running as well. The jms adapter that we're using in camel can automatically discover the broker endpoint based on environment variables (which is how it will work inside a kubernetes environment). You can opt to run a broker locally and run the broker on 61616 and it should just work. Otherwise, you'll want to set the following environment variables to be able to discover the broker: 18 | 19 | ``` 20 | export BROKER_HOST=127.0.0.1 21 | export BROKER_PORT=61616 22 | ``` 23 | 24 | > mvn camel:run 25 | 26 | You may also want to try the same thing using `mvn exec:java` 27 | 28 | > mvn exec:java 29 | 30 | This will run the app's main file (from [camel-boot](camel-boot)) using the classpath from maven. 31 | 32 | ## Building a docker image 33 | 34 | FIS includes a supported maven plugin for building Docker images from your project. Unless you're running on Linux, you'll need to install a guest VM that has Docker. We recommend the Red Hat [Container Development Kit v2](https://www.redhat.com/en/about/blog/introducing-red-hat-container-development-kit-2-beta) 35 | 36 | For the maven plugin to work, it will need to be able to locate a Docker Daemon (ideally running in a guest-local VM). To do this, you'll want to have the following environment variables set: 37 | 38 | export DOCKER_HOST=tcp://10.1.2.2:2376 39 | export DOCKER_CERT_PATH=/path/to/cdk/.vagrant/machines/default/virtualbox/.docker 40 | export DOCKER_TLS_VERIFY=1 41 | 42 | Note the `DOCKER_HOST` needs to point to the location of the docker daemon, and `DOCKER_CERT_PATH` needs to point to the location of the cert for your docker daemon. 43 | 44 | It would also be great if you had the native docker CLI tools installed on your Host machine (ie your Windows or Mac machine) so you can `docker images` and `docker ps` 45 | 46 | ### Running as camel-boot microservice 47 | 48 | Before we build the docker image, we should specify whether we're going to use [camel-boot][camel-boot] (Plain Old Java Main with flat-classloader) or a Karaf osgi classloader. We recommend building using [camel-boot][camel-boot]. Basically what happens is we zip up the maven classpath and inject a little helper script to run the app using the classpath. This simplifies the deployment so we don't have to guess about which classpath we'll be using; it'll be exactly the same as when you ran locally. 49 | 50 | To do this, run the following command: 51 | 52 | > $ mvn clean install -Pfabric8 -Phawtapp 53 | 54 | (Skip tests can be done with adding `-Dtest=false -DfailIfNoTests=false`) 55 | 56 | After the build you should see the following in the target dir: 57 | 58 | ``` 59 | drwxr-xr-x 6 ceposta staff 204B Feb 1 10:58 classes 60 | drwxr-xr-x 3 ceposta staff 102B Feb 1 10:58 fabric8 61 | drwxr-xr-x 3 ceposta staff 102B Feb 1 10:58 generated-sources 62 | drwxr-xr-x 3 ceposta staff 102B Feb 1 10:58 generated-test-sources 63 | drwxr-xr-x 4 ceposta staff 136B Feb 1 10:58 hawt-app 64 | drwxr-xr-x 3 ceposta staff 102B Feb 1 10:58 maven-status 65 | -rw-r--r-- 1 ceposta staff 47M Feb 1 10:58 rider-auto-backend-5.0-SNAPSHOT-app.tar.gz 66 | -rw-r--r-- 1 ceposta staff 6.8K Feb 1 10:58 rider-auto-backend-5.0-SNAPSHOT.jar 67 | drwxr-xr-x 4 ceposta staff 136B Feb 1 10:58 test-classes 68 | ``` 69 | 70 | Notice the *.tar.gz file (can also generate zip file by setting the hawtapp-maven-plugin archiver to "zip"). 71 | In that zip/tar file, you'll find a completely packed up and ready to run app. For example if you unzip that file, you'll get the following contents: 72 | 73 | ``` 74 | drwxr-xr-x 3 ceposta staff 102B Jan 26 08:39 bin 75 | drwxr-xr-x 200 ceposta staff 6.6K Jan 26 08:39 lib 76 | 77 | ``` 78 | 79 | From that folder, you can run: 80 | 81 | > ./bin/run.sh 82 | 83 | Which should bootstrap the application and run it as a standalone camel-boot app. 84 | 85 | ### Building the camel-boot service as a docker container 86 | 87 | Now that you understand the camel-boot packaging using hawtapp-maven-plugin, we can build a docker container: 88 | 89 | > $ mvn clean install -Pfabric8 -Phawtapp docker:build 90 | 91 | (Skip tests can be done with adding `-Dtest=false -DfailIfNoTests=false`) 92 | 93 | Note, we have to have a working docker daemon available as mentioned above. 94 | 95 | You should end up with output similar to this: 96 | 97 | ``` 98 | [INFO] --- docker-maven-plugin:0.13.6:build (default-cli) @ rider-auto-backend --- 99 | [INFO] Copying files to /Users/ceposta/dev/sandbox/RedHatWorkshops/rider-auto-osgi/rider-auto-backend/target/docker/fabric8/rider-auto-backend/5.0-SNAPSHOT/build/maven 100 | [INFO] Building tar: /Users/ceposta/dev/sandbox/RedHatWorkshops/rider-auto-osgi/rider-auto-backend/target/docker/fabric8/rider-auto-backend/5.0-SNAPSHOT/tmp/docker-build.tar 101 | [INFO] DOCKER> [fabric8/rider-auto-backend:5.0-SNAPSHOT] : Built image 81d921f951c7 102 | [INFO] ------------------------------------------------------------------------ 103 | [INFO] BUILD SUCCESS 104 | [INFO] ------------------------------------------------------------------------ 105 | [INFO] Total time: 21.954 s 106 | [INFO] Finished at: 2016-02-01T11:00:36-07:00 107 | [INFO] Final Memory: 78M/998M 108 | [INFO] ------------------------------------------------------------------------ 109 | 110 | ``` 111 | 112 | Now if you do a `docker images` you should see your new docker image: 113 | 114 | ``` 115 | REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE 116 | fabric8/rider-auto-backend 5.0-SNAPSHOT 81d921f951c7 15 hours ago 485.1 MB 117 | ``` 118 | 119 | You can even try to run you docker container as is and map the ports locally so you can see the service running within the docker image: 120 | 121 | > docker run -it --rm fabric8/rider-auto-backend:5.0-SNAPSHOT 122 | 123 | 124 | Note for that to work, you need an AMQ up and running. Continue on to the next section to see setting that up on OpenShift. 125 | 126 | Yay! You now have your microservice packaged as a docker image ready to go. Let's take a look at what that looks like if you want to build the karaf-based microservice: 127 | 128 | 129 | ### Running as Karaf-based microservice 130 | 131 | We can also convert existing karaf-based deployments over to the FIS deployment model. Just like with the camel-boot option (above) that packages the entire JVM together with its dependencies, we'll be doing that with Karaf. What this means is that your build will _actually produce a completely independent Karaf assembly_ which can then be used to run your application. No more build your app and chuck it into a running Karaf and hope it resolves; now all OSGI resolution is done at build time and the resulting output is a fully baked Karaf distribution with your app inside it. 132 | 133 | Run the following command to do this: 134 | 135 | 136 | > mvn clean install -Pfabric8 -Pkaraf-distro 137 | 138 | (Skip tests can be done with adding `-Dtest=false -DfailIfNoTests=false`) 139 | 140 | That should produce output like this in /target 141 | 142 | ``` 143 | drwxr-xr-x 7 ceposta staff 238B Feb 1 11:02 assembly 144 | drwxr-xr-x 6 ceposta staff 204B Feb 1 11:02 classes 145 | drwxr-xr-x 3 ceposta staff 102B Feb 1 11:02 fabric8 146 | drwxr-xr-x 3 ceposta staff 102B Feb 1 11:02 generated-sources 147 | drwxr-xr-x 3 ceposta staff 102B Feb 1 11:02 generated-test-sources 148 | drwxr-xr-x 3 ceposta staff 102B Feb 1 11:02 maven-status 149 | -rw-r--r-- 1 ceposta staff 6.8K Feb 1 11:02 rider-auto-backend-5.0-SNAPSHOT.jar 150 | -rw-r--r-- 1 ceposta staff 37M Feb 1 11:02 rider-auto-backend-5.0-SNAPSHOT.tar.gz 151 | -rw-r--r-- 1 ceposta staff 37M Feb 1 11:02 rider-auto-backend-5.0-SNAPSHOT.zip 152 | drwxr-xr-x 4 ceposta staff 136B Feb 1 11:02 test-classes 153 | ``` 154 | 155 | 156 | The *.zip file is the fully-baked karaf assembly. If you unzip it, it looks like a Karaf/Fuse distribution as you'd expect: 157 | 158 | ``` 159 | drwxr-xr-x 20 ceposta staff 680B Jan 26 08:58 bin 160 | drwxr-xr-x 3 ceposta staff 102B Jan 26 08:58 data 161 | drwxr-xr-x 45 ceposta staff 1.5K Jan 26 08:58 etc 162 | drwxr-xr-x 13 ceposta staff 442B Jan 26 08:58 lib 163 | drwxr-xr-x 7 ceposta staff 238B Jan 26 08:58 system 164 | ``` 165 | 166 | Can run `./bin/karaf` to boot up the karaf distro. 167 | 168 | 169 | ### Building the karaf-based service as a docker container 170 | 171 | > mvn clean install -Pfabric8 -Pkaraf-distro docker:build 172 | 173 | (Skip tests can be done with adding `-Dtest=false -DfailIfNoTests=false`) 174 | 175 | Note, we have to have a working docker daemon available as mentioned above. 176 | 177 | You should end up with output similar to this: 178 | 179 | ``` 180 | [INFO] 181 | [INFO] --- docker-maven-plugin:0.13.6:build (default-cli) @ rider-auto-backend --- 182 | [INFO] Copying files to /Users/ceposta/dev/sandbox/RedHatWorkshops/rider-auto-osgi/rider-auto-backend/target/docker/fabric8/rider-auto-backend/5.0-SNAPSHOT/build/maven 183 | [INFO] Building tar: /Users/ceposta/dev/sandbox/RedHatWorkshops/rider-auto-osgi/rider-auto-backend/target/docker/fabric8/rider-auto-backend/5.0-SNAPSHOT/tmp/docker-build.tar 184 | [INFO] DOCKER> [fabric8/rider-auto-backend:5.0-SNAPSHOT] : Built image 4464648fcf93 185 | [INFO] ------------------------------------------------------------------------ 186 | [INFO] BUILD SUCCESS 187 | [INFO] ------------------------------------------------------------------------ 188 | [INFO] Total time: 18.200 s 189 | [INFO] Finished at: 2016-02-01T11:06:18-07:00 190 | [INFO] Final Memory: 76M/892M 191 | [INFO] ------------------------------------------------------------------------ 192 | ``` 193 | 194 | Now if you do a `docker images` you should see your new docker image: 195 | 196 | ``` 197 | REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE 198 | fabric8/rider-auto-backend 5.0-SNAPSHOT f140fa83fc04 About a minute ago 491.7 MB 199 | ``` 200 | 201 | You can even try to run you docker container as is and map the ports locally so you can see the service running within the docker image: 202 | 203 | > docker run -it --rm fabric8/rider-auto-backend:5.0-SNAPSHOT 204 | 205 | Note for that to work, we need to have the guest VM map port 8183 to the host VM. 206 | 207 | ## Deploying to OpenShift 208 | 209 | 210 | To deploy into openshift, we need to generate the correct JSON manifest which includes all of our Services, Replication Controllers and Pods. We can [do this a few different ways](http://blog.christianposta.com/typesafe-kubernetes-dsl-for-yaml-json-generation/) but for this module we use the [fabric8 maven plugin](http://fabric8.io/guide/mavenFabric8Json.html). The plugin basically scans the list of maven properties and will generate a Kubernetes json or OpenShift template depending on the properties. 211 | 212 | For example: 213 | 214 | ${project.artifactId} 215 | true 216 | 217 | true 218 | 9779 219 | 220 | ${project.artifactId} 221 | java 222 | rider-auto 223 | camel 224 | 225 | These maven properties will produce a JSON output when you build the project: 226 | 227 | $ mvn clean install 228 | 229 | The location of the `kubernetes.json` file is in `target/classes/kubernetes.json` 230 | 231 | ``` 232 | { 233 | "apiVersion" : "v1", 234 | "kind" : "Template", 235 | "labels" : { }, 236 | "metadata" : { 237 | "annotations" : { 238 | "fabric8.rider-auto-backend/iconUrl" : "https://cdn.rawgit.com/fabric8io/fabric8/master/fabric8-maven-plugin/src/main/resources/icons/camel.svg" 239 | }, 240 | "labels" : { }, 241 | "name" : "rider-auto-backend" 242 | }, 243 | "objects" : [ { 244 | "apiVersion" : "v1", 245 | "kind" : "Service", 246 | "metadata" : { 247 | "annotations" : { 248 | "prometheus.io/port" : "9779", 249 | "prometheus.io/scrape" : "true" 250 | }, 251 | "labels" : { 252 | "container" : "java", 253 | "component" : "rider-auto-backend", 254 | "provider" : "fabric8", 255 | "project" : "rider-auto-backend", 256 | "version" : "5.0-SNAPSHOT", 257 | "group" : "rider-auto" 258 | }, 259 | "name" : "rider-auto-backend" 260 | }, 261 | "spec" : { 262 | "clusterIP" : "None", 263 | "deprecatedPublicIPs" : [ ], 264 | "externalIPs" : [ ], 265 | "ports" : [ { 266 | "port" : 1 267 | } ], 268 | "selector" : { 269 | "container" : "java", 270 | "project" : "rider-auto-backend", 271 | "component" : "rider-auto-backend", 272 | "provider" : "fabric8", 273 | "group" : "rider-auto" 274 | } 275 | } 276 | }, { 277 | "apiVersion" : "v1", 278 | "kind" : "ReplicationController", 279 | "metadata" : { 280 | "annotations" : { }, 281 | "labels" : { 282 | "container" : "java", 283 | "component" : "rider-auto-backend", 284 | "provider" : "fabric8", 285 | "project" : "rider-auto-backend", 286 | "version" : "5.0-SNAPSHOT", 287 | "group" : "rider-auto" 288 | }, 289 | "name" : "rider-auto-backend" 290 | }, 291 | "spec" : { 292 | "replicas" : 1, 293 | "selector" : { 294 | "container" : "java", 295 | "component" : "rider-auto-backend", 296 | "provider" : "fabric8", 297 | "project" : "rider-auto-backend", 298 | "version" : "5.0-SNAPSHOT", 299 | "group" : "rider-auto" 300 | }, 301 | "template" : { 302 | "metadata" : { 303 | "annotations" : { }, 304 | "labels" : { 305 | "container" : "java", 306 | "component" : "rider-auto-backend", 307 | "provider" : "fabric8", 308 | "project" : "rider-auto-backend", 309 | "version" : "5.0-SNAPSHOT", 310 | "group" : "rider-auto" 311 | } 312 | }, 313 | "spec" : { 314 | "containers" : [ { 315 | "args" : [ ], 316 | "command" : [ ], 317 | "env" : [ { 318 | "name" : "KUBERNETES_NAMESPACE", 319 | "valueFrom" : { 320 | "fieldRef" : { 321 | "fieldPath" : "metadata.namespace" 322 | } 323 | } 324 | } ], 325 | "image" : "fabric8/rider-auto-backend:5.0-SNAPSHOT", 326 | "name" : "rider-auto-backend", 327 | "ports" : [ { 328 | "containerPort" : 8778, 329 | "name" : "jolokia" 330 | } ], 331 | "securityContext" : { }, 332 | "volumeMounts" : [ ] 333 | } ], 334 | "imagePullSecrets" : [ ], 335 | "nodeSelector" : { }, 336 | "volumes" : [ ] 337 | } 338 | } 339 | } 340 | } ], 341 | "parameters" : [ ] 342 | } 343 | ``` 344 | 345 | We can take that json and "apply" it to a running OpenShift installation. Note that for this plugin to work, you must 346 | already be logged into openshift with `oc login` and have the following environment variable set: 347 | 348 | ``` 349 | export KUBERNETES_MASTER=https://10.1.2.2:8443 350 | export KUBERNETES_DOMAIN= 351 | export KUBERNETES_TRUST_CERT=true 352 | ``` 353 | 354 | Then you should be able to run the following maven command to deploy: 355 | 356 | 357 | > $ mvn clean install -Pfabric8 fabric8:apply 358 | 359 | Note for this to work, you must have run the `docker:build` previously. Or you can combine all of them: 360 | 361 | > $ mvn clean install -Pfabric8 -Phawtapp docker:build fabric8:apply 362 | 363 | This command assumes everything is running locally (like on the CDK). Otherwise, if deploying to a centralized openshift 364 | installation, you can build the docker image locally, then do `docker:push` to get the image up to OpenShift and then run 365 | the `fabric8:apply` command to deploy the app. 366 | 367 | 368 | ## Deploy A-MQ 369 | This example uses JBoss A-MQ, so we need to have that running in the same project/namespace as the rider-auto apps (including this module). 370 | To deploy AMQ, follow the [instructions from the xPaaS AMQ documentation](https://docs.openshift.com/enterprise/3.1/using_images/xpaas_images/a_mq.html). On the CDK, you can do this: 371 | 372 | ### Create a template for JBoss A-MQ 373 | 374 | > oc create -f https://raw.githubusercontent.com/openshift/openshift-ansible/master/roles/openshift_examples/files/examples/v1.1/xpaas-templates/amq62-basic.json 375 | > oc process amq62-basic -v APPLICATION_NAME=broker -v MQ_USERNAME=admin -v MQ_PASSWORD=admin 376 | 377 | Or you can use the template i've included in the root of this project: 378 | 379 | > oc create -f amq.json 380 | 381 | ``` 382 | service "broker-amq-tcp" created 383 | deploymentconfig "broker-amq" created 384 | ``` 385 | Note that the user name and password need to be `admin/admin` as that's what the rider-auto-osgi project expects. 386 | 387 | 388 | [camel-boot]: http://camel.apache.org/camel-boot.html 389 | -------------------------------------------------------------------------------- /rider-auto-backend/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 24 | 4.0.0 25 | 26 | 27 | org.fusesource.examples 28 | rider-auto-osgi 29 | 5.0-SNAPSHOT 30 | 31 | 32 | rider-auto-backend 33 | bundle 34 | 35 | Rider Auto OSGi Example :: Backend 36 | http://fusesource.com 37 | 38 | 39 | 40 | 41 | 43 | org.jboss.fuse 44 | fuse-karaf-framework 45 | ${fuse.version} 46 | kar 47 | 48 | 49 | 50 | * 51 | * 52 | 53 | 54 | 55 | 56 | org.apache.karaf.assemblies.features 57 | standard 58 | ${karaf.version} 59 | features 60 | xml 61 | 62 | 63 | org.apache.karaf.assemblies.features 64 | enterprise 65 | ${karaf.version} 66 | features 67 | xml 68 | 69 | 70 | org.apache.camel.karaf 71 | apache-camel 72 | ${camel-version} 73 | features 74 | xml 75 | 76 | 77 | org.apache.activemq 78 | activemq-karaf 79 | ${activemq-version} 80 | features 81 | xml 82 | 83 | 84 | org.apache.karaf.features 85 | spring 86 | ${spring.features.version} 87 | features 88 | xml 89 | 90 | 91 | 92 | io.fabric8.mq 93 | camel-amq 94 | 95 | 96 | 97 | org.fusesource.examples 98 | rider-auto-common 99 | 100 | 101 | 102 | 103 | org.apache.camel 104 | camel-spring 105 | runtime 106 | 107 | 108 | 109 | 110 | org.apache.camel 111 | camel-jaxb 112 | runtime 113 | 114 | 115 | 116 | 117 | org.apache.activemq 118 | activemq-camel 119 | runtime 120 | 121 | 122 | 123 | org.slf4j 124 | slf4j-api 125 | runtime 126 | 127 | 128 | 129 | junit 130 | junit 131 | test 132 | 133 | 134 | org.apache.camel 135 | camel-test 136 | test 137 | 138 | 139 | org.apache.camel 140 | camel-test-spring 141 | test 142 | 143 | 144 | org.slf4j 145 | slf4j-simple 146 | test 147 | 148 | 149 | org.apache.activemq 150 | activemq-broker 151 | test 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | org.apache.felix 160 | maven-bundle-plugin 161 | true 162 | 163 | 164 | 165 | org.apache.camel 166 | camel-maven-plugin 167 | 168 | 169 | 170 | org.codehaus.mojo 171 | exec-maven-plugin 172 | 1.4.0 173 | 174 | org.apache.camel.spring.Main 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | fabric8 183 | 184 | true 185 | 186 | 187 | ${project.artifactId} 188 | true 189 | 190 | true 191 | 9779 192 | 193 | 194 | ${project.artifactId} 195 | java 196 | rider-auto 197 | camel 198 | 199 | 200 | 201 | 202 | 203 | 204 | junit 205 | junit 206 | test 207 | 208 | 209 | org.jboss.arquillian.junit 210 | arquillian-junit-container 211 | test 212 | 213 | 214 | io.fabric8 215 | fabric8-arquillian 216 | test 217 | 218 | 219 | org.jboss.shrinkwrap.resolver 220 | shrinkwrap-resolver-impl-maven 221 | test 222 | 223 | 224 | 225 | 226 | 227 | io.fabric8 228 | fabric8-maven-plugin 229 | ${fabric8.version} 230 | 231 | 232 | json 233 | generate-resources 234 | 235 | json 236 | 237 | 238 | 239 | attach 240 | package 241 | 242 | attach 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | karaf-distro 252 | 253 | jboss-fuse-6/fis-karaf-openshift:1.0 254 | 255 | 256 | 257 | 258 | org.apache.karaf.tooling 259 | karaf-maven-plugin 260 | ${karaf.plugin.version} 261 | true 262 | 263 | 264 | karaf-assembly 265 | 266 | assembly 267 | 268 | install 269 | 270 | 271 | karaf-archive 272 | 273 | archive 274 | 275 | install 276 | 277 | 278 | 279 | v24 280 | 1.8 281 | true 282 | 283 | false 284 | 285 | 286 | karaf-framework 287 | shell 288 | jaas 289 | spring 290 | activemq-client 291 | activemq-camel 292 | camel-spring 293 | camel-bindy 294 | 295 | 296 | 297 | mvn:org.apache.karaf.bundle/org.apache.karaf.bundle.core/3.0.4 298 | mvn:io.fabric8.mq/mq-client/2.2.0.redhat-079 299 | mvn:io.fabric8/fabric8-utils/2.2.0.redhat-079 300 | mvn:${project.groupId}/${project.artifactId}/${project.version} 301 | 302 | 303 | 304 | 305 | org.jolokia 306 | docker-maven-plugin 307 | ${docker.maven.plugin.version} 308 | 309 | 310 | 311 | ${docker.image} 312 | 313 | ${docker.from} 314 | 315 | /deployments 316 | jboss:jboss:jboss 317 | 319 | ${project.artifactId} 320 | 321 | 322 | 323 | ${project.build.directory}/${project.artifactId}-${project.version}.tar.gz 324 | / 325 | 326 | 327 | 328 | 329 | 330 | /deployments/deploy-and-run.sh 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | hawtapp 342 | 343 | 344 | 345 | io.fabric8 346 | hawt-app-maven-plugin 347 | ${fabric8.version} 348 | 349 | 350 | hawt-app 351 | 352 | build 353 | 354 | 355 | org.apache.camel.spring.Main 356 | 357 | 358 | 359 | 360 | 361 | org.jolokia 362 | docker-maven-plugin 363 | ${docker.maven.plugin.version} 364 | 365 | 366 | 367 | ${docker.image} 368 | 369 | ${docker.from} 370 | 371 | /deployments 372 | hawt-app 373 | 374 | 375 | /deployments/lib 376 | org.apache.camel.spring.Main 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | -------------------------------------------------------------------------------- /rider-auto-backend/src/main/java/org/fusesource/camel/impl/BackEndImpl.java: -------------------------------------------------------------------------------- 1 | package org.fusesource.camel.impl; 2 | 3 | import org.fusesource.camel.model.Order; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | 7 | public class BackEndImpl { 8 | private static final Logger LOG = LoggerFactory.getLogger(BackEndImpl.class); 9 | 10 | public void doWork(Order order) { 11 | LOG.info("Received order for {} {}s.", order.getAmount(), order.getName()); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /rider-auto-backend/src/main/resources/META-INF/spring/camel-context.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /rider-auto-backend/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | 2 | # 3 | # The logging properties used for eclipse testing, We want to see debug output on the console. 4 | # 5 | log4j.rootLogger=INFO, out 6 | 7 | # uncomment the following line to turn on Camel debugging 8 | #log4j.logger.org.apache.camel=DEBUG 9 | 10 | log4j.logger.org.springframework=WARN 11 | log4j.logger.org.apache.activemq=WARN 12 | 13 | # CONSOLE appender not used by default 14 | log4j.appender.out=org.apache.log4j.ConsoleAppender 15 | log4j.appender.out.layout=org.apache.log4j.PatternLayout 16 | log4j.appender.out.layout.ConversionPattern=[%30.30t] %-30.30c{1} %-5p %m%n 17 | #log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n 18 | -------------------------------------------------------------------------------- /rider-auto-backend/src/test/java/org/fusesource/camel/kubetest/KubernetesIntegrationKT.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005-2015 Red Hat, Inc. 3 | * 4 | * Red Hat licenses this file to you under the Apache License, version 5 | * 2.0 (the "License"); you may not use this file except in compliance 6 | * with the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 13 | * implied. See the License for the specific language governing 14 | * permissions and limitations under the License. 15 | */ 16 | package org.fusesource.camel.kubetest; 17 | 18 | import io.fabric8.arquillian.kubernetes.Session; 19 | import io.fabric8.kubernetes.api.model.Pod; 20 | import io.fabric8.kubernetes.client.KubernetesClient; 21 | import org.assertj.core.api.Condition; 22 | import org.jboss.arquillian.junit.Arquillian; 23 | import org.jboss.arquillian.test.api.ArquillianResource; 24 | import org.junit.Test; 25 | import org.junit.runner.RunWith; 26 | 27 | import static io.fabric8.kubernetes.assertions.Assertions.assertThat; 28 | 29 | @RunWith(Arquillian.class) 30 | public class KubernetesIntegrationKT { 31 | 32 | @ArquillianResource 33 | KubernetesClient client; 34 | 35 | @ArquillianResource 36 | Session session; 37 | 38 | @Test 39 | public void testAppProvisionsRunningPods() throws Exception { 40 | assertThat(client).pods() 41 | .runningStatus() 42 | .filterNamespace(session.getNamespace()) 43 | .haveAtLeast(1, new Condition() { 44 | @Override 45 | public boolean matches(Pod podSchema) { 46 | return true; 47 | } 48 | }); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /rider-auto-common/.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | .settings 3 | .project 4 | .classpath 5 | -------------------------------------------------------------------------------- /rider-auto-common/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 24 | 4.0.0 25 | 26 | 27 | org.fusesource.examples 28 | rider-auto-osgi 29 | 5.0-SNAPSHOT 30 | 31 | 32 | rider-auto-common 33 | bundle 34 | 35 | Rider Auto OSGi Example :: Common 36 | http://fusesource.com 37 | 38 | 39 | 40 | 41 | org.apache.camel 42 | camel-bindy 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | src/main/resources 51 | true 52 | 53 | 54 | 55 | 56 | 57 | 58 | org.apache.felix 59 | maven-bundle-plugin 60 | true 61 | 62 | 63 | 64 | org.codehaus.mojo 65 | build-helper-maven-plugin 66 | 67 | 68 | attach-features-xml 69 | package 70 | 71 | attach-artifact 72 | 73 | 74 | 75 | 76 | target/classes/features.xml 77 | xml 78 | features 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /rider-auto-common/src/data/message1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | motor 4 | 1 5 | -------------------------------------------------------------------------------- /rider-auto-common/src/data/message2.csv: -------------------------------------------------------------------------------- 1 | name,amount 2 | brake pad,2 -------------------------------------------------------------------------------- /rider-auto-common/src/main/java/org/fusesource/camel/model/Order.java: -------------------------------------------------------------------------------- 1 | 2 | package org.fusesource.camel.model; 3 | 4 | import java.io.Serializable; 5 | 6 | import javax.xml.bind.annotation.XmlAccessType; 7 | import javax.xml.bind.annotation.XmlAccessorType; 8 | import javax.xml.bind.annotation.XmlElement; 9 | import javax.xml.bind.annotation.XmlRootElement; 10 | import javax.xml.bind.annotation.XmlType; 11 | 12 | import org.apache.camel.dataformat.bindy.annotation.CsvRecord; 13 | import org.apache.camel.dataformat.bindy.annotation.DataField; 14 | 15 | @XmlAccessorType(XmlAccessType.FIELD) 16 | @XmlType(name = "", propOrder = { 17 | "name", 18 | "amount" 19 | }) 20 | @XmlRootElement(name = "order") 21 | @CsvRecord(separator = ",", skipFirstLine = true) 22 | public class Order implements Serializable { 23 | 24 | private static final long serialVersionUID = 7593349011208666446L; 25 | 26 | @XmlElement(required = true) 27 | @DataField(pos = 1) 28 | protected String name; 29 | 30 | @XmlElement(required = true) 31 | @DataField(pos = 2) 32 | protected int amount; 33 | 34 | /** 35 | * Gets the value of the name property. 36 | * 37 | * @return 38 | * possible object is 39 | * {@link String } 40 | * 41 | */ 42 | public String getName() { 43 | return name; 44 | } 45 | 46 | /** 47 | * Sets the value of the name property. 48 | * 49 | * @param value 50 | * allowed object is 51 | * {@link String } 52 | * 53 | */ 54 | public void setName(String value) { 55 | this.name = value; 56 | } 57 | 58 | /** 59 | * Gets the value of the amount property. 60 | * 61 | */ 62 | public int getAmount() { 63 | return amount; 64 | } 65 | 66 | /** 67 | * Sets the value of the amount property. 68 | * 69 | */ 70 | public void setAmount(int value) { 71 | this.amount = value; 72 | } 73 | 74 | @Override 75 | public boolean equals(Object other) { 76 | if (this == other) { 77 | return true; 78 | } 79 | if (other == null) { 80 | return false; 81 | } 82 | if (this.getClass() != other.getClass()) { 83 | return false; 84 | } 85 | Order that = (Order) other; 86 | return this.name.equals(that.name) && this.amount == that.amount; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /rider-auto-common/src/main/resources/features.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | mvn:org.apache.camel.karaf/apache-camel/${camel-version}/xml/features 5 | mvn:org.apache.activemq/activemq-karaf/${activemq-version}/xml/features 6 | 7 | 8 | camel-core 9 | camel-spring 10 | activemq-camel 11 | camel-jaxb 12 | camel-bindy 13 | camel-cxf 14 | mvn:org.fusesource.examples/rider-auto-common/${project.version} 15 | mvn:org.fusesource.examples/rider-auto-file/${project.version} 16 | mvn:org.fusesource.examples/rider-auto-ws/${project.version} 17 | mvn:org.fusesource.examples/rider-auto-normalizer/${project.version} 18 | mvn:org.fusesource.examples/rider-auto-backend/${project.version} 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /rider-auto-common/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | 2 | # 3 | # The logging properties used for eclipse testing, We want to see debug output on the console. 4 | # 5 | log4j.rootLogger=INFO, out 6 | 7 | # uncomment the following line to turn on Camel debugging 8 | #log4j.logger.org.apache.camel=DEBUG 9 | 10 | log4j.logger.org.springframework=WARN 11 | log4j.logger.org.apache.activemq=WARN 12 | 13 | # CONSOLE appender not used by default 14 | log4j.appender.out=org.apache.log4j.ConsoleAppender 15 | log4j.appender.out.layout=org.apache.log4j.PatternLayout 16 | log4j.appender.out.layout.ConversionPattern=[%30.30t] %-30.30c{1} %-5p %m%n 17 | #log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n 18 | -------------------------------------------------------------------------------- /rider-auto-common/src/main/resources/org/fusesource/camel/model/jaxb.index: -------------------------------------------------------------------------------- 1 | Order -------------------------------------------------------------------------------- /rider-auto-file/.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | .settings 3 | .project 4 | .classpath 5 | -------------------------------------------------------------------------------- /rider-auto-file/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 24 | 4.0.0 25 | 26 | 27 | org.fusesource.examples 28 | rider-auto-osgi 29 | 5.0-SNAPSHOT 30 | 31 | 32 | rider-auto-file 33 | bundle 34 | 35 | Rider Auto OSGi Example :: File Poller 36 | http://fusesource.com 37 | 38 | 39 | 40 | 41 | 43 | org.jboss.fuse 44 | fuse-karaf-framework 45 | ${fuse.version} 46 | kar 47 | 48 | 49 | 50 | * 51 | * 52 | 53 | 54 | 55 | 56 | org.apache.karaf.assemblies.features 57 | standard 58 | ${karaf.version} 59 | features 60 | xml 61 | 62 | 63 | org.apache.karaf.assemblies.features 64 | enterprise 65 | ${karaf.version} 66 | features 67 | xml 68 | 69 | 70 | org.apache.camel.karaf 71 | apache-camel 72 | ${camel-version} 73 | features 74 | xml 75 | 76 | 77 | org.apache.activemq 78 | activemq-karaf 79 | ${activemq-version} 80 | features 81 | xml 82 | 83 | 84 | org.apache.karaf.features 85 | spring 86 | ${spring.features.version} 87 | features 88 | xml 89 | 90 | 91 | 92 | 93 | org.apache.camel 94 | camel-spring 95 | runtime 96 | 97 | 98 | 99 | io.fabric8.mq 100 | camel-amq 101 | 102 | 103 | 104 | 105 | org.apache.activemq 106 | activemq-camel 107 | 108 | 109 | 110 | 111 | org.slf4j 112 | slf4j-api 113 | runtime 114 | 115 | 116 | org.slf4j 117 | slf4j-log4j12 118 | runtime 119 | 120 | 121 | 122 | junit 123 | junit 124 | test 125 | 126 | 127 | org.apache.camel 128 | camel-test 129 | test 130 | 131 | 132 | org.apache.camel 133 | camel-test-spring 134 | test 135 | 136 | 137 | org.slf4j 138 | slf4j-simple 139 | test 140 | 141 | 142 | org.apache.activemq 143 | activemq-broker 144 | test 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | org.apache.felix 153 | maven-bundle-plugin 154 | true 155 | 156 | 157 | 158 | 159 | io.fabric8.mq.camel;version="[2.2,3)" 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | org.apache.camel 168 | camel-maven-plugin 169 | 170 | 171 | 172 | 173 | 174 | org.codehaus.mojo 175 | exec-maven-plugin 176 | 1.4.0 177 | 178 | org.apache.camel.spring.Main 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | kube-generate 187 | 188 | true 189 | 190 | 191 | 192 | 193 | io.fabric8 194 | kubernetes-generator 195 | 196 | 197 | 198 | 199 | 200 | fabric8 201 | 202 | true 203 | 204 | 205 | ${project.artifactId} 206 | true 207 | 208 | true 209 | 9779 210 | 211 | 212 | true 213 | 214 | 215 | false 216 | 217 | ${project.artifactId} 218 | java 219 | rider-auto 220 | camel 221 | 222 | 223 | 224 | 225 | 226 | junit 227 | junit 228 | test 229 | 230 | 231 | org.jboss.arquillian.junit 232 | arquillian-junit-container 233 | test 234 | 235 | 236 | io.fabric8 237 | fabric8-arquillian 238 | test 239 | 240 | 241 | org.jboss.shrinkwrap.resolver 242 | shrinkwrap-resolver-impl-maven 243 | test 244 | 245 | 246 | 247 | 248 | 249 | io.fabric8 250 | fabric8-maven-plugin 251 | ${fabric8.version} 252 | 253 | 254 | json 255 | generate-resources 256 | 257 | json 258 | 259 | 260 | 261 | attach 262 | package 263 | 264 | attach 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | karaf-distro 274 | 275 | jboss-fuse-6/fis-karaf-openshift:1.0 276 | 277 | 278 | 279 | 280 | org.apache.maven.plugins 281 | maven-compiler-plugin 282 | 283 | 284 | **/*ModelProcessor.java 285 | 286 | 287 | **/*KT.java 288 | 289 | 290 | 291 | 292 | org.apache.karaf.tooling 293 | karaf-maven-plugin 294 | ${karaf.plugin.version} 295 | true 296 | 297 | 298 | karaf-assembly 299 | 300 | assembly 301 | 302 | install 303 | 304 | 305 | karaf-archive 306 | 307 | archive 308 | 309 | install 310 | 311 | 312 | 313 | v24 314 | 1.8 315 | true 316 | 317 | false 318 | 319 | 320 | karaf-framework 321 | shell 322 | jaas 323 | spring 324 | activemq-client 325 | activemq-camel 326 | camel-spring 327 | 328 | 329 | 330 | mvn:org.apache.karaf.bundle/org.apache.karaf.bundle.core/3.0.4 331 | mvn:io.fabric8.mq/mq-client/2.2.0.redhat-079 332 | mvn:io.fabric8/fabric8-utils/2.2.0.redhat-079 333 | mvn:${project.groupId}/${project.artifactId}/${project.version} 334 | 335 | 336 | 337 | 338 | org.jolokia 339 | docker-maven-plugin 340 | ${docker.maven.plugin.version} 341 | 342 | 343 | 344 | ${docker.image} 345 | 346 | ${docker.from} 347 | 348 | /deployments 349 | root:root:root 350 | 352 | ${project.artifactId} 353 | 354 | 355 | 356 | ${project.build.directory}/${project.artifactId}-${project.version}.tar.gz 357 | / 358 | 359 | 360 | 361 | 362 | 363 | /deployments/deploy-and-run.sh 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | hawtapp 375 | 376 | 377 | 378 | org.apache.maven.plugins 379 | maven-compiler-plugin 380 | 381 | 382 | **/*ModelProcessor.java 383 | 384 | 385 | **/*KT.java 386 | 387 | 388 | 389 | 390 | io.fabric8 391 | hawt-app-maven-plugin 392 | ${fabric8.version} 393 | 394 | 395 | hawt-app 396 | 397 | build 398 | 399 | 400 | org.apache.camel.spring.Main 401 | 402 | 403 | 404 | 405 | 406 | org.jolokia 407 | docker-maven-plugin 408 | ${docker.maven.plugin.version} 409 | 410 | 411 | 412 | ${docker.image} 413 | 414 | ${docker.from} 415 | 416 | /deployments 417 | root:root:root 418 | hawt-app 419 | 420 | 421 | /deployments/lib 422 | org.apache.camel.spring.Main 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | -------------------------------------------------------------------------------- /rider-auto-file/src/main/fabric8/vagrant-pv.yaml: -------------------------------------------------------------------------------- 1 | kind: PersistentVolume 2 | apiVersion: v1 3 | metadata: 4 | name: rider-auto-file-pv 5 | labels: 6 | type: local 7 | spec: 8 | capacity: 9 | storage: 100Ki 10 | accessModes: 11 | - ReadWriteOnce 12 | persistentVolumeReclaimPolicy: Recycle 13 | hostPath: 14 | path: "/opt/camel" -------------------------------------------------------------------------------- /rider-auto-file/src/main/java/org/fusesource/examples/kube/RiderAutoJsonModelProcessor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | *

9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | *

11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.fusesource.examples.kube; 18 | 19 | import io.fabric8.kubernetes.api.model.*; 20 | import io.fabric8.kubernetes.generator.annotation.KubernetesModelProcessor; 21 | import io.fabric8.openshift.api.model.TemplateBuilder; 22 | 23 | import javax.inject.Named; 24 | import java.util.HashMap; 25 | 26 | /** 27 | * Created by ceposta 28 | * requests = new HashMap<>(); 55 | requests.put("storage", claimSize); 56 | rc.setRequests(requests); 57 | return rc; 58 | } 59 | 60 | public void withPodTemplate(PodTemplateSpecBuilder builder) { 61 | builder.withSpec(builder.getSpec()).editSpec() 62 | .addNewVolume() 63 | .withName("rider-auto-file-volume") 64 | .withPersistentVolumeClaim(getPersistentVolumeClaimSource()) 65 | .endVolume() 66 | .endSpec().build(); 67 | } 68 | 69 | private PersistentVolumeClaimVolumeSource getPersistentVolumeClaimSource() { 70 | PersistentVolumeClaimVolumeSource rc = new PersistentVolumeClaimVolumeSource("rider-auto-file-pvc", false); 71 | return rc; 72 | } 73 | 74 | @Named("rider-auto-file") 75 | public void withVolumeMounts(ContainerBuilder builder) { 76 | builder.withVolumeMounts(new VolumeMount("/deployments/target/placeorder", "rider-auto-file-volume", false)) 77 | .build(); 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /rider-auto-file/src/main/resources/META-INF/spring/camel-context.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /rider-auto-file/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | 2 | # 3 | # The logging properties used for eclipse testing, We want to see debug output on the console. 4 | # 5 | log4j.rootLogger=INFO, out 6 | 7 | # uncomment the following line to turn on Camel debugging 8 | #log4j.logger.org.apache.camel=DEBUG 9 | 10 | log4j.logger.org.springframework=WARN 11 | log4j.logger.org.apache.activemq=WARN 12 | 13 | # CONSOLE appender not used by default 14 | log4j.appender.out=org.apache.log4j.ConsoleAppender 15 | log4j.appender.out.layout=org.apache.log4j.PatternLayout 16 | log4j.appender.out.layout.ConversionPattern=[%30.30t] %-30.30c{1} %-5p %m%n 17 | #log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n 18 | -------------------------------------------------------------------------------- /rider-auto-file/src/test/java/org/fusesource/camel/kubetest/KubernetesIntegrationKT.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005-2015 Red Hat, Inc. 3 | * 4 | * Red Hat licenses this file to you under the Apache License, version 5 | * 2.0 (the "License"); you may not use this file except in compliance 6 | * with the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 13 | * implied. See the License for the specific language governing 14 | * permissions and limitations under the License. 15 | */ 16 | package org.fusesource.camel.kubetest; 17 | 18 | import io.fabric8.arquillian.kubernetes.Session; 19 | import io.fabric8.kubernetes.api.model.Pod; 20 | import io.fabric8.kubernetes.client.KubernetesClient; 21 | import org.assertj.core.api.Condition; 22 | import org.jboss.arquillian.junit.Arquillian; 23 | import org.jboss.arquillian.test.api.ArquillianResource; 24 | import org.junit.Test; 25 | import org.junit.runner.RunWith; 26 | 27 | import static io.fabric8.kubernetes.assertions.Assertions.assertThat; 28 | 29 | @RunWith(Arquillian.class) 30 | public class KubernetesIntegrationKT { 31 | 32 | @ArquillianResource 33 | KubernetesClient client; 34 | 35 | @ArquillianResource 36 | Session session; 37 | 38 | @Test 39 | public void testAppProvisionsRunningPods() throws Exception { 40 | assertThat(client).pods() 41 | .runningStatus() 42 | .filterNamespace(session.getNamespace()) 43 | .haveAtLeast(1, new Condition() { 44 | @Override 45 | public boolean matches(Pod podSchema) { 46 | return true; 47 | } 48 | }); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /rider-auto-normalizer/.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | .settings 3 | .project 4 | .classpath 5 | -------------------------------------------------------------------------------- /rider-auto-normalizer/README.md: -------------------------------------------------------------------------------- 1 | # Rider Auto Normalizer Module 2 | 3 | This module exposes an integration route that takes incoming data and "normalizes" it to a canonical model used by the "backend" of the rider-auto enterprise. If you take a look at the camel context, we can see that it takes "xml" files or "csv" files and uses data formats to transform them into the "canonical model" 4 | 5 | 6 | ## Building 7 | 8 | You can build this module with Maven: 9 | 10 | > mvn clean install 11 | 12 | If you'd like to skip tests: 13 | 14 | > mvn clean install -Dtest=false -DfailIfNoTests=false 15 | 16 | ## Running locally 17 | You should be able to run this locally using mvn, and it should work as expected. We highly recommend you test your services out locally before packaging as Docker containers. For this service to run correctly, it's expecting a JBoss-AMQ to be running as well. The jms adapter that we're using in camel can automatically discover the broker endpoint based on environment variables (which is how it will work inside a kubernetes environment). You can opt to run a broker locally and run the broker on 61616 and it should just work. Otherwise, you'll want to set the following environment variables to be able to discover the broker: 18 | 19 | ``` 20 | export BROKER_HOST=127.0.0.1 21 | export BROKER_PORT=61616 22 | ``` 23 | 24 | > mvn camel:run 25 | 26 | You may also want to try the same thing using `mvn exec:java` 27 | 28 | > mvn exec:java 29 | 30 | This will run the app's main file (from [camel-boot](camel-boot)) using the classpath from maven. 31 | 32 | ## Building a docker image 33 | 34 | FIS includes a supported maven plugin for building Docker images from your project. Unless you're running on Linux, you'll need to install a guest VM that has Docker. We recommend the Red Hat [Container Development Kit v2](https://www.redhat.com/en/about/blog/introducing-red-hat-container-development-kit-2-beta) 35 | 36 | For the maven plugin to work, it will need to be able to locate a Docker Daemon (ideally running in a guest-local VM). To do this, you'll want to have the following environment variables set: 37 | 38 | export DOCKER_HOST=tcp://10.1.2.2:2376 39 | export DOCKER_CERT_PATH=/path/to/cdk/.vagrant/machines/default/virtualbox/.docker 40 | export DOCKER_TLS_VERIFY=1 41 | 42 | Note the `DOCKER_HOST` needs to point to the location of the docker daemon, and `DOCKER_CERT_PATH` needs to point to the location of the cert for your docker daemon. 43 | 44 | It would also be great if you had the native docker CLI tools installed on your Host machine (ie your Windows or Mac machine) so you can `docker images` and `docker ps` 45 | 46 | ### Running as camel-boot microservice 47 | 48 | Before we build the docker image, we should specify whether we're going to use [camel-boot][camel-boot] (Plain Old Java Main with flat-classloader) or a Karaf osgi classloader. We recommend building using [camel-boot][camel-boot]. Basically what happens is we zip up the maven classpath and inject a little helper script to run the app using the classpath. This simplifies the deployment so we don't have to guess about which classpath we'll be using; it'll be exactly the same as when you ran locally. 49 | 50 | To do this, run the following command: 51 | 52 | > $ mvn clean install -Pfabric8 -Phawtapp 53 | 54 | (Skip tests can be done with adding `-Dtest=false -DfailIfNoTests=false`) 55 | 56 | After the build you should see the following in the target dir: 57 | 58 | ``` 59 | drwxr-xr-x 6 ceposta staff 204B Feb 1 10:40 classes 60 | drwxr-xr-x 3 ceposta staff 102B Feb 1 10:40 fabric8 61 | drwxr-xr-x 3 ceposta staff 102B Feb 1 10:40 generated-sources 62 | drwxr-xr-x 3 ceposta staff 102B Feb 1 10:40 generated-test-sources 63 | drwxr-xr-x 4 ceposta staff 136B Feb 1 10:40 hawt-app 64 | drwxr-xr-x 3 ceposta staff 102B Feb 1 10:40 maven-status 65 | -rw-r--r-- 1 ceposta staff 47M Feb 1 10:40 rider-auto-normalizer-5.0-SNAPSHOT-app.tar.gz 66 | -rw-r--r-- 1 ceposta staff 8.1K Feb 1 10:40 rider-auto-normalizer-5.0-SNAPSHOT.jar 67 | drwxr-xr-x 4 ceposta staff 136B Feb 1 10:40 test-classes 68 | ``` 69 | 70 | Notice the *.tar.gz file (can also generate zip file by setting the hawtapp-maven-plugin archiver to "zip"). 71 | In that zip/tar file, you'll find a completely packed up and ready to run app. For example if you unzip that file, you'll get the following contents: 72 | 73 | ``` 74 | drwxr-xr-x 3 ceposta staff 102B Jan 26 08:39 bin 75 | drwxr-xr-x 200 ceposta staff 6.6K Jan 26 08:39 lib 76 | 77 | ``` 78 | 79 | From that folder, you can run: 80 | 81 | > ./bin/run.sh 82 | 83 | Which should bootstrap the application and run it as a standalone camel-boot app. 84 | 85 | ### Building the camel-boot service as a docker container 86 | 87 | Now that you understand the camel-boot packaging using hawtapp-maven-plugin, we can build a docker container: 88 | 89 | > $ mvn clean install -Pfabric8 -Phawtapp docker:build 90 | 91 | (Skip tests can be done with adding `-Dtest=false -DfailIfNoTests=false`) 92 | 93 | Note, we have to have a working docker daemon available as mentioned above. 94 | 95 | You should end up with output similar to this: 96 | 97 | ``` 98 | [INFO] --- docker-maven-plugin:0.13.6:build (default-cli) @ rider-auto-normalizer --- 99 | [INFO] Copying files to /Users/ceposta/dev/sandbox/RedHatWorkshops/rider-auto-osgi/rider-auto-normalizer/target/docker/fabric8/rider-auto-normalizer/5.0-SNAPSHOT/build/maven 100 | [INFO] Building tar: /Users/ceposta/dev/sandbox/RedHatWorkshops/rider-auto-osgi/rider-auto-normalizer/target/docker/fabric8/rider-auto-normalizer/5.0-SNAPSHOT/tmp/docker-build.tar 101 | [INFO] DOCKER> [fabric8/rider-auto-normalizer:5.0-SNAPSHOT] : Built image 9e03d8ec338e 102 | [INFO] ------------------------------------------------------------------------ 103 | [INFO] BUILD SUCCESS 104 | [INFO] ------------------------------------------------------------------------ 105 | [INFO] Total time: 20.194 s 106 | [INFO] Finished at: 2016-02-01T10:43:41-07:00 107 | [INFO] Final Memory: 79M/1006M 108 | [INFO] ------------------------------------------------------------------------ 109 | 110 | ``` 111 | 112 | Now if you do a `docker images` you should see your new docker image: 113 | 114 | ``` 115 | REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE 116 | fabric8/rider-auto-normalizer 5.0-SNAPSHOT 9e03d8ec338e 15 hours ago 485.1 MB 117 | ``` 118 | 119 | You can even try to run you docker container as is and map the ports locally so you can see the service running within the docker image: 120 | 121 | > docker run -it --rm fabric8/rider-auto-normalizer:5.0-SNAPSHOT 122 | 123 | 124 | Note for that to work, you need an AMQ up and running. Continue on to the next section to see setting that up on OpenShift. 125 | 126 | Yay! You now have your microservice packaged as a docker image ready to go. Let's take a look at what that looks like if you want to build the karaf-based microservice: 127 | 128 | 129 | ### Running as Karaf-based microservice 130 | 131 | We can also convert existing karaf-based deployments over to the FIS deployment model. Just like with the camel-boot option (above) that packages the entire JVM together with its dependencies, we'll be doing that with Karaf. What this means is that your build will _actually produce a completely independent Karaf assembly_ which can then be used to run your application. No more build your app and chuck it into a running Karaf and hope it resolves; now all OSGI resolution is done at build time and the resulting output is a fully baked Karaf distribution with your app inside it. 132 | 133 | Run the following command to do this: 134 | 135 | 136 | > mvn clean install -Pfabric8 -Pkaraf-distro 137 | 138 | (Skip tests can be done with adding `-Dtest=false -DfailIfNoTests=false`) 139 | 140 | That should produce output like this in /target 141 | 142 | ``` 143 | drwxr-xr-x 7 ceposta staff 238B Feb 1 10:46 assembly 144 | drwxr-xr-x 6 ceposta staff 204B Feb 1 10:46 classes 145 | drwxr-xr-x 3 ceposta staff 102B Feb 1 10:46 fabric8 146 | drwxr-xr-x 3 ceposta staff 102B Feb 1 10:46 generated-sources 147 | drwxr-xr-x 3 ceposta staff 102B Feb 1 10:46 generated-test-sources 148 | drwxr-xr-x 3 ceposta staff 102B Feb 1 10:46 maven-status 149 | -rw-r--r-- 1 ceposta staff 8.1K Feb 1 10:46 rider-auto-normalizer-5.0-SNAPSHOT.jar 150 | -rw-r--r-- 1 ceposta staff 37M Feb 1 10:46 rider-auto-normalizer-5.0-SNAPSHOT.tar.gz 151 | -rw-r--r-- 1 ceposta staff 37M Feb 1 10:46 rider-auto-normalizer-5.0-SNAPSHOT.zip 152 | drwxr-xr-x 4 ceposta staff 136B Feb 1 10:46 test-classes 153 | ``` 154 | 155 | 156 | The *.zip file is the fully-baked karaf assembly. If you unzip it, it looks like a Karaf/Fuse distribution as you'd expect: 157 | 158 | ``` 159 | drwxr-xr-x 20 ceposta staff 680B Jan 26 08:58 bin 160 | drwxr-xr-x 3 ceposta staff 102B Jan 26 08:58 data 161 | drwxr-xr-x 45 ceposta staff 1.5K Jan 26 08:58 etc 162 | drwxr-xr-x 13 ceposta staff 442B Jan 26 08:58 lib 163 | drwxr-xr-x 7 ceposta staff 238B Jan 26 08:58 system 164 | ``` 165 | 166 | Can run `./bin/karaf` to boot up the karaf distro. 167 | 168 | 169 | ### Building the karaf-based service as a docker container 170 | 171 | > mvn clean install -Pfabric8 -Pkaraf-distro docker:build 172 | 173 | (Skip tests can be done with adding `-Dtest=false -DfailIfNoTests=false`) 174 | 175 | Note, we have to have a working docker daemon available as mentioned above. 176 | 177 | You should end up with output similar to this: 178 | 179 | ``` 180 | [INFO] 181 | [INFO] --- docker-maven-plugin:0.13.6:build (default-cli) @ rider-auto-ws --- 182 | [INFO] Copying files to /Users/ceposta/dev/sandbox/RedHatWorkshops/rider-auto-osgi/rider-auto-ws/target/docker/fabric8/rider-auto-ws/5.0-SNAPSHOT/build/maven 183 | [INFO] Building tar: /Users/ceposta/dev/sandbox/RedHatWorkshops/rider-auto-osgi/rider-auto-ws/target/docker/fabric8/rider-auto-ws/5.0-SNAPSHOT/tmp/docker-build.tar 184 | [INFO] DOCKER> [fabric8/rider-auto-ws:5.0-SNAPSHOT] : Built image f140fa83fc04 185 | [INFO] ------------------------------------------------------------------------ 186 | [INFO] BUILD SUCCESS 187 | [INFO] ------------------------------------------------------------------------ 188 | [INFO] Total time: 20.133 s 189 | [INFO] Finished at: 2016-01-26T08:45:53-07:00 190 | [INFO] Final Memory: 79M/889M 191 | [INFO] ------------------------------------------------------------------------ 192 | ``` 193 | 194 | Now if you do a `docker images` you should see your new docker image: 195 | 196 | ``` 197 | ceposta@postamac(rider-auto-ws (fis-enable)) $ docker images 198 | REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE 199 | fabric8/rider-auto-ws 5.0-SNAPSHOT f140fa83fc04 About a minute ago 491.7 MB 200 | ``` 201 | 202 | You can even try to run you docker container as is and map the ports locally so you can see the service running within the docker image: 203 | 204 | > docker run -it --rm fabric8/rider-auto-normalizer:5.0-SNAPSHOT 205 | 206 | Note for that to work, we need to have the guest VM map port 8183 to the host VM. 207 | 208 | ## Deploying to OpenShift 209 | 210 | 211 | To deploy into openshift, we need to generate the correct JSON manifest which includes all of our Services, Replication Controllers and Pods. We can [do this a few different ways](http://blog.christianposta.com/typesafe-kubernetes-dsl-for-yaml-json-generation/) but for this module we use the [fabric8 maven plugin](http://fabric8.io/guide/mavenFabric8Json.html). The plugin basically scans the list of maven properties and will generate a Kubernetes json or OpenShift template depending on the properties. 212 | 213 | For example: 214 | 215 | ${project.artifactId} 216 | true 217 | 218 | true 219 | 9779 220 | 221 | ${project.artifactId} 222 | java 223 | rider-auto 224 | camel 225 | 226 | These maven properties will produce a JSON output when you build the project: 227 | 228 | $ mvn clean install 229 | 230 | The location of the `kubernetes.json` file is in `target/classes/kubernetes.json` 231 | 232 | ``` 233 | { 234 | "apiVersion" : "v1", 235 | "kind" : "Template", 236 | "labels" : { }, 237 | "metadata" : { 238 | "annotations" : { 239 | "fabric8.rider-auto-normalizer/iconUrl" : "https://cdn.rawgit.com/fabric8io/fabric8/master/fabric8-maven-plugin/src/main/resources/icons/camel.svg" 240 | }, 241 | "labels" : { }, 242 | "name" : "rider-auto-normalizer" 243 | }, 244 | "objects" : [ { 245 | "apiVersion" : "v1", 246 | "kind" : "Service", 247 | "metadata" : { 248 | "annotations" : { 249 | "prometheus.io/port" : "9779", 250 | "prometheus.io/scrape" : "true" 251 | }, 252 | "labels" : { 253 | "container" : "java", 254 | "component" : "rider-auto-normalizer", 255 | "provider" : "fabric8", 256 | "project" : "rider-auto-normalizer", 257 | "version" : "5.0-SNAPSHOT", 258 | "group" : "rider-auto" 259 | }, 260 | "name" : "rider-auto-normalizer" 261 | }, 262 | "spec" : { 263 | "clusterIP" : "None", 264 | "deprecatedPublicIPs" : [ ], 265 | "externalIPs" : [ ], 266 | "ports" : [ { 267 | "port" : 1 268 | } ], 269 | "selector" : { 270 | "container" : "java", 271 | "project" : "rider-auto-normalizer", 272 | "component" : "rider-auto-normalizer", 273 | "provider" : "fabric8", 274 | "group" : "rider-auto" 275 | } 276 | } 277 | }, { 278 | "apiVersion" : "v1", 279 | "kind" : "ReplicationController", 280 | "metadata" : { 281 | "annotations" : { }, 282 | "labels" : { 283 | "container" : "java", 284 | "component" : "rider-auto-normalizer", 285 | "provider" : "fabric8", 286 | "project" : "rider-auto-normalizer", 287 | "version" : "5.0-SNAPSHOT", 288 | "group" : "rider-auto" 289 | }, 290 | "name" : "rider-auto-normalizer" 291 | }, 292 | "spec" : { 293 | "replicas" : 1, 294 | "selector" : { 295 | "container" : "java", 296 | "component" : "rider-auto-normalizer", 297 | "provider" : "fabric8", 298 | "project" : "rider-auto-normalizer", 299 | "version" : "5.0-SNAPSHOT", 300 | "group" : "rider-auto" 301 | }, 302 | "template" : { 303 | "metadata" : { 304 | "annotations" : { }, 305 | "labels" : { 306 | "container" : "java", 307 | "component" : "rider-auto-normalizer", 308 | "provider" : "fabric8", 309 | "project" : "rider-auto-normalizer", 310 | "version" : "5.0-SNAPSHOT", 311 | "group" : "rider-auto" 312 | } 313 | }, 314 | "spec" : { 315 | "containers" : [ { 316 | "args" : [ ], 317 | "command" : [ ], 318 | "env" : [ { 319 | "name" : "KUBERNETES_NAMESPACE", 320 | "valueFrom" : { 321 | "fieldRef" : { 322 | "fieldPath" : "metadata.namespace" 323 | } 324 | } 325 | } ], 326 | "image" : "fabric8/rider-auto-normalizer:5.0-SNAPSHOT", 327 | "name" : "rider-auto-normalizer", 328 | "ports" : [ { 329 | "containerPort" : 8778, 330 | "name" : "jolokia" 331 | } ], 332 | "securityContext" : { }, 333 | "volumeMounts" : [ ] 334 | } ], 335 | "imagePullSecrets" : [ ], 336 | "nodeSelector" : { }, 337 | "volumes" : [ ] 338 | } 339 | } 340 | } 341 | } ], 342 | "parameters" : [ ] 343 | } 344 | ``` 345 | 346 | We can take that json and "apply" it to a running OpenShift installation. Note that for this plugin to work, you must 347 | already be logged into openshift with `oc login` and have the following environment variable set: 348 | 349 | ``` 350 | export KUBERNETES_MASTER=https://10.1.2.2:8443 351 | export KUBERNETES_DOMAIN= 352 | export KUBERNETES_TRUST_CERT=true 353 | ``` 354 | 355 | Then you should be able to run the following maven command to deploy: 356 | 357 | 358 | > $ mvn clean install -Pfabric8 fabric8:apply 359 | 360 | Note for this to work, you must have run the `docker:build` previously. Or you can combine all of them: 361 | 362 | > $ mvn clean install -Pfabric8 -Phawtapp docker:build fabric8:apply 363 | 364 | This command assumes everything is running locally (like on the CDK). Otherwise, if deploying to a centralized openshift 365 | installation, you can build the docker image locally, then do `docker:push` to get the image up to OpenShift and then run 366 | the `fabric8:apply` command to deploy the app. 367 | 368 | 369 | ## Deploy A-MQ 370 | This example uses JBoss A-MQ, so we need to have that running in the same project/namespace as the rider-auto apps (including this module). 371 | To deploy AMQ, follow the [instructions from the xPaaS AMQ documentation](https://docs.openshift.com/enterprise/3.1/using_images/xpaas_images/a_mq.html). On the CDK, you can do this: 372 | 373 | ### Create a template for JBoss A-MQ 374 | 375 | > oc create -f https://raw.githubusercontent.com/openshift/openshift-ansible/master/roles/openshift_examples/files/examples/v1.1/xpaas-templates/amq62-basic.json 376 | > oc process amq62-basic -v APPLICATION_NAME=broker -v MQ_USERNAME=admin -v MQ_PASSWORD=admin 377 | 378 | Or you can use the template i've included in the root of this project: 379 | 380 | > oc create -f amq.json 381 | 382 | ``` 383 | service "broker-amq-tcp" created 384 | deploymentconfig "broker-amq" created 385 | ``` 386 | Note that the user name and password need to be `admin/admin` as that's what the rider-auto-osgi project expects. 387 | 388 | 389 | [camel-boot]: http://camel.apache.org/camel-boot.html 390 | -------------------------------------------------------------------------------- /rider-auto-normalizer/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 24 | 4.0.0 25 | 26 | 27 | org.fusesource.examples 28 | rider-auto-osgi 29 | 5.0-SNAPSHOT 30 | 31 | 32 | rider-auto-normalizer 33 | bundle 34 | 35 | Rider Auto OSGi Example :: Normalizer 36 | http://fusesource.com 37 | 38 | 39 | 40 | 41 | 43 | org.jboss.fuse 44 | fuse-karaf-framework 45 | ${fuse.version} 46 | kar 47 | 48 | 49 | 50 | * 51 | * 52 | 53 | 54 | 55 | 56 | org.apache.karaf.assemblies.features 57 | standard 58 | ${karaf.version} 59 | features 60 | xml 61 | 62 | 63 | org.apache.karaf.assemblies.features 64 | enterprise 65 | ${karaf.version} 66 | features 67 | xml 68 | 69 | 70 | org.apache.camel.karaf 71 | apache-camel 72 | ${camel-version} 73 | features 74 | xml 75 | 76 | 77 | org.apache.activemq 78 | activemq-karaf 79 | ${activemq-version} 80 | features 81 | xml 82 | 83 | 84 | org.apache.karaf.features 85 | spring 86 | ${spring.features.version} 87 | features 88 | xml 89 | 90 | 91 | 92 | io.fabric8.mq 93 | camel-amq 94 | 95 | 96 | 97 | org.fusesource.examples 98 | rider-auto-common 99 | 100 | 101 | 102 | org.apache.camel 103 | camel-core 104 | 105 | 106 | 107 | 108 | org.apache.camel 109 | camel-spring 110 | runtime 111 | 112 | 113 | 114 | 115 | org.apache.activemq 116 | activemq-camel 117 | runtime 118 | 119 | 120 | 121 | 122 | org.apache.camel 123 | camel-jaxb 124 | runtime 125 | 126 | 127 | 128 | 129 | org.apache.camel 130 | camel-bindy 131 | runtime 132 | 133 | 134 | 135 | org.slf4j 136 | slf4j-api 137 | runtime 138 | 139 | 140 | 141 | junit 142 | junit 143 | test 144 | 145 | 146 | org.apache.camel 147 | camel-test 148 | test 149 | 150 | 151 | org.apache.camel 152 | camel-test-spring 153 | test 154 | 155 | 156 | org.slf4j 157 | slf4j-simple 158 | test 159 | 160 | 161 | org.apache.activemq 162 | activemq-broker 163 | test 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | org.apache.felix 173 | maven-bundle-plugin 174 | true 175 | 176 | 177 | org.fusesource.camel.model, * 178 | !org.fusesource.camel.util 179 | 180 | 181 | 182 | 183 | 184 | 185 | org.apache.camel 186 | camel-maven-plugin 187 | 188 | 189 | 190 | org.codehaus.mojo 191 | exec-maven-plugin 192 | 1.4.0 193 | 194 | org.apache.camel.spring.Main 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | fabric8 203 | 204 | true 205 | 206 | 207 | ${project.artifactId} 208 | true 209 | 210 | true 211 | 9779 212 | 213 | 214 | ${project.artifactId} 215 | java 216 | rider-auto 217 | camel 218 | 219 | 220 | 221 | 222 | 223 | 224 | junit 225 | junit 226 | test 227 | 228 | 229 | org.jboss.arquillian.junit 230 | arquillian-junit-container 231 | test 232 | 233 | 234 | io.fabric8 235 | fabric8-arquillian 236 | test 237 | 238 | 239 | org.jboss.shrinkwrap.resolver 240 | shrinkwrap-resolver-impl-maven 241 | test 242 | 243 | 244 | 245 | 246 | 247 | io.fabric8 248 | fabric8-maven-plugin 249 | ${fabric8.version} 250 | 251 | 252 | json 253 | generate-resources 254 | 255 | json 256 | 257 | 258 | 259 | attach 260 | package 261 | 262 | attach 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | karaf-distro 272 | 273 | jboss-fuse-6/fis-karaf-openshift:1.0 274 | 275 | 276 | 277 | 278 | org.apache.karaf.tooling 279 | karaf-maven-plugin 280 | ${karaf.plugin.version} 281 | true 282 | 283 | 284 | karaf-assembly 285 | 286 | assembly 287 | 288 | install 289 | 290 | 291 | karaf-archive 292 | 293 | archive 294 | 295 | install 296 | 297 | 298 | 299 | v24 300 | 1.8 301 | true 302 | 303 | false 304 | 305 | 306 | karaf-framework 307 | shell 308 | jaas 309 | spring 310 | camel-spring 311 | camel-jaxb 312 | camel-bindy 313 | activemq-client 314 | activemq-camel 315 | 316 | 317 | 318 | mvn:org.apache.karaf.bundle/org.apache.karaf.bundle.core/3.0.4 319 | mvn:io.fabric8.mq/mq-client/2.2.0.redhat-079 320 | mvn:io.fabric8/fabric8-utils/2.2.0.redhat-079 321 | mvn:${project.groupId}/${project.artifactId}/${project.version} 322 | 323 | 324 | 325 | 326 | org.jolokia 327 | docker-maven-plugin 328 | ${docker.maven.plugin.version} 329 | 330 | 331 | 332 | ${docker.image} 333 | 334 | ${docker.from} 335 | 336 | /deployments 337 | jboss:jboss:jboss 338 | 340 | ${project.artifactId} 341 | 342 | 343 | 344 | ${project.build.directory}/${project.artifactId}-${project.version}.tar.gz 345 | / 346 | 347 | 348 | 349 | 350 | 351 | /deployments/deploy-and-run.sh 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | hawtapp 363 | 364 | 365 | 366 | io.fabric8 367 | hawt-app-maven-plugin 368 | ${fabric8.version} 369 | 370 | 371 | hawt-app 372 | 373 | build 374 | 375 | 376 | org.apache.camel.spring.Main 377 | 378 | 379 | 380 | 381 | 382 | org.jolokia 383 | docker-maven-plugin 384 | ${docker.maven.plugin.version} 385 | 386 | 387 | 388 | ${docker.image} 389 | 390 | ${docker.from} 391 | 392 | /deployments 393 | hawt-app 394 | 395 | 396 | /deployments/lib 397 | org.apache.camel.spring.Main 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | -------------------------------------------------------------------------------- /rider-auto-normalizer/src/main/java/org/fusesource/camel/util/OrderConverter.java: -------------------------------------------------------------------------------- 1 | package org.fusesource.camel.util; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Map; 5 | import java.util.Map.Entry; 6 | 7 | import org.apache.camel.Converter; 8 | import org.fusesource.camel.model.Order; 9 | 10 | @Converter 11 | public class OrderConverter { 12 | 13 | @Converter 14 | public static Order toOrder(ArrayList> csvOrder) { 15 | Order order = null; 16 | Map map = csvOrder.get(0); 17 | for (Entry entry : map.entrySet()) { 18 | order = (Order) entry.getValue(); 19 | break; 20 | } 21 | return order; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /rider-auto-normalizer/src/main/resources/META-INF/services/org/apache/camel/TypeConverter: -------------------------------------------------------------------------------- 1 | org.fusesource.camel.util -------------------------------------------------------------------------------- /rider-auto-normalizer/src/main/resources/META-INF/spring/camel-context.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | ${header.CamelFileName} regex '^.*xml$' 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | ${header.CamelFileName} regex '^.*(csv|csl)$' 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /rider-auto-normalizer/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | 2 | # 3 | # The logging properties used for eclipse testing, We want to see debug output on the console. 4 | # 5 | log4j.rootLogger=INFO, out 6 | 7 | # uncomment the following line to turn on Camel debugging 8 | #log4j.logger.org.apache.camel=DEBUG 9 | 10 | log4j.logger.org.springframework=WARN 11 | log4j.logger.org.apache.activemq=WARN 12 | 13 | # CONSOLE appender not used by default 14 | log4j.appender.out=org.apache.log4j.ConsoleAppender 15 | log4j.appender.out.layout=org.apache.log4j.PatternLayout 16 | log4j.appender.out.layout.ConversionPattern=[%30.30t] %-30.30c{1} %-5p %m%n 17 | #log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n 18 | -------------------------------------------------------------------------------- /rider-auto-normalizer/src/test/java/org/fusesource/camel/kubetest/KubernetesIntegrationKT.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005-2015 Red Hat, Inc. 3 | * 4 | * Red Hat licenses this file to you under the Apache License, version 5 | * 2.0 (the "License"); you may not use this file except in compliance 6 | * with the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 13 | * implied. See the License for the specific language governing 14 | * permissions and limitations under the License. 15 | */ 16 | package org.fusesource.camel.kubetest; 17 | 18 | import io.fabric8.arquillian.kubernetes.Session; 19 | import io.fabric8.kubernetes.api.model.Pod; 20 | import io.fabric8.kubernetes.client.KubernetesClient; 21 | import org.assertj.core.api.Condition; 22 | import org.jboss.arquillian.junit.Arquillian; 23 | import org.jboss.arquillian.test.api.ArquillianResource; 24 | import org.junit.Test; 25 | import org.junit.runner.RunWith; 26 | 27 | import static io.fabric8.kubernetes.assertions.Assertions.assertThat; 28 | 29 | @RunWith(Arquillian.class) 30 | public class KubernetesIntegrationKT { 31 | 32 | @ArquillianResource 33 | KubernetesClient client; 34 | 35 | @ArquillianResource 36 | Session session; 37 | 38 | @Test 39 | public void testAppProvisionsRunningPods() throws Exception { 40 | assertThat(client).pods() 41 | .runningStatus() 42 | .filterNamespace(session.getNamespace()) 43 | .haveAtLeast(1, new Condition() { 44 | @Override 45 | public boolean matches(Pod podSchema) { 46 | return true; 47 | } 48 | }); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /rider-auto-ose-installer/README.md: -------------------------------------------------------------------------------- 1 | # How to install rider-auto 2 | 3 | The rider-auto app consists of a set of microservices all packaged as Docker containers. 4 | 5 | 6 | ## Create new OpenShift project 7 | For this demo, we'll want to create a new OpenShift project and install all of the rider-auto microservices there. 8 | 9 | > oc new-project rider-auto 10 | 11 | ## Install Persistent Volume 12 | 13 | The rider-auto-file module will poll for new orders to start processing and it listens to a directory on a file system. In this example, we'll use Kubernetes [Persistent Volumes](http://kubernetes.io/v1.1/docs/user-guide/persistent-volumes.html) and map the location that Camel polls to a HostPath Persistent Volume which we can use to test out that everything works. For example, this is the yaml for the PV: 14 | 15 | ``` 16 | kind: PersistentVolume 17 | apiVersion: v1 18 | metadata: 19 | name: rider-auto-file-pv 20 | labels: 21 | type: local 22 | spec: 23 | capacity: 24 | storage: 100Ki 25 | accessModes: 26 | - ReadWriteOnce 27 | persistentVolumeReclaimPolicy: Recycle 28 | hostPath: 29 | path: "/opt/camel" 30 | ``` 31 | 32 | 33 | This means that the path on disk "/opt/camel" will be the location that we can send files to and have the rider-auto-file pod pick it up and process it. 34 | 35 | To install this HostPath PV, you'll need to be an admin user on the "rider-auto" project and try the following: 36 | 37 | 38 | > oc create -f rider-auto-file/src/main/fabric8/vagrant-pv.yaml 39 | 40 | After doing this, you should double check that it was created properly: 41 | 42 | > oc get pv 43 | 44 | ``` 45 | [root@localhost ~]# oc get pv 46 | NAME LABELS CAPACITY ACCESSMODES STATUS CLAIM REASON AGE 47 | rider-auto-file-pv type=local 100Ki RWO Available 4m 48 | ``` 49 | 50 | ## Install AMQ 51 | 52 | The microservices in this project communicate over JMS and use JBoss AMQ. To do this, we should boot up a broker in the `rider-auto` project. In the root of the project, we have a curated `amq.json` file that contains the broker. 53 | 54 | > oc create -f amq.json 55 | 56 | ## Builder Docker containers 57 | 58 | To run these microservices on openshift, you should build the docker images for each module. See the docs for each module for how to do that. 59 | 60 | ## Install microservices 61 | 62 | From the root directory of `rider-auto-ose-installer` project, run: 63 | 64 | > mvn clean install fabric8:json fabric8:apply 65 | 66 | -------------------------------------------------------------------------------- /rider-auto-ose-installer/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | rider-auto-osgi 7 | org.fusesource.examples 8 | 5.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | rider-auto-ose-installer 13 | Rider Auto OSGi Example :: OpenShift Installer 14 | 15 | 16 | 17 | 18 | ${project.groupId} 19 | rider-auto-ws 20 | ${project.version} 21 | kubernetes 22 | json 23 | 24 | 25 | ${project.groupId} 26 | rider-auto-file 27 | ${project.version} 28 | kubernetes 29 | json 30 | 31 | 32 | ${project.groupId} 33 | rider-auto-backend 34 | ${project.version} 35 | kubernetes 36 | json 37 | 38 | 39 | ${project.groupId} 40 | rider-auto-normalizer 41 | ${project.version} 42 | kubernetes 43 | json 44 | 45 | 46 | 47 | 48 | 49 | fabric8 50 | 51 | true 52 | 53 | 54 | true 55 | false 56 | false 57 | true 58 | 59 | 60 | 61 | 62 | io.fabric8 63 | fabric8-maven-plugin 64 | ${fabric8.version} 65 | 66 | 67 | json 68 | generate-resources 69 | 70 | json 71 | 72 | 73 | 74 | attach 75 | package 76 | 77 | attach 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /rider-auto-rest/README.md: -------------------------------------------------------------------------------- 1 | # REST module 2 | 3 | This module exposes a REST endpoint using Camel's rest dsl and returns information about the host it's running on. 4 | 5 | 6 | ## Building 7 | 8 | You can build this module with Maven: 9 | 10 | > mvn clean install 11 | 12 | If you'd like to skip tests: 13 | 14 | > mvn clean install -Dtest=false -DfailIfNoTests=false 15 | 16 | ## Running locally 17 | You should be able to run this locally using mvn, and it should work as expected. We highly recommend you test your services out locally before packaging as Docker containers: 18 | 19 | > mvn camel:run 20 | 21 | You can then test that it works by using a SOAP tool, or hitting it in a web browser: 22 | 23 | > curl http://localhost:8080/demo 24 | 25 | You should end up with the WSDL returned: 26 | 27 | ceposta@postamac(~) $ curl http://localhost:8080/demo 28 | { 29 | "timestamp" : 1456410711899, 30 | "hostIP" : "10.0.1.20", 31 | "hostname" : "postamac.local" 32 | } 33 | 34 | 35 | You may also want to try the same thing using `mvn exec:java` 36 | 37 | > mvn exec:java 38 | 39 | This will run the app's main file (from [camel-boot](camel-boot)) using the classpath from maven. 40 | 41 | ## Building a docker image 42 | 43 | FIS includes a supported maven plugin for building Docker images from your project. Unless you're running on Linux, you'll need to install a guest VM that has Docker. We recommend the Red Hat [Container Development Kit v2](https://www.redhat.com/en/about/blog/introducing-red-hat-container-development-kit-2-beta) 44 | 45 | For the maven plugin to work, it will need to be able to locate a Docker Daemon (ideally running in a guest-local VM). To do this, you'll want to have the following environment variables set: 46 | 47 | export DOCKER_HOST=tcp://10.1.2.2:2376 48 | export DOCKER_CERT_PATH=/path/to/cdk/.vagrant/machines/default/virtualbox/.docker 49 | export DOCKER_TLS_VERIFY=1 50 | 51 | Note the `DOCKER_HOST` needs to point to the location of the docker daemon, and `DOCKER_CERT_PATH` needs to point to the location of the cert for your docker daemon. 52 | 53 | It would also be great if you had the native docker CLI tools installed on your Host machine (ie your Windows or Mac machine) so you can `docker images` and `docker ps` 54 | 55 | ### Running as camel-boot microservice 56 | 57 | Before we build the docker image, we should specify whether we're going to use [camel-boot][camel-boot] (Plain Old Java Main with flat-classloader) or a Karaf osgi classloader. We recommend building using [camel-boot][camel-boot]. Basically what happens is we zip up the maven classpath and inject a little helper script to run the app using the classpath. This simplifies the deployment so we don't have to guess about which classpath we'll be using; it'll be exactly the same as when you ran locally. 58 | 59 | To do this, run the following command: 60 | 61 | > $ mvn clean install -Pfabric8 -Phawtapp 62 | 63 | (Skip tests can be done with adding `-Dtest=false -DfailIfNoTests=false`) 64 | 65 | After the build you should see the following in the target dir: 66 | 67 | ``` 68 | drwxr-xr-x 6 ceposta staff 204B Feb 25 07:13 classes 69 | drwxr-xr-x 3 ceposta staff 102B Feb 25 07:27 docker 70 | drwxr-xr-x 3 ceposta staff 102B Feb 25 07:08 fabric8 71 | drwxr-xr-x 3 ceposta staff 102B Feb 25 07:13 generated-sources 72 | drwxr-xr-x 4 ceposta staff 136B Feb 25 07:25 hawt-app 73 | drwxr-xr-x 3 ceposta staff 102B Feb 25 07:04 maven-status 74 | -rw-r--r-- 1 ceposta staff 49M Feb 25 07:32 rider-auto-rest-5.0-SNAPSHOT-app.tar.gz 75 | -rw-r--r-- 1 ceposta staff 7.5K Feb 25 07:32 rider-auto-rest-5.0-SNAPSHOT.jar 76 | ``` 77 | 78 | Notice the *.tar.gz file (can also generate zip file by setting the hawtapp-maven-plugin archiver to "zip"). 79 | In that zip/tar file, you'll find a completely packed up and ready to run app. For example if you unzip that file, you'll get the following contents: 80 | 81 | ``` 82 | drwxr-xr-x 3 ceposta staff 102B Jan 26 08:39 bin 83 | drwxr-xr-x 200 ceposta staff 6.6K Jan 26 08:39 lib 84 | 85 | ``` 86 | 87 | From that folder, you can run: 88 | 89 | > ./bin/run.sh 90 | 91 | Which should bootstrap the application and run it as a standalone camel-boot app. 92 | 93 | ### Building the camel-boot service as a docker container 94 | 95 | Now that you understand the camel-boot packaging using hawtapp-maven-plugin, we can build a docker container: 96 | 97 | > $ mvn clean install -Pfabric8 -Phawtapp docker:build 98 | 99 | (Skip tests can be done with adding `-Dtest=false -DfailIfNoTests=false`) 100 | 101 | Note, we have to have a working docker daemon available as mentioned above. 102 | 103 | You should end up with output similar to this: 104 | 105 | ``` 106 | [INFO] --- docker-maven-plugin:0.13.6:build (default-cli) @ rider-auto-rest --- 107 | [INFO] Copying files to /Users/ceposta/dev/sandbox/RedHatWorkshops/rider-auto-openshift/rider-auto-rest/target/docker/fabric8/rider-auto-rest/5.0-SNAPSHOT/build/maven 108 | [INFO] Building tar: /Users/ceposta/dev/sandbox/RedHatWorkshops/rider-auto-openshift/rider-auto-rest/target/docker/fabric8/rider-auto-rest/5.0-SNAPSHOT/tmp/docker-build.tar 109 | [INFO] DOCKER> [fabric8/rider-auto-rest:5.0-SNAPSHOT] : Built image 50b666dd2bd3 110 | [INFO] ------------------------------------------------------------------------ 111 | [INFO] BUILD SUCCESS 112 | [INFO] ------------------------------------------------------------------------ 113 | [INFO] Total time: 17.368 s 114 | [INFO] Finished at: 2016-02-25T07:35:50-07:00 115 | [INFO] Final Memory: 53M/889M 116 | [INFO] ------------------------------------------------------------------------ 117 | 118 | ``` 119 | 120 | Now if you do a `docker images` you should see your new docker image: 121 | 122 | ``` 123 | ceposta@postamac(rider-auto-rest (fis-enable)) $ docker images 124 | REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE 125 | fabric8/rider-auto-rest 5.0-SNAPSHOT f140fa83fc04 About a minute ago 491.7 MB 126 | ``` 127 | 128 | You can even try to run you docker container as is and map the ports locally so you can see the service running within the docker image: 129 | 130 | > docker run -it --rm -p 8080:8080 fabric8/rider-auto-rest:5.0-SNAPSHOT 131 | > curl http://localhost:8080/demo 132 | 133 | Note for that to work, we need to have the guest VM map port 8080 to the host VM. 134 | 135 | Yay! You now have your microservice packaged as a docker image ready to go. Let's take a look at what that looks like if you want to build the karaf-based microservice: 136 | 137 | 138 | ### Running as Karaf-based microservice 139 | 140 | We can also convert existing karaf-based deployments over to the FIS deployment model. Just like with the camel-boot option (above) that packages the entire JVM together with its dependencies, we'll be doing that with Karaf. What this means is that your build will _actually produce a completely independent Karaf assembly_ which can then be used to run your application. No more build your app and chuck it into a running Karaf and hope it resolves; now all OSGI resolution is done at build time and the resulting output is a fully baked Karaf distribution with your app inside it. 141 | 142 | Run the following command to do this: 143 | 144 | 145 | > mvn clean install -Pfabric8 -Pkaraf-distro 146 | 147 | (Skip tests can be done with adding `-Dtest=false -DfailIfNoTests=false`) 148 | 149 | That should produce output like this in /target 150 | 151 | ``` 152 | drwxr-xr-x 7 ceposta staff 238B Jan 26 08:58 assembly 153 | drwxr-xr-x 6 ceposta staff 204B Jan 26 08:58 classes 154 | drwxr-xr-x 3 ceposta staff 102B Jan 26 08:58 fabric8 155 | drwxr-xr-x 3 ceposta staff 102B Jan 26 08:58 generated-sources 156 | drwxr-xr-x 3 ceposta staff 102B Jan 26 08:58 generated-test-sources 157 | drwxr-xr-x 3 ceposta staff 102B Jan 26 08:58 maven-status 158 | -rw-r--r-- 1 ceposta staff 6.8K Jan 26 08:58 rider-auto-ws-5.0-SNAPSHOT.jar 159 | -rw-r--r-- 1 ceposta staff 48M Jan 26 08:59 rider-auto-ws-5.0-SNAPSHOT.tar.gz 160 | -rw-r--r-- 1 ceposta staff 49M Jan 26 08:59 rider-auto-ws-5.0-SNAPSHOT.zip 161 | drwxr-xr-x 4 ceposta staff 136B Jan 26 08:58 test-classes 162 | ``` 163 | 164 | 165 | The *.zip file is the fully-baked karaf assembly. If you unzip it, it looks like a Karaf/Fuse distribution as you'd expect: 166 | 167 | ``` 168 | drwxr-xr-x 20 ceposta staff 680B Jan 26 08:58 bin 169 | drwxr-xr-x 3 ceposta staff 102B Jan 26 08:58 data 170 | drwxr-xr-x 45 ceposta staff 1.5K Jan 26 08:58 etc 171 | drwxr-xr-x 13 ceposta staff 442B Jan 26 08:58 lib 172 | drwxr-xr-x 7 ceposta staff 238B Jan 26 08:58 system 173 | ``` 174 | 175 | Can run `./bin/karaf` to boot up the karaf distro. 176 | 177 | 178 | ### Building the karaf-based service as a docker container 179 | 180 | > $ mvn clean install -Pfabric8 -Pkaraf-distro docker:build 181 | 182 | (Skip tests can be done with adding `-Dtest=false -DfailIfNoTests=false`) 183 | 184 | Note, we have to have a working docker daemon available as mentioned above. 185 | 186 | You should end up with output similar to this: 187 | 188 | ``` 189 | [INFO] 190 | [INFO] --- docker-maven-plugin:0.13.6:build (default-cli) @ rider-auto-ws --- 191 | [INFO] Copying files to /Users/ceposta/dev/sandbox/RedHatWorkshops/rider-auto-osgi/rider-auto-ws/target/docker/fabric8/rider-auto-rest/5.0-SNAPSHOT/build/maven 192 | [INFO] Building tar: /Users/ceposta/dev/sandbox/RedHatWorkshops/rider-auto-osgi/rider-auto-rest/target/docker/fabric8/rider-auto-rest/5.0-SNAPSHOT/tmp/docker-build.tar 193 | [INFO] DOCKER> [fabric8/rider-auto-rest:5.0-SNAPSHOT] : Built image f140fa83fc04 194 | [INFO] ------------------------------------------------------------------------ 195 | [INFO] BUILD SUCCESS 196 | [INFO] ------------------------------------------------------------------------ 197 | [INFO] Total time: 20.133 s 198 | [INFO] Finished at: 2016-01-26T08:45:53-07:00 199 | [INFO] Final Memory: 79M/889M 200 | [INFO] ------------------------------------------------------------------------ 201 | ``` 202 | 203 | Now if you do a `docker images` you should see your new docker image: 204 | 205 | ``` 206 | ceposta@postamac(rider-auto-ws (fis-enable)) $ docker images 207 | REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE 208 | fabric8/rider-auto-rest 5.0-SNAPSHOT f140fa83fc04 About a minute ago 491.7 MB 209 | ``` 210 | 211 | You can even try to run you docker container as is and map the ports locally so you can see the service running within the docker image: 212 | 213 | > docker run -it --rm -p 8080:8080 fabric8/rider-auto-rest:5.0-SNAPSHOT 214 | > > curl http://localhost:8080/demo 215 | 216 | Note for that to work, we need to have the guest VM map port 8080 to the host VM (or run the docker commands from the docker host and you don't need to worry about VM port mapping). 217 | 218 | ## Deploying to OpenShift 219 | 220 | 221 | To deploy into openshift, we need to generate the correct JSON manifest which includes all of our Services, Replication Controllers and Pods. We can [do this a few different ways](http://blog.christianposta.com/typesafe-kubernetes-dsl-for-yaml-json-generation/) but for this module we use the [fabric8 maven plugin](http://fabric8.io/guide/mavenFabric8Json.html). The plugin basically scans the list of maven properties and will generate a Kubernetes json or OpenShift template depending on the properties. 222 | 223 | For example: 224 | 225 | ${project.artifactId} 226 | true 227 | 228 | true 229 | 9779 230 | 8080 231 | 232 | ${project.artifactId} 233 | 80 234 | 8080 235 | 236 | ${project.artifactId} 237 | java 238 | rider-auto 239 | camel 240 | 241 | These maven properties will produce a JSON output when you build the project: 242 | 243 | $ mvn clean install 244 | 245 | The location of the `kubernetes.json` file is in `target/classes/kubernetes.json` 246 | 247 | ``` 248 | { 249 | "apiVersion" : "v1", 250 | "kind" : "Template", 251 | "labels" : { }, 252 | "metadata" : { 253 | "annotations" : { 254 | "fabric8.rider-auto-ws/iconUrl" : "https://cdn.rawgit.com/fabric8io/fabric8/master/fabric8-maven-plugin/src/main/resources/icons/camel.svg", 255 | }, 256 | "labels" : { }, 257 | "name" : "rider-auto-rest" 258 | }, 259 | "objects" : [ { 260 | "apiVersion" : "v1", 261 | "kind" : "Service", 262 | "metadata" : { 263 | "annotations" : { 264 | "prometheus.io/port" : "9779", 265 | "prometheus.io/scrape" : "true" 266 | }, 267 | "labels" : { 268 | "container" : "java", 269 | "component" : "rider-auto-rest", 270 | "provider" : "fabric8", 271 | "project" : "rider-auto-rest", 272 | "version" : "5.0-SNAPSHOT", 273 | "group" : "rider-auto" 274 | }, 275 | "name" : "rider-auto-rest" 276 | }, 277 | "spec" : { 278 | "deprecatedPublicIPs" : [ ], 279 | "externalIPs" : [ ], 280 | "ports" : [ { 281 | "port" : 80, 282 | "protocol" : "TCP", 283 | "provider" : "fabric8", 284 | "project" : "rider-auto-rest", 285 | "version" : "5.0-SNAPSHOT", 286 | "group" : "rider-auto" 287 | }, 288 | "name" : "rider-auto-rest" 289 | }, 290 | "spec" : { 291 | "replicas" : 1, 292 | "selector" : { 293 | "container" : "java", 294 | "component" : "rider-auto-rest", 295 | "provider" : "fabric8", 296 | "project" : "rider-auto-rest", 297 | "version" : "5.0-SNAPSHOT", 298 | "group" : "rider-auto" 299 | }, 300 | "template" : { 301 | "metadata" : { 302 | "annotations" : { }, 303 | "labels" : { 304 | "container" : "java", 305 | "component" : "rider-auto-rest", 306 | "provider" : "fabric8", 307 | "project" : "rider-auto-rest", 308 | "version" : "5.0-SNAPSHOT", 309 | "group" : "rider-auto" 310 | } 311 | }, 312 | "spec" : { 313 | "containers" : [ { 314 | "args" : [ ], 315 | "command" : [ ], 316 | "env" : [ { 317 | "name" : "KUBERNETES_NAMESPACE", 318 | "valueFrom" : { 319 | "fieldRef" : { 320 | "fieldPath" : "metadata.namespace" 321 | } 322 | } 323 | } ], 324 | "image" : "fabric8/rider-auto-rest:5.0-SNAPSHOT", 325 | "name" : "rider-auto-rest", 326 | "ports" : [ { 327 | "containerPort" : 8080, 328 | "name" : "rest" 329 | }, { 330 | "containerPort" : 8778, 331 | "name" : "jolokia" 332 | } ], 333 | "resources" : { 334 | "limits" : { 335 | "cpu" : "100m", 336 | "memory" : "64Mi" 337 | }, 338 | "requests" : { 339 | "cpu" : "100m", 340 | "memory" : "64Mi" 341 | } 342 | }, 343 | "securityContext" : { }, 344 | "volumeMounts" : [ ] 345 | } ], 346 | "imagePullSecrets" : [ ], 347 | "nodeSelector" : { }, 348 | "volumes" : [ ] 349 | } 350 | } 351 | } 352 | } ], 353 | "parameters" : [ ] 354 | } 355 | 356 | ``` 357 | 358 | We can take that json and "apply" it to a running OpenShift installation. Note that for this plugin to work, you must 359 | already be logged into openshift with `oc login` and have the following environment variable set: 360 | 361 | ``` 362 | export KUBERNETES_MASTER=https://10.1.2.2:8443 363 | export KUBERNETES_DOMAIN= 364 | export KUBERNETES_TRUST_CERT=true 365 | ``` 366 | 367 | Then you should be able to run the following maven command to deploy: 368 | 369 | 370 | > $ mvn clean install -Pfabric8 -Pkube-generate fabric8:apply 371 | 372 | Note for this to work, you must have run the `docker:build` previously. Or you can combine all of them: 373 | 374 | > $ mvn clean install -Pfabric8 -Phawtapp docker:build fabric8:apply 375 | 376 | This command assumes everything is running locally (like on the CDK). Otherwise, if deploying to a centralized openshift 377 | installation, you can build the docker image locally, then do `docker:push` to get the image up to OpenShift and then run 378 | the `fabric8:apply` command to deploy the app. 379 | 380 | 381 | ## Deploy A-MQ 382 | This example uses JBoss A-MQ, so we need to have that running in the same project/namespace as the rider-auto apps (including this module). 383 | To deploy AMQ, follow the [instructions from the xPaaS AMQ documentation](https://docs.openshift.com/enterprise/3.1/using_images/xpaas_images/a_mq.html). On the CDK, you can do this: 384 | 385 | ### Create a template for JBoss A-MQ 386 | 387 | > oc create -f https://raw.githubusercontent.com/openshift/openshift-ansible/master/roles/openshift_examples/files/examples/v1.1/xpaas-templates/amq62-basic.json 388 | > oc process amq62-basic -v APPLICATION_NAME=broker -v MQ_USERNAME=admin -v MQ_PASSWORD=admin 389 | 390 | Or you can use the template i've included in the root of this project: 391 | 392 | > oc create -f amq.json 393 | 394 | ``` 395 | service "broker-amq-tcp" created 396 | deploymentconfig "broker-amq" created 397 | ``` 398 | Note that the user name and password need to be `admin/admin` as that's what the rider-auto-osgi project expects. 399 | 400 | 401 | [camel-boot]: http://camel.apache.org/camel-boot.html 402 | -------------------------------------------------------------------------------- /rider-auto-rest/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | rider-auto-osgi 7 | org.fusesource.examples 8 | 5.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | rider-auto-rest 13 | 14 | Rider Auto OSGi Example :: REST service 15 | http://www.jboss.org/products/fuse/overview/ 16 | bundle 17 | 18 | 19 | 20 | 21 | 23 | org.jboss.fuse 24 | fuse-karaf-framework 25 | ${fuse.version} 26 | kar 27 | 28 | 29 | 30 | * 31 | * 32 | 33 | 34 | 35 | 36 | org.apache.karaf.assemblies.features 37 | standard 38 | ${karaf.version} 39 | features 40 | xml 41 | 42 | 43 | org.apache.karaf.assemblies.features 44 | enterprise 45 | ${karaf.version} 46 | features 47 | xml 48 | 49 | 50 | org.apache.camel.karaf 51 | apache-camel 52 | ${camel-version} 53 | features 54 | xml 55 | 56 | 57 | org.apache.activemq 58 | activemq-karaf 59 | ${activemq-version} 60 | features 61 | xml 62 | 63 | 64 | org.apache.karaf.features 65 | spring 66 | ${spring.features.version} 67 | features 68 | xml 69 | 70 | 71 | 72 | org.fusesource.examples 73 | rider-auto-common 74 | 75 | 76 | 77 | io.fabric8.mq 78 | camel-amq 79 | 80 | 81 | 82 | 83 | org.apache.camel 84 | camel-spring 85 | runtime 86 | 87 | 88 | 89 | org.apache.camel 90 | camel-jackson 91 | runtime 92 | 93 | 94 | org.apache.camel 95 | camel-netty-http 96 | runtime 97 | 98 | 99 | 100 | 101 | org.apache.activemq 102 | activemq-camel 103 | runtime 104 | 105 | 106 | 107 | org.slf4j 108 | slf4j-api 109 | runtime 110 | 111 | 112 | 113 | junit 114 | junit 115 | test 116 | 117 | 118 | org.apache.camel 119 | camel-test 120 | test 121 | 122 | 123 | org.apache.camel 124 | camel-test-spring 125 | test 126 | 127 | 128 | org.slf4j 129 | slf4j-simple 130 | test 131 | 132 | 133 | org.apache.activemq 134 | activemq-broker 135 | test 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | org.apache.felix 144 | maven-bundle-plugin 145 | true 146 | 147 | 148 | 149 | 150 | org.apache.camel 151 | camel-maven-plugin 152 | 153 | 154 | 155 | org.codehaus.mojo 156 | exec-maven-plugin 157 | 1.4.0 158 | 159 | org.apache.camel.spring.Main 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | kube-generate 168 | 169 | true 170 | 171 | 172 | 173 | 174 | io.fabric8 175 | kubernetes-generator 176 | 177 | 178 | 179 | 180 | fabric8 181 | 182 | true 183 | 184 | 185 | ${project.artifactId} 186 | true 187 | 188 | true 189 | 9779 190 | 8080 191 | 192 | ${project.artifactId} 193 | 80 194 | 8080 195 | 196 | ${project.artifactId} 197 | java 198 | rider-auto 199 | camel 200 | 201 | 202 | 203 | 204 | 205 | 206 | junit 207 | junit 208 | test 209 | 210 | 211 | org.jboss.arquillian.junit 212 | arquillian-junit-container 213 | test 214 | 215 | 216 | io.fabric8 217 | fabric8-arquillian 218 | test 219 | 220 | 221 | org.jboss.shrinkwrap.resolver 222 | shrinkwrap-resolver-impl-maven 223 | test 224 | 225 | 226 | 227 | 228 | 229 | io.fabric8 230 | fabric8-maven-plugin 231 | ${fabric8.version} 232 | 233 | 234 | json 235 | generate-resources 236 | 237 | json 238 | 239 | 240 | 241 | attach 242 | package 243 | 244 | attach 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | karaf-distro 254 | 255 | jboss-fuse-6/fis-karaf-openshift:1.0 256 | 257 | 258 | 259 | 260 | org.apache.maven.plugins 261 | maven-compiler-plugin 262 | 263 | 264 | **/*ModelProcessor.java 265 | 266 | 267 | **/*KT.java 268 | 269 | 270 | 271 | 272 | org.apache.karaf.tooling 273 | karaf-maven-plugin 274 | ${karaf.plugin.version} 275 | true 276 | 277 | 278 | karaf-assembly 279 | 280 | assembly 281 | 282 | install 283 | 284 | 285 | karaf-archive 286 | 287 | archive 288 | 289 | install 290 | 291 | 292 | 293 | v24 294 | 1.8 295 | true 296 | 297 | false 298 | 299 | 300 | karaf-framework 301 | shell 302 | jaas 303 | spring 304 | camel-spring 305 | camel-jackson 306 | camel-netty-http 307 | camel-bindy 308 | activemq-client 309 | activemq-camel 310 | 311 | 312 | 313 | mvn:org.apache.karaf.bundle/org.apache.karaf.bundle.core/3.0.4 314 | mvn:io.fabric8.mq/mq-client/2.2.0.redhat-079 315 | mvn:io.fabric8/fabric8-utils/2.2.0.redhat-079 316 | mvn:${project.groupId}/${project.artifactId}/${project.version} 317 | 318 | 319 | 320 | 321 | org.jolokia 322 | docker-maven-plugin 323 | ${docker.maven.plugin.version} 324 | 325 | 326 | 327 | ${docker.image} 328 | 329 | ${docker.from} 330 | 331 | /deployments 332 | jboss:jboss:jboss 333 | 335 | ${project.artifactId} 336 | 337 | 338 | 339 | ${project.build.directory}/${project.artifactId}-${project.version}.tar.gz 340 | / 341 | 342 | 343 | 344 | 345 | 346 | /deployments/deploy-and-run.sh 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | hawtapp 358 | 359 | 360 | 361 | 362 | 363 | org.apache.maven.plugins 364 | maven-compiler-plugin 365 | 366 | 367 | **/*ModelProcessor.java 368 | 369 | 370 | **/*KT.java 371 | 372 | 373 | 374 | 375 | org.jolokia 376 | docker-maven-plugin 377 | ${docker.maven.plugin.version} 378 | 379 | 380 | 381 | ${docker.image} 382 | 383 | ${docker.from} 384 | 385 | /deployments 386 | hawt-app 387 | 388 | 389 | /deployments/lib 390 | org.apache.camel.spring.Main 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | io.fabric8 399 | hawt-app-maven-plugin 400 | ${fabric8.version} 401 | 402 | 403 | hawt-app 404 | 405 | build 406 | 407 | 408 | org.apache.camel.spring.Main 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | -------------------------------------------------------------------------------- /rider-auto-rest/src/main/fabric8/horizontal-pod-autoscaler.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: extensions/v1beta1 3 | kind: HorizontalPodAutoscaler 4 | metadata: 5 | name: rider-auto-rest-autoscaler 6 | spec: 7 | scaleRef: 8 | kind: ReplicationController 9 | name: rider-auto-rest 10 | apiVersion: v1 11 | subresource: scale 12 | minReplicas: 1 13 | maxReplicas: 3 14 | cpuUtilization: 15 | targetPercentage: 50 -------------------------------------------------------------------------------- /rider-auto-rest/src/main/fabric8/project-limits.yml: -------------------------------------------------------------------------------- 1 | { 2 | "apiVersion": "v1", 3 | "kind": "LimitRange", 4 | "metadata": { 5 | "name": "limits" 6 | }, 7 | "spec": { 8 | "limits": [{ 9 | "type": "Pod", 10 | "max": { 11 | "cpu": "2", 12 | "memory": "1Gi" 13 | }, 14 | "min": { 15 | "cpu": "200m", 16 | "memory": "6Mi" 17 | } 18 | }, 19 | { 20 | "type": "Container", 21 | "max": { 22 | "cpu": "2", 23 | "memory": "1Gi" 24 | }, 25 | "min": { 26 | "cpu": "100m", 27 | "memory": "4Mi" 28 | }, 29 | "default": { 30 | "cpu": "300m", 31 | "memory": "200Mi" 32 | }, 33 | "defaultRequest": { 34 | "cpu": "200m", 35 | "memory": "100Mi" 36 | }, 37 | "maxLimitRequestRatio": { 38 | "cpu": "10" 39 | } 40 | }] 41 | } 42 | } -------------------------------------------------------------------------------- /rider-auto-rest/src/main/java/org/fusesource/camel/route/RestResponseDTO.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | *

9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | *

11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.fusesource.camel.route; 18 | 19 | import java.net.InetAddress; 20 | 21 | /** 22 | * Created by ceposta 23 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | *

11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.fusesource.camel.route; 18 | 19 | import org.apache.camel.Exchange; 20 | import org.apache.camel.Processor; 21 | import org.apache.camel.builder.RouteBuilder; 22 | import org.apache.camel.model.rest.RestBindingMode; 23 | 24 | import javax.crypto.Cipher; 25 | import javax.crypto.spec.IvParameterSpec; 26 | import javax.crypto.spec.SecretKeySpec; 27 | 28 | /** 29 | * Created by ceposta 30 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | *

11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.fusesource.examples.kube; 18 | 19 | import io.fabric8.kubernetes.api.model.ContainerBuilder; 20 | import io.fabric8.kubernetes.api.model.Quantity; 21 | import io.fabric8.kubernetes.generator.annotation.KubernetesModelProcessor; 22 | 23 | import javax.inject.Named; 24 | 25 | /** 26 | * Created by ceposta 27 | * 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /rider-auto-rest/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | 2 | # 3 | # The logging properties used for eclipse testing, We want to see debug output on the console. 4 | # 5 | log4j.rootLogger=INFO, out 6 | 7 | # uncomment the following line to turn on Camel debugging 8 | #log4j.logger.org.apache.camel=DEBUG 9 | 10 | log4j.logger.org.springframework=WARN 11 | log4j.logger.org.apache.activemq=WARN 12 | 13 | # CONSOLE appender not used by default 14 | log4j.appender.out=org.apache.log4j.ConsoleAppender 15 | log4j.appender.out.layout=org.apache.log4j.PatternLayout 16 | log4j.appender.out.layout.ConversionPattern=[%30.30t] %-30.30c{1} %-5p %m%n 17 | #log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n 18 | -------------------------------------------------------------------------------- /rider-auto-ws/.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | .settings 3 | .project 4 | .classpath 5 | -------------------------------------------------------------------------------- /rider-auto-ws/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 24 | 4.0.0 25 | 26 | 27 | org.fusesource.examples 28 | rider-auto-osgi 29 | 5.0-SNAPSHOT 30 | 31 | 32 | rider-auto-ws 33 | bundle 34 | 35 | Rider Auto OSGi Example :: Web Service 36 | http://fusesource.com 37 | 38 | 39 | 40 | 42 | org.jboss.fuse 43 | fuse-karaf-framework 44 | ${fuse.version} 45 | kar 46 | 47 | 48 | 49 | * 50 | * 51 | 52 | 53 | 54 | 55 | org.apache.karaf.assemblies.features 56 | standard 57 | ${karaf.version} 58 | features 59 | xml 60 | 61 | 62 | org.apache.karaf.assemblies.features 63 | enterprise 64 | ${karaf.version} 65 | features 66 | xml 67 | 68 | 69 | org.apache.camel.karaf 70 | apache-camel 71 | ${camel-version} 72 | features 73 | xml 74 | 75 | 76 | org.apache.activemq 77 | activemq-karaf 78 | ${activemq-version} 79 | features 80 | xml 81 | 82 | 83 | org.apache.karaf.features 84 | spring 85 | ${spring.features.version} 86 | features 87 | xml 88 | 89 | 90 | 91 | org.fusesource.examples 92 | rider-auto-common 93 | 94 | 95 | 96 | io.fabric8.mq 97 | camel-amq 98 | 99 | 100 | 101 | org.apache.camel 102 | camel-cxf 103 | runtime 104 | 105 | 106 | org.apache.cxf 107 | cxf-rt-transports-http-jetty 108 | runtime 109 | 110 | 111 | 112 | 113 | org.apache.camel 114 | camel-spring 115 | runtime 116 | 117 | 118 | 119 | 120 | org.apache.camel 121 | camel-jaxb 122 | runtime 123 | 124 | 125 | 126 | 127 | org.apache.activemq 128 | activemq-camel 129 | runtime 130 | 131 | 132 | 133 | org.slf4j 134 | slf4j-api 135 | runtime 136 | 137 | 138 | 139 | junit 140 | junit 141 | test 142 | 143 | 144 | org.apache.camel 145 | camel-test 146 | test 147 | 148 | 149 | org.apache.camel 150 | camel-test-spring 151 | test 152 | 153 | 154 | org.slf4j 155 | slf4j-simple 156 | test 157 | 158 | 159 | org.apache.activemq 160 | activemq-broker 161 | test 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | org.apache.felix 170 | maven-bundle-plugin 171 | true 172 | 173 | 174 | 175 | 176 | org.apache.camel 177 | camel-maven-plugin 178 | 179 | 180 | 181 | org.codehaus.mojo 182 | exec-maven-plugin 183 | 1.4.0 184 | 185 | org.apache.camel.spring.Main 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | kube-generate 194 | 195 | true 196 | 197 | 198 | 199 | 200 | io.fabric8 201 | kubernetes-generator 202 | 203 | 204 | 205 | 206 | fabric8 207 | 208 | true 209 | 210 | 211 | ${project.artifactId} 212 | true 213 | 214 | true 215 | 9779 216 | 8080 217 | 218 | ${project.artifactId} 219 | 80 220 | 8080 221 | 222 | ${project.artifactId} 223 | java 224 | rider-auto 225 | camel 226 | 227 | 228 | 229 | 230 | 231 | 232 | junit 233 | junit 234 | test 235 | 236 | 237 | org.jboss.arquillian.junit 238 | arquillian-junit-container 239 | test 240 | 241 | 242 | io.fabric8 243 | fabric8-arquillian 244 | test 245 | 246 | 247 | org.jboss.shrinkwrap.resolver 248 | shrinkwrap-resolver-impl-maven 249 | test 250 | 251 | 252 | 253 | 254 | 255 | io.fabric8 256 | fabric8-maven-plugin 257 | ${fabric8.version} 258 | 259 | 260 | json 261 | generate-resources 262 | 263 | json 264 | 265 | 266 | 267 | attach 268 | package 269 | 270 | attach 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | karaf-distro 280 | 281 | jboss-fuse-6/fis-karaf-openshift:1.0 282 | 283 | 284 | 285 | 286 | org.apache.maven.plugins 287 | maven-compiler-plugin 288 | 289 | 290 | **/*ModelProcessor.java 291 | 292 | 293 | **/*KT.java 294 | 295 | 296 | 297 | 298 | org.apache.karaf.tooling 299 | karaf-maven-plugin 300 | ${karaf.plugin.version} 301 | true 302 | 303 | 304 | karaf-assembly 305 | 306 | assembly 307 | 308 | install 309 | 310 | 311 | karaf-archive 312 | 313 | archive 314 | 315 | install 316 | 317 | 318 | 319 | v24 320 | 1.8 321 | true 322 | 323 | false 324 | 325 | 326 | karaf-framework 327 | shell 328 | jaas 329 | spring 330 | camel-spring 331 | camel-jaxb 332 | camel-cxf 333 | camel-bindy 334 | cxf-http-jetty 335 | activemq-client 336 | activemq-camel 337 | 338 | 339 | 340 | mvn:org.apache.karaf.bundle/org.apache.karaf.bundle.core/3.0.4 341 | mvn:io.fabric8.mq/mq-client/2.2.0.redhat-079 342 | mvn:io.fabric8/fabric8-utils/2.2.0.redhat-079 343 | mvn:${project.groupId}/${project.artifactId}/${project.version} 344 | 345 | 346 | 347 | 348 | org.jolokia 349 | docker-maven-plugin 350 | ${docker.maven.plugin.version} 351 | 352 | 353 | 354 | ${docker.image} 355 | 356 | ${docker.from} 357 | 358 | /deployments 359 | jboss:jboss:jboss 360 | 362 | ${project.artifactId} 363 | 364 | 365 | 366 | ${project.build.directory}/${project.artifactId}-${project.version}.tar.gz 367 | / 368 | 369 | 370 | 371 | 372 | 373 | /deployments/deploy-and-run.sh 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | hawtapp 385 | 386 | 387 | 388 | 389 | 390 | org.apache.maven.plugins 391 | maven-compiler-plugin 392 | 393 | 394 | **/*ModelProcessor.java 395 | 396 | 397 | **/*KT.java 398 | 399 | 400 | 401 | 402 | org.jolokia 403 | docker-maven-plugin 404 | ${docker.maven.plugin.version} 405 | 406 | 407 | 408 | ${docker.image} 409 | 410 | ${docker.from} 411 | 412 | /deployments 413 | hawt-app 414 | 415 | 416 | /deployments/lib 417 | org.apache.camel.spring.Main 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | io.fabric8 426 | hawt-app-maven-plugin 427 | ${fabric8.version} 428 | 429 | 430 | hawt-app 431 | 432 | build 433 | 434 | 435 | org.apache.camel.spring.Main 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | -------------------------------------------------------------------------------- /rider-auto-ws/src/data/message1.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /rider-auto-ws/src/data/message2.csv: -------------------------------------------------------------------------------- 1 | name,amount 2 | brake pad,2 -------------------------------------------------------------------------------- /rider-auto-ws/src/main/java/org/fusesource/camel/ws/OrderEndpoint.java: -------------------------------------------------------------------------------- 1 | package org.fusesource.camel.ws; 2 | 3 | import javax.jws.WebService; 4 | import javax.jws.soap.SOAPBinding; 5 | 6 | import org.fusesource.camel.model.Order; 7 | 8 | @WebService 9 | @SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE) 10 | public interface OrderEndpoint { 11 | 12 | public String order(Order in); 13 | } 14 | -------------------------------------------------------------------------------- /rider-auto-ws/src/main/java/org/fusesource/examples/kube/RiderAutoJsonModelProcessor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | *

9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | *

11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.fusesource.examples.kube; 18 | 19 | import io.fabric8.kubernetes.api.model.*; 20 | import io.fabric8.kubernetes.generator.annotation.KubernetesModelProcessor; 21 | import io.fabric8.openshift.api.model.TemplateBuilder; 22 | 23 | import javax.inject.Named; 24 | import java.util.HashMap; 25 | 26 | /** 27 | * Created by ceposta 28 | * 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 23 | 24 | 25 | 26 | 27 | 28 | ${in.body[0]} 29 | 30 | 31 | 32 | 33 | 34 | 35 | OK 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /rider-auto-ws/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | 2 | # 3 | # The logging properties used for eclipse testing, We want to see debug output on the console. 4 | # 5 | log4j.rootLogger=INFO, out 6 | 7 | # uncomment the following line to turn on Camel debugging 8 | #log4j.logger.org.apache.camel=DEBUG 9 | 10 | log4j.logger.org.springframework=WARN 11 | log4j.logger.org.apache.activemq=WARN 12 | 13 | # CONSOLE appender not used by default 14 | log4j.appender.out=org.apache.log4j.ConsoleAppender 15 | log4j.appender.out.layout=org.apache.log4j.PatternLayout 16 | log4j.appender.out.layout.ConversionPattern=[%30.30t] %-30.30c{1} %-5p %m%n 17 | #log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n 18 | -------------------------------------------------------------------------------- /rider-auto-ws/src/test/java/org/fusesource/camel/kubetest/KubernetesIntegrationKT.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005-2015 Red Hat, Inc. 3 | * 4 | * Red Hat licenses this file to you under the Apache License, version 5 | * 2.0 (the "License"); you may not use this file except in compliance 6 | * with the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 13 | * implied. See the License for the specific language governing 14 | * permissions and limitations under the License. 15 | */ 16 | package org.fusesource.camel.kubetest; 17 | 18 | import io.fabric8.arquillian.kubernetes.Session; 19 | import io.fabric8.kubernetes.api.model.Pod; 20 | import io.fabric8.kubernetes.client.KubernetesClient; 21 | import org.assertj.core.api.Condition; 22 | import org.jboss.arquillian.junit.Arquillian; 23 | import org.jboss.arquillian.test.api.ArquillianResource; 24 | import org.junit.Test; 25 | import org.junit.runner.RunWith; 26 | 27 | import static io.fabric8.kubernetes.assertions.Assertions.assertThat; 28 | 29 | @RunWith(Arquillian.class) 30 | public class KubernetesIntegrationKT { 31 | 32 | @ArquillianResource 33 | KubernetesClient client; 34 | 35 | @ArquillianResource 36 | Session session; 37 | 38 | @Test 39 | public void testAppProvisionsRunningPods() throws Exception { 40 | assertThat(client).pods() 41 | .runningStatus() 42 | .filterNamespace(session.getNamespace()) 43 | .haveAtLeast(1, new Condition() { 44 | @Override 45 | public boolean matches(Pod podSchema) { 46 | return true; 47 | } 48 | }); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /rider-auto-ws/src/test/soapui/OrderService-soapui-project.xml: -------------------------------------------------------------------------------- 1 | 2 | http://localhost:8080/cxf/order?wsdl 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | ]]>http://schemas.xmlsoap.org/wsdl/http://localhost:8080/cxf/order<xml-fragment/>UTF-8http://localhost:8080/cxf/order 46 | 47 | 48 | 49 | ball bearing 50 | 5 51 | 52 | 53 | ]]>No Authorization --------------------------------------------------------------------------------