A module to create AKS cluster with Azure Container Registry assigned

David Sánchez
Devgurus
Published in
2 min readJan 24, 2023

At DMI Company, we create MACH solutions. We have projects deployed on AWS, GCP, and Azure. We are committed to deploying our solutions in Kubernetes with the infrastructure as code and always respecting good practices. For this reason, in this article, I will talk about how to use our module to create an AKS cluster with Azure Container Registry assigned.

In Terraform, modules are used to organize and reuse code. They allow you to encapsulate Terraform code into reusable blocks that can be easily shared and distributed. Modules also enable you to break up large Terraform configurations into smaller, manageable pieces, making it easier to understand and maintain your infrastructure.

Using modules can help make your Terraform code more organized and readable and can also make it easier to update and maintain your infrastructure over time. Additionally, modules can help to enforce best practices and conventions for naming resources, variables, and outputs, which can help to make your code more consistent and predictable.

We rely on the terraform-azurerm-aks module. However, we are missing new functionalities to adapt to our way of working.

The module can be used to create the AKS cluster and assign roles to the ACR. The module also enables the configuration of Azure policy, RBAC, auto-scaling, and log monitoring using Azure Monitor and Azure Log Analytics. Additionally, the module allows for the creation of a second node, which can be configured as a spot instance for cost optimization, and we can add the creation of a container registry and assign roles to the AKS cluster.

To use the module, you will also need an Azure to install and configure the Azure CLI and kubectl tools, as well as Terraform. You will also need an Azure subscription and the necessary permissions to create and manage resources in Azure. Usually, an owner or contributor role.

Before using this module you need to create some resources like a Resource group, Virtual Network, Subnet, and Azure container registry.

An example of deploying a cluster using the module

Conclusion

This statement suggests that the module being discussed allows for easy management of a cluster for deploying e-commerce applications, including an associated container registry.

--

--

David Sánchez
Devgurus
Writer for

Senior DevOps Engineer en DMI (Digital Management, LLC)