Tuesday, November 1, 2016

Into'ing Kubernetes (k8s)

Kubernetes (k8s) is an open source platform for automating container operations such as deployment, scheduling and scalability across a cluster of nodes.  If you are familiar with Docker container technology to deploy your containers, then consider Docker as a low level component used internally by Kubernetes to deploy containers.

 - Managing application containers, using Kubernetes 
 - Manage deploying, scaling, and updating your applications

A Kubernetes cluster consists of two types of resources:
  • Master coordinates the cluster - scheduling applications, maintaining applications' desired state, scaling applications, and rolling out new updates.
  • Nodes are the workers that run applications - Each node has a Kubelet, which is an agent for managing the node and communicating with the Kubernetes master. The node should also have tools for handling container operations, such as Docker or rkt.
Masters manage the cluster and the nodes are used to host the running applications.
When you deploy applications on Kubernetes, you tell the master to start the application containers. The master schedules the containers to run on the cluster's nodes. The nodes communicate with the master using the Kubernetes API, which the master exposes. End users can also use the Kubernetes API directly to interact with the cluster.
A Kubernetes cluster can be deployed on either physical or virtual machines.

Try out kubernetes interactive tutorial :
http://kubernetes.io/docs/tutorials/kubernetes-basics/cluster-interactive/




Thursday, October 27, 2016

Docker to run your applications

Begin with a simple sample;
Sample 1 : Running a PHP application 

src/index.php
<?php
Echo “Hello user”;

dockerfile
FROM php:7.0-apache
COPY src/ /var/www/html
EXPOSE 80
.
├── dockerfile
└── src
    └── index.php

Build: docker build -t myhelloapp .
Run: docker run -v /home/thilini/Desktop/docker/src/:/var/www/html/ myhelloapp
OR
docker run -p 80:80 -v /home/thilini/Desktop/docker/src/:/var/www/html/ myhelloapp


Output:
111.png
Sample 2 : Running a Java application

docker file
FROM java:7
COPY src/ /usr/src/myapp
WORKDIR /usr/src/myapp
RUN javac HelloWorld.java
CMD ["java", "HelloWorld"]
docker build -t my-java-app .
docker run -it --rm --name my-running-app my-java-app

More.. 

List containers : docker ps 
Verify the image was built successfully : docker ps -a OR docker ps --all
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS      PORTS NAMES

List docker images : docker images 
REPOSITORY          TAG                   IMAGE ID            CREATED             SIZE 

Remove unwanted docker containers : rm {container_ID}

Thursday, June 9, 2016

Adding business rules to your enterprise applications


Business rules help to determine the flow of your processes based on a group of rules you define.

Compared to traditional systems, the addition of business rules to you application has the following advantages.
  • Shortened development time
  • Changes can be made faster, with a lower risk
  • Rules are externalized and easily shareable among multiple applications
  • Lowers the cost for modifying the business logic
  • Increase the Line of Business (LOB) control over implemented decision logic for compliance and business management.
  • Reduce/remove the reliance on IT for changes in the production systems.
  • Improve process efficiency.
Business Rules capabilities in the WSO2 middleware platform brings the agility of business rules to your SOA toolkit. Based on a solid platform for hosting business rules, WSO2 business rules excel at extending the capabilities of your SOA.


It's used to define, deploy, execute, monitor and maintain the variety and complexity of decision logic that is used by operational systems within an enterprise.

SOA is the most prominent architectural pattern used to integrate heterogeneous systems. Therefore if the business decisions written as rules can be exposed as services then business rules can also be integrated to SOA systems.

Tuesday, June 7, 2016

Start a Process Instance using the BPMN REST API

Request endpoint to start a BPMN process instance

  https://<Host_Name>:<Port>/bpmn/runtime/process-instances
Request type: 
POST

Request Body:  

Request body (start by process definition Id):


{
   "processDefinitionId":"sampleJavaServiceTask:1:27503",
   "businessKey":"myBusinessKey",
   "variables": [
      {
        "name":"myVar",
        "value":"This is a variable"
      }
   ]
}


Request body (start by process definition key):


{
   "processDefinitionKey":"sampleJavaServiceTask",
   "businessKey":"myBusinessKey",
   "tenantId""tenant1",
   "variables": [
      {
        "name":"myVar",
        "value":"This is a variable"
      }
   ]
}



Starting the process instance via an ESB proxy service (with PayloadFactory Mediator)



<?xml version="1.0" encoding="UTF-8"?>

<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="OrderProxy"
       transports="https http"
       startOnLoad="true"
       trace="disable">

   <description/>
   <target>

//Calling the request endpoint
      <endpoint>
         <http method="POST"
               uri-template="https://localhost:9443/bpmn/runtime/process-instances"/>
      </endpoint>

//PayloadFactory Mediator transforms or replaces the contents of a message. Configuring 
the format of the request/response and mapping it to the arguments provided.

      <inSequence>
         <payloadFactory media-type="json">
            <format>{
   "processDefinitionId":"manualTaskProcess:1:2532",
   "businessKey":"myBusinessKey",
   "variables": [
      {
        "name":"myVar",
        "value":"This is a variable"
       
      }
   ]
}
            </format>
            <args/>
         </payloadFactory>

//Passing basic-auth credentials to invoke the secured service in BPS. Another way is to 
get these information from the secure vault.

         <property name="Authorization"
                   expression="fn:concat('Basic ', base64Encode('admin:admin'))"
                   scope="transport"
                   type="STRING"/>

         <property name="Content-Type"
                   value="application/json"
                   scope="transport"
                   type="STRING"/>
      </inSequence>
   </target>
</proxy>