{"id":4170,"date":"2021-10-28T07:51:00","date_gmt":"2021-10-28T07:51:00","guid":{"rendered":"https:\/\/viewmyprojects.com\/winwirewp\/?p=4170"},"modified":"2024-09-16T10:32:16","modified_gmt":"2024-09-16T10:32:16","slug":"deploy-application-azure-kubernetes-service-azure-devops","status":"publish","type":"post","link":"https:\/\/viewmyprojects.com\/winwirewp\/blog\/deploy-application-azure-kubernetes-service-azure-devops\/","title":{"rendered":"How to Deploy Application in Azure Kubernetes Service using Azure DevOps"},"content":{"rendered":"\n<p>When working on projects, you typically need to invest a lot of initial effort to set up an automated build and release process by configuring the CI\/CD pipelines.<\/p>\n\n\n\n<p>In this blog, we will learn how to create a Build pipeline and push the docker image to Azure Container Registry (ACR) by using&nbsp;<a href=\"https:\/\/viewmyprojects.com\/winwirewp\/devops-digital-transformation\/\" target=\"_blank\" rel=\"noreferrer noopener\">Azure DevOps<\/a>&nbsp;and how to create a Release pipeline to pull the image from ACR and deploy in Kubernetes. Docker majorly helps us to package an application and its dependencies in isolated environments called containers.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><em>What is a Docker File?<\/em><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A&nbsp;Docker file&nbsp;is a text document that contains all the commands a user could call on the command line to assemble an image.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><em>What is an Image?<\/em><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A Docker image is a template that contains a set of instructions for creating a container. It provides a convenient way to package up applications and preconfigured server environments.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><em>What is a container?<\/em><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A docker container is a running instance of the image.<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/viewmyprojects.com\/winwirewp\/wp-content\/uploads\/2023\/11\/Picture1-1-1.webp\" alt=\"Docker\" class=\"wp-image-4172\"\/><\/figure><\/div>\n\n\n<p>Docker runs instructions in aDockerfilein order. ADockerfilemust begin with aFROMinstruction.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Sample Docker file for a node js application:<\/h3>\n\n\n\n<p>#Base image<\/p>\n\n\n\n<p>FROM node:11<\/p>\n\n\n\n<p># Create app directory<\/p>\n\n\n\n<p>WORKDIR \/usr\/src\/app<\/p>\n\n\n\n<p># Install app dependencies<\/p>\n\n\n\n<p># A wildcard is used to ensure both package.json AND package-lock.json are copied<\/p>\n\n\n\n<p>COPY package*.json .\/<\/p>\n\n\n\n<p>RUN npm install<\/p>\n\n\n\n<p># Bundle app source<\/p>\n\n\n\n<p>COPY . .<\/p>\n\n\n\n<p>EXPOSE 3000<\/p>\n\n\n\n<p>CMD [ \u201cnpm\u201d, \u201cstart\u201d ]<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The&nbsp;FROM&nbsp;instruction initializes a new build stage and sets the&nbsp;<a href=\"https:\/\/docs.docker.com\/glossary\/#base_image\" target=\"_blank\" rel=\"noopener\">Base Image<\/a>&nbsp;for subsequent instructions.<\/li>\n\n\n\n<li>The&nbsp;WORKDIR&nbsp;instruction sets the working directory for any&nbsp;RUN,&nbsp;CMD and&nbsp;COPY instructions.<\/li>\n\n\n\n<li>The&nbsp;RUN&nbsp;instruction will execute any commands on top of the current image and commit the results.<\/li>\n\n\n\n<li>The&nbsp;COPY&nbsp;instruction copies new files or directories from&nbsp;source&nbsp;and adds them to the filesystem of the container at the path&nbsp;destination<\/li>\n\n\n\n<li>The&nbsp;EXPOSE&nbsp;instruction informs Docker that the container listens on the specified network ports at runtime<\/li>\n\n\n\n<li>The main purpose of a&nbsp;CMD&nbsp;is to provide defaults for an executing container. There can only be one&nbsp;CMD&nbsp;instruction in a&nbsp;Dockerfile<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Introduction to Azure Kubernetes Service (AKS)<\/h3>\n\n\n\n<p>Azure Kubernetes Service is a container orchestration platform adopted by&nbsp;<a href=\"https:\/\/viewmyprojects.com\/winwirewp\/azure-cloud-services\/\" target=\"_blank\" rel=\"noreferrer noopener\">Microsoft Azure<\/a>&nbsp;based upon the open-source Kubernetes system.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><em>What is a Master Node?<\/em><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A master node is a node which controls and manages a set of worker nodes<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">What is a Worker Node?<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><em>A<\/em>&nbsp;Kubernetes cluster consists of a set of worker machines \u2013 called&nbsp;nodes, that run containerized applications. Every cluster has at least one worker node.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">What is a Pod?<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A set of Running containers.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Using Azure DevOps for Build and Deployment<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">Build Pipeline<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The Build pipeline will build the application and create the image by using the Dockerfile.<\/li>\n\n\n\n<li>&nbsp;The image will then be pushed to the ACR (Azure Container Registry).<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">Steps to create a Build pipeline<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Create a new pipeline.<\/li>\n\n\n\n<li>Select the Repository and branch of your application.<\/li>\n\n\n\n<li>Click on + symbol next to Agent job and search for Docker and click on Add. Please find below for reference.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/viewmyprojects.com\/winwirewp\/wp-content\/uploads\/2023\/11\/Picture2-2.webp\" alt=\"Azure Kubernetes Service\" class=\"wp-image-4173\"\/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Now select the task and provide the necessary details like<\/li>\n<\/ul>\n\n\n\n<p>\u2013 Service connection to the container registry<br>\u2013 Container repository name<br>\u2013 Select the command \u2018Build and Push\u2019<br>\u2013 Leave all other defaults as is<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/viewmyprojects.com\/winwirewp\/wp-content\/uploads\/2023\/11\/Picture3-1-1.webp\" alt=\"Azure Kubernetes Service\" class=\"wp-image-4174\"\/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Click on \u2018Save &amp; queue\u2019 option to save and run the pipeline. PFB for reference.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Release Pipeline<\/h3>\n\n\n\n<p>The Release pipeline will pull the image from the ACR and then will create a POD in Azure Kubernetes Service.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Create a new release pipeline<\/li>\n\n\n\n<li>Select the Azure repo as the artifact \u2013 the Kubernetes manifest file will be present in the repo.<\/li>\n\n\n\n<li>Click on + symbol next to Agent job and search for kubectl and click on Add. PFB for reference.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/viewmyprojects.com\/winwirewp\/wp-content\/uploads\/2023\/11\/Picture4-1-1.webp\" alt=\"Azure Kubernetes Service\" class=\"wp-image-4175\"\/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Select the task added in the previous step and provide the following inputs.<\/li>\n\n\n\n<li>Select Service Connection type as \u2018Kubernetes Service Connection\u2019\n<ul class=\"wp-block-list\">\n<li>Select the service connection<\/li>\n\n\n\n<li>Provide the Namespace where you want to deploy \u2013 If the namespace is not provided, the commands will run in the default namespace.<\/li>\n\n\n\n<li>Select the command \u2018apply\u2019<\/li>\n\n\n\n<li>Select the checkbox next to Use configuration<\/li>\n\n\n\n<li>Select the configuration type as \u2018File path\u2019 and provide the path of the manifest file<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p>Below is the reference<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/viewmyprojects.com\/winwirewp\/wp-content\/uploads\/2023\/11\/Picture5-1-1.webp\" alt=\"AKS deployment\" class=\"wp-image-4176\"\/><\/figure>\n\n\n\n<p>Save the changes and create a release for deployment<\/p>\n\n\n\n<p>The following picture will help to understand the flow in Azure DevOps<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/viewmyprojects.com\/winwirewp\/wp-content\/uploads\/2023\/11\/Picture6-1-1.webp\" alt=\"AKS azure devops\" class=\"wp-image-4178\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Conclusion<\/strong><\/h2>\n\n\n\n<p>Once the build process has completed its execution, the release pipeline starts execution and deploys the application to Azure Kubernetes Service.Through this blog, the user should understand the Basics of Docker and Kubernetes and can effortlessly create the&nbsp;<a href=\"https:\/\/viewmyprojects.com\/winwirewp\/cicd-with-azure-devops-testproject\/\" target=\"_blank\" rel=\"noreferrer noopener\">Azure DevOps build and release pipelines<\/a>&nbsp;by building the image and pushing it to the ACR and automation of deploying the image from Azure Container Registry to Azure Kubernetes Service.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When working on projects, you typically need to invest a lot of initial effort to set up an automated build and release process by configuring the CI\/CD pipelines. In this blog, we will learn how to create a Build pipeline and push the docker image to Azure Container Registry (ACR) by using&nbsp;Azure DevOps&nbsp;and how to&hellip; <a class=\"more-link\" href=\"https:\/\/viewmyprojects.com\/winwirewp\/blog\/deploy-application-azure-kubernetes-service-azure-devops\/\">Continue reading <span class=\"screen-reader-text\">How to Deploy Application in Azure Kubernetes Service using Azure DevOps<\/span><\/a><\/p>\n","protected":false},"author":8,"featured_media":16372,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_eb_attr":"","_uag_custom_page_level_css":"","footnotes":""},"categories":[48,61,62,59],"tags":[],"class_list":["post-4170","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cloud-devops-and-automation","category-app-modernization-blogs","category-cloud-blogs","category-blogs","entry"],"acf":[],"featured_image_src":"https:\/\/viewmyprojects.com\/winwirewp\/wp-content\/uploads\/2023\/10\/How-to-Deploy-Application-in-Azure-Kubernetes-Service-using-Azure-DevOps-2.webp","author_info":{"display_name":"Siva","author_link":"https:\/\/viewmyprojects.com\/winwirewp\/author\/siva\/"},"views":4514,"uagb_featured_image_src":{"full":["https:\/\/viewmyprojects.com\/winwirewp\/wp-content\/uploads\/2023\/10\/How-to-Deploy-Application-in-Azure-Kubernetes-Service-using-Azure-DevOps-2.webp",800,440,false],"thumbnail":["https:\/\/viewmyprojects.com\/winwirewp\/wp-content\/uploads\/2023\/10\/How-to-Deploy-Application-in-Azure-Kubernetes-Service-using-Azure-DevOps-2-150x150.webp",150,150,true],"medium":["https:\/\/viewmyprojects.com\/winwirewp\/wp-content\/uploads\/2023\/10\/How-to-Deploy-Application-in-Azure-Kubernetes-Service-using-Azure-DevOps-2-300x165.webp",300,165,true],"medium_large":["https:\/\/viewmyprojects.com\/winwirewp\/wp-content\/uploads\/2023\/10\/How-to-Deploy-Application-in-Azure-Kubernetes-Service-using-Azure-DevOps-2-768x422.webp",750,412,true],"large":["https:\/\/viewmyprojects.com\/winwirewp\/wp-content\/uploads\/2023\/10\/How-to-Deploy-Application-in-Azure-Kubernetes-Service-using-Azure-DevOps-2.webp",750,413,false],"1536x1536":["https:\/\/viewmyprojects.com\/winwirewp\/wp-content\/uploads\/2023\/10\/How-to-Deploy-Application-in-Azure-Kubernetes-Service-using-Azure-DevOps-2.webp",800,440,false],"2048x2048":["https:\/\/viewmyprojects.com\/winwirewp\/wp-content\/uploads\/2023\/10\/How-to-Deploy-Application-in-Azure-Kubernetes-Service-using-Azure-DevOps-2.webp",800,440,false],"post-thumbnail":["https:\/\/viewmyprojects.com\/winwirewp\/wp-content\/uploads\/2023\/10\/How-to-Deploy-Application-in-Azure-Kubernetes-Service-using-Azure-DevOps-2.webp",800,440,false]},"uagb_author_info":{"display_name":"Siva","author_link":"https:\/\/viewmyprojects.com\/winwirewp\/author\/siva\/"},"uagb_comment_info":0,"uagb_excerpt":"When working on projects, you typically need to invest a lot of initial effort to set up an automated build and release process by configuring the CI\/CD pipelines. In this blog, we will learn how to create a Build pipeline and push the docker image to Azure Container Registry (ACR) by using&nbsp;Azure DevOps&nbsp;and how to&hellip;&hellip;","_links":{"self":[{"href":"https:\/\/viewmyprojects.com\/winwirewp\/wp-json\/wp\/v2\/posts\/4170","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/viewmyprojects.com\/winwirewp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/viewmyprojects.com\/winwirewp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/viewmyprojects.com\/winwirewp\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/viewmyprojects.com\/winwirewp\/wp-json\/wp\/v2\/comments?post=4170"}],"version-history":[{"count":3,"href":"https:\/\/viewmyprojects.com\/winwirewp\/wp-json\/wp\/v2\/posts\/4170\/revisions"}],"predecessor-version":[{"id":17902,"href":"https:\/\/viewmyprojects.com\/winwirewp\/wp-json\/wp\/v2\/posts\/4170\/revisions\/17902"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/viewmyprojects.com\/winwirewp\/wp-json\/wp\/v2\/media\/16372"}],"wp:attachment":[{"href":"https:\/\/viewmyprojects.com\/winwirewp\/wp-json\/wp\/v2\/media?parent=4170"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/viewmyprojects.com\/winwirewp\/wp-json\/wp\/v2\/categories?post=4170"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/viewmyprojects.com\/winwirewp\/wp-json\/wp\/v2\/tags?post=4170"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}