Building a Cloud-Agnostic Serverless infrastructure with Knative

KNATIVE is Kubernetes-based platform to build, deploy, and manage modern serverless workloads

“Knative provides a set of middleware components that are essential to build modern, source-centric, and container-based applications that can run anywhere: on premises, in the cloud, or even in a third-party data center. Knative components are built on Kubernetes and codify the best practices shared by successful real-world Kubernetes-based frameworks. It enables developers to focus just on writing interesting code, without worrying about the “boring but difficult” parts of building, deploying, and managing an application.” []

“Knative has been developed by Google in close partnership with PivotalIBMRed Hat, and SAP.” []

A simpel rest web service with powershell

Below a sample webservice for exposte active directory queries using a powershell server… Ttest it wirh http://localhost:8000/user/<domainname>/<SamAccountName>

# Create a listener on port 8000
$listener = New-Object System.Net.HttpListener
‘Listening …’

# Run until you send a GET request to /end
while ($true) {
$context = $listener.GetContext()

# Capture the details about the request
$request = $context.Request

# Setup a place to deliver a response
$response = $context.Response

# Break from loop if GET request sent to /end
if ($request.Url -match ‘/end$’) {
} else {

# Split request URL to get command and options
$requestvars = ([String]$request.Url).split(“/”);

# If a request is sent to http:// :8000/user/<domainname>/<SamAccountName>

if ($requestvars[3] -eq “user”) {
$dom = $requestvars[4]
$user = $requestvars[5]
$domainname = $dom + “”
$dc = Get-ADDomainController -DomainName $domainname -Discover -NextClosestSite
echo $dc
$searchbase = ‘DC=’ + $dom + ‘,DC=redaelli,DC=org’
# Get the class name and server name from the URL and run get-WMIObject
$result = Get-ADUser -Server $dc.HostName[0] -SearchBase $searchbase -Filter {SamAccountName -eq $user} -Properties * | select SamAccountName, sn,GivenName,DisplayName,mail,DistinguishedName,telephoneNumber,mobile,l,company,co,whenCreated,whenChanged,PasswordExpired,PasswordLastSet,PasswordNeverExpires,lockedOut,LastLogonDate,lockoutTime

# Convert the returned data to JSON and set the HTTP content type to JSON
$message = $result | ConvertTo-Json;
$response.ContentType = ‘application/json’;

} else {

# If no matching subdirectory/route is found generate a 404 message
$message = “This is not the page you’re looking for.”;
$response.ContentType = ‘text/html’ ;

# Convert the data to UTF8 bytes
[byte[]]$buffer = [System.Text.Encoding]::UTF8.GetBytes($message)

# Set length of response
$response.ContentLength64 = $buffer.length

# Write response out and close
$output = $response.OutputStream
$output.Write($buffer, 0, $buffer.length)

#Terminate the listener


Querying public knowledge graph databases

You can query public knowledge graph databases (like and using SPARQL. For instance for extracting all “known” programming languages, you can use the query

SELECT ?item ?itemLabel WHERE {
  ?item wdt:P31 wd:Q9143.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
LIMIT 1000

There are also SPARQL clients for most of programming languages.

With (swi) prolog you can easily run

sparql_query('SELECT ?item ?itemLabel WHERE {?item wdt:P31 wd:Q9143. SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }} LIMIT 1000', Row, [ scheme(https),host(''), path('/sparql')]).

Prolog for theorem proving, expert systems, type inference systems, and automated planning…

In the name of the father of Prolog (Alain_Colmerauer who died few days ago), I’ll show how to use Prolog for solving a common business problem: finding the paths in a graph between two nodes..

“Prolog is declarative programming language: the program logic is expressed in terms of relations, represented as facts and rules. A computation is initiated by running a query over these relations”. [Wikipiedia].

Prolog is a general-purpose logic programming language associated with artificial intelligence and computational linguistics [..] The language has been used for theorem provingexpert systemstype inference systems, and automated planning, as well as its original intended field of use, natural language processing.[Wikipiedia].

You tell Prolog the facts and rules of your game and it will find the solution 😉

In this tutorial my graph is the network of underground/train stations of Milan.

The facts are like

station('Affori centro', m3).
station('Affori FN', m3).
station('Affori', s2).
station('Affori', s4).
station('Airuno', s8).
station('Albairate - Vermezzo', s9).
station('Albate Camerlata', s11).
station('Albizzate', s5).
station('Amendola Fiera', m1).
station('Arcore', s8).
station('Assago Milanofiori Forum', m2).
station('Assago Milanofiori Nord', m2).

edge('Villapizzone', 'Lancetti', s5).
edge('Villapizzone', 'Lancetti', s6).
edge('Villa Pompea', 'Gorgonzola', m2).
edge('Villa Raverio', 'Carate-Calò', s7).
edge('Villasanta', 'Monza Sobborghi', s7).
edge('Villa S. Giovanni', 'Precotto', m1).
edge('Vimodrone', 'Cascina Burrona', m2).
edge('Vittuone', 'Pregnana Milanese', s6).
edge('Wagner', 'De Angeli', m1).
edge('Zara', 'Isola', m5).
edge('Zara', 'Sondrio', m3).

The rules are like

adiacent([X,L1], [Y,L1]) :- edge(X,Y, L1) ; edge(Y, X, L1).

change(L1,L2, X) :-
 not(L1 == L2).
same_line_path(Node, Node, _, [Node]). % rule 1
same_line_path(Start, Finish, Visited, [Start | Path]) :- % rule 2
 adiacent(Start, X),
 not(member(X, Visited)),
 same_line_path(X, Finish, [X | Visited], Path).

one_change_line_path([Start,L1], [End,L2], Visited, Path):-
 change(L1,L2, X), 
 same_line_path([Start,L1], [X,L1], [[Start,L1]|Visited], Path1), 
 same_line_path([X,L2], [End,L2], [[X,L2]|Visited], Path2),
 append(Path1, Path2, Path).

You can find a sample test page at and the source code of the Prolog webservice at

Deploy tomcat applications in Docker containers

Deploying you applications in containers, you are sure that they are easily portable and scalable…

Here a sample of deploying a .war application using a Docker container

Create a Dockerfile like

FROM tomcat:8-jre8

MAINTAINER "Matteo <>"

ADD server.xml /usr/local/tomcat/conf/
ADD tomcat-users.xml /usr/local/tomcat/conf/
ADD ojdbc6.jar /usr/local/tomcat/lib/
ADD bips.war /usr/local/tomcat/webapps/

Build a docker image

docker build . -t myapp

Run one or more docker images of your appplication with

docker run --restart=unless-stopped --name myapp1 -p 8080:8080 -d myapp
docker run --restart=unless-stopped --name myapp2 -p 8081:8080 -d myapp

It is better to redirect tomcat logs to stdout: in this way you can see them with

docker logs myapp

Docker containers can be managed among several servers using tools like Kubernetes (an open-source system for automating deployment, scaling, and management of containerized applications), but it should be an other post 😉

Continuous integration and continuous delivery with Jenkins

In this post I’ll show how to use the opensource tool #Jenkins, “the leading #opensource automation server, Jenkins provides hundreds of plugins to support building, deploying and automating any project”. I’ll create a simple pipeline that executes remote tasks via ssh. It could be used for continuous integration and continuous delivery for Oracle OBIEE Systems

Install (in a docker container)

docker run -p 8080:8080 -p 50000:50000 -v /home/oracle/docker_shares/jenkins:/var/jenkins_home -d jenkins

Configure credentials

Login to Jenkins  (

Jenkins -> Manage Jenkins -> Credential -> System -> Add credential

Configure remote nodes

Jenkins -> Manage Jenkins -> Manage nodes ->  Add node

Configure Pipeline

Jenkins -> New Item -> Pipeline