 Hi, my name is JJ Asgar and I'm a developer advocate for the IBM Cloud. Today I'm going to be showing you Code Engine, which has just been recently released by IBM Cloud as a managed serverless platform. You can run your application job or container inside of it. And today I'm going to take a very simple Python application, containerize it, get it up onto a registry, then use Code Engine to actually run it for me. So let's get started. So if you haven't seen this before, this is the Code Engine main website. And just as I said a moment ago, you can run your application job or container. I'm actually not going to spend much more time inside of the GUI here. I'm going to do most of my work through the command line to show you how easy it is to get everything up and going. So let's start off from the very beginning. So as you see here, I have an application called app.py. I'm going to build a container. So if you bring up this Docker file, as you see, there's a few things that happen. We run Python SLAM, and then we run the actual application app.py8080. So if I go ahead and show this application, of course, it's a very, very advanced application that returns a statement. This is a temp statement. So what I'm going to do first is I'm going to go ahead and build a container and tag it with v1. As you see, I've already done this, so it was very quick, which is great. Next I'm going to go ahead and test it to make sure it does what I want. So I'll go ahead and run this container with port 8080, and I believe that is the same shot it is. So we'll go ahead and hit enter. And as you see, we're listing on port 8080 on all interfaces. So if I go ahead and go to local post 8080, we see that this is a temp statement. We'll also notice that we have our get, so we know that we're actually talking to it. Just to verify one more time, I stop it, and as you see, nothing is actually running. So I now have a working Docker container with Python inside of it with a very simple app.py. Next, I need to go ahead and push this container up to a registry. I'm going to go ahead and use quay, as you see, I've already done it just to make sure this is nice and quick. Next, what we're going to need to do is install the code engine plugin. It doesn't come by default with IBM, the IBM Cloud CLI, so you will need to actually install it. I've already installed it, but I'm going to go ahead and update it to make sure you see how quickly this is done. Wonderful. Next, I need to go ahead and target a resource group. So if I type resource group, target resource group right there, as you see, I target my default resource group. And then, I need to create the container, or create the application, CE. If you are missing something, IBM Cloud will come back and tell you you need to run these specific commands. But luckily, because I've already done it, it's already set up for me. Python example. So I'm going to go ahead and create this Python example with the image of quayJJASGAR CE example one. And there we go. As it's creating, I'm just going to prove to you that it is actually doing something on the other side. So if I go over to this project and I go into JJ testing, we should see applications. And there we go. We are actually deploying our Python example as we speak. We'll take, give it a couple of moments just to go ahead and make things happen. But it will actually tell us when it's up and running and give us a URL that we can go to, which we won't do in a moment. Now, if you wanted to do this asynchronously, you can tack on to the command of dash n w for no wait. And it immediately gives you your, your command prompt back. But I just wanted to show you how quickly this actually works together. There we go. We've already gone ahead and started waiting for a web balancer. And we've bring this up. So if I am correct on this, I should be able to click this link. And there we go. This is our temp statement. Simple, right? Now, let's actually get some interesting information around this. So if I go do IBM cloud, see application, get dash dash name, Python example, we get a lot of interesting information about what the status of our actual application is. So if you see here, we get our ID name, our URL, where the image is coming from, that's on the actual service that is running, and the revision and get the traffic where you can manipulate all of this to whatever you want. Now notice we notice right here, the maximum scale of 10 and minimum scale of zero. This is really, really important, especially in the serverless ecosystem. So over a time out of five minutes, if there's no communication to the container coming through the ingress, it will go ahead and scale it down to zero, which is really neat. That means I'm only using the service for when I need to actually get it done. There's a little bit of a hiccup when it needs to start from zero. But let's say, for instance, we want to make sure that there's always at least one up and running for us. We can go ahead and do IBM cloud CE update, name of Python example, and we can do it of the min of, let's say five. So if I go ahead and do five, we can go ahead and see that things are happening. It should go ahead and change that for us. If we come back over to the code engine and into Python example, as you see, we're redeploying it because we made a runtime change. As you see here, the minimum instances is now five and the maximum instances of 10. Just got to do its thing. It is still deploying. There we go. It's got our one instance up and running now, and it should go ahead and give us the four instances. Wonderful. So we can go back here in just a moment. There we go. We're waiting on the load balancer to be ready. And then we can go ahead and see this. So let's go ahead and just as it says here, run that exact same get command. We did a moment ago and double check that we have everything we expected to. As we see, we have a minimum scale of five. And now we actually have five of the instances up and running. As you notice, it is terminating the first one to roll it out because it is a configuration change. And that's important to know. So we've got five going, but that's not really what we want. We want to leverage to serve this platform for what it is. So what I'll do is I'll spin it back down to the min of zero. And I'll do that dash NW, as I mentioned earlier, to no weight. So it sends it off and it says, hey, go ahead and do this. Go ahead and go back down to zero, and it'll start doing the things in the background. Well, that's happening. Let's go ahead and make a change and show you how what I would do to update something. So obviously, the name of temp statement is useless in this case. So let's go ahead and change that to I'm a little teapot short and stout. And just like we were doing earlier, what we would do is we'd go ahead and build the container. We'd grab it a new version of V2 and it goes and pushes things. This takes a moment because we are building it from the ground up here again, just to be on the safe side. And then it should only take a couple of seconds. And as that's going, we'll go back to here and we'll notice now that we have only two instances up and running, but more importantly, our runtime comes back down to zero. So we now know through the command line, we can go ahead and manipulate things that we need to get done. And as you see here, the references, this actually should be one, oh, I'm sorry. So I'll go ahead and cancel that real quick and go back to one and period. We'll go ahead because when we do the update and we ask for code engine to pull it back down, it needs to be the same tag. Because we need to edit that to make sure it's a difference. That was my mistake, but hey, that's what demos are like, right? So let that happen. And I'll end up pushing it again. While this is still going, there is wonderful documentation and there's also logging. So let me take a moment and show you the logs of the actual work. It brings up log DNA for you to be able to see exactly what's happening. And as you can see here, you can search for very specific things, but most importantly, you should notice this line right here where it is saying it is actually outputting the exact same thing that we were expecting to see, which is wonderful. All right, so we've now successfully built it. So let's go ahead and do docker run dash it with port 8080 call an 8080 and go ahead and run that Shaw again. And if I go back to local host 8080, I'm a little teapot short and step. So next we've verified, so we need to go ahead and push this back up into our version one. It should only be relatively quick and as that's going, we'll give it a moment again. Let me show you some other things. We should be able to see if we go down to this live button, the actual live outputs. As you see again here, we're down to zero instances. So for five minutes, nothing was talking to this. So if I go ahead and click on the application URL, as you see here in a moment, it'll go ahead and spin it up. And we're still running our temp statement because we haven't updated it. And as you see now, we have one instance. And we should be able to come down here and see live. If I go ahead and refresh this a couple of times, we should be able to see our get. And there we go. There's our get. There's a small little delay in the logs mainly because it's aggregating it. But as you see, we get our get. So we actually see communications happening there. All right. There's some very interesting information you can grab from this, but normally you want to just check the stage to make sure everything's working correctly. You can easily manipulate all of these things either via the command line or through this runtime. But remember, every time you make one of these changes, it does a full redeploy. So keep that in mind. But because these commands are so straightforward, as hopefully you've seen, you can easily put this inside of your CI and CD pipelines. So when you do push out a change and you merge it into the main branch, in theory, you should be able to just run these commands and success would be able to get the new change made to it. All right. It's still pushing. That was supposed to be significantly faster, but it is not. And as you see here, because we haven't had any communication for a couple of moments, we're going back down to zero instances. As we saw earlier, here is the version and that traffic and just as we were expecting. And I'll go ahead and speed up this part of the video right now. And there we go. We've gone ahead and pushed up our container into our repository, which is great. The next thing we need to do is go ahead and check out a new version of or tell our our code engine instance to go ahead and update it. As you saw, here's that shot again. If I go back into code engine, I believe there's a way for me to verify that we have that same version. And I believe we click on this and we should see no, we cannot see that. That is fine. So what we'll go ahead and do is tell it now to go ahead and update. Now, the interesting thing about update is that if you just do the update with no other flags, so we just do IBM Cloud CE application update named Python example, and we'll go ahead and attempt to kick it off. And because I did the no wait, it will go ahead and pull the new version of our application here. As you see the version for and it's redeploying, and I'll go ahead and wait for the URL again. It's still the point. There we go. Now we're waiting for the load balancer, and we should see one instance that is ready. And now we have our link just as we saw a moment ago, I click on this. And now we have this actually out on the real internet. I'm a little teapot short and stuff. Again, here's our logs again. As we see, it went ahead and pulled it and it will go ahead and spin down to zero as we did earlier. One final thing, it is as easy to create it is to destroy serverless actions. So if I do IBM Cloud, see application, delete dash dash name, Python example, dash F for force, I go ahead and hit that. It deletes it. And now if we come back to our page, and I refresh it, it kicks us off because there's no longer this application, which is exactly what we're hoping for. And as you see here too, it is completely gone also. And that's it. Hopefully you saw something come together, which is the ultimate goal of this. Please go ahead and start playing with it. It's GA and available now. Thank you so much. Bye.