Getting Started With Kustomize (2022)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
what is going on everybody my name is michael lavanne thank you so much for joining me today and what i want to do is i want to go through something that i personally find super interesting called customize now if you've never heard of customize think about it like this when we deploy our applications we have dev staging or sometimes people call it uat and prod maybe there's even a fourth stage in there called qa now here's the problem if we're deploying you know let's say multiple kubernetes applications in manifest or maybe we have some helm charts whatever the case may be you're going to pretty much have this same kubernetes manifest copied throughout stages but just you know the values are changed in them so for example maybe you're using uh the latest of a container image that you built in dev but in prod you want to use a specific version maybe in dev you want to run one replica for your pod but in production maybe you want to run three to five so it's like literally the same well the same kubernetes manifest but it's a little bit different so how can we kind of get around that well there are a bunch of different ways but one way that i really like is customized so with customize you essentially have one base kubernetes manifest and then maybe you have some directories called like dev staging prod and then within each of those directories you have essentially environment files or environment variable files so let's go ahead and take a look at what that kind of looks like here all right so first thing i'm going to do is i'm going to create a directory called base now inside of my base directory is where i'm going to have maybe a deployment.amo okay so what i'm going to do is i'm going to go ahead and i'm going to copy one of my deployment dials here and i'm going to paste it in so this is just a general standard nginx stateless application kubernetes manifest it's not doing anything crazy it's you know using port 80 the latest version of nginx so then after that we have the customization file now the customization file is essentially acting like you know any other operator so i'm going to show you that in a second but we're going to call it customization.yaml okay so as you can see it is an operator like there is an api that's created for this the api version well the api path rather is customize.config.k8s.io and this api is not in the core api group it's in the named api group so any new apis inside of kubernetes are all in the named chord or sorry the named group okay and as you can see it is still in beta perfectly okay and you have the kind here and the kind is customization okay and then you can specify your resources now your resources are whatever your files are called now in this case i only have the deployment.yaml so we'll go ahead and we'll go with that so pretty much what we set up here is we have our kubernetes manifest and this is going to be our application that we want to deploy you know to the world right to any environment and then we have our customization file that essentially just looks in here and says okay what resources do we want to call upon the deployment.yaml again we can have a service.yaml we can have as many animals as we want in here it doesn't really matter the point is is that if you want to use customize you have to define your resources aka your kubernetes manifest inside of this block right here all right so now let's create a new directory called overlay and then inside of here we'll call this maybe dev right so oops sorry this actually should be a directory let's try that one more time coffee is still kicking in this morning so we're gonna have one called dev okay and then under dev i'm gonna have a customization dot yaml so customization dot yaml okay and then i'm going to paste in that code so let's go ahead and take a look at this code again i'm using essentially the operator again right the kind is customized but here's the thing the resource i'm pointing to the base directory and the reason why is because the code in here is what i want to be manipulated right now what i mean by that is if i open up my customization.yemo notice here how i have the application name called nginx deployment okay as you can see under the metadata label we can see name equals nginx deployment so that's our application now the count for my replicas i have is one but notice here my replicas in the base kubernetes manifest is two okay so what happens when i run this well let's give it a shot so i'm going to open up my terminal here and then what i'm going to do is i'm gonna run a command called cubectl minus k so minus k essentially what that means is it's for customize and what i'm saying is look in the directory the current directory right that's what the dot is right so as you can see it's going to give me an error and essentially what is that error well it's saying that it cannot find a customization.yaml file this is very very important you must have your file name that looks like this right it has to have one of these extensions here right it has to look like this that's how customized knows so let's go ahead and give this a shot again we're going to cd into overlay dev and if i ls here we can see that i have my customization.yaml file and that means customize is going to know okay i'm going to look inside of this directory with this command and then oh okay it matches one of these file extensions or one of these file names so i'm going to go ahead and i'm going to use that so let's run that right and as we can see this was created so if i run cube ctl get pods check it out now i only have one pod running so to recap here my deployment.yaml my kubernetes manifest my base manifest right really like a template almost has two replicas but because in my dev overlay i'm specifying that i only want one replica customize is going to use this configuration right here from line six through eight against my resources in the base directory which is this kubernetes manifest so hope that you enjoyed that little demo i personally really like customized i think it's great for any environment production dev just playing around etc thank you so much for watching really do appreciate it and we'll see you again next time
Info
Channel: Michael Levan
Views: 18,601
Rating: undefined out of 5
Keywords: kubernetes, k8s, learn kubernetes, learn k8s, kubernetes getting started, kustomize, kustomize getting started, docker, containers, devops, cloud
Id: 7kpm01EKY6A
Channel Id: undefined
Length: 7min 9sec (429 seconds)
Published: Mon Jun 13 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.