Deploy to Azure Kubernetes (AKS) from Azure DevOps with Azure Pipelines | Build LIVE with Me

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] you showed me how to dare to love so tell me what you think you know [Music] you show me what you think [Music] tell me [Music] show me [Music] so [Music] my [Music] ah [Music] don't [Music] [Music] [Music] here we are we should be live hi everybody uh good morning good afternoon good evening uh wherever you are and actually let me know in the chat where you are and where you're watching this from what country what city i would love to know where you're watching from um thanks everyone for being here i see there's few people already uh we will wait few more minutes because i know there's a lot more people joining tonight um but yeah so oh from zlatan from serbia hi nice nice to see you here um my hometown is fairly close to serbia um not super close but i guess you may know it it's called trieste it's the border city between italy and slovenia and i know there's a lot of people passing there to go to go around oh yk2 official says he's watching from stockholm sweden wow uh thanks thanks to be here thanks to be here on your afternoon on my night it's uh 9 35 p.m here um all right so oh my my friend dipin from canada hi it's been it's been a long time since last time we spoke uh bartos from poland oh we have quite a quite a bit of representative i guess the only ones the only people that may not be able to join tonight is um are the people from from australia because of the time zone but i think we have uh we have quite a quite a representative of basically everyone else um just before we start very quickly two things i want i want to mention uh the first one is that if you guys follow me also on my for for my blogs you know that i i blog and post the articles on the dev2 platform and we are about to cross the 100 000 views on the articles so i just wanted to to no to kind of celebrate in advance because we are like 99 and 800 views or something like that so almost 100 000 views um second thing and then we start is that yesterday i sent out the monthly newsletter for from from the channel um and i noted quite a few people um haven't received that and it's not that you haven't received it but it check check the spam folder because i've been told by the by the provider of the newsletter that they changed the ip addresses they are sending a newsletter from um and so those ip addresses are still in kind of warm-up stage so they may have been um you know putting put in the spam so check check the spam folder if you're if you haven't received the newsletter yet um and if you don't know what i'm talking about or you're not yet part of the newsletter uh try and go to coderdavid.ioslash newsletter i just put the link in the um in the chat if you want to you want to do that and subscribe to the newsletter and i'll be i will be resending the um the monthly newsletter to all the new subscribers and to the people that haven't received it or for some reason haven't been able to open it so go ahead and um go and subscribe tonight is the last chance for you to get the newsletter of the month with that said um i think i think we can start so what i want to do tonight is walk you through uh how you can deploy from azure devops to aks or for what matters basically any other kubernetes because the procedures are basically the same um and i want to do that from scratch um i will i will point a number of things out during during the live and this is how i would do this for for for a client and i i want to really you know walk you through all the steps so i will start from from scratch and i will i will explain everything as we go so let me switch to the screen uh one more thing before we start is that um i will not i'm not sure i will be able to see the shot all the time so if you do have any question feel free to ask in in the chat but i may not be able to answer straight away i will check the time uh the chat from time to time so bear with me because i only have two screens so i need i need to have a few other things on on the screen so i'll try to take a look at the chat from time to time but i may not be able to see it continuously so uh let me jump to the screen we should yep all right so um let's let's set up the stage so what do we have we have uh azure devops here this project and i'll leave that i'll leave this for for last because i want to explain a few things here i do have the the code for the application and i'm hosting it on github because at the end of the stream you will be able to go to this repo this repo is public and at the end of the stream you will have the full yaml template at the full yaml pipeline um for this deployment that we are going to build together so you can reference that if you if you decide to do so so uh mark down this report you also find the link in the video description if you want to reference that afterwards and what i have here is just a simple application um in my case it's a net core application but uh just because i'm more familiar with net but this of course will work with any other kind of application we do have a docker file for containers containerizing the application and i do have some very simple kubernetes deployment files that i want to show you right here um we have a deployment the i'm since i have a lot of imagination i decided to call this up sample app um and this deployment just takes the the container um that we are going to publish and uh you know published publish it on kubernetes on aks and we do have a service to just expose that application because it's a asp.net application so it's a web application um this is all i have over here so apart from that i do have already created the kubernetes the aks cluster the kubernetes cluster in azure for sake of time the cluster creation may take a little bit of time so i recreate it but as you can see um i have only the system deployments and also if you look at the pods i only have the system pods running so the application is not running yet it's not being deployed and i also have an azure container registry already created but once again this is completely empty and we will use this to publish or sorry to push the image we are going to build for the application that we we need a container registry to host our image um and i decided to do so because in in azure container registry because you know we are on azure and i want to do that it's easier but that would work as i mentioned before basically with any kubernetes service and any container registry that you want to use so going back to our azure devops this this project is basically empty at the moment you can see that i do not have anything in the repo because as i mentioned my code is in in github i don't currently have any pipeline over here and um same for environments but what i do have um the only thing i've already created are these service connections and we do have the service connection to my um github user so i'll be able to pull the code from from github um and i created already the service connection for my azure container registry and for my kubernetes cluster i did so because it contains the secrets i didn't want to show the secret during the live stream but all you have to do to do to create that you just go to new service connection and you go to github for the github account you go to docker registry and then you select azure container registry if you want to create the service connection for that and then you can go to kubernetes and uh again you can switch between subscription service account google ctl etc and you create a service connection to your kubernetes cluster so basically those three things are all i have at the moment for for this um for these um live streams so without further ado let's start let's go to pipelines and create a new pipeline so of course the the the goal for me tonight will be to get the code we have in github and have that at the end of the day the application running into my aks um cluster but i want to do it as it as if it was a real application so i just i don't want to just you know deploy it in whatever i want to guide you through the the thought process i would have when deploying a real application on a on a production cluster so first of all we go on the github because is where my my code is and that of course asks for permissions we take the deploy to aks repo there is where i have my code and so first thing here if you if you know or if you see we do have these deployed to azure kubernetes service which basically would set up almost everything i'm gonna do tonight um the reason why i don't wanna i don't wanna use this is because as i mentioned a few times already i wanna walk you through all the steps that are needed so you do understand what uh you know what is needed and why we do what we do um if i would use this one everything will be created um there would be few things to change because it's not everything as i like it and as i would do in a production scenario but we will lose all the reasoning behind the scenes so this is why i'm not gonna start with this template but i'm gonna start with just building the docker image for for my application and as you can see it already identified that my my docker file is in the up folder and we do have this docker file over here so it's in the build source directory and app slash dockerfile so i would use that docker file and of course this creates the pipeline for me um and this pipeline as i mentioned just builds the docker image but there are a few things i wanna um i wanna change here before of course saving it so we already have the tag for our image and i'm okay using the build id but what i want to do is also parameterize the image name or the repo name i will call image repo and we call it just same sample up and this is something i recommend every to everyone whenever you have like hard-coded things like the name of an app or sorry the name of the image or anything like that do create variables because you never know if you need to change later on it's much easier to change the variable rather than changing uh you know every instance of the um of the name basically um this created for us already the stages this is a build stage and it's building the image of course it's a job so we don't have to check out the code because it's checking out the code automatically by itself it's running these on linux and i'm i'm okay with that the docker file is already here and what i want to do here though is not just building these this image but i want to build and push it to my container registry so i'm going to do i'm going to modify what we have over here i'm changing this from build to build and push and i'm going to select here the container registry service connection that i've created before that and i've shown you i'm going to use here the variable that i just add so that would be um what did i call it image repo and this will identify the container repository in the container registry i'm gonna use the full path as i mentioned before for the um docker file and i'm also gonna add the latest tag now if you know me and if you've seen any other of my videos you know that i hate using the latest tags for for container images for many different reasons and we can talk about this in the in a while if you if you wish so let me know in the chat if you want to explain why i don't use the latest but for the time being there's a reason why i need to use latest and i'll talk about that in a second we will get rid of this in a in a later stage so and basically i'm gonna change that task before with this build and push um so another thing i would need to know so with this we will be able to build our image and push our image to the container registry so next thing i need to do is deploy these two to kubernetes right so i don't want to do it in the same stage i want to do it in a separate stage because i want to be able to repeat the stage for example if anything goes wrong so i'm gonna add let me copy just this part because i don't wanna write it all i'm gonna add this new stage called deploy we can call it deploying on dev and of course we need to specify that this stage depends on the previous stage otherwise they will run in um simultaneously and in here of course we have the jobs and we also yeah so the job would be probably something like sorry um job deploy we can call it um we can call it for example deploy to aks and let me check we of course need the pool and um vm image we can use the same we used before which is ubuntu latests and then we have the steps right um why ah because this should be i ops i hate the indentation of yaml i guess we can all agree that yamo it's 2p keep right so what do i need for deploying well i need few things first of all i need to have the manifests right and i do have my manifests in here um but i do the deployment and the service yaml manifests for for kubernetes but i don't want to access my repo directly from this job because this is a deployment job and notice that i use again a normal job and i'll explain that in a second but again as i said i want to i just said before i want to do it gradually so just use a normal job for the time being so as i mentioned i don't want to access the repo because this is just a deployment job the logic here would be that the the ci jobs can access the repo and access external resources if needed but when when you go to deployment jobs or to jobs that take care of the continuous deployment they should never um they should never access the external resources or especially the repo so to avoid that what i need to do is adding one more step over here and i need to grab these manifests that we have in the repo and publish them in order to be available for the other jobs the way to do so is using the uh defect the um where is it not the download but the publish pipeline artifact task and we need to tell them that we need to tell this task that we want to get grab um all the files in the kubernetes as you've seen before everything i have is in the kubernetes folder um one one one thing one small tip here you can see that if you if you want to access the sources file sorry the sources folder in your pipelines you can either use this syntax over here with build.source directory or you can use the pipeline.workspace s the two things are equivalent they point to the same folder basically so i can use any of those and um let me think uh the target path is this one the artifact name we can call it manifests and that's it so i can just add this task over here and what this will do basically will take the content of the kubernetes folder so in my case those two yaml files that are the manifest for deploying into kubernetes and they will this task will publish these artifacts or this yaml file as an artifact and made them available to any other stage after this stage with the name manifest and therefore since we have it over here next thing we have to do would be to download the artifacts in this stage so once again we can search for download here and we have um download pipeline artifacts we can use of course the we should use the same name and we perhaps want to download it in a path that we know and we call it manifests money fests all right so we download it in the folder with the same name we go here and we can add it all right so with this with this trick with this technique now we have the yaml files published from um from our build step and made available to our deploy step so and remember we do have the image already in our container registry or when we execute this we will have that available um so the let me think the other thing we need to do is to deploy of course using those manifests and to do so we go again over here we use the deploy to kubernetes task and uh we do use the deploy action at the moment it's fine we select the service connection remember this is the service connection as i said before that i've created for this uh for my cluster the the namespace is the i wanna deploy the default namespace just just because of and we leave this uh let's call it replace me um and we leave everything else out here like this so and i'll explain you in a second why i want to do this so now we do have our deployment the only thing we need to do is replace this with the actual manifest that we have in here so what i can do i can get rid of these and oops and with this because i have two manifest files i can specify uh one is called service.yaml and the other one is deployment.ammo it's deployment.yamo and the other one is service.yaml this little thing over here the pipe means that uh that basically tells the yama pipelines this is a multi-line um field so i can specify the both of the deployments sorry both of the manifests in the same in the same um you know parameter so we do have here basically what we need there is one more thing that you need to pay attention to so if you remember i've shown you in azure and we can go here we have the aks cluster the kubernetes cluster and then we have our azure container registry where we will host the um the image the one thing that most of the people forget about when they try to deploy is that azure container registry is a private container registry and that means that the kubernetes cluster must have some credentials to be able to access the container registry and consume the images this is a very important step because most of the time people will try and deploy and it fails and the failing the failure is because of the missing credential um there are different ways to do so i what i like to do is keeping things separate so i would normally create a secret for kubernetes in a different step and then try deploy and this is what i want to do now so i want to again use this kubernetes um and the action type i want to select is create secret and i'm going to use again this cluster service connection the namespace is default the docker the type of secret is a docker registry um azure container registry is basically a docker registry um we can call it how we want it let's let's use a variable for this um let's call it i don't know acr secret and i'm planning to use this later in other stages so uh sorry another job so what i will do is adding here a variable and in here i'll uh these and uh let's call it um i don't know um what if uh let's call it something like this i've seen there is a there is a question and is why not use the environment um this is a good question and as i mentioned before um i didn't mention it before but i will use it later i wanted to have gradually to gradually build all the things we need and explain step by step why i do the things i do so i'm starting with the with the basic scenario um just using normal jobs and then in the next step when we have these deployed for the first time i will add on top of this and add the environments and so on so forth so i wanted to to be gradual and explain uh everything step by step because we're starting from from scratch here um there is mj sabido from the philippines hello there's uh another guy from poland uh glad to have you all guys here okay so where where was i um we've created the variable with the name for our secret this will uh create our secret and of course we need the docker register service connection and once again we can use the um container registry connection that i've created before when i add these in here it's this will create a secret a kubernetes secret inside the aks cluster and being this a docker registry type of secret um whenever whenever um the aks cluster will need to pull an image from my k8s examples acr my azure container registry will have the authentication data of the the the authentication credentials for for that um ford acr i'm just double checking that i haven't forgotten anything but we should have everything we need so if we go back let me get rid of these i don't like that so this trigger on ci um we have the two variables for the image repo name and the tag for that for that um image and we create the docker image we build the image we tag it as latest and i will explain while it builds why i've done that we publish the manifest as artifacts so we are able to consume them in the deployment stage that depends obviously on build and the deployment stage will download the manifests will create a secret in kubernetes to be able to authenticate to the azure container registry and then we'll deploy the application using the um the deployment files let me save and run so this will start building and then i will explain you a couple of more things so this is creating the pipeline and in fact it's creating it on github so if i go over here you'll see that it just created the yaml pipeline file in here and so this will should start building in a moment i'm not sure why it's taking this long okay so this is building um i have the cube ctl open here this will point to that cluster and you'll see that there's no cluster at the moment let's put it in watch mode so we will see if anything changes and what is that should be like this so this is building the image uh let me go back to the let me go back to the pipeline and i want to explain two things here first of all is as i mentioned why i'm using the latest tag the reason why i'm using the latest tag is because in this moment what i'm relying on is this deployment manifest and as you can see here i don't have a tag for that image in here because this substitution in here would be quite um quite complex to to do and we will do that later in a different way so the only thing i want to do the only thing i can do is taking the latest image um from from the registry from the sorry image repository so that's why i'm using latest even though i don't like using the latest because if you use the latest and you publish a new version of the application with the latest and your cluster for any reason needs to pull another image it may pull the wrong image it may it may pull the the new version for example or a different version of the application and you don't have control over that so this was the first first thing second thing is um why i'm creating the secret in a different step and before actually deploying the application i'm doing so because if the um if the secret creation fails there's no point in deploying because the deployment will be failing because the there's no credentials for for aks to connect to the azure container registry so i want to be able to deploy only if this doesn't fail if i if i do altogether it skips even on failure and may try to deploy and i will let the feedback just too late or later if i do it in two different steps um that will be immediate let me go back to here so the our build image is done now it's deploying let me see if there's anything in the chat in the meantime zubair said uh is connecting from australia so i was wrong we do have people from australia i thought there would not be people because of the time zone um is someone else [Music] i will take a look at that in a moment and we see that our our container is our pod is now running so this will this means that being running means that the secret creation went well and the deployment went well as well and in fact now it's completed so as you can see we do have also one artifact and in fact this artifact is the yaml files that we've published as a result of the build if i go back here you can see that now i do have if it if this loads and i have the sample up repository and i have both the one three one five four image and the latest one so this has worked as we've seen and if we wanna double proof is i can go in the workloads and you can see that i have the sample app deployment and i have the simple app pod running so the simple scenario is completed but this of course is a simple scenario is not what you actually would do in um in a normal in a normal application and by the way let me show you that the application is working we can check the services to get the id of the application and we get the external ip let's put it here and we do have a welcome to youtube which is what is written in the homepage of my application all right so we have these now what's the next thing this it this works but i will never use this to deploy in production on any application so how we can make this better well the next thing to do would be as someone pointed out before um i guess was zlafcevic we can use environments so let's let me go to the environment section and i'll explain step by step why i'm going to do this and let's create something an environment we call it as dev for example we make it of type kubernetes and we use of course aks the thing here is that for some reason these this ui instead of using the service connections that you already have require you to basically recreate a new service connection not sure why so i need to go and select my uh my subscription i only have one cluster in there so i'm going to select that and i'm using the default namespace i'm creating this and this will take just a few few moments and we see that we have the kasdev environment and um we have the default namespace mapped here so we can go back to our pipeline and let's change a few things over here first of all let's as i mentioned before this is a deployment so we should not be using a normal job for it we should instead be using a deployment job because deployment jobs are the one that are designed to you know handle deployments as the name says and also because the normal job would check out our repo and that will take time for nothing and we will end up having all the sources also in our deployment agents that we don't need also of course these um requires on environments and this is why we have created environments the environment we created it's called k8s dev and remember and this is something also i see very often people forgetting to add the namespace in here if you go back to environments you see that we have the ktfksdev but the resource is actually the namespace the default namespace in this case you need to use the environment here with both the name and the namespace you want to deploy into otherwise the deployment will still require the things that we will we are going to remove now being this uh um a deployment job not a normal job requires a strategy now i'm not gonna talk too much about the strategy but basically thanks to these you can uh implement canary you can implement rolling deployments uh but that doesn't really work with with kubernetes very well if you want to do canary in kubernetes you better use the canary deployment that you can find in the deploy here um and that would double that will work all right now why i'm using the environment here for a couple of different reasons first of all since we are using the environment and as i mentioned and each environment has its own service connection we can get rid of this service connection over here and this service connection over here because uh this task will inherit it enter it the service connection from the environment itself um and so this is also better because if you need to change it you can just change the environment you don't need to change all the recurrence of the service connection inside your tasks second thing is that by using the environments and we will see these in a second we don't need to go like i've done just a moment ago on to the azure portal to see the deployments to see the pods etc we can see it directly from within azure devops um so we've done this let me check my node we've changed the job to deployment and we've removed the uh the kubernetes service credentials from uh from the the tasks using all using it directly in the um in the environment so this is my step number two and let let's uh well let's just try this out and see what happens um while this build this will take a moment to to refresh while this build i'll may drink some water because it's it's 10 11 pm but it's still fairly hot i have 7 27 degrees celsius in my room at the moment i don't have an air con because if not it's too noisy for uh for the stream and while these builds let me go back to the chat and see if there's anything else um the school notion asking if it's possible to create a pipeline in azure devops that runs two or more independent pipelines and does nothing else um [Music] you you can do it in two ways you can either use the trigger completion uh that sorry the pipeline completion trigger but in that case it's not the main pipeline that will trigger the other pipelines but it's the other pipelines the dependent pipelines that will check for the execution of the main pipeline and when it finishes uh they will auto kick off themselves if you will and you can just say i don't do anything on the main pipeline and i just use it as a trigger or you can excuse me you can use a task that is called um trigger pipeline task it's not out of the box you need to go to the marketplace there's a couple of tasks they do basically the same thing and that would also let you trigger that um you know properly or what i mean by probably is that this time will be the main pipeline running that uh that trigger tusk and therefore will trigger the other dependent pipelines um but i would say [Music] that if you as you as you specify here if you have an application that have independent micro services um and you mentioned that they are they can be built and deployed separately but then if you want to uh to deploy them all together i wouldn't necessarily recommend doing doing so because how many times you will need to do that in theory maybe once when you have a greenfield application because after that you will have your deployment running and if they are deployable really in uh you know independently you should never be able to or you should never need to do so uh that my that's my thought but yeah definitely you can do you can concatenate pipelines either with the two methods i just explained our deployment is running and it's actually run so we will not see any difference in here sorry in the um in the pods we will still have one pod and with the same age because nothing changed in the application so far so that will not change but what we will see is if we go back to our environments we can see that now we do have the image deployed we know what image it is with with uh the tag we can access the services in our clusters and if we go inside the workload we can also see the pods all of these without leaving azure devops and um so that it doesn't you you don't need if you're an admin you don't need to give permission to your users for the azure portal because they can see everything from here um if you want to know more about the environments i do have a video on a series of video actually on the channel about the azure pipeline's environments or azure devops environments and so check that out if you want to have more information i have one specifically for kubernetes i have others uh general for environments in general and other things so let's go back to our um to our pipeline because there is one more thing that i wanna i wanna do here so so far we've been deploying just the latest image and if we go back and check our um this is the the index if we go back and check our deployment you can see that i have one replica and that is hard coded and i do not want to hard code this and i want to be flexible i want to have different images i want to actually deploy only the one and make sure that i deploy the image i just built so there are a few things i need to change to make that happen first of all if i go back first of all let's remove the latest tag so we are not going to deploy the latest anymore and to be even more sure i want to go to the container registry and in the repository and let me delete the latest tag so now we have only one image all right so i've deleted the latest tag from here and um what we do first let's let's take care of the image name so if i go back to my deployment over here you can see you can see that let's use this so i have these containers section and this will basically override the container section over here or at least what we can find in here what i mean by that is that instead of having now this hard-coded i want to use this over here but again i don't want to hard code this so i'm going to do a few things first of all i'm going to use the variable name because i do have the variable on the top here so i'm going to replace this with my image repo variable and i'm going to also um make this a variable and i'm going to use it as uh yeah i'm going to use it here i want to have these as stage variables so let's call it acr dev url and we oops and we have this over here um copy and again i'm going to use the variable here and finally i'm also going to use the tag variable so this one will basically substitute will replace the k8s exampleacr.socr.eo sample app that i have in my manifest with basically the same thing but adding the tag that is automatically generated by the build the build job over here so this is what this will do so let me reselect this and add and reform oops my bad there we go uh one more okay so this will make sure that i'm going to deploy just the image i want the image with the tag i want and not you know the latest because i don't have the latest anymore the other thing i want to say i want to do that i mentioned is i want to get rid of these and make it dynamic so to make it dynamic we can tokenize this field or any other field for that for what matter and make this dynamic so what i'm going to do is i'm going to change this with let's say replica number oops so i'm going to use this as a token and you can and i'll show you in a second you can use anything you want for uh as the limiter for the for the token one thing don't use something like this don't use the percentage for the limiter because yaml doesn't like percentages so if you do so it will break basically so we have this replica number and now we need to change that we need to you know replace that inside the pipeline to do so i'm going to use a task called replace tokens this is not a task that you can find out of the box it's a marketplace task that's obviously completely free and you can find the link for this task also in the video description below if you if you want to use this um but the way it works is it just take whatever file that is either xml yaml or basically any any text file you have and search for tokens and replace the tokens with the environment variables that have the same name so i created here this replica number token so what i need to do is create in again we can do it over here we can create an environment variable with the exact same name and we give it a value for example three i want to have three replicas of that pod the key here is that it must have the same name otherwise uh it will not work so we have now the uh the variable so what i want to do is tell them to parse my deployment.yaml file and change and replace the tokens so i'm gonna if you remember we were saving the manifests in here or actually i can grab these and oops my bad so the root directory will be where we have our manifest the target file or files will be my deployment yaml we can leave everything else like like it is but i want to change the prefix and suffix for the token because in my case i just use the um the the the that thing i don't remember the name um the the sharp like in c-sharp right um and that's all it takes i'm gonna insert it before the deployment task and there it is uh let's give it a proper name let's call it display name replace tokens and here we have it um what else yeah so what we've done is we've tokenized the replica number in here and we've told our pipeline to replace that with the replica number here which now is three and we also changed we replaced the container in the um in the manifest file so we are going to use the exact version of the image that we are building uh where is it over here let me save this um this of course will kick off the pipeline so i'm gonna i'm gonna cancel it because i need to i need to um why it's so slow today i need to push to the to the remote repo my manifest wow this is slow this is really slow i'm not actually sure why is this low hopefully i'm not having network problems that would be that would be bad all right so let me go here and let's cancel this out i'm canceling this because as i mentioned i need to still running why is it still running okay it's being canceled all right um i need to i need to commit this and i also want to change my my file over here and let's say welcome to color dave so i do i do have to comment this i'm a cli guy so i'm gonna do this from the terminal over here and remember to always add a comment so the comment will be changed manifest and index and let's push it to our remote repo when you do that normally oh of course i need to pull it first um you normally don't try to push directly to the to the main branch uh it's not what you should do but for the sake of the demo in the sake of time i will do that all right now we have our deployment with the replica number on the remote in theory so just let's just double check here we have the change manifest and index so now we can go back and wait for our pipeline let me see if there's anything um this is a very interesting question uh what if we put the build and deploy in separate pipelines what is your suggestion for sharing the image tag i would not recommend doing that especially with the yaml pipelines because basically you don't need to um you have here all you need and all you want to have a single pipeline if you are concerned for example if you have multiple multiple um what's called multiple environments that you need to deploy to let's say you have dev test qa etc so you're concerned that your python will become too long or too big your yaml file then split it up in templates but use the same pipeline it's it's much more efficient um i wouldn't i wouldn't see basically a single reason why you would want to split yaml pipelines between deployment and build but even if you want to do so the only way you have to share the image tag is let me think um i guess it's using the apis so i don't remember if the the trigger trigger task i mentioned before if you can share a payload for example and consume that as an as an input but um but no i don't think you can you can you can share that with if you use a release pipeline so if instead of deploying through yaml you you decide to re to deploy using a release pipeline so a classic pipeline then you can you can get in my case for example the tag is the build id so you can get the build id from the calling pipeline but if you use any other any other tag then it will not be possible to to to share that as well so i would i wouldn't necessarily recommend that and and and plus if you use the release pipelines you don't have access to the environment's um goodness that you have over here so um yeah i wouldn't i wouldn't do that so this is deploying let's see if we can let me clear these up let's try and watch this we still have only one thing running and think i mean pod and now you can see that uh we are having a error for some reason this is interesting let me double check the execution of the pipeline so we have the replace tokens we see that we have replaced the token so that should have worked um i know this is the term the other one terminating but i'm not sure why we only have one pod i know in fact we have um no my bad we have we have three pods of course each pod is only one uh one pod uh one container each so yeah that's all right so we do have the three pods right now because we've replaced it in here um in the manifest slash deployment yamo and we now have three replicas so that has worked and in fact we can go back here to our environment and in here we can also double check that we do have three pods and all three are available with the image this time one five seven because we can see over here this was the build 157 and we do have if i scroll down it should be here somewhere um where is the uh there we go it's been tagged with the 157 so yeah that's uh that's it i guess um if as i mentioned before if you want to check this pipeline out you have this full yaml pipeline inside the repo and you can play with that if you want you can grab the the whole content and as i mentioned you have everything over here everything we've done so if i if i go back and re take a look at the pipeline just for summary we can see all we've done and we started from a simple scenario which as i mentioned is not the one i would normally recommend to deploy anywhere that is not just a test environment and we grew we change our pipeline up to reach a point in which i would feel confident and to use this in a production deployment um if you know me you know that i would actually not use this approach necessarily um i will do something different but i i will leave that to another video i actually do have another video but it's that is more to do on how i like to build my container images and how i i like to use that than for deploying across different environments but for a normal scenario even a production scenario this is more than more than enough we have our build of the of the image we use parameters to change to use the name for the tag and so on and so forth we publish the kubernetes manifests the yaml files as um artifacts so our deployment job doesn't have to access the repo it's never a good idea for deployments job to access the repo and then um we take that and we do uh we we download in a deployment job we use a deployment job so we can access the environments so we have all the goodness we've seen and we download the artifacts so we can use the kubernetes manifest for deployment we go and create the secret that it's used for pulling the image from our azure container registry and this is needed and we do it in a separate task so if it fails we don't waste time in doing anything else because this any anyway will not work um we parameterize our manifest files so we can use variables for example for uh the replica numbers but you can parametry parameterize anything else and finally we deploy using our manifests so this is what we have done today oh thank you thank you very much italian fanart for the super chat said very good job dave thank you thank you very much i really really appreciate the super chat um yeah that's that's basically that's basically it uh let's see if you have any other question feel free to ask now i will still be up a couple of minutes if you guys want to say anything want to have any answer to any question feel free to ask now and i'll drink some water in the meantime and i really hope this has been valuable um i know i started quite slowly i started from very from the very beginning but this was the aim for this video to start from scratch um says thanks for this great job thank you for your compliments and yeah i really hope this was helpful also why are saying thank you very much dave uh you're very welcome and thanks for you know staying staying until the end i really appreciate that as i mentioned at the beginning um go and check out the dev2 um blogging platform uh you can also find the link in the video description we are about to cross the 100 000 views on my articles so uh thanks for that and i know that some of you also follow me there so again thank you and last but not least as i mentioned in the beginning i've sent the newsletter the monthly newsletter some people may have not received it or they have received but in the spam because the newsletter provider told me that they changed the ip addresses and they are still in warm-up mode so if you have if you are subscribed and you haven't received the the email of the newsletter uh checking your spam folder or your junk folder and it may be there just whitelist it so um should not go in the spam anymore for the other ones if you're not subscribed go to colordave.ioslash newsletter and um and subscribe if you like to have the newsletter uh sent to you and i will resend tomorrow probably the the newsletter to all the new subscribers and to the people that i see that haven't received it so i guess that's it that's it for me um skull of schoolnotion said thank you dave again thank you thank you to all of you to stick around until the end of this streaming and i guess there's no there's no questions but if there would be any other question in the future just feel free to use the comment section of this video or any other video for what matters and if you want to be part of the coder dave community or the extended community devops community go and check out again in the video description there is a link to my discord server we have a bunch of people there we talk about devops we talk about github we talk about azure devops there's q a and so on so forth so if you want to be part of that just feel free to join with this said i think i'm gonna close the stream i thank you again all for being here tonight with me or today i'm not sure where you are and i hope to see you all soon uh on the channel bye [Music]
Info
Channel: CoderDave
Views: 1,938
Rating: 5 out of 5
Keywords: CoderDave, Davide Benvegnu, deploy to azure kubernetes, azure kubernetes, aks, deploy to azure, from azure devops, azure devops, azure devops pipelines, azure devops pipeline, azure pipeline, azure pipelines, aks azure devops pipeline, microsoft azure, azure, azure aks, azure aks deployment, azure kubernetes service
Id: 4Oa5HneTuKs
Channel Id: undefined
Length: 66min 24sec (3984 seconds)
Published: Tue Aug 03 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.