|
|
# # Microservice Sofware Development on IBM i
|
|
|
|
|
|
Although I am going to be developing on my PC, please note, that this exact code is also running on my IBM i.
|
|
|
Indeed, the demo website you're about to see, _is_ running on my i-box at home.
|
|
|
In other words, I can develop, locally, on my PC, and deploy to my IBM i, just like on any another modern tool chain. _*#MakeIBMiNormal*_
|
|
|
|
|
|
My argument for using SOA, and specifically microservices, is many fold; Over time, I find it easier to maintain many small programs that each do one thing well, for my mind, it helps prevent code rot, it forces me to architect things that can be testet and run in isolation, it provides for a sane way to enable fault tolerance and so on.
|
|
|
|
|
|
But most importantly, it is because it gives me a "right tool for the job" option, different programming languages have different properties, and sometimes implementing something in one language is a lot easier than in another. - with a microservice based architecture, I can quickly build systems, and if needed, swap out components if need arises, with less fear of side effects.
|
|
|
|
|
|
Although the demo is syntentic, we've tried to _make a thing_ that could potentially _be_ a thing, meaning this is *not* a hello world application.
|
|
|
|
|
|
It is built with free opensource tools and frameworks, where most even allow you to modify them, if you needed to. And again, this is all running on IBM i, with one, none essential bit, running Linux on Power - That is mostly there to promote using free cores, which most of the boxes, I've seen at least, have!
|
|
|
|
|
|
**Warning!!**
|
|
|
We're about to enter David Spurway ([@D_Spurway](https://twitter.com/d_spurway)) mode ;)
|
|
|
Ready? - Lean forward :) ... 3,2,1... _GO!_
|
|
|
|
|
|
# Demo of site
|
|
|
|
|
|
* Usually with travel websites, it is the same old story, you enter a start and end date, pick some random destination your hip friend told you about, and the system gives your possible ways to get there.
|
|
|
|
|
|
* We propose a shortcut! **Vacations on your schedule!**
|
|
|
|
|
|
### Introducing [Travallar](https://travallar.proxy.sitemule.com)
|
|
|
|
|
|
# Walk through
|
|
|
|
|
|
* Google Website Credentials
|
|
|
* [Create access, setup endpoints](https://console.developers.google.com/apis/credentials?project=travallar-demo-sitemule-com)
|
|
|
* [Google API's, specifically calendar](https://console.developers.google.com/apis/library?project=travallar-demo-sitemule-com)
|
|
|
|
|
|
* OAuth2
|
|
|
* Open authentication is a way of allowing a user to use their google, facebook, open-id etc. credentials, to access your website, instead of having to register directly with you; A side benefit, is that you can then also gain access to the service providing those credentials, knowledge of that user!
|
|
|
![OAuth flow](https://assets.digitalocean.com/articles/oauth/auth_code_flow.png "OAuth2 flow")
|
|
|
* During this talk, we'll need some tools and such, I'll briefly name them, but they're pretty common, and googling them will provide more update information than I could possibly provide in the allotted time, one (two or more) such items are...
|
|
|
* [Node.js](https://nodejs.org/en/)+[NPM](https://www.npmjs.com/) - (And in particular the node modules [Expressjs](https://expressjs.com/) and [Passportjs](http://www.passportjs.org/))
|
|
|
* These enable the use of javascript on the serverside, and we'll make use of that to begin with.
|
|
|
* AuthService - [Service flow diagram](https://travallar.proxy.sitemule.com/img/Travalar-Service-Flow.png)
|
|
|
* `git clone https://gitlab.devops.sitemule.com/demos/i-ug-uk/travallar/authservice.git`
|
|
|
|
|
|
* The most important bits for your fancy new project would be `npm install passport passport-google-oauth`
|
|
|
* The user performs a [login](http://localhost:9083/auth) and hopefully, google calls the callback (The endpoint we told them about earlier)
|
|
|
![Session domain](https://travallar.proxy.sitemule.com/img/code/1-auth-callback.png)
|
|
|
Code for login, is![Session domain](https://travallar.proxy.sitemule.com/img/code/1-auth-login.png)
|
|
|
Of course, there is a logout
|
|
|
![Session domain](https://travallar.proxy.sitemule.com/img/code/1-auth-logout.png)
|
|
|
* Bind session cookie to the shortest shared internet domain.
|
|
|
![Session domain](https://travallar.proxy.sitemule.com/img/code/1-auth-session-domain.png)
|
|
|
* Redis
|
|
|
* [What is it](https://redis.io/)
|
|
|
* In-Memory Key/Value store, we're using it for session management between services.
|
|
|
* Installation and startup
|
|
|
* `ssh username@your.ibm.i`
|
|
|
* `yum install redis`
|
|
|
* `redis-server`
|
|
|
* They have a CLI interface, which is very useful, but we need something more service like...
|
|
|
* Redis REST service - [Service flow diagram](https://travallar.proxy.sitemule.com/img/Travalar-Service-Flow.png)
|
|
|
* `git clone https://gitlab.devops.sitemule.com/demos/i-ug-uk/travallar/node-redis-rest.git`
|
|
|
|
|
|
* or `npm install redis` to your own project.
|
|
|
* List all keys (or by pattern)
|
|
|
![List keys](https://travallar.proxy.sitemule.com/img/code/2-redis-keys.png)
|
|
|
* View key content
|
|
|
![View content](https://travallar.proxy.sitemule.com/img/code/2-redis-key.png)
|
|
|
* Calendar - [Service flow diagram](https://travallar.proxy.sitemule.com/img/Travalar-Service-Flow.png)
|
|
|
* A note on [Spring-boot](https://spring.io/projects/spring-boot)+[Gradle](https://gradle.org/)
|
|
|
|
|
|
* Let's talk to [Google Calendar API](https://developers.google.com/google-ads/scripts/docs/examples/google-calendar)
|
|
|
![Connect to google](https://travallar.proxy.sitemule.com/img/code/3-calendar-connect-google.png)
|
|
|
And fetch the users events, call their service
|
|
|
![Calendar events](https://travallar.proxy.sitemule.com/img/code/3-calendar-events-google-1.png)
|
|
|
... and return the results...
|
|
|
![Calendar events](https://travallar.proxy.sitemule.com/img/code/3-calendar-events-google-2.png)
|
|
|
* Let's talk to and [ILEastic service](http://dksrv133.sysmet.local:9082/travel/roundTripFlights/?fromAirportCode=CPH&fromDate=2019-06-01&toDate=2019-07-01)
|
|
|
* It's so easy, I didn't need to crop the code!
|
|
|
![IBMi data](https://travallar.proxy.sitemule.com/img/code/3-calendar-flights-ileastic.png)
|
|
|
^^^That really is it!
|
|
|
* Website - [Service flow diagram](https://travallar.proxy.sitemule.com/img/Travalar-Service-Flow.png)
|
|
|
* Joining it all together!
|
|
|
![Bootstrap](https://travallar.proxy.sitemule.com/img/code/4-website-bootstrap.png)
|
|
|
|
|
|
* A template for user details
|
|
|
![User details](https://travallar.proxy.sitemule.com/img/code/4-website-user-details.png)
|
|
|
Search template
|
|
|
![Search template](https://travallar.proxy.sitemule.com/img/code/4-website-search.png)
|
|
|
Search code
|
|
|
![Search code](https://travallar.proxy.sitemule.com/img/code/4-website-search-code.png)
|
|
|
And show the results
|
|
|
![Search results](https://travallar.proxy.sitemule.com/img/code/4-website-results.png)
|
|
|
|
|
|
* Nginx
|
|
|
* [What is it](https://www.nginx.com/)
|
|
|
* Very high performance load balancer, meaning, it routes http requests round the system really fast!
|
|
|
|
|
|
* We'll use it to create a single point of entry for our app, and offload https on it - Remember that shortest shared domain? Now is the time to shine ;)
|
|
|
* Installation and startup
|
|
|
* `ssh username@your.ibm.i`
|
|
|
* `yum install nginx`
|
|
|
* `nginx`
|
|
|
|
|
|
* A comment about [https (and http/2)](http://www.http2demo.io/) - _speed_ is a _feature_ !
|
|
|
* And the none essential (Nginx is fully configured in plain text files) - This looks better on stage: [Nginx-Proxy-Manager](http://localhost:81) (Full disclosure; We run that with Linux on Power)
|
|
|
|
|
|
# DevOps
|
|
|
|
|
|
* Coding locally, deploying automatically!
|
|
|
* Mainly; We use git and gitlab ( That's a session! )
|
|
|
|
|
|
* We use gitlab, because it allows both cloud and on-premise, self hosting, also...
|
|
|
* Opensource and has free edition
|
|
|
* Private AND public code repositories
|
|
|
* Testing and monitoring code, unit tests, integration tests and end-to-end testing:
|
|
|
There are _many_ options - If pressed for time - Have a look at cypress.io end sentry.io ( Another session )
|
|
|
Importantly, I've yet to meet a solution that didn't, at some point, require tweaking - Most developers/clients have their preferred way of doing things, and I find it is better to cater than subjugate!
|
|
|
|
|
|
* IBM i challenges
|
|
|
* Gitlab doesn't support Power architecture (yet) - we run our own copy, but you could get an account on their cloud; In fairness there are obvious alternatives, but I actually like gitlab ;).
|
|
|
|
|
|
* Importantly, Gitlab-runner, does run on Power, but requires Linux (That is actually a benefit for us)
|
|
|
* Free cores on power system, doesn't tie up resources on IBM i partition.
|
|
|
* Custom glue, to make nice with i
|
|
|
* SSH
|
|
|
* Shellscript
|
|
|
* `system` command
|
|
|
|
|
|
### Aaaaand breathe... Thank you for your attention.
|
|
|
|
|
|
|
|
|
|
|
|
# Q/A:
|
|
|
|
|
|
* I stand at the ready, physically for the rest of the day, and always at jmc@sitemule.com ! |
|
|
\ No newline at end of file |