 Welcome everyone. Hi everyone. Yeah, okay So we're going to be talking a little bit about a polyglot developer experience on top of Kubernetes The idea of having kind of like a dockerless docker file less also and jam less experience when you are building applications on top of Kubernetes we will be talking a little bit about Kennedy we will be talking a little bit about functions as well So we are just going to go over a bunch of topics and just you know Play a little game. My name is Mauricio Salatino. I do work for VMware But my main responsibility nowadays is to work 100% of my time in Knative I'm also writing a book that it's called continuous delivery for Kubernetes You know, there are like a couple of discounts there if you're interested in that just check the slides later on I will be sharing that and here I have Thomas with me. Yes I work as a software architect at Systematic a Danish software company. I am really passionate about anything cloud native I'm also writing a book. It's called cloud native spring in action with spring boot and Kubernetes I like contributing to open source. So it's really great to be here and Sharing our passion and knowledge around all these open source projects. It's really great. Yeah So before we start the presentation, how many of you folks like joined the maintenance truck before Not so many. Okay a couple great So we will be playing a game today with all of you It's like yeah It's like a game that it's running in a Kubernetes cluster, of course And I wanted to show you what we are going to play at the end of the session So you kind of know how it will work. So this game, of course It's been built using K native and using functions and it looked like this We will be sharing kind of like the link to access the real application. This is just a demo Where you can just generate a username and then just click play and then it's just a quiz game Right, so you will be answering a couple of questions about Valencia and then interacting with some other questions That are you know picking stuff and doing stuff Well something important there is that you have a timer there that it takes like 10 seconds So you have like a timer there and you need to answer before that if you answer you save some seconds You get some extra points for that and then of course There are like questions that were you need to press buttons or copy texts and do different kind of things as well You have like 10 seconds to answer that each of these levels in the sec in the in the game It's just basically a function So there is a container that it's been bootstrapped in a Kubernetes cluster Dynamically and based on the month right and we will be showing kind like the architecture that we use for this game Which is pretty simple, but at the same time it's it's interesting and we have learned a lot of very useful lessons One of the things that I wanted to show you is that when you reach kind like this final Screen there should be here like a tweet button at the bottom that it's not showing up But it should it will show up in your phones And if you tweet and if you score high in the game, we are going to be sharing some swag and some stuff as well So at the end we all played together with that Yeah, perfect So let's start and see how we can build such a platform and such a game On top of the platform we're gonna start by talking about serverless when I say serverless I specifically mean that I want to focus on the developer experience I want to have developers focus on the business logic and push any kind of Infrastructure of concerns down to the platform so the platform is gonna take care of provisioning the infrastructure necessary for Our purpose our business purpose It's gonna manage the workloads that we deploy on Kubernetes and also it will handle dynamic scaling So if I have more users or more People playing the game for example, I don't want to do anything manually or explicitly I want the platform to take care of that and scaling out so to accommodate the increase in the number of requests in coming into our system and One way of building such a serverless platform on top of Kubernetes what we're gonna use today is based on k-native a Component within the k-native serving project It's Yeah, k-native serving so it's used to build a serverless experience on top of Kubernetes So we are still dealing with Kubernetes resources. It's completely Kubernetes native and we're gonna get for starters developer friendly abstractions so instead of dealing with Ingresses services deployments replica sets pods We're gonna get one type of abstraction that the developer is concerned with and that's it So we're gonna see it's a much much easier for a developer to interact with such a platform We get from code to URL experience So I have my application and then I want to get the URL Where I can access my application running in Kubernetes I don't want to deal with all the steps that are in between this process. I Also want auto scaling in particular also scaling to zero if there's no request Incoming if there's no event if there's no reason for my containers to be up and running I don't want them to run so scaling to zero. It's really great also for cost optimization, of course and Being more resource efficient. I I also have the possibility to handle progressive rollouts So via K native I can implement Deployment patterns, for example, I can have the the blue green deployments I can do canary releases all through the simple single Abstraction that K native serving exposes It's all request driven and event driven That's also what triggers the auto scaling is based on the request or the events in coming into the system And finally it's cloud agnostic. You can run it on any Kubernetes distribution But at this point we can get this container as a service experience So we have a platform where we can provide Just a container image and then the platform takes care of the rest But still as a developer I need to build that container image and I don't want to do that explicitly because first I want to focus on the business logic if I'm a developer and second Maybe I don't know all the details in order to build a production ready image in terms of security in terms of performance That's why we like to use bill packs another CNCF project with bill packs. We get a specification That converts application source code into container images, which are ready to go in production So it's all based on a builder image. That's what is called that Knows so has knowledge about how to containerize in the best possible way different kinds of applications Implemented with different languages and different frameworks. So this means we don't have to write a dog or file and It's also a great way for an enterprise to control the type of software that we put into production because this Bill packs. This is a specification then you need to choose an implementation. You can have one We're gonna use the packet of bill packs An open source implementation of bill packs But you can have your own or control your own in your company so that for example, you can add your compliance and security rules into the mechanism and make sure that all developers are using Everything that is compliant with your company policies so Let's see it running. I Have built a very simple and small go application here It exposes an HTTP endpoint returning a list of books So the first thing I can do I have already Built a container image out of the the application so I can use the K native CLI Km I can say Km service create and then I give it a name Cook on you and let's make it bigger like that Cube come you Funk yes K native funk So we give you the name like we would do with the dog or CLI then I need to specify the image I Pushed it to my github container registry like that and this is the name And then I need to specify the port number that I want to expose my application have an extra space there Like that. Oh, yes, of course I have an extra space Let's get rid of that So the image name once again and the port number and that's it So now the platform K native takes this container image It generates all the resources in Kubernetes that are necessary to run my Application and we return a very convenient URL where I can access my application So let's give you the try I can say HTTP send a get request to the books endpoint And I get back the list of books So I started from a container image and they got it running in Kubernetes without having to write Specific deployment service ingress configuration final part how to build a container image I can use the pack CLI from the build packs project so I can say pack build and Then the builder I have to specify a builder. I mentioned that for this presentation We are using the pocket of bill packs implementation The builder image and Then I give the container a name for example book service And that's it once I get the image then I can go ahead and have K native taking care of the rest so if we are Going to summarize this experience what we have achieved so far. We started from an application I use go you could use Java you could use dot net it doesn't matter because once we use bill packs Bill packs can can take any kind of application with different languages and frameworks and build an image and to do that We use the pack CLI Once we have a container image then K native does the rest I can use for example the KN CLI to do that and Deploy the application in a Kubernetes cluster final part I get back a URL a public URL where I can consume the application But still this approach is really great. I can use it for any kind of workload But there are two things that we can improve first We can automate even more of this process so to improve the developer experience when using such a platform and Second since now we have these serverless capabilities and scale to zero features provided by K native We can start talking about functions So what Thomas has showed is basically the process of a development No, like a development team just creating software and then just packaging that Containerizing it and then running it into cover in his cluster Kennedy is doing a lot there to you know to simplify that experience providing some CLI tools if you need to do the same Using jammer files you will have like shorter and smaller jammer files that you can use as well When you start thinking about improving the developer experience you need to ask why and kind of what kind of use cases Do you want to implement functions and building functions as a service platforms provide that kind like simplification for certain kind of Workloads and certain kind of applications So we will be looking at this more specific use case of building a platforms that is just targeting these function developers So when you are dealing with functions, you are dealing with a different programming model It's just a different way of building applications and solving problems Initially like functions are going to be triggered by requests or events in that are happening in the in the platform or in the Infrastructure or out even outside of your company Functions tend to be more stateless and they are very very focused on doing a single thing Right like in the game example that we showed each function in this case is analyzing some input and then just producing some scores And it's kind of like it's just general the case that you can build functions And then you can write unit test for these functions that are going to validate that the function is doing what it's doing Usually you tend to build, you know integration testing across multiple functions But not for a single function, which is kind like a nice simplified way of building applications When you talk about functions, you are also being a start like hearing about cold starts That's basically means that because now the platform is dealing with the scaling up and scaling down the application Our functions the the programs that we are building needs to quickly start So the platform, you know, don't leave the ones that are creating requests like hanging there and waiting for the container to start So functions frameworks are optimized just to make sure that you know these functions these containers can be started fast And because we can scale down to zero when we are building with fun when we are working with functions You know, we can just start saving some money because functions that are not being used are completely downscaled They are not running in the cluster and the platform will take care of just starting them when we are getting kind of requests So when we again when we talk when we start working with functions You definitely need to change the way that you design and you know implement the applications And you tend to have like two different in like, you know interaction patterns with functions You have like the synchronous side of things where you can interact with the function sending an HTTP request And then you know the function will do something but you are not interested in the response So we just let it work there. You know that it will put data somewhere and then the application can continue from there You have a more like a request response approach where you just call the function and then you need to wait to get the results back To continue processing remember the game we are evaluating the inputs from an answer And then we are creating a score and then we are sending the score back to the user interface in that case We are using that pattern and then When you're using request response or fire and forget you also most of the time I would say 90 of the time you need to go and interact with some kind of External storage right because functions are stateless. They are not storing a state So you might need to go out and say and write something to a database or read stuff from the database And that you know and that will influence the way that you design your functions because again If you are like using request response where you need to wait for the results Then latency becomes a thing You can switch also to the asynchronous way of doing things most mostly related with events Where like you can have functions that are going to react to events that are happening in the platform or coming from outside In that case functions are just going to react there You don't need to call them and they will do something and at the end They will probably produce another event that another function can use Building event-based functions and using k native Something that we will be showing here like with tomas. Uh, it's pretty easy. It's pretty natural and straightforward And it's also integrated into the platform So when you're building this kind of functions You also need to rely on the platform providing some constructs so you can wire functions together And then you ended up in building these event-driven applications where you know You have functions creating consuming events emitting events and other functions, you know reacting to them And by that you just create like more complex logic and more complex behaviors So what I wanted to show now it's basically expanding on the demo that uh, tomas showed I want to use something that we call in k native the funk cli So this is another cli provided by the k native project That basically allows you to start building functions from from scratch, right? So I will just do here I need to learn to type so kubicon funk. I will just create a function directory here funk So if I go to that directory What I can do is I can use the funk cli Just to run this command and in this case again I'm choosing go as a language because we are in kubicon We I guess that everybody's familiar with go but again here is where you can just choose java. You can use, you know dot net you can use node Rust and all the things and here like the template here the last http that I'm calling here It's basically the interaction way, right? I want to send an http request to my function So it can do something I can also choose like the cloud event based approach for listening to events if I want to What I have here if I open this into my id is just the template like the initial template for a function Where I can just go there basically and code my my business logic, right? So let me show you quickly. How does that look like? This is pretty simple code It also has like a test already like a unit test there So you don't forget about writing tests and it basically tells you like, you know Every time that you you get a request and this is kind of where you need to write the logic for that request and I will say Hello kubicon from a function Today is my birthday. So this is my birthday gift. Today is my birthday There you go So if you write that kind of function pretty simple stuff The next thing that you can do is to go to the terminal And then run a single command here deploy Just to run this function in my k native cluster, right and I can use the verbose approach So we can see what happens. Let's see if this works Uh, the first thing that it asks, of course, because we are going to containerize this We need to push this to a docker registry and I will be using thomas here thomas registry in github container registry.io and then Yeah, that's his registry We have already the credentials configured for that registry and what funk is going to do basically here Is it going to use paketo build packs as he showed before just to understand in which language this function is created Create a container for it And then we are going to push that container to you know to to github container registry in this case You can see that it's installing go there in the container. It's going to download all dependencies that my function needs Create a container with different layers and then push that to a registry When all that happens the next step is going to be to deploy that into the cluster Using something similar that like what we saw before with kn right that it's just deploying a container Into the container cluster and at the end of the you know at the end of this execution We should be able to get like a url for my function We are building kind of like different layers for different use cases So the developer experience is it gets easier and easier and in this case We are using the function programming model in order to make it like way easier Again, just using a function cli just get stuff up and running while this is running I'm just pushing now. I think they're pushing to the repository. Yeah, that's pushing to the repository It should take a couple of more seconds But it's important to understand that what we are building there in funk in the in the functions project inside kn80 It's also an experience where You will you might have developers that doesn't have docker installed in their laptop So all this building process can also happen remotely in the cluster, right? So I can trigger this build process remotely It will use tecton in the cluster if you have tecton installed in the cluster It will use tecton and it will build and deploy everything remotely So you as a developer just work with go start the function locally Play around with it and when you're ready you trigger the build look remotely and it will deploy do the deployment there in the cluster So now it's just deploying the function into the cluster and then as you can see here We have the url, which is of course The thing that we just created. So if I do an htp request here for that function I should be able to get the function that I've just built Yep. Yeah, that was really great So if you're wondering what's happening in the cluster, so how we are how are we deploying this? I'll quickly show you That developer friendly abstraction I mentioned earlier. So what funk and also the kncli does is creating This 11 lines of yaml So where you just define the container port the image name and then kn80 takes care of the rest So what we achieved so far? Let's recap We have yes Well, yeah, so quick quick mentions about like the knative functions products, right like as I show you I just created a function from scratch You usually will not do that like I was creating a game creating different levels And I can quickly create like a template like a more advanced template that connects to redis and do more Things pretty easily like from a remote repository We support multiple languages and frameworks as I we said before you can also run the function locally That will basically start the docker container locally if you want to play around with it for a bit I mentioned the on cluster builds and we are Working on defining what 1.0 for this project means and that will probably go out this year So if you're interested in contributing to this project, please Reach out because there are tons of things that we need to do there And I think that it's a pretty easy project to get started with because you know No matter the language that you know, you will be able to help there Yes, and as a developer is a great experience because now we have a way to bootstrap Our project with funk create we could use different languages and frameworks and even build our own templates In order to quickly start a project based for example on our company guidelines and policies We can use funk deploy So now the two operations that earlier I did manually with the pack cli in the k and cli now they are combined and Taking care of by funk deploy and once again the image will be Run as containers inside the cluster. I get the URL back And that's really great. I get auto scaling. I didn't have to write any doger file any yaml file But still we have something missing because we're talking about serverless And functions we mentioned event based Application so we should talk a bit about events So the first thing we talk about events. We are in this Cloud native world. We are in a kubernetes cluster events really can come from many different sources So the first problem we need to solve is how we exchange those events across different possibly very different systems And one of the cncf project solves this problem cloud events is a specification to define how we exchange data in the cloud And this is for interoperability reasons So it doesn't matter the technology or the stack that we use but we can Always understand and exchange cloud events And we have a standard we have a standard in the cloud to Do event based architectures. This is how a cloud event look like we have some metadata That we use for example to route those events in different systems and the data So the payload could be anything it could be a json object But you could even wrap for example a mqp messages that you use in your rabbit mq cluster or kafka mqtt So it's really a powerful concept. So it's not a protocol. It's a format For exchanging this data in the cloud as events, but then you can use whatever protocol you want Cloud events is the base for k native eventing. This is another component within the k native project That allows to build event driven architectures. We have a few different features here Once again, we have very developer friendly abstractions That I'll show We show in a second we can build these event driven architectures And the project itself takes care of routing. So we have a a broker abstraction And then we could plug any kind of event source that we might have It's polyglot support with different technologies and languages because it's based on cloud events So as long as we understand cloud events, then we can interact with the system It's pluggable as I said So if you have your rabbit mq cluster your kafka you can have events coming from a twitter stream For example or from slack you can do that as well because through the subtraction Then we talk cloud events across the entire system independently from what is the specific technology we are using At the lower level once again, this is cloud agnostic. So it runs on any Kubernetes cluster You don't need to have k native serving to use k native eventing also. There are two separate Projects you can run them both. We are running both of them in our game architecture, but you can choose depending on your requirements So if we recap after adding the event part In the cluster, we have something extra. So we don't have only k native serving installed We also have k native eventing and because of that we can define a k native broker abstraction The k native broker then can collect and route events across different Sources and destinations and within the cluster we identify the destinations or the listeners Via triggers. So if we want to create a function listening to some events We use the good old fun create again, but this time we also specify a trigger so that this function should listen to specific events And then again, we can use the language that we want cloud events has SDKs supporting different languages and frameworks We use func deploy and we get a url back. So from a developer point of view same Friendly experience, but now we are also doing event driven on top of serverless And let's see now how we used all of this in our game. Yeah, let's do a quick Like review of the architecture that it's pretty simple But at the same time we have learned some very good lessons by just building it And I think that the main lesson for us is like if you are not used to build function based applications Then you again need to start changing the mindset We have a very simple architecture and we build kind like the idea of a game where you can just add as many levels as you want So it's pretty dynamic on the front end the front end can support as many levels as you want as soon as you have a user interface And then each level is a function as we mentioned before the interactions The interactions between you know the front end and the functions are very basically driven by this You know orchestrator component in there that knows which functions to call next based on the level that you are playing in right And all the interactions are HTTP based in the sense that like just basically the same as I did before right like in order to Interact with the level you need to send an HTTP request That's a synchronous request and because the level is storing data in redis When you send that request you need to wait for the data to be stored in redis in order to be able to have You know the response back in the user there are techniques to avoid doing that Of course, but we wanted to keep it really really simple to see how that can like works out When we all play here together And what we did next is because again, we have event like and we have can any event being installed We can expand the the you know the application to start basically emitting events and consuming events for a more reactive experience So we what we did is we built a leaderboard that we will be putting in the screen here That is consuming events that are being created by all the you know Every level every time that you finish a level you are going to be sending a cloud event to a broker Which is again one of these routers and it's going to be you know We have a trigger defined so we can send you know the event back to the user interface And inside the user interface we are using a socket to propagate that event back to my browser Right in this case you need to connect and route things across different components So I can get you know kind of like push notifications on my side and we will get those in the screen in a bit So by building this we can wire these cloud events and we can route these cloud events For example to other functions or if we for example, we want to get rid of like writing synchronously to redis We can have another function that picks these you know score events and then do like the writes in an asynchronous fashion as well So it gets kind of like quite complex And we are aiming to have this example for you to run in your own laptops or in your own classes If you want to because at the end of the day we are kind of like using the same concepts again and again And I think that before we play we will just set up the game We just need to run a couple of commands first And then we'll have some fun And then we will just be playing all together the idea here is that Again, every time that you play with the with the game that basically will mean that there is a function Instance being created on the backend and we can just see that kind of like in real life But we also be able we will be also getting kind of like all the cloud events here in the leaderboard that we will be showing in the screen But first we will just share these so if you have your phone with you And if you want to scan kind of like the qr code here, you have the yeah Yes Let's set it up So let's do it because we have another couple of minutes left. Yes We have no wi-fi or something like that. Oh, yes. Is that the problem? Yeah Classic classic. It's like we are just breaking the cloud. You see Do you want to put the game up at least the qr because i'm pretty sure that folks yes, let's start doing that Yeah So if you want to open, you know the game and let's hope that the wi-fi works There you go. Look at all the phones up Let's put it big, please Yes, actually we have wi-fi just a second Yeah, there you go So if you open that if the qr code doesn't work you can enter that, you know url It should take you to the same place Apologize for not being able to show the leaderboard But the wi-fi it's not working as we expected It was working before you all entered the room Yes, as you can imagine This is how it goes that one. Yes. Yes But we don't have like a yeah adapter. Do we have an adapter? This one Yes, okay, let's plug it in. Thank you. Thank you very much Oh, yes, we're in are we in There you go Live demos everyone running on kubernetes. No wi-fi There you go All right Let's see if it works. So do we have it? Drum rolls drum rolls There you go Okay, we have some people playing at least That's very good. Yes. If you haven't scanned the qr code There you go this again And you can see like this. Yeah the events popping up You see all those cloud events. Are you folks just playing there? So I think that again like just to recap a little bit We just try to build a platform where the main construct is a function We show that in the architecture when you're building this kind of applications If you are doing sync functions, you need an orchestrator to define which functions to call next But you can also build event-driven applications. Look at those notifications. That's great. You are going to cost us a lot of money Look at that. How many people is there? So all of these are cloud events We we got them via our socket a binary reactive protocol that we're using in the front that wow, there's so many events coming in This is awesome. Thanks for playing with us Look at how many players 300 players folks. I think that that's pretty much it. Yeah, remember to tweet your score If you did the score, there are some prices We will be calculating the winners later on but I think that's pretty much it my friend, right? Yes Yeah, we will share the slides you'll find also links to our github repositories or you can run this example on your cluster even locally And that was it. Thank you very much for joining. Thank you very much folks I think that we have like a couple of minutes for questions. There are two microphones here You know, if you want to ask any question, please feel free to approach us as well Or follow us there on twitter Yeah Yeah, thank you. Thank you very much Thank you