 Hello! Welcome to another DevNation Live! Today I'm the presenter on your host, I'm at Siena Naga because Berser is on vacation but you know what's even better than being on a beach in Thailand, having a session about the K-native deep dive with the great Kamesh Sampa. So Kamesh is one of the best speakers and engineers that we have inside Red Hat and I'm pretty sure you'll be amazed at what he has to present. So Kamesh, this stage is yours. Thank you so much it's a hello everyone from other corners of the world probably I'm live from Bangalore which is GMT plus 500 hours close to midnight. Today's session I'm going to take as I was saying I'm going to talk about K-native it's a bit of deep dive. I have very less slides to show to you and more demos to show to you have three to four demos lined up with demo guides with me today so I should be having fun with me today, right? Any questions if we have please feel free to reach out to my email or my Twitter handle here I'll be happy to answer your questions and then you can also find the slides in this bit.ly link here on my slides bit.ly K-n serving from where you can get the thing as well. All right let me see yeah so before we get further into the details about K-native I want to tell you guys that there are a bunch of resources that's available don't worry if you miss my commands on the screen or anything else so all the GitHub resources that's there on the right side of the things is where you find all the materials and also like you can also go to my blog which is there which I've done a couple of months back before Christmas on K-native bill and K-native serving. All right so so before I jump into I'm not going to go very deep inside K-native I'm going to touch upon three important building blocks of K-native the one which is called a serving which technically as a name says that it serves you your request of invading a serverless company gets executed or HTTP or events responding to events etc. One of the important things about this is that the scale down to zero which is which is quite something which is new to the serverless which is where we wanted to scale up and down to zero pretty fast in Kubernetes world you've heard about that we use the scale down using the replicas here it is done automatically so that's a big difference with respect to K-native and adding to the Kubernetes primitives as well. I can also find the the GitHub link which is the live spec still the latest if I believe right today what I saw was 0.3 that's the release which is going to happen soon with respect to K-native with serving. I can go to this link to find more about serving and what it all gives and has installed for you all right so before we get further I want to go show you a quick demo as I said earlier so much this session is going to be full of demos so let me quickly check to my screen so I am three basic installations of K-native one is one is done on local mini shift which is which is the single load cluster of open shit that can run on your laptop or a desktop computers and I also have one GKE instance where I deployed the complete K-native stack here and I also have one more instance running on cloud on Google cloud where I deployed open shit as well I'm going to shift through three three instances to show you that the commands remain same everything remain same all that the instances are going to be deployed in different consoles as well right just to have a feel of that we can also go hybrid on the things how K-native works as well right so if you're very curious on how it works how it gets deployed so I can I can go to this link right on my browser I think I'm not able to I can put them chat so if I'm trying to see if I can blow this up so that's get up link where you can go find out the documentation from where you can install K-native an open shift and mini shift etc that's how I follow the guides today to do my installation if you want to see how we want to deploy K-native to other platforms that you might have I would suggest you that you go to the upstream from where you can see how to deploy K-native in the other platforms as well I use a similar one like here what you see on my screen to deploy K-native on Kubernetes GKE engine so that you can have different flavors of Kubernetes running K-native for you all right so first of all the demos like this demo is basically show you like deploy a very simple allowable program and also I'm going to show you like how K-native will do an automatic scale up and scale down for you so we'll just alter some parameters to make sure that it is pretty fast within the time window I have so I'm right out logging in as you told you like these blogs are there as part of the link resources which I shared earlier so let me quickly see what I need to do I have two different heads one of them on Java and one of them on Node.js pretty much the same application which says allowable to you so what I'm going to do is like I'm just going to do Java and then let me quickly build a Docker image for you let's say M-V-N-W I'm using GIMP for people who want to have GIMP, J-I-B-Z, the build-up plugin which can which can be used to build Docker images and push it to external registries and just doing a GIMP build right now to do the Docker build of my application it just packages the application for you and then makes a Docker image which can be used for you to deploy your first K native application for you while you see this it gets from the the app the image that's from GCR.io and then it's loading the Docker daemon to kind of talk to you when and we have this particular image we see here got created for you right so dev.local creature is something which is getting created here all right so the multiple strategies to deploy your serverless applications so what I'm going to do is like I just want to keep total I have an alias called SK so I'm just expanding that right now to get pods in batch as W to see that I'm watching what pods gets deployed right now for you right and then quickly I'll also go to my screen to show you what I have going to do this right so let me jump to the service so this is a typical service YAML if you will that deploys your service a service is a holistic deployment that deploys all the building blocks of K native so in this example don't worry about the internal software it still looks like your typical Kubernetes resource right and we have an image which says that okay this is an image that's going to get deployed and we pass couple of environment parameters as well so the syntax looks very close to the Kubernetes service and plus deployment together but this is this one uses your CRD the custom resource definitions which has a serving K native dev VU and alpha one right so let's quickly deploy this F and then I'll say service.yaml go one another and then the moment you see this the deployment starts I have cast a few images earlier to say our time so we'll see one deployment automatically getting created here for you and then it's up and ready for you to run so let's say let's get to see as I told you earlier K is an ally from a Kubernetes just to save some typing for me and say get SVC I just say K SVC which is Kubernetes can edit service you'll see one service getting deployed and then you also see a custom domain name which is given to this we'll be using this to call this particular service here so let's see how we call this so to call the service I might need to use one more service let's queue get SVC K native ingress gateway FNM STO it's backed by STO system okay maybe I'll make something let me check it's getting all the services from STO system maybe I'm have some people right there is the you this you system so if you see this K native ingress K2 I think there is no dash earlier so and then it's it has a load load balancer I mean a load port available in 3 2 3 8 0 so that's what I'm going to use curl if I hedge if you remember that the earlier service gave us the name as creator.example.com I'm just going to use this as my host header since I don't have any domain name doing things inside and then I need to use the mini shift IP so which is which can be got like mini shift IP 8 0 there you go right so you got the response for your first candidate service just like that I curl I can hedge host name and then you give the actual domain name which can be controlled as one we'll do one more interesting thing right here so let me see if I have this command it's going to watch the port here and then I'm going to tune a bit of parameters here on my K native side so I'll just go to my scripts and then what the script does is it just alters your one of the internal auto scaling configurations for K native which controls when your services has to come down and come up etc how long it has to stay before it gets terminated automatically so this exact thing you can find more details about this particular config map right here on my screen so the one which are interested here is like the one right below the scale to zero threshold and scale to zero grace period right the threshold basically says that how long it has to wait before goes down right at the grace period like basically it's okay if you have incoming request to your services it has to wait for that many number of seconds before it can start to terminate your parts so what I'm going to do right now is like I'm just to bring down this value to 30 seconds and then one minute so that they can quickly see within this time window that how quickly the service scales up and scales down as well right so I'm just going to use this skip and then say configure scaling this just a script which I wrote which kinds of brings down the part and then updates the config map and then bring up the part again so as you're seeing this this this particular deployment has been there for four minutes so probably I would probably might start to shut down and next for a fifth minute or so so let's let me see this so wait for the script to complete so that we have things to do scaling and also I'm also going to show you like how auto scaling automatically happens for you as well so can I give us a future by which like if I configure a request right so so if there it was it can automatically scale up the parts to serve your request in our case if you remember that what I've done is that by default the the container concurrency how many can request it can handle this is technically by default hundred so what I'm trying to do right now is I'm going to make this to 30 so that like if I do if I'm going to send under request right right now it at least requires much of more parts more than two parts to serve the request right all right so the scaling configuration is done let's wait for the the existing parts to go down and while that goes down what I'll also show you that the what's script and what to learn so I just have a script which says that it goes cause this this particular same URL which we did siege is a tool that's used to do concurrency testing with Kubernetes so I'm going to have a concurrency of 100 users and it's going to fire to the same call here right now what we see here so let's see this guy goes down in a second now let's try to see let's play with this to see if it works now this guy is already has 100 so it's quickly serves a request because it has 100 request so let's see if this this comes down in a second so while this comes down to zero what I'm going to quickly show you that I'm going to take you to the Google computer engine so that I'm going to show you I already have a k-native deployed here I'm just going to show you how to deploy k-native to an external thing as well right so I'm just logging into my Kubernetes cluster in GKE let's see if this is not a diet so let's wait for some more time and once you see this this cloud container clusters we can try to log into that it might take a bit of time we got it so right now it's got into the cluster right now so let's quickly close this because I logged into another thing so I cannot use this one right now so what I'm going to do is like I'm just going to do the same thing let's see quickly k get parts that's w and I'm just saying to say k applied at first so it is not right you should see the same deployment starting again here and then but this is a node version of the deployment so it is up and running let me quickly grab the commands that I need to do here so I have my it here's the same way we call this we if you see this we have the same third deployed here get SVC case we see k-native we got the data.default.example.com here in this case it's deployed into a namespace called as default so that's a reason why if you see our URL right here is changed to default.example.com and then the IP address or the the big advantage with GKE is that they already have load balancer deployed if you see this services list here on GKE so you'll see the services list has the load balancer for k-native ingress gateway deployed as load balancer it's available for you so we don't need to use a node port right here so that's one advantage with this since I have not configured load balancer locally for mini-shift as well as for my open-shift instance temporary show in a second so you might need to use a node port technique to kind of connect to the server okay so let's log back in to see what we have here we'll see login if you need by default the credentials for local mini-shift is admin-admin to use mini-shift ID 28443 so I'm logged in to my uh we'll see change my project to my project so let's start our watch again and see I don't have any part I think it's still it's still running so probably it's stuck somewhere let's get back to that until it gets terminated so what I'm going to do is I'll just clear clear this off here delete so the command to clear this off is same service.ml it is using delete command to see if this gets terminated okay we'll see key ports there's no resources there so what I'm going to do is like just start apply the service here okay apply pressure let's see if the port's come up yes it's initializing state and then it started to run it's 27 seconds okay let's try to flash our watch command let's this is 36 I think probably maybe 10 seconds so that we know this guy's going to come down and not all right so I'm just running out of time I'll just jump to the the other demo right now so this this doesn't get shut down like we'll see I have to log into another console here so as I told you let me get back to my slides problem let me move it from my screen so so if you see the bill the bill takes care of taking it's simply the bill lifecycle of your serverless deployment for example in this case what you see on my screen as a user creates a bill and it pulls the resources from your GitHub and then we have something like a build template just imagine it like to be your Jenkins job template kind of stuff so it takes and the build is kind of uses this template to kind of run multiple steps once the steps is done then what exactly happens is that it pushes the build container to container registry and then that the service takes it up and then kinds of deploy this right now what you have done in our case if you remember the previous case we did a docker build and then what we did is after we did the docker build we kind of push the image into the registry and then we kind of deploy the service separately in this case what you're going to do is like I'm just going to do a service direct deployment and service as a reference to the build and the build out of it's automatically for you so let's quickly take this demo as well here so I'm just going to go to my build I'm just going to log to my gcp server that's an open shift upload here and then the first thing what I'd need to do is like what I do is like I have a template I need to create a template first so I'm just I'm just going to do the same command again a applied a chef templates Java template template gets created now and then if you see this let me pull this service again the similar similar service what you've seen earlier and then let me okay Java here so what I do here is that I have a build configuration defined and then I say from where I need to pull the resources from and then come and then bunch of parameters that I pass to my java builder template right I also use a pbc to kind of store the navadat effect so each and every build off minus pretty much faster and quicker so as usual we do the watch what part gets created that shows you then put on the part that gets executed when the build runs so I'm going to do is just we get out to the root directory there's no there's not going to be any builds and let me get to the java directory so okay sorry this is a build right go build off uh i'd like to see the build marks okay we see that there's a bunch of um four init containers that gets created this is a little bit hacky right now because uh all the build steps get created as init containers um and at times like you might be wondering like how do I see the logs so one of the ways I found was like using a tool called a scale which is Kubernetes scale is tool is called scale and then I can kind of traverse upon to see what build gets executed and then and then lots though currently the limitation right now with uh with candidate builders that in case the build fails uh I have to delete and restart it again so that's getting circumvented by our pipelines which is the main spec that's getting executed right now as well and then once the build is done so you'll see this this automatically creates a container for you so let's watch that via the console this is my open ship console uh that's available from the gcp machine for me so you can also watch this from the gcp as well and okay come on then this time okay the part gets completed and then you will see the deployment starts right now in a few seconds we should have the deployment upon running so let me grab the command that I used to call this girl as well so you see this this java k81 open ship this right now coming from from this particular thing right all right I think uh I have three more minutes left probably uh I might be short of my other demo which I plan for uh so I'll leave to it's to see the question that could be answered for now that you could be able to answer this one uh alessandro was asking which of the features being demonstrated are provided by k native and which of them are provided by kuban it is um the the the basic the features what are we sure today the service is is given by k native the route is given by k native the configurations is given by k native the only thing uh what kuban it is gives us is is the platform to run the serverless workloads so and then like you also use the same uh same technique like how we define a service how do you define a resource etc it goes to follow the same yama structure via the crds so and then that gets injected inside your kuban it is to run the ship and exploring this this question if people here are new some people are new to k native and kuban it is why k native so important for for the kuban is platform regarding serverless workloads okay that's a that's an awesome question so uh the whole idea is like if you're seeing if you're seeing the serverless uh how it evolved over the period uh you will see that there are various platforms which plug into own features and then it kind of affects the portability across the platforms for example in this case I showed you that I ran the same code in my local machine and then I also ran in uh gke on kuban it is uh engine and as well as on a gcp on a different cloud with open ship everywhere I went I follow the same procedure to build and deploy my serverless workloads so which which is something which was quite important from the serverless point of view because we want to have a standard or a platform where I can run uh the serverless workload in native kuban it is way uh so that like it adheres to all the primitives that kuban it is gives for us with the script application authorization uh Adam has another question for you uh how much latency should a client expect if a k native service uh scales to zero for example use uh I personally I'm not seeing uh a big latency right now here um at least with my with my whatever I measured with my local platform uh there is a momentary uh latency bar the service has to come up uh technically like if if you have if you have your uh Java services right now as of today uh there is a bit of latency for it to come up uh which which will soon be mitigated uh by things like gral or other kind of stuff um so if you see node or any kind of uh go lang or any any kind of other programming language is used to build your services they are too fast and you hardly see any kind of a difference for them to come up and down I think we have time for one question and um we have here when will k native become a GA feature on OpenShift uh okay let's see that's a very nice question but we just announced that in kubcon about uh k native but I personally I don't have any timelines with me and when it's going to be GN or OpenShift oh we might have some one last question here uh so one minute any comments on performance under a high workload for k native um I think there's I think right up right as of today I think still the the specs are maturing if you see the latest release of k native serving is one is 0.3 um definitely there are some performance hiccups uh even I have seen few when I was building these demos uh these days uh but it should be definitely be optimized when it we just guess what you're right um I think we are uh out of time so first of all I'd like to thank you for watching the session and I would like to thank Kamesh also for this great presentation and Kamesh said on the slide uh if you have any questions you can send any mail or tweet to Kamesh I'm pretty sure he'll be more than happy to answer uh the questions and see you on the next definition live