Automatic deployment of the application in Kubernetes

We will now create a new definition of release that automatically deploys our application in the AKS cluster that we created in the previous Using AKS section. For this deployment, in Azure Pipelines, we create a new release by performing the following steps: 

  1. Regarding the choice of template for the release, select the Empty template.
  2. Create a stage called AKS, and inside add a task that allows the kubectl commands (this task is present by default in the Azure DevOps tasks catalog), as shown in the following screenshot:

  1. Add the Deploy to Kubernetes task to the Azure Pipelines tasks catalog with the following configuration:

The settings for the Deploy to Kubernetes task are as follows:

    • We choose the endpoint of the Kubernetes cluster—the New button allows us to add a new endpoint configuration of a cluster.
    • Then, we choose the apply command to be executed by kubectl—here, we will execute an application.
    • Finally, we choose the directory, coming from the artifacts, which contains the YAML specification files.
  1. We save the release definition by clicking on the Save button.
  2. Finally, we click on the Create a new release button, which triggers a deployment in our AKS cluster.

At the end of the release execution, it is possible to check that the application has been deployed by executing the command in a Terminal as follows:

kubectl get pods,services

This command displays the list of pods and services that are present in our AKS Kubernetes cluster, and the result of this command is shown in the following screenshot:

We can see our two deployed web applications pods and the NodePort service that exposes our applications outside the cluster. Then, we open a web browser with the http://localhost:31000 URL, and our application is displayed correctly:

We have created a complete CI/CD pipeline that deploys an application in a Kubernetes cluster. If our application (HTML file) is modified, the build will create and push a new version of the image (in the latest tag), and then the release will apply the deployment on the Kubernetes cluster.

In this section, we have created an end-to-end DevOps CI/CD pipeline in order to deploy an application in a Kubernetes cluster (AKS for our example) with Azure Pipelines.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.128.79.88