Skip to content

Latest commit

 

History

History
79 lines (58 loc) · 4 KB

README.md

File metadata and controls

79 lines (58 loc) · 4 KB

Azure Kubernetes Service Cluster deployment with Terraform

=== version up to date Juin 2022 ===

= Tested with success with Terraform v1.2.2 on linux_amd64 (WSL2)

  • provider registry.terraform.io/hashicorp/azurerm v3.11.0
  • provider registry.terraform.io/hashicorp/helm v2.5.0
  • provider registry.terraform.io/hashicorp/kubernetes v2.10.0
  • provider registry.terraform.io/hashicorp/random v3.3.2
  • provider registry.terraform.io/providers/hashicorp/time v0.7.2
  • provider https://registry.terraform.io/providers/grafana/grafana/latest/docs v1.22.0

This is a set of Terraform files used to deploy an Azure Kubernetes Cluster with some cool features :

  • Nodes will be dispatched in different Availability Zones (AZ)
  • Node pools will support Autoscaling
  • pool1 is a linux node pool (it is mandatory because of kube system pods)
  • pool2 (optional) is a windows server 2019 node pool with a taint
  • System Managed Identities are used instead of Service Principal
  • Choice of SKU (Free or Paid) for Azure Kubernetes Service (Control Plane)

These Terraform files can be used to deploy the following Azure components :

  • An Azure Resource Group
  • An Azure Kubernetes Services Cluster with 1 node pool running Linux
  • An additionnal node pool (pool2) with Windows Server 2019 nodes (optional)
  • An Azure Load Balancer Standard SKU
  • A Virtual Network with it Subnets (subnet for AKS Pods, subnets for AzureBastion and AzureFirewall/NVA if needed, Azure Application Gateway)
  • Azure Application Gateway + Application Gateway Ingress Controller AKS add-on
  • An Azure Log Analytics Workspace (used for Azure Monitor Container Insight)

On Kubernetes, these Terraform files will :

  • Deploy Grafana using Bitnami Helm Chart and exposed Grafana Dashboard using Ingress (and AGIC)
  • Install Prometheus
  • Configure Grafana : user / folder / prometheus datasource / dashboard

Prerequisites :

To deploy this infrastructure :

  1. Log to your Azure subscription (az login)
  2. Create an Azure Key Vault and create all secrets defined in datasource.tf
  3. Define the value of each variable in .tf and/or .tfvars files
  4. Initialize your terraform deployment : terraform init
  5. Plan your terraform deployment : terraform plan --var-file=myconf.tfvars
  6. Apply your terraform deployment : terraform apply --var-file=myconf.tfvars

For more information about Terraform & Azure, Kubernetes few additional online resources :

After deployment is succeeded, you can check your cluster using portal or better with azure cli and the following command: az aks show --resource-group NAMEOFYOURRESOURCEGROUP --name NAMEOFYOURAKSCLUSTER -o jsonc

Get your kubeconfig using :

az aks get-credentials --resource-group NAMEOFYOURRESOURCEGROUP --name NAMEOFYOURAKSCLUSTER --admin

Connect to Grafana Dashboard through Ingress

terraform outputto get FQDN

Magic