 Good morning. Good afternoon. Good evening. Wherever you're handling from welcome to the developer experience office hour here on Red Hat live streaming. I am Chris short host and Showrunner is the proper TV title. I've been told I'm joined today by DeWon Ahmed and Eric Andrea We're gonna have an awesome time with fruit apparently I'm curious how this is gonna go DeWon Please introduce yourself for the audience and tell us what we're doing today Absolutely, so my name is DeWon and I'm joining you from the beautiful new Brunswick Which is in the eastern part of Canada and we'll have some fun with fruits. What's your favorite fruit Chris? Oh gosh, probably. Oh man. That's tough favorite fruit probably oranges or blueberries like you know, I mean So one of those one of those enriched high in vitamin C ones then yeah, exactly, right? Okay, a lot of antioxidants that kind of thing. Yeah, okay going to going to Eric then for his intro and favorite fruit My favorite so good like Chris said good morning. Good afternoon. Good evening. Wherever it is that you are I'm Eric DeAndrea like DeWon. I'm not nest not in Canada, but just below him I'm in new those great state of New Hampshire granted state My favorite fruit. I like watermelon, especially this time of year. It's been really really good We buy a lot of watermelon and it's been really really good this year Perfect hard to find in the winter time though So so Chris, do you know about this game where you chopped the fruits with the sword? Yeah, no my daughter played that quite a bit when it was popular. Yeah, so someone told me Eric has a black belt Wow, I do have a black belt in martial arts. Wow. Okay. Wow, so we have a tech geek I can't do stuff though. We have a ninja on the show Really doesn't look like will he disappear and Other places. I mean what kind of maybe it doesn't work You know, you could hear and then reappear not on air My monitor screen action right now actually looks like I threw a Chinese star at it's got a big spider web crack through it I have no idea how it happened. So That's rough. Yeah Sorry to hear that And that was my Monday morning and of course the kids didn't do it No, like this is why you only have one kid because you know who always does it Well, you're the big kid right you got all the toys right like I mean But to be honest with you most of the toys back there for my five year olds enjoyment You just don't allow many where near miss because you know, he can totally grab whatever he wants off the shelf But the problem is there's just a lot of crap in front of it So, yeah, let's this was kind of the first Developer experience officer we've had in a while. So, you know, I apologize, you know think life has happened It's summer all these other things hell We had storms rolling through here this weekend that left me without power for almost 48 hours So, you know, there's there's a lot going on and DeWon is new to the team and this is his first office hour of sorts. So At least live here. So thank you for joining us DeWon. We really appreciate you. Yeah, thank you And we were chatting a little bit beforehand to this. This is kind of how we feel every day, right? Yes Yes, like especially today after not like having access to anything like cell servers power internet anything yesterday Like coming to work today is like that right there How you want it to be like right like yes, yes, very nice the world and harmony kind of thing. Yeah But instead it's just T-rex chasing Even if we don't know sometimes we're the T-rex and we're probably chasing someone else We always think that we're the we're the person on that on that Jeep, right? Yeah, exactly Awesome Okay, so what are we gonna talk about today? well You tell me something about Since since we started the show with talk about six fruits so maybe maybe let's talk about fruits, but How to build a fruit sap, maybe All right Let's so are you're you're doing this on Your own can your own cluster. This is not a lab. Okay. Cool. Yeah, just make it sure yeah Yeah, yeah, so so let me start by sharing my screen and if you if you can see my cool t-shirt That's the only Java t-shirt. I could find nice in my wardrobe. So so we're gonna we're gonna build something with with spring framework and We will deploy the app on OpenShift But the good thing is what we're gonna show you today. You don't have to have access to an OpenShift cluster So let me start by sharing my screen. I was gonna add on while he's doing that is that he mentioned It's his only, you know, cool t-shirt the only clean cool t-shirt. Yeah to be clear, right like Very clean. Yes. Yeah. Yes. Yes, it's all like sprayed with hand sanitizers, so it's very clean and Okay, so I think you can see the link on on the screen learn that OpenShift dot com but My friend can also add this link on the on the chat or comments or however you're seeing this. Yeah, okay Okay, perfect. So learn that OpenShift dot com Actually, let me go to the the main page so you can also see how to navigate here And there's tons of scenarios for for different topics But today's topic is developing with spring and spring book So if you click that tab right here, you get six scenarios. Let's start with the first one getting started with spring If you click on start the scenario This this setup runs on On on an OpenShift cluster which which is not your OpenShift cluster This is provided for you as a sandbox And I think if I'm not mistaken, this is live for 60 minutes But that should be more than enough to to complete this scenario If you somehow can't complete in time you can refresh and you can have access to one more 60 minutes environment So once you you start this scenario some magic happens in the background So basically it installs some required software and once you see this ready, you can you can start the scenario One of the cool thing with that is you can type in the command, but you can also click and execute So for example, if I do an LS dash LA, I don't have anything here So first step is you have to clone the repository. So if I click that bam, it clones the repository See now I have a typical looking Java project with palm.xml. Let me clear up the screen Maybe put it on top. Nope, not there Yeah, like that. And if I do a tree, I can see the the file Structure folder and all the file structure as well All right, so that's all nice and great. Let's look at the palm.xml So if we look at the palm.xml You'll see a typical palm.xml with some to-do So these to-dos are stuff that we would like you to add yourself Just to get used to the scenario and and do the scenario yourselves But majority of the stuff are already added for you So this is more like a template and you add only the missing pieces Again, all this thing you can type by hand But because we don't want to do that, we can do just click and execute So if you come here this section, you see a nice copy to editor button Watch the line watch line number 59 So this is the the dependency for spring boot started web Web dependency if I click here There you have that dependency added So that's the very first of the dependency just to even run the application We add the other dependencies, but for the first step, you don't need anything else You can click maybe in spring boot run And it starts running. So this is a after maybe even downloads the internet Yes. Yes. That's why I wanted to say if you actually the introduction we had We could have the introduction right now How how's everything the state of world Whatever you wanted to chat probably now is the time when we even download the internet So let's discuss how much of the internet is actually downloading. I mean hundreds of megs gigs It's probably I mean if you think about you take a spring boot app and you package it into an uber jar It's about 100 megs six between 60 and 100 megs somewhere And yeah, we were just overestimating the runtime because I think it was like seven or eight seconds Till we made the joke seat the jvm running for one dot three seconds So now you have the app running so where you can see the app where you have two options First is you can click right here the local web browser not there. That's just an image You to click right here local web browser and There you go as you said you can add or edit a fruit You can also Get this same link by clicking here use this link. It takes you that same app Now, of course, we don't have the methods to actually add or get at the foot. This is just an slash api fruits The list doesn't have any fruit. So that's what we can expect So I think Eric was mentioning about watermelon So if we do say it's not going to do anything because it doesn't have the methods to to add the fruit But but don't you worry. We are going to add that watermelon to the list. That's our promise Sometimes today All right, so so now that we have that let's do a control c exit that process and congratulations We will keep congratulating you on every step because we are sure you can do it. Okay, so Let's go to the next step Now we have to read content for from a database from this step and we add A jpa to this application so you can see line 65 if I click copy to editor you add the dependency And h2 is an in-memory database right Eric or spring Yeah h2 is an in-memory database. Yeah, right, right, right So that that's just a quick way of if you're under test your application. You can use an in-memory database rather than Maybe spinning up an actual like a full-fledged database So we'll add again. That's if you scroll down on the palm You'll see there's a section add h2 dependency line 130. So copy to editor So now we're going to the the meat of the of the project where you have to create an entity class The first one is the fruit class fruit dot java So if you see source main java We don't have anything yet That's gonna change. So if I click copy editor, you can also like click here and then copy to editor It's gonna do the same thing copy to editor actually opens up the of the file on the on the UI and then copies the content If you like them, you can also do that stay like a vm and then you can copy that file name and Add that from the terminal with however you want you can you have lots of options So here we're adding that the fruit dot java Has some some it has the constructor it has some some methods as you can see Now we need to create a repository class for for a content like some something that will talk to the database so like it's like it's a middle layer from from your from your source file and talking to your database Yeah, one thing to kind of point out there too Dewan is that entity class is just standard jpa There's really nothing spring related So any application that you are building in whatever framework that supported jpa would be the same rough. Yeah much Yep. Yep And to do let me Open up this link right here on a separate tab and we'll come back to that Later, but that will be handy sometimes later So next we have to populate the database with some initial content. There's nothing in the database right now So if we click here Just some sql commands sql sql One one of those two As you can see we have three fruits in the list cherry apple banana no watermelon yet Next who doesn't like testing right we have to have a test class application test or java copy to editor Do you see the application test or java source test java? um Yep, we see application test java All right, so at this point We have the necessary structure to run may even verify we have some classes some methods And we have a test class that tests those methods So if we do may even verify Now apparently maven didn't download the whole internet the first time. Yes. Yes. So yeah, I wanted to ask Sliver at least. Yeah, just part of it. Just part Is the concept similar to um Docker file eric like where it caches all the previous stages Um, let's say if I do maven x command and then maven y command the previous dependencies that may even download it It only downloads the thing that it didn't download in the previous step. Is that right? Yeah, maven has a cache on the file system that Any dependencies it's already downloaded it won't read download So I think the first time when you ran it you didn't have a test class So there was nothing for it to do for sure fire to do so it didn't download any of the test scope dependencies But when you ran verify the second time They said hey, I've got some stuff to do but I don't know how to compile this stuff Let me go out and download everything I need Correct and that applies to let's say the version as well. So if I have uh a dependency and I updated the version It's gonna again download the the newer version, right? Correct. Okay All right. So as you can see on the screen, we did run the maven verify and as expected We can see test run five no failure. So all our tests passed. Whoo. So that's that's a good step Again, congratulations, uh for completing step two out of five So we should have like an icon that has like a pat on the back kind of thing like pat yourself on the back You know, actually on that note. I I saw a patent online Pat on the back patent. You can you can google right now like pat on the back patent So someone actually paid in an idea of a device Which like you attach here and then you you move that and then the mechanical arm that hats you in the back This is apparently a patent on that Okay, so coming back to the We're a bundle of useless knowledge. We should go on jeopardy Right So coming back to to rest so so far you have your application running locally So no one can access that right so on other than yourself. So opening up To the internet means you add some rest endpoints So that folks from the internet can can talk to your application See the list of the fruits you have so for that we'll start with the fruit controller Uh, so you can see this this class has and again an empty to do so if I take copy to editor We'll add those those methods. It doesn't have anything except slash api slash fruit slash Slash fruits, which is just a list tongue twister Okay, let me throw something else in there too people a lot of people it's spring I'm familiar with like the thing called auto wired and you notice there's no auto wired on the fruit repository and You might start like asking why why is there no auto wired and that that goes to What's called field injection versus constructor injection and Although the spring team doesn't come out and say it, you know in any of their documentation They they really do recommend constructor injection over the field injection for a lot of different reasons one as a myself as a committer If you do field injection, you're they won't merge your code You have to do it this way as a as a committer But there's there's a couple different reasons why and if you think about it Passing your dependencies that a class depends on if you just have them as fields It makes it really hard as someone who's trying to use that class to know what what things do I need to provide this class in order For it to function properly, right by using constructor injection. It's pretty obvious, right? It's a kind of a self documenting thing Plus there's you know, I don't know how measurable it is But there is some performance benefit because at runtime it doesn't have to use reflection to do the injection It can just call new pass the thing and be done with that So just a little little tidbit of information. No, no that that that's That's a that's a lot of helpful information. So here if you see the the method Find all so you can you can find this method in the classes we have written But if you see it the the type of repository variable is fruit repository So if I see fruit repository it imports this particular package and If I look here in the document in the spring documentation and try to find this method find all I can see where it gets the the definition of the method So coming back here So we added The the fruit repository class Well, we added that before so here we added fruit controller class. Let me Open up fruit controller right here here. So we added fruit controller With some to do to add additional service calls here So with the empty service calls we can now again run Maven spring boot run At this point We're skipping the test because we actually don't have any test to test the endpoints which we haven't added So you can see that jgm is running. I can go to my local web browser And see it here And if I try to add watermelon at this point We still can't because we don't have the methods In order to add add a fruit. So so that's okay Next We'll create additional service. So here we can update create and delete. So if I click copy to editor So you can see the post mapping This dot repository dot save. So this should let us Save any new fruit that we're adding to the list Eric, do you have any comments on on any of these? No, no, it looks good. I mean like like anything in software engineering There's a million different ways you could solve the same problem and the same holds true in spring I mean, there's like you notice there's like some exception handling and validation handling that's there That's one way you could do it. There's probably five other ways that you could do it as well Yeah, yep So I know you all have been waiting eagerly to to see the watermelon Eric's favorite fruit on on the list. So let's see if we can get that working In this try and this time I'm not going to click this link right here We can go from this link which should pick us to the same list All right, so let's see watermelon There you go On a on a hot summer day. We now have the essential watermelon in the list And talk about uh good fruits Apple in this list is my least favorite fruit. So let me try to remove it Yes, we are able to remove. So it seems the methods that we added are working We can we can see the list which is just in slash api slash fruits and then we can add fruit We can even update the fruit, right? Probably we can favorite cherry So we can we can update the fruit So if you're watching this live or you're watching this at a later time We have a challenge for you. So let's say watermelon if I add it again It adds a second watermelon So the the to-do for you if you're watching it at any time now or in future How do you add a check so that it doesn't add the same fruit to the list? So that's that's that's your to-do All right, so let's let's do a control my mind's already racing challenge accepted, you know after this I'm gonna have to go off and do I'm one of those kinds of people that I can't just like you can't let it go I can't just let it go. It'll bother me like I won't be able to sleep tonight. It'll He's gonna have to wake you up in the middle of night haunting your dreams kind of thing Yeah, I only wanted one watermelon, you know, I really like watermelon only one at a time I can't have two watermelon though. It'll go bad. You can't eat it fast enough I imagine that The dinosaur chasing you with a watermelon giant watermelon Okay, so let's clear up the screen continue to the next tape so all good I know we've been talking a lot about the local Environment and and building a spring app But now you have to deploy and let's deploy to the best platform best cooperatives platform on OpenShift Okay, so if you haven't used OpenShift before Let me show you one more scenario. So if I go to learn.openshift.com I think somewhere at the bottom you have OpenShift playground So you can go to OpenShift playground and choose whichever version will say OpenShift 4.7 It's going to give you one more 60 minutes Sandbox where you can type in different commands and learn about OpenShift And once you're familiar, you can all the instructions are here by the way But in case you want to get more familiar with OpenShift, you can have you can have that playground So coming back here. So we have our code right here on this directory And the first step would be for you to connect to your OpenShift cluster So since this is a sandbox, we are already connected to the OpenShift cluster OC who am I will show us like who's the who's the current user? So it shows we are the admin so we can do a lot of stuff Admin OC delete all dash dash all dash and dash all That sounds like a great idea For that for that we need odd z not only odd n we need odd z who can do what? All right So let's let's be let's just create a simple project. Let's not cause any havoc Let's say you do something at that OC delete and then Chris's internet goes down again, right? So we don't want to do that. It's got to be again. It wasn't my fault I Can't prevent natural disasters. I'm sorry Using using OC delete commands could could cause natural disaster. No, that's that's not true Since we're on air Chris isn't going to invite me on any more of these things. I know right? Okay, so now that you have You are authenticated to the cluster. You have created a project. Let's actually go to the open shift web console Oops, let's try again open shift console Should probably mention to the whole scenario itself is running on an open shift cluster So even like when you're doing ls and you've got that nice terminal whatnot. You're already on an open shift cluster So yes, you're just going to the same cluster. Just a different project. Yes. Yes, and and probably This will be fixed as later did but if you're if you're trying this scenario now I will suggest you use admin admin credential to log in rather than developer developer because If you are developer, you probably won't be able to switch projects Right now because we are using dev project And let's say if you're people project, you probably won't be able to switch right now So if you go from here administrator, you can see all the projects Dev is the project we are we should be on and now if I switch The perspective to develop perspective. We are in dev. We shouldn't have any resources. It's a clean select So first step after you create the project would be Creating a database a postgres equal database. So remember we were using an h2d database in in previous steps But now you can and that is as simple as oc new app And some some environment variables for for the username and password And then you specify this is the image image name open ship slash postgres equal and the version and you give it a name So once you do that, let's go back to the topology and so you can see now the database is starting up If you're using open ship for the first time the the sign blue circle means The deployment config or the pods Are still setting up. It's not running. And I think the solid blue. Yeah, right like that It means it's running. So if I hover my mouse, it says it's running All right, so You can see the database configuration here source main jcube deployment dot yml And again you can go you can navigate from here or you can just click right here And it's going to open up which will show you the db username the db password And so shall we talk a little bit about what jcube is so like yes, please Yeah, so jcube is a it's a set of maven plugins for interacting with kubernetes platforms and open shift being one of them So it's a way where you can take your application your java application It's not real specific to spring But I just through running a maven command deploy that application To a kubernetes cluster in this case We're using the the open shift maven plugin because it we're dealing with open shift So there's some open shift like a deployment config instead of a deployment in a root instead of an ingress and all that stuff And so what you can do is if you go back to your editor there and you go into that source main jcube directory Is you notice this if you scroll up to the top of the editor That's not a a complete well actually this one is a complete one But it doesn't have to be a complete manifest file. It could be just what they call a fragment So it'll create the jcube plugin when it runs It'll actually create all the necessary kubernetes manifests And it'll look in this source main jcube and if you've specified anything So in this case, it's like deployment or deployment config dot yaml It'll apply those on top of whatever it generates So if you overwrite something like an environment variable section or what add some labels or whatever It'll apply that on top of whatever it generates before it does the actual deployment And this is kind of the next incarnation to do if there was the old fabric eight maven plugin and suite of tools So this that kind of died on the vine and and this is the new incarnation of that which Reuses a lot of the code but it's it's a little bit more structured because I you know I'll throw my hand out there and say i'm a gradle fan and not a maven fan That this kind of stuff didn't exist in gradle before I still don't think it does But it's it's getting there because they've done a lot of refactoring and a lot of retooling around how the the code is structured so That's my two-minute Spiel here No, that that's that's very important. And also Eric like here. I see that for for openshift maven plugin It helps with like building s2i images So for example, when we do that the command we haven't executed yet, but when we do maven oc deploy We'll be able to see like how it builds the image before actually deploying it, right? So s2i is one one mechanism where Openshift builds container images right from your source repository So you don't have to have a docker file. It's just one of the techniques how Openshift builds right so I can see that openshift maven plugin. It has An integration if we may say uh to to build those s2i images Yeah, so s2i I mean that I think the term s2i gets thrown around and there's really three different use cases that we call source to image There's true source to image which is like what you just said where you just give it a github repo or bit bucket or whatever And it'll actually take your source compile it and then create a container image around it But in this case, we're actually doing what's called a binary build where we're going to use maven on our And I'm in air quotes here local environment, which is our catacoda environment to produce the uber jar And then the we'll just tell Openshift. Hey, Openshift I've already built that binary just wrap it in a container image and deploy it for me And so that's still considered in again in air quotes here s2i. Yeah, but it's not actually doing the maven build It's already built because I know a lot of organizations at least where I used to work A part of our build process we take that jar that uber jar and we'd still publish that to like nexus or Artifactory or whatever it is that you're using Because you might want to run that outside of a container somewhere You know in some way shape or form But then you need a container image to run it on a kubernetes platform like Openshift Right, right and that reminds me of the pre-container era where the actual jar was the The deployment artifact like you produce the jar and the jar that's the jar you pushed onto some other vm And that's what around the server But now is the container and container image is what you use to deploy your image Coming back to it's like if you had a local you're in again in air quotes If I were doing it on my laptop here, you know a lot of organizations are so locked down You can't even install a java runtime, right? So assuming you had a java runtime But you can't install the docker runtime, you know that that's forbidden especially in financial services, which is my background You can still do this and build container images because the container image part of that is not actually happening on your machine And so you don't need the the docker runtime Got it so coming back So where we were was we logged into the Openshift cluster. We created a new project called dev We created a postgres SQL database called my database and we could see in the topology that you have your my database But we don't have the app yet But before actually creating the app we again have to so if you remember the palm dot xml It had lots of to do so in the last 20 minutes or so So we added all those to do but one to do or two to do actually are left one of them Is the postgres SQL dependency? So if I click here it has the postgres SQL database and the final dependency is a health check so using Spring Boot provides something called actuator and it exposes like that slash health matrix And if I click here, I think that's the other I'm saying what's cool about that if you're going back to the jcube conversation is jcube kind of understands it You know that your app is a spring boot app and that if you have actuator It knows that it has health and ready and liveness probe endpoints already built in So it'll add those to the deployment and the or the deployment config for you automatically that gets deployed So you don't have to go do that Awesome So now that our palm dot xml is complete. Let's actually deploy to openshift Single command. I think there's a maybe an package like build, but if you do like deploy deploy Does the build and deploy all together? So let's click that And you'll see More of the world needs to be downloaded more of the world needs to be now now is the other parts of the galaxy being downloaded and then Let's let's let's show the top of the g This is actually going to take a few minutes because the container build will take a minute or two to do so. Yeah It would be interesting elevator music I mean I can put on some music if you if you want us to We could talk about my book. We could talk about my Let's talk about your book. Yes, please Yeah, so I don't know if I did it in the introduction But in my background is spraying amma or at least I was for a period of time a committer a lot a lot of stuff in spring security But I was I was a committer and a lot of spring stuff and for those who haven't heard of this thing called corkis That's out there. I've written a book that's going to be published in August at some point mid to late august We're looking at corkis from a spring developers perspective. So looking at a lot of the conventions like spring data gpa and controllers and Cloud and kubernetes and all that kind of stuff But looking at it from the eye of a spring developer and kind of showcasing side by side Hey, this is how you do something in spring and this is what it looks like in corkis And by the way, it's not really so different. You know, there's really not a big learning curve to it. So Nice Do we have a link to the book yet or do we know where it's going to be when it does come out? And fortunately, we're still we're we're building that now. It'll be on developers.redhat.com. They'll be like, it's free It's not something we're going to send you to amazon and make you pay 50 bucks for it. Yeah, it'll be on the ebooks page I just it'll be on the ebooks page Cool Hopefully the end of august it'll it'll be out Beautiful. Yeah, you know, I know how books go just to keep it on air Eric did promise me a signed copy of like a physical copy of the book Assigned physical copy of the book when it comes out I've only have a handful of those Yeah, we're hoping to do a few printed copies as we start to get back to in-person events, you know, finally You know, these virtual conferences are kind I'm tired of they are. Yeah, they are what they are So we're hoping to have printed copies and you know, I'll do autograph sessions and whatnot if anybody wants it who autograph sessions Just have you in the red hat booth of the next conference signing books That's right. Who's that guy who's signing books? I got a crowd around me. I must be important, right? All right, it looks like it's done now that we yes Now that the bill is complete. No, that was a very important plug Now that the bill is complete part of part of the command You can see like your familiar doctor like commands where you can see like step one two like you see using a base image Um, so you can see like how the the image is built in in different different parts So once the bill is done, we can go back to the topology topology of you and you can see now the the deploy con The deployment config is there. Uh, you can also check from command line Oc rollout status the name of the deployment config is spring getting started let me clear up the screen And it should say successfully rolled out So this is running on open open ship. This is no longer your local local machine And if we click here, we should see the same fruits app and Let's see if we can add Eric's favorite fruit Yes, we can Eric finally can have watermelon on open shift so So so I think that's that's the that's the demo piece. There is something even more cool cooler Yes, cooler. So so let's say this is a 60 minute sandbox and you want more right you want more time you Yeah, you all you always want more So I think my friend is gonna add a link in the chat or comments for red hat developer sandbox So It's actually in the lower third folks that qr code there will teach you straight to it Perfect. So red hat developer sandbox So you can get started on the sandbox for 30 days. You'll have an open shift cluster. Absolutely no credit card required No swiping needed No swiping needed So since I have already have the sandbox if I click and start using my sandbox, it takes me right to my sandbox And here, uh, I already have this deployed, but let me Delete the previous deployment just to show how I can also Use my sandbox to deploy the application For the sake of time, I'll keep the database. I'll just keep the database for the sake of time So if you see at the end, um, of Of your scenario, you can fork the repository. So for that, there's a there's a nifty little script that my friend Eric, uh Written and if you click here, um, it's going to give you a code This code right here and then you copy the code right here To for device activation Um, I'm already like I already authorized github before and I already went through with Forking of the repository. So if I come back if I close right here Uh And come here You gotta follow the instructions. You gotta press enter. There you go. Yeah. Yeah. There you go Authentication complete press enter to continue Um, I assure you to log out now All right So if I come here That's just sort of there that the the credentials that you entered like for github are the learn.openshift.com platform knows nothing about that That's a complete like oauth call using the github cli. Yeah, there's no access to any of the credentials or anything there Right so you can see that the repository I have it here forked And then on my local. So this is my local machine. Uh I have again if I do ls-la I I have the The clone version of uh of the repository that we just forked and now i'm i'm going to deploy it on my sandbox environment Which is right here. So let me just copy the the actual Maven oc deploy command Uh, I'll copy this one right here You should mention too that there are two branches in the repository The main branch is kind of like where you were starting from at the beginning of the scenario with all the tutus in there And then there's also the solution branch, which is what you got at the end of the scenario You know what you should have Yes, so once you once you check out, you'll probably be with a master branch and then if you check out solution Uh, you'll have the the all all the solutions. So you just completed something on learn.openshift.com You probably don't want to read to the same thing. You just want to deploy you can check out solution brands and Let's say the project i'm on right now. I'm on the one. I'm at that step. That's fine. I'm just going to deploy on this project I already have the database, uh, which was created before So now the same command that we ran before, uh, but this is not on uh on a 60 minutes cluster. This is actually now I'm going to deploy on your 30 days developer sandbox cluster similar similar command for for building the the s2i process first And then it'll create the deployment Config now just kind of all that's going add on that the the 30 days it expires It will destroy after automatically after 30 days But even right after that you can come back and do another one right and for another 30 days No credit card required We discourage you from running production like that though You better have a really good ansible playbook right to be able to recreate everything from work Yeah, I mean you need something like Load balancers and all kinds of stuff to even make that work. I feel like so yeah, don't do that There's some resource constraints and resource quarters Like you get like I think two or three namespaces that you can use that you can't change the name of And you can only run so many Cores or memory workloads or something. I don't know exactly what the quotas are but there are some quotas that can enforce Almost almost done. All right. It's finished now The pod is not yet running. It's container creating stage Let's see maybe within a few seconds If I go to the url and I write down the application should be down and As soon as the the circle turns solid blue True What's going on? Yeah, I was just gonna say what's kind of cool. You can actually go and see what's going on and watch And tell the log in real time. Yes All right, so if I refresh the page With our familiar application But this is on a 30 day developer sandbox. All right, so I I know I took a bit of extra time I'm gonna stop sharing right here And let Eric take over 15 minutes Eric you got this 15 minutes. I'll talk really really fast Have the dinosaur start chasing you that'll help that dinosaur. I gotta get really so I am actually a runner But I'm a distance runner not a not a sprinter not a sprinter. Yeah, I'm in it for the long haul You know not not the short distance here. Yeah, so that that's all kind of cool You know what we what we just did but you know one thing that a lot of developers And I you gotta kind of figure out is okay I deployed this environment and I deployed you know, I tied my app to a database right and we did that through environment variables So how do I take that application and then move it from dev to qa to integration test to smoke test You know, whatever, you know, n number of environments you have until you get to production And I'm going to use the word environment in air quotes again because in the old days, you know An environment was a physical environment, you know, it took weeks months years You know, how what you submitted a request and you needed a bare metal server or vm or whatnot And then god forbid you need a new environment, you know, where everything needs to be wired together I mean that you know, the ops people just you know, you need to send them on early retirement if you start mentioning that kind of stuff. So Kubernetes and OpenShift make that really really easy and what I'm going to do is I'm going to There's actually another scenario here that talks about externalized configuration And I'm going to kind of blow through some of the setup stuff because it's you know, essentially the same stuff that DeWon just did And I want this thing is my font size good and what everybody can read what I'm doing here Uh go up one more one more Waiting for the environment to spin up, okay Amen and then started again Did we break the internet? That's possible We've been known to break things on this show not the whole internet, but Yeah, here we go All right, so that that's going it's pulling down the the gdk and whatnot Looks that's done. All right. We're good to go. So I'm going to go So it's the same source repo just to do there's a bunch of different projects in that source repo So it's the same source repo just a different folder within it. I don't know if I can make this bigger, but So essentially we've got that we're still dealing with fruits We've got a fruit controller except this one's much simpler It doesn't have all the whiz bang stuff that DeWon was just showing with like the list and being able to do stuff But what this really showcases is I'm going to read a property from a properties file And I want to change that property without having to change my applications Kind of simulating as if I was moving my application from one environment to another and hooking up different configuration to it So we've got and again, you know, I talked about in the in the last one You know, we talked about constructor injection versus field injection. Well, here's here's the field injection example here We've got this other bean Called message properties, which is a a good way to if you if you just have like a one-off property great You know spring has that at value annotation that you can use to inject a property value But if you need a bunch of properties that are kind of somewhat related to each other and you want to do validation on it or You know strong typing that kind of stuff you you would build a with spring calls a configuration properties class And you can you can you see this one has validation and it makes sure that there's actually a message You know a greeting dot message variable and if your application goes to start up and it's not there It won't it'll fail to start So it's doing some some startup validation that you're that your properties are there And so when we run it look again air quotes here locally we have our greeting dot message And you notice it's a it's kind of an injection your favorite fruit is and then the The thing that gets injected is what you actually passed in the in the As a request parameter So if I run this guy, I should have run this guy while we were talking because maven needs to go download the internet I'm on theme on this show Yeah, it's a theme next time it's run the thing before you start talking, right? Yep, lesson learned post mortem All right, so all that goes well I'll actually open a new terminal just to kind of show off a little bit of the catechota stuff You can open new terminals as well and whatever the active terminal is is I think where the command goes So if I click the command it goes into the new terminal So we're kind of doing stuff in the background here So one thing that you kind of need it with some of this actuator stuff the One thing in in this project we're using is the The spring cloud kubernetes spring boot starter in this case specifically the config starter which means gives us the ability to to natively Our application to natively use the cube api to read Config maps and secrets, right? And those are two object types within kubernetes But in order to do that your project needs a policy the service account that runs the pod Needs a policy that gives it access to that cube api So we have to add that by by default open shift doesn't allow that doesn't allow you the default service account Because we're just using all the defaults here. So we've got to add that that role to our user And then we'll create a config map. So in in the source here. We've got the source main etsy Application we've just got a greeting message that we're going to create as as a config map Oh, because I'm at another terminal. I'm not in the right directory here Get our thing finished Yeah, I think finished. So if I run that on this terminal It created a config map. But if we want to go to the open shift console, we can actually see that you to do Would we say admin admin always administrator give us destructive privileges Give me root and I'll give you a broken system Yeah, and I always promise not to break anything right and cross my fingers behind my back kind of thing So if we go to the dev project and we look at our config map, so now there shouldn't be any nothing really running here But we do have a config map. And if you look at the config map, there's a There's actually a whole application that properties file that's embedded in the config map There's a bunch of ways you could do it You could do it this way or you could just specify the property So I could just have a greeting dot message without being part of the file and that would work just fine that the underlying Spring boot started for that, you know, it doesn't really care how you do it At least the last time I checked Um, and then we're going to deploy this to open shift Again cue the cue the elevator music To do to do so so how about them Mets, huh? Yeah, how about the Mets they doing okay for you this year? Yeah, I don't know I give a baseball a long time ago. Yeah, I know the tigers are being awful this year. So, uh, well not awful, but you know Not up to the standard Detroit is used to I feel like And the one from Canada you must be a hockey guy Well, is that just a stereotype? Or yeah, is that like a really bad stereotype? Yeah on the on the topic of stereotype. I have that if you want, I can That's fair. I like importance. I can bring some poutine as well and and holla to my friend mousse somewhere in my backyard So maybe what I'll do here because we've got some limited time Is I'll just kind of skip to the thing I wanted to talk about, you know once while maven's downloading the internet again At the very at the very end of every scenario all the spring scenarios all the cork of scenarios You know do on show the you know being able to fork it to your own github and downloading and clone it and use the developer sandbox Which is all cool stuff one thing that's there as part of the developer sandbox is a What we call code ready workspaces, which is based on the upstream eclipse chay Which is an ide so if you don't even have an ide on your machine Well, who who doesn't have an ide but if you don't have an ide any machine You don't have all the right tooling or the java versions or all that kind of stuff You can use the the code ready workspaces that's there as part of the developer sandbox to actually develop your your your applications and Like this catechota environment. It's running in the cloud and it's running on the open shift cluster It's a you you use the same red hat account. There's a link here You would click it takes a few a minute or so to start it up So like any good cooking show I've already kind of put it in the oven and and taken it out You know in real time here So it would actually load the solution we talked about the two branches It would load the solution branch, but it would filter You know when you've got the repo just claw and there's a bunch of projects in there So this that would actually filter it to the one that you're actually working on in that scenario So the whole source code is there you can do all the same commands There's this nice little thing that's pre-configured for you with all these different tools If I want to build the app I can just click it and it'll go and again Actually, I think I already did it although It it does have an idle time if you leave it idle for I don't know I don't know what the timeout is but the pods will stop um But it should have Notice it didn't have to read download the internet. It does have persistent storage So even if your workspace stops as long as you don't destroy it and you restart it All stuff any changes you made are still there on the file system Because it all the persistent storage is attached you see it build I could do an open shift deploy I could run it and then in the air quotes again locally Against my local machine. I think it'll actually fail because it's looking for a postgres database Maybe it uses h2. I forget I built the scenario, but I can't remember what I did Oh, no, it actually works and if you notice it's got this little hey I see that there's something running on 8080 you want to open it I can either open it in this little preview thing that comes up over here Or I can just have it open a new tab and Voila. I've got my my thing built make it a little bigger I like watermelon All right I can say up your favorite fruits watermelon, but what's Cool, what we wanted to show as part of the scenario, you know, now that it's actually deployed if I go back And I run Using the local not local web browser. I actually wanted to go to the open shift console like cooking here And I've got the same thing if I say watermelon you see it's Greetings, you've picked watermelon your favorite fruit if I go back and I actually edit this config map So instead of greetings I say bonjour. Do you speak french up there? I know I know enough french to be dangerous. Yeah, me too. Yeah, I know I know all the slang words that all my friends have taught me, right? nice So I can save the config map and if I come back here and I instead of watermelon I say banana You say now it says bonjour Because it's picking up the change. I didn't even have to restart my app. It's picking up the change Nice And so you could see as I started deploying the same app in multiple namespaces with the same config map just with different values It would you know pick up pick it up or even pick it up on the fly that being said There's always the question is this is a good thing to do and you need to be careful about what things you're going to change At runtime on the fly right because your application as a whole Is your app that you deploy that static and your configuration? Which is at runtime and the combination of those two forms like a versioned View of your application and if you start changing things on the fly How do you make sure that those changes get back into source control and Configuration drift and all that good stuff that we could have a whole separate conversation on So I think that's that's what we wanted to showcase here and look at that three minutes amazing not not just martial arts ninja I don't climb walls and I don't wear well, I guess I do wear masks right these days Not the the type of ninja mask you're thinking about Yeah, that's a good point All right. Well, thank you Dewan and Eric. This was awesome to see and demo and everything If there's any questions after the fact Feel free to reach out to me on twitter at chris short or short at redhead.com and I will forge your message to the right people But yeah, thank you for demoing this today Dewan and Eric. This was a great Great stream really appreciate it It's our it's our pleasure and thanks chris and bobby and all the folks making the the show always as awesome Yeah, thanks for having me. Hey, you know for how many times. Thank you