Nov 15 2022
Management

How to Use Red Hat’s Ansible to Create Kubernetes Container Clusters in Azure

Ansible, an IT automation platform, makes it easy to automate an entire Azure Kubernetes setup.

Containers are technology that isolates application components and their dependencies while simultaneously providing virtualization and scalability. Kubernetes is a portable, extensible, open-source platform for managing containerized workloads and services.

Azure Kubernetes Service (AKS) makes it simple to deploy a managed Kubernetes cluster in Microsoft Azure. AKS reduces the complexity and operational overhead of managing Kubernetes by offloading much of that responsibility to Azure. You can automate an entire Azure Kubernetes setup and application deployment using Red Hat’s Ansible, an IT automation platform. Here’s how. 

Click the banner below to receive exclusive cloud content when you register as an Insider.

1. Create an Azure Resource Group

Start by creating an Azure resource group via the command below using the Azure command-line interface. The below example creates a resource group named aks-group in the eastus location. A new resource group isn’t necessarily required unless you have one you’d already like to use.

az group create --name aks-group --location eastus

2. Create an Azure Kubernetes Service Cluster

In this example, create an AKS cluster named myAKSCluster in the “aks-group” resource group that you created previously. We will also enable managed identity (--enable-managed-identity) and monitoring (--enable-addons monitoring).

az aks create -g aks-group -n myAKSCluster --enable-managed-identity --node-count 1 --enable-addons monitoring --enable-msi-auth-for-monitoring --generate-ssh-keys

FIND OUT: If you should add containers to your virtual machine environment.

3. Install Ansible Using a Package Management System

Now that you have an AKS cluster, you can install Ansible. The easiest way to install Ansible is to use pip, a package management system that simplifies the process of installing and managing software packages.

To install Ansible using pip, ensure you have Python installed and run the below command. 

python3 -m pip install --user ansible

4. Deploy an Application on Azure Kubernetes Service

Create a manifest file named azure-vote.yaml. Google “Azure vote Kubernetes” and you should find the manifest file contents necessary to deploy a demonstration application. This manifest file contains all the metadata required to deploy the application. Using a manifest file allows you to version your application and makes it easy to deploy.

When you have a manifest built, run the kubectl apply command to deploy the application and you should have your first application running on AKS.

kubectl apply -f azure-vote.yaml

EXPLORE: Whether businesses should consider open-source container tools

Andriy Onufriyenko/Getty Images
Close

Become an Insider

Unlock white papers, personalized recommendations and other premium content for an in-depth look at evolving IT