 welcome everybody how are you now have you had lunch we energize it cool I'm glad that you are here so let's start talking about microservice with communities Docker and Jenkins for those who don't know me my name is Rafael Benevides I work for Red Hat as a director of developer experience if you'll get into the one to get in touch with me you can send me an email my mail address is Benevides at redhat.com or you can also find me in Twitter my Twitter handle is Rafa Bene I guess it's much more easier I'm always living there at the Twitter I've been working with Java for quite a while more than 15 years I guess so it's even more pleasure to be here at Java one so before we start in talking about communities microservices and Jenkins I like to invite everybody that want to know more about micro profile that that was just released there will be a launch Thursday on 11 30 there will be an that's will that will be a good opportunity to know about what is micro profile and what are the this initiative and how it relates to Java E and all this kind of knowledge and information and also I'd like to invite everybody here to join the developers dot red hat dot red hat dot com with a portal there that we can find resources for developers like you can have free access to products so you can have free access to a books blog posts a lot of information as well so let me start here asking who ever ever run Java application inside container inside Docker and now I have another question why did you do that if Java is supposed to be portable among virtual machines perfect so let me reply his answer Java is portable among virtual machines but sometimes you need to and that all other things like the application server with your pre configured thread pool with environment variables data sources everything else so we have a lot of advantage when you are running Java application inside containers but I like to also introduce you to Kubernetes Kubernetes is a project from Google Google has a lot of expertise with containers since 2008 they are deploying almost two millions of containers per week so even before containers become popular like since 2014 Google is working with containers but they use an internal project called Borg and what they did is get that knowledge and release an open source project called called Kubernetes and it's one of the most popular project inside GitHub you can see that there are a lot of contributors a lot of commits and even more GitHub stars and red hats is the second top contributor of this project I want to show you this application is it was an application that I presented when I was talking specifically about Kubernetes and this application uses two microservice one is the guestbook service that is a micro profile application using wall flies worm and another thing that we will do is instead of deploying a pre built image of hello world service we will build one from scratch and deploy that using a Jenkins pipeline okay this is the overview of the application but of course we will have a chance to reveal how would we run a Kubernetes microservice so let me start here this demo let me increase of course the font size okay so again let's get the our guest book source guest book service source the first thing that we need to do with a Java application is run the Maven package right I have here a shell script that will run the the Maven package and then after that we'll build the Docker image for us so what it's doing now is that after it created a war file it will get use the wall flies worm plugin and package the war file together with wall fly and create a fetch are the guest book service swarm fetch are that contains the wall flies worm you just need to run a Java manager Java dash dash jar in this wall flies worm and it will start the application for you and something that I also did is use Docker file to create this image as you can see this this parent image just has the open JDK the JDK 8 I specify the environment variable to limit the hip memory and also I added the fetch are inside my my image so I have this image now in my in my internal Docker registry since I have here people that have have worked with Docker how would we run this image with Docker can who can can give me a tip suppose that I don't know Docker let's see Docker run dash D to create a detached process it's also a good practice to give the container a name so it would be guest book service and then the name of the image right yeah that's what you usually do to run a Docker process but now I want to run that using Kubernetes to run Kubernetes it's almost the same but instead of running Docker run it's Cube CTL run the second per parameter is already name and then you can specify here the image with the image parameter but you can do something more let me open here the open shift console this is the my sequel instance that I have already running here I can specify the numbers of replicas here is straight from the console I want to run two replicas of this image of when I do that it automatically created replication controller as you can see here replication controller guest book service created with two pods running of course each one of these pods has its own IP address I need to create an abstraction to be able to connect to those service with Kubernetes I can do that running Cube CTL I want I want to expose that replication controller that's called guest book service using the part 8080 because it's a wildfire container that runs on part 8080 when I did that it created a service well we can see these two replicas running here I cannot scale it up and down with these two arrows I can see the pods running here or I can do a Cube CTL get pods you can see it's both the same name a1 xxc pl hg0 I can follow the logs of each one of these pods they are they have been started and we can see that the replication controller will always keep two replicas running so for example if I open the bash inside this container I'm now inside the container I can see the Java process here and suppose that I kill this process or this process died for any reason as you can see it it's crashed at my terminal and the replication controller created another restarted the container for me so again q1 look here it restarts a container and I always have two replicas running so this is one of the ways that I can do to run a process inside a Kubernetes process inside my cluster but on honestly I prefer to keep all the resources declared inside the MO files so instead of typing Cube CTL run the name of the image the name of the port I can for example here specify everything that I need in a YAML file I can store that YAML file in github I can have multiple people working I can have track the version track the changes so what I will do now is deploy the all the front end for that application again the hello world service the second service we will deploy that via CICD pipeline so let's create it here to create using a file I will use Cube CTL create dash F the name of the file which is front end RC for the replication controller at the front end their service for the service when I did that I have now the front end and the guestbook service running now I need to expose that to outside of of OpenShift I can do that running creating a route so what I will do is get this IP address and I will give a name of Java one plus this host here that I have a DNS pointing to this host once that I create I can click on the host name and finally I see the application running I know that the database is working because it returned this record here this registry here from the database and you might ask how the application how this guestbook service knows where the database is well let me open again the the bash all the cluster all the pods inside Kubernetes we uses a software defined network so if I ping in the name of the service like for example ping my sequel it will resolve resolve to the name of the service or I can use an environment variable because when one when I create a service environment variables will be also created to point to the IP address and the port of the exposed service so that's how it knows the same thing I can do with for example the front end get pods kubectl is ack the name of the pod bash I can grab the guestbook so I this is how the front end knows where the guestbook service is running so this application is very simple but when I because it will post the message to the guestbook service it will restore in that in the database but it will also try to run a hello world so welcome everyone when I click submit there is a error here because the hello world is not running but the message was stored inside the guestbook service we need now to create the hello world service what I will do to create the hello world service is use fabricate so let me open here fabricate fabricate first is a microservice platform it says open source project that integrates Jenkins nexus gets a git server so let me my browser froze let me force quit and open it again restore okay close this page close this one and let's open fabricates admin admin here in the fabricate console I can have multiple teams because each each team can work with your own set of microservice so you'll get here the default team now this team will create the hello world service I can create it from the fabricate UI I don't need to know about talker I don't know I don't need to know about Jenkins I don't need to know how even how to create for example a spring boot or a Node.js application because once that I click here click here and they create the project it will provide some templates in different technologies but we are in a Java conference so let's use a Java a spring boot application right it needs to be the hello I've increased the font size hello world service next now it has the same screen that you see in the start.spring.io you can choose the version you can choose your dependencies so I will use here a web dependency and re actuator to guarantee my the health of the application when I click it next this the fabricate already created the project here in a Git server that's running inside for OpenShift it was provided provisioned together with fabricate so let's see that gogs admin red hat one okay you can see here I have the application the next thing that fabricate asks me is what kind of pipeline do you want to use I have here a library of pipelines with different stages this just deployed in this test and environment I'll use this one that's most complete I need to have my source code reach in the production and brief before the staging the staging in the production I want to have a manual approval process so are you choose this one I want to copy that to the project click next and as you can see that my project will be we will have another commit with the Jenkins file that controls the pipeline at the same moment this project was also placed inside the Jenkins that's running together with fabricate so as you can see the hello world service was created and I build number one just started and let's wait for this project to have the pipeline completed as you can see it's a typical Java project in this case here that I did don't need to know about Jenkins I don't need to know about Kubernetes I don't know if even by the way the dependencies are being obtained by an internal nexus server so let's open there isn't internal nexus service I closed it sorry because inside the POM XML of this application there is a definition of this nexus ripple yeah for no JS projects I guess there there will be an internal no JS server so okay it's running here but we need to make some changes in this project so let's check out this project here projects Java one git clone it's cloned I can open this project in my IDE I can see sorry they the fonts a little bit small but you can see that's a typical spring boot application and what I need to do now is implement the hello world instead of typing everything what I will do is cheat a little bit I will deploy the code using a script okay we can let's refresh our our IDE and now you can see that I have a rest API that we will expect the hello and the name let's see what's happening with our build the build now is waiting for an approval I don't want to send that version to the production it was already deployed here in the staging so let's not approve that let's abort the build number one we can also verify here that inside open shift that hello world version one was deployed in the station I also don't want to have that in the station so I will delete that and what I want is that version that I just created so I don't need to build it locally I just need to commit that so let's get status get add the POM XML and the source let's commit my code added code and let's push that to the origin once that I committed you can see that in a few seconds Jenkins will detect that and it will start start automatically the build number two let's okay we have here the build number two running we can also see that the changes that I did is now inside gogs there is no there is my commit here the builds running inside Jenkins but you can see also inside fact the fabricate console and let's wait for this builds as you can see here they I deleted the the station environment and once that this pipeline wants to deploy the application in the pipeline it will recreate the station environment for me with this version while while it's building I want to use the opportunity to verify if you have any questions okay running the integration testing because something that all every pipeline needs to have is a testing how do you guarantee that at the least the basic features are working sorry yeah in this case here is just a place mark for integration test there is no real test implemented but it that shows to you that at that place mark you should implement your integration test so now it's waiting to approval the station environment was created let's approve that to go to the production let me okay proceed now note here that it created the version 102 in production we can open the production environment here and see that the whole world world service is being deployed and we can even open the pod here to see the container starting it's a that spring boot application we can follow the logs and let's wait for this application to become available so we can finally test and see that our front end is working let me open here that let me get the hello world logs follow it takes a while to deploy but let's try it Rafael test one oh it's working so I got the the result from my application and that application as you can see as you saw was created without any interaction directly with Kubernetes the Jenkins pipeline work was created automatically for you the next server was provisioned for you the GitHub server I just need to check out my code do the the change that I need commit that and the build run automatically for me any questions questions questions well this is the question is is this running in the cloud can I run that in a in enterprise well fabricate is that open source project made for my microservice there's no no no product supported for that yet is more project from the community but shows that concept to create microservice environment if you want to know more about Kubernetes I want to invite you to the Kubernetes for Java developers it will be a three hours lab that will happen tomorrow from 12 30 to 2 30 it will be a great opportunity to go from the very basics from Kubernetes until OpenShift also don't forget to subscribe to developers.redhat.com and if you have any feedback from this session if you want to see or just get in touch with me my email my Twitter handle is Rafa Bene I'll be very very pleased to answer your question or hear your feedback thank you