 Hello could you hear me? Oh I'm so happy to be here. So I'm Eric I came from Brazil the other side of the world and actually there is 36 degrees celsius and here is like minus nine I'm really freezing right here it's completely different for me today I'm gonna talk about kubernetes and docker and a lot of good stuff but here I'm not just I'm not selling any technology I'm just showing some experience in that type of beauty and something that I'm creating at home or at my job so I work as a trainer and software architect in Brazil work with financial companies and a lot of stuffs so first of all who here has worked with docker oh there's a lot of people and working with docker swarm in production oh that is not so much okay and with kubernetes oh that is amazing okay so this talk is focused on uh real scenarios we will talk a lot about a lot of things about kubernetes and how to scale applications we will talk a little bit about no too because it's our context but with these tips you can use in any application in any scenario just making this semi-configuration I will show also some tools to improve your current cluster your current cluster and help your application okay we are here because nodes so node we know that's node scales node are using in everywhere we can use on raspberry pi on servers and everywhere and when we we think about node we think oh node that's incredible we can use everywhere yeah but we know that's scaling the application scales but we know that the word scale sometimes is is confusing scaling application is not that simple we should think a little bit more what is this scaling I will show my opinion all of this is based on my experience and if you use your agree we can talk a little bit more later scaling for me is when you have your chaos or you have your application running and you should deploy new applications you should deploy new versions and you should understand and monitor all of your applications it's not just about copies here you have a lot of customers a lot of consumers and we should understand what our application is doing or not so it's not just copies we will talk a little bit more in how this could run and here we are here to talk about kubernetes and kubernetes is also called by k8 so I spend a lot of time to make this animation so yeah I showed my mom won't see that yet this is amazing so yeah kubernetes is an orchestrator it's also called by docker captain so it's just managing your container managing your applications to make some decisions make to have checks understand how is the healthy of your application and how to make something good and in my opinion one thing that is good that broke some fights is that they put soft engineers and scre is to work together now the developers will create the manifest files the scre will work together to monitor to create the developed pipeline and all of them is working in peace and working together and kubernetes in my opinion one of the best features is rolling updates so it's the ability that we can run our updates on cluster without worries we can make their updates granularly and update just a few pieces of our applications or microservices and we can check before this goes to production just before the customer tries to access here I have the scenario so I have a lot of consumers they are accessing my kubernetes it's not actually accessing directly the kubernetes we have also like a pay gateway or something that is a later layer before going to kubernetes but in this case I have a few versions of my api products you know you deliver a new version so I have the product on v2 so I'm updating this this application and the kubernetes will make some health checks they will ping in your application to see if this is safe or not to use so here I just finish the deploy the kubernetes will establish some connections will ping in your new routes they say okay I'm ready to receive requests when I'm ready to receive requests the kubernetes will redirect all of new incomes to these new applications and then we'll just remove the old version let's think about another scenario in other scenarios we have also an deployment we have the v3 right now but this v3 is not safe maybe the database is wrong or maybe some connection some third part object is not working and then it's not working but seeing our infrastructure continues the same the kubernetes won't redirect all their incomes to this wrong application and just heal the other version so our infrastructure is safe and is running as planned I'm gonna talk about the components so kubernetes when you look at the documentation we have a lot of lists a lot of concepts a lot of topics to understand but here I brought something that to you maybe you usually do in your home or when you think to move to kubernetes you should use these components so first I will talk about pods pods is the smallest unit of our code we can have more than one application is in each pod but it's not recommended it's not recommended you can use only you can put your application right there your docker image you can have your database as well but they are not smart so they they need someone to control them so we're gonna talk now about deployment so deployment we will specify how many have because how many copies we will have of this project what is the limits how many memory or cpu your application would use our version so I can deploy the version one and version two at the same time but I can expose this data for a different way and how I will update this project or how I will share and expose to my consumers for database we usually use stateful set whereas deployment files is stateless the stateful set could just proceed data storage we can use unik network to the fires and we can make everything order we can we have like graceful deletions I don't remember that the word but we can delete all of the instances in order as well so it's so much powerful to database to something that you want to start data okay we have deployment and we have stateful sets and now we want to expose we want to establish a connection through your infrastructure and here we have the service so the services the goal is to expose your systems to the world it's also a load balancer if you configure but here I'm exposing only the pod only the application on version one I will only make a load balancer I have other other types of services too inside the governance cluster I can say oh this application is running on per on port 3000 so expose on this port and I can have like an alias when I call this name they will redirect to deployment for stateful set is the same idea is the same target same labels it doesn't change so much but when my application tries to access the stateful set the database it has to access the servers and the server will route you for the current instance so if you want more replicas or more instances of the database you just put there in the search we understand what they have to do and this is amazing okay we have services we have deployment and all of them are running inside a node so the node is just the VM properly and the VM we have the networking the networking is the port forwarding understanding inside the the cluster is how they understand and the responsible for our servers communicate itself we have the kubelet the kubelet they analyze the manifest file to see if your application is running as plain like limits copies or everything that you make it on your manifest file the kubelet will run and we have also the container runtime we are talking about docker but we have other container runtimes as well that you can run inside the kubelet as well okay we have nodes that is all VMs connected and we have the master so the master will choose and we make some decisions about your cluster so we have the cluster store that we manage and store all information about the cluster we have the scheduler when we have a new pod we have to to send this new pod to our node and understand what is going on or if a node is right or not to receive we have a few controllers as well we have node controllers to know if the node is safe we have replication controller to see if the copies and the amount of instance is correct and we have also the api server that we use is the front end that we use to perform operations on the control plane of the whole kubernetes when we run a command on the kubernetes we will run inside the api server but now let's see how the master or how is the behavior of kubernetes compared to other approach so here we will define a master manifest config file that would be json or yaml file we will have defined it like we have a desired state my desire is streamstance okay i will run streamstance so i have two in canada and i have one in brazil okay my current state is exactly the same than my desired state but imagine for somehow the the server in brazil is not responding so the kubernetes will make some checkings and we will schedule a new a new instance to other nodes we'll make some checkings and now the node in canada will receive the missing pod and i will have the same idea in the same go okay when you use kubernetes we know that's nothing is bulletproof we know that sometimes using just docker compose or just using our property vm itself would help and now let's talk about why it's good so my opinion zero down time up days when you can test when you can check your application before exposing to our customers you can replace and you can put a new instance with no worries yeah actually your consumer is not knowing what is going on you just switch our code you can use canary deployments and a lot of microservices fun stuff we can use multi-region clusters we can use raspberry pi we can use linux servers we can use everywhere the world just join the vm on the clusters so this is so amazing and this is something that you should think about your application so you have only one api your api is not you are not deploying every time so maybe kubernetes is not so good for you because you have so much effort to create infrastructure and you're not using all of the benefits so if you have a lot of apis or you should have more than one instance so you have to to provide 24 hours up over infrastructure maybe kubernetes will help you more and this is some polemic no vendor looking but when you go to some cloud platform when you go age your aws google we have the same manifest file but sometimes the configuration would be different this is when you use the manifest file is the same language the same idea the same attributes but when we talk about the external services such as storage or other thing that you must use on a specific cloud this would be different okay why kubernetes why we we are actually using other stuff here we are just making our production our deployment pipeline and maybe why should we change or should consider using that so how many of you using docker composing production oh docker compose so docker compose is amazing we can use like i've been using you with portainer if something goes wrong i just click there we start and everything's okay but when we think about scale with docker compose we should enter and make everything manually so it's not it's not so smart than other approach so if your application dies you can make like an alert send you an alert and you go there and replace or restart and we have docker swarm so docker swarm is the same idea then then kubernetes the the docker swarm is so similar than kubernetes as well but it works only on the container runtime of the docker and if you want support you go to the docker enterprise but at the same time the kubernetes is a little bit more powerful technically so it provides check health checking provisions uh inside the pod level so we can use a schedule and scaling namespace and roll basis access so you can create like manifest files to say what is application will run inside the kubernetes uh a little bit and this is my scenario so at my company and some customers they are actually using uh acs or ac or acs in production what is the difference here the difference here is you have now the dependency of the third party and like in acs you are dependent of ac2 vm so if you want to scale more you have a little time to look a new vm and configure some time and uh put this up but out of this you should use aws or azure or google platform so you should learn more about the specific version of your uh go so gotta hack how do we start this gift is amazing uh hackers on this is amazing gotta hack how do we start so we can start from a lot of places first of all i love this gift yeah i'm the bad guy oh yeah we can start with cube adm going to on prem solutions you can install on your vm you can install on russ bar pie on or whenever you want but you have to configure networking monitoring the masternode you have to configure all of them by yourself this is sometimes a little bit harder than going to another approach you can go to a cloud solution provider i put here just the cloud that i remember but i know that there are a lot of communities services for outside so i've been using uh azure and uh aws a lot in my job and my customers and it works so fine so they provide you the master and you can just up and manage the nodes so this is so much straightforward than configuring managing the node the master node okay so in develop you can use mincube so i'm using here mincube with virtual box and i can run all of the configuration manifest files that i will be using production in my machine just to test how we threw a ramp and to show the power of the mincube all of this presentation and demos were were run using the mincube before going to minicube qbdm or cloud solution we should run a manifest file so our manifest file first has to say what is the kind what is the component that you are creating so in this case is deployment okay what is the metadata so how do you create this this component and then how many copies how many replicas do you have and you can see you can show selectors the selector is powerful for something that you have already on air is running and you you want to replace this instance or you want to update this instance use these uh match labels we have the template as well so how the application will actually work or we were actually created inside our cluster we can put the image pull secrets when you are using docker registry private docker registry and we put actually the container itself so you can put environment variables storage and everything inside this file okay i will run first the mong db because my requirement is to use mong db i created and i will expose this mong db using the cli so i'm just i can use cli or i can use manifest files but just for example reasons i'm creating from cli here i'm got the plotting that is fine i will get the svc that is the service and the mong db is right to run after that the mong db is correctly configured i have the service i have the pod and now i will create my application that i created in this manifest file and now i created and then i will expose again again i'm running on cli but i could run inside a file as well because i'm using minicube i will get the url from minicube and they will expose a url for me and then i will just make a request to see if my application is responding and going through the mong db and get the result so looks like nice so i just created one file and i run a few comments and my application is on there so fast let's talk about tooling so we have a lot of things about kubernetes that i really love one of them is with everything is plugable is a plugin play you just apply a pro you you just run kubectl apply in a file and then we can see the result the plugin the plugins just sharing each other understanding each other we have istio so istio is a server smash that provides you a lot of tools to monitor the applications and to install in your cluster and i will show some tools that comes when you start then so here i'm just running the demo i just copy paste from the website but they install a lot of components for us and if you go to one of them we can see the promifius the promifius is a monitoring tool that we can run queries and see some metrics from the your kubernetes servers so here i have a lot of metrics and a lot of data that comes from the the kubernetes and here i will just make the same so i'm redirecting the request from my my pod to my my machine and i will go to grafana so grafana is the data visualization so here is the demo from the garfana as well so you can get informations for your disk memory create alerts and install dashboards this is so much powerful and i just run a comment and then i have everything enhanced so this is so powerful we have elm too so the helm is a package manager it's our npm for kubernetes so you can create a lot of stuff a lot of packages and we can use actually this stuff so here i will try to find the reds actually the production reds that is configured with cluster is if configured if everything that i will want to run in production and then i will install these reds i will install they will show a lot of suggestions to test if my reds is working or not and here i have the password and everything that's just i will copy paste this just to see if it's working or not and then i enter in my reds and i just ping to see if this message is okay so with three comments i have everything prepared to production so if i just try to create the reds from myself i have five or six files to configure to create roles and to create passwords for everywhere so it's not so easy to make it in hands and here we can create templates so with templates i will open just on vscode and we have the templates so you can create like dynamic files and you can change these files just changing a little code so here i have all of the dynamic part all that i can reuse through the applications and i have here the services dynamic as well so i can change only a few variables and when i go to the values i just put the value that i really want imagine that you have the same servers in three different environments you just change the values and you have the same environments working everywhere the same actually is the same infrastructure running in different environments with different values okay we are here to talk about scaling no js applications though i love that yeah so we should talk about what is scaling so scaling itself what does it mean so scale this is my opinion scale again is something that you can control the chaos you can control all of your copies you can redirect your request when you need so if you need more extensive if you need to update any time this you are scaling your application if you are worried to make a deploy like on midday sometimes you are not scaling this is my opinion okay and talking about kubernetes to scale your application if you forgot everything here just remember that part this part we have some useful configuration that makes some that helps kubernetes to to run your coaster so you have liveness and redness probe who never know about liveness and redness probe okay oh liveness and redness probe so kubernetes is not that smart so you have to say oh here you have to ping this url and then if you respond to you in that time then it's okay then you can run or not otherwise the kubernetes we wait like 10 seconds 5 seconds we'll just say oh if your application doesn't crash in 5 seconds maybe it's right but sometimes it's not it's just because you are not catching the exceptions so here we have a lot of code too but let's pay attention just redness and liveness probe so the redness you say to the cluster oh are you ready to receive requests okay i'm ready to receive requests so how many time i have to wait before the first request oh i want two seconds three seconds to establish connections establish like third-party connections and then if this first request is paying more than two seconds something goes wrong you have to delete this instance because it's trash so we will up a new instance and you see the result the liveness probe is something similar but the difference is the kubernetes is making a lot of health checkings in our cluster to understand if it's still running or not so we have here are you alive in two seconds three seconds and here we have how many times i will wait for the first request two seconds okay i will have the time out seconds as well sometimes you have a problem with like in term in terms of problems and you really don't know what's going on but the kubernetes making this health check this is the leading application in creating again and you actually don't know what's going on you just know because you see how many restarts or how many new records you have and we have the pod outscaler so this pod outscaler you put measure so oh i you this application can access 20 megabytes or 200 gigabytes to access something or it can access memory or other kind of thing and you spend limits so if my application reads 50 percent then the value that i put there i want three more instances four more instances and actually it doesn't it works super fine and this is something that you could use on black friday so you are receiving a lot of requests okay kubernetes but more and more and more instances but if i don't want more instances just kill them all and then this is fine so this is super nice but okay there's a lot of information i know that's a lot of things on internet and a lot of things that we do actually on daily day but let's just summarize everything in your mind so come docker kubernetes is just someone that is a code is someone that will replace your application when they are not healthy making strategy or update your application when you need you can do rolling updates you can make strategies to up to a pdation new version to test a new version you can make load balances just using services and making your target just choosing which application is the best for your customers and if your application is not safe if your application is not responding you have automated rollbacks so you can use everything inside the kubernetes with no worries so all of this content all of docker things and a lot of stuff that i've been doing to is already on my website if you want to see more or if you want to talk more send me a ping on on twitter too that i i really want to learn more with you okay so thank you so much for having me i'm super proud to be here here is the links if you want to take a picture all these slides is right here if you want to talk to me on twitter or LinkedIn i would be really grateful for you to talk and to learn more with you