Skip to content

A module used to simplify the deployment of an Azure Kubernetes Cluster based on some parameters 🐳

License

Notifications You must be signed in to change notification settings

libre-devops/terraform-azurerm-aks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

module "rg" {
  source = "registry.terraform.io/libre-devops/rg/azurerm"

  rg_name  = "rg-${var.short}-${var.loc}-${terraform.workspace}-build" // rg-ldo-euw-dev-build
  location = local.location                                            // compares var.loc with the var.regions var to match a long-hand name, in this case, "euw", so "westeurope"
  tags     = local.tags

  #  lock_level = "CanNotDelete" // Do not set this value to skip lock
}

module "network" {
  source = "registry.terraform.io/libre-devops/network/azurerm"

  rg_name  = module.rg.rg_name // rg-ldo-euw-dev-build
  location = module.rg.rg_location
  tags     = local.tags

  vnet_name     = "vnet-${var.short}-${var.loc}-${terraform.workspace}-01" // vnet-ldo-euw-dev-01
  vnet_location = module.network.vnet_location

  address_space   = ["10.0.0.0/16"]
  subnet_prefixes = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"]
  subnet_names    = ["sn1-${module.network.vnet_name}", "sn2-${module.network.vnet_name}", "sn3-${module.network.vnet_name}"] //sn1-vnet-ldo-euw-dev-01
  subnet_service_endpoints = {
    "sn1-${module.network.vnet_name}" = ["Microsoft.Storage"]                   // Adds extra subnet endpoints to sn1-vnet-ldo-euw-dev-01
    "sn2-${module.network.vnet_name}" = ["Microsoft.Storage", "Microsoft.Sql"], // Adds extra subnet endpoints to sn2-vnet-ldo-euw-dev-01
    "sn3-${module.network.vnet_name}" = ["Microsoft.AzureActiveDirectory"]      // Adds extra subnet endpoints to sn3-vnet-ldo-euw-dev-01
  }
}

module "aks" {
  source = "registry.terraform.io/libre-devops/aks/azurerm"

  rg_name  = module.rg.rg_name
  location = module.rg.rg_location
  tags     = module.rg.rg_tags

  aks_name                = "aks-${var.short}-${var.loc}-${terraform.workspace}-01"
  admin_username          = "LibreDevOpsAdmin"
  ssh_public_key          = data.azurerm_ssh_public_key.mgmt_ssh_key.public_key
  kubernetes_version      = "1.22"
  dns_prefix              = "ldo"
  sku_tier                = "Free"
  private_cluster_enabled = true

  default_node_enable_auto_scaling  = false
  default_node_orchestrator_version = "1.22"
  default_node_pool_name            = "lbdo-pool"
  default_node_vm_size              = "Standard_B2ms"
  default_node_os_disk_size_gb      = "127"
  default_node_subnet_id            = element(values(module.network.subnets_ids), 2)
  default_node_availability_zones   = ["1"]
  default_node_count                = "1"
  default_node_agents_min_count     = null
  default_node_agents_max_count     = null
  enable_rbac                       = true
  identity_type                     = "SystemAssigned"
}

For a full example build, check out the Libre DevOps Website

Requirements

No requirements.

Providers

Name Version
azurerm n/a

Modules

No modules.

Resources

Name Type
azurerm_kubernetes_cluster.main_aks resource

Inputs

Name Description Type Default Required
admin_username The admin username of the cluster string n/a yes
aks_name The name of the resource to be created string n/a yes
client_id The ID of the service principle, if one is to be used, defaults to empty string as it is not used string "" no
client_secret The client secret of the service principle, if one is to used, defaults to empty string as it is not used string "" no
default_node_agents_max_count The maximum count of agent that are deployed to the default node, defaults to 1 number "1" no
default_node_agents_min_count The minimum count of agents that are deployed to the default node, defaults to 1 number n/a yes
default_node_agents_type Sets the default agent type string "VirtualMachineScaleSets" no
default_node_availability_zones The default nodes availability zones, in list format list(string) n/a yes
default_node_count The default amount of nodes to be provisioned, defaults to 1 number 1 no
default_node_enable_auto_scaling If auto scaling should be enabled for the default node, defaults to false bool false no
default_node_enable_manually_scaling If manually scaling should be enabled for the default node, defaults to false bool true no
default_node_orchestrator_version The orchestrator version of the default node string n/a yes
default_node_os_disk_size_gb The size of the disk of the VM number n/a yes
default_node_pool_name The default pool name of the default node string n/a yes
default_node_subnet_id The subnet ID for the kubernetes cluster string n/a yes
default_node_vm_size The VM size of the default node, e.g. Standard_B4ms string n/a yes
dns_prefix The DNS prefix to be assigned to the kubernetes cluster string n/a yes
enable_auto_scaling Whether auto scaling should be enabled, defaults to false bool false no
enable_azure_policy Whether or not an Azure policy needs to be assigned, defaults to false bool false no
enable_http_application_routing Whether or not http routing is allowed, defaults to false bool false no
enable_ingress_application_gateway Whether or not a application gateway should be enabled for ingress controller, defaults to null any null no
enable_node_public_ip (Optional) Should nodes in this Node Pool have a Public IP Address? Defaults to false. bool false no
identity_type The type of identity to be used, defaults to system-assigned string "SystemAssigned" no
kubernetes_version The kubernetes version in floating point string n/a yes
location The location for this resource to be put in string n/a yes
net_profile_dns_service_ip (Optional) IP address within the Kubernetes service address range that will be used by cluster service discovery (kube-dns). Changing this forces a new resource to be created. string null no
net_profile_docker_bridge_cidr (Optional) IP address (in CIDR notation) used as the Docker bridge IP address on nodes. Changing this forces a new resource to be created. string null no
net_profile_outbound_type (Optional) The outbound (egress) routing method which should be used for this Kubernetes Cluster. Possible values are loadBalancer and userDefinedRouting. Defaults to loadBalancer. string "loadBalancer" no
net_profile_pod_cidr (Optional) The CIDR to use for pod IP addresses. This field can only be set when network_plugin is set to kubenet. Changing this forces a new resource to be created. string null no
net_profile_service_cidr (Optional) The Network Range used by the Kubernetes service. Changing this forces a new resource to be created. string null no
network_plugin Network plugin to use for networking. string "kubenet" no
network_policy (Optional) Sets up network policy to be used with Azure CNI. Network policy allows us to control the traffic flow between pods. Currently supported values are calico and azure. Changing this forces a new resource to be created. string null no
private_cluster_enabled If true cluster API server will be exposed only on internal IP address and available only in cluster vnet. bool true no
rg_name The name of the resource group, this module does not create a resource group, it is expecting the value of a resource group already exists string n/a yes
sku_tier The SKU tier of the kubernetes cluster, default is Free. Difference only is if there is an SLA string "Free" no
ssh_public_key The public key for the admin user string n/a yes
tags The tags assigned to the resource map(string) n/a yes
user_assigned_identity_id The ID of the user assigned managed identity string n/a yes

Outputs

Name Description
cluster_api_service_authorised_ranges The list of authorised IPs
cluster_fqdn The FQDN of the cluster
cluster_id The id of the cluster
cluster_name The name of the cluster
kube_admin_config The name of full kube_admin config, is a sensitive value
kube_client_certificate The client certificate within the kube config, needed for terraform kubernetes provider
kube_client_key The client secret within the kube conifg, needed for terraform kubernetes provider
kube_cluster_ca_certificate The client ca certificate located within the kube config, needed for terraform kubernetes provider
kube_config The full kube_config block, is a sensitive value
kube_config_host The name of the config host within kube config, needed for terraform kubernetes provider
kube_password The user password within kube config, needed for terraform kubernetes provider
kube_username The username within kube config, needed for terraform kubernetes provider
kublet_identity The first element of the identity object