Azure Hands-On - Application and package management using Helm in AKS

Azure Hands-On - Application and package management using Helm in AKS

Azure Learning Path for Cloud and DevOps Engineers

📝Introduction

Kubernetes allows us to manage the deployment lifecycle of cloud-native applications using a Kubernetes package manager. A Kubernetes package manager allows us to standardize, simplify, and implement reusable deployment strategies for our applications.

In this hands-on lab, we learned how to create and manage Kubernetes releases using Helm as a Kubernetes package manager.

Learning objectives

In this module, you'll learn how to:

  • Describe the benefits of using Helm as a Kubernetes package manager

  • Create a Helm chart for a cloud-native application

  • Manage a cloud-native application release using Helm

📝Basic Understanding of Helm

When deploying, versioning, and updating applications, we need to ensure we have the correct versions of software libraries and configurations so that the application functions as expected.

Let's say the development team decides to deploy a company website to Kubernetes. As part of the process, the team creates deployment, service, and ingress YAML-based files. They hardcode and maintain the information in each file for each target environment by hand. However, maintaining three files for each environment is cumbersome and increases in complexity as the application grows.

In this situation, we can use Helm to simplify the application deployment process and avoid hardcoded deployment variables and settings.

And, what is a Helm? It is a package manager for Kubernetes that combines all your application's resources and deployment information into a single deployment package.

We can imagine Helm similar to the Windows Package Manager on Windows, the Advanced Package Tool (apt) on Linux, or Homebrew on macOS. We specify the name of the application we want to install, update, or remove, and Helm takes care of the process.

With Helm, we are not limited to installing a single app at a time. It allows us to create templates, and human-readable YAML script files to manage your application's deployment. These template files allow us to specify all required dependencies, configuration mapping, and secrets used to manage the deploy of an application successfully.

Helm uses four components to manage application deployments on a Kubernetes cluster:

  • The Helm client

  • Helm charts

  • Helm releases

  • Helm repositories

Helm Client

It is a client-installed binary responsible for creating and submitting the manifest files required to deploy a Kubernetes application. It is responsible for the interaction between the user and the Kubernetes cluster.

In Azure, the Helm client is preinstalled in the Cloud Shell and supports all security, identity, and authorization features of Kubernetes, it is also available for all major operating systems.

Helm chart

It is a templated deployment package that describes a related set of Kubernetes resources. It contains all the information required to build and deploy the manifest files for an application to run on a Kubernetes cluster.

It consists of several files and folders to describe the chart. Some of the components are required and some are optional. What you choose to include is based on the apps configuration requirements.

The following list describes the file and folder components of a Helm chart with the required items in bold:

Helm release

It is the application or group of applications deployed using a chart. Each time you install a chart, a new instance of an application is created on the cluster. Each instance has a release name that allows you to interact with the specific application instance.

Helm repository

It is a dedicated HTTP server that stores information on Helm charts. The server hosts a file that describes charts and where to download each chart.

Benefits of using Helm

Helm introduces many benefits that simplify application deployment and improve productivity in the development and deployment lifecycle of cloud-native applications. With Helm, we have application releases that are:

  • Repeatable,

  • Reliable,

  • Manageable in multiple and complex environments, and

  • Reusable across different development teams.

📝Set up the environment

Clone a Sample Application

  1. Navigate to the Azure Cloud Shell or Azure CLI and make sure you're using the Bash environment.

  2. Set the subscription you want to use for this module using the az account set command.

     az account set --subscription <subscription-name>
    
  3. Clone the sample application to your development environment using the git clone command.

     git clone https://github.com/Azure-Samples/aks-store-demo.git
    
  4. Change into the cloned directory using cd.

     cd aks-store-demo
    

Create Azure resources

  1. Create a resource group using the az group create command.

    Azure CLICopyOpen Cloud Shell

     az group create --name <resource-group-name> --location <location>
    
  2. Create an Azure container registry using the az acr create command and provide our own unique registry name. The registry name must be unique within Azure.

     az acr create --resource-group <resource-group-name> --name <acr-name> --sku Basic
    
  3. Create an AKS cluster using the az aks create command and attach the ACR to the AKS cluster using the --attach-acr parameter.

     az aks create --resource-group <resource-group-name> --name <aks-cluster-name> --node-count 2 --attach-acr <acr-name> --generate-ssh-keys
    
  4. Connect to the AKS cluster using the az aks get-credentials command.

     az aks get-credentials --resource-group <resource-group-name> --name <aks-cluster-name>
    
  5. Verify the connection to the AKS cluster using the kubectl get nodes command.

     kubectl get nodes
    

📝Create and install a Helm chart

Deploy a Helm chart

  1. Navigate to the Azure Cloud Shell or Azure CLI and make sure you're in the aks-store-demo directory. If not, change to the directory using cd.

    BashCopy

     cd aks-store-demo
    
  2. Change into the charts/aks-store-demo directory using cd.

     cd charts
     cd aks-store-demo
    
  3. Deploy the pet store front Helm chart using the helm install command.

     helm install aks-store-demo ./aks-store-demo
    

    The command should return a result similar to the following output:

  4. Helm allows you to query all the installed release on the cluster. List all Helm releases using the helm list command.

     helm list
    

  5. Helm allows you to fetch manifest information related to each release. Fetch manifest information using the helm get manifest command.

     helm get manifest aks-store-demo
    

  6. Validate that the pod is deployed using the kubectl get pods command.

     kubectl get pods -o wide -w
    

    Use Ctrl+C to exit the command once done.

Delete a Helm release

  1. Delete the Helm release using the helm delete command.

     helm delete aks-store-demo
    

    The command should return a result similar to the following output:

     release "aks-store-demo" uninstalled
    

Install a Helm chart with set values

We can override values for a Helm chart by passing either a value parameter or our own values.yaml file. For now, use the following commands to see how to update a value using the --set parameter.

  1. Install the Helm chart using the helm install command with the --set parameter to set the replicaCount of the deployment template to five replicas.

     helm install --set replicaCount=5 aks-store-demo ./aks-store-demo
    
  2. Validate that five pod replicas were deployed using the kubectl get pods command.

     kubectl get pods -o wide -w
    

    Use Ctrl+C to exit the command once done.

  3. Delete the Helm chart using the helm delete command.

     helm delete aks-store-demo
    

📌Note - At the end of each hands-on Lab, always clean up all resources previously created to avoid being charged.

Congratulations — you have completed this hands-on lab covering the basics of creating an Application and package management using Helm in Azure Kubernetes(AKS).

Thank you for reading. I hope you understood and learned something helpful from my blog.

Please follow me on Cloud&DevOpsLearn and LinkedIn, franciscojblsouza