Git Product home page Git Product logo

terraform-azurerm-aks's Introduction

terraform-azure-aks

Terraform module which configure a Kubernetes cluster (AKS) on Microsoft Azure

Versions

Use Terraform 0.13 and Terraform Azure Provider 2.3+.

Usage

module "aks" {
  source  = "nlamirault/aks/azure"
  version = "X.Y.Z"

  cluster_name = var.cluster_name
  location = var.location

  resource_group_name  = var.resource_group_name
  subscription_id      = var.subscription_id
  subnet_name          = var.subnet_name
  virtual_network_name = var.virtual_network_name

  kubernetes_version  = var.kubernetes_version
  pod_security_policy = var.pod_security_policy
  rbac                = var.rbac

  api_server_authorized_ip_ranges = var.api_server_authorized_ip_ranges

  # Default node pool
  node_count               = var.node_count
  node_vm_size             = var.node_vm_size
  os_disk_size_gb          = var.os_disk_size_gb
  node_availability_zones  = var.node_availability_zones
  enable_auto_scaling      = var.enable_auto_scaling
  node_min_count           = var.node_min_count
  node_max_count           = var.node_max_count
  node_max_pods            = var.node_max_pods
  node_taints              = var.node_taints

  # Network profile
  network_plugin     = var.network_plugin
  network_policy     = var.network_policy
  pod_cidr           = var.pod_cidr
  service_cidr       = var.service_cidr
  dns_service_ip     = var.dns_service_ip
  docker_bridge_cidr = var.docker_bridge_cidr

  # Addon profile
  aci_connector_linux = var.aci_connector_linux
  azure_policy = var.azure_policy
  http_application_routing = var.http_application_routing
  kube_dashboard = var.kube_dashboard

  # Autoscaler profile
  balance_similar_node_groups      = var.balance_similar_node_groups
  max_graceful_termination_sec     = var.max_graceful_termination_sec
  scan_interval                    = var.scan_interval
  scale_down_delay_after_add       = var.scale_down_delay_after_add
  scale_down_delay_after_delete    = var.scale_down_delay_after_delete
  scale_down_delay_after_failure   = var.scale_down_delay_after_failure
  scale_down_unneeded              = var.scale_down_unneeded
  scale_down_unready               = var.scale_down_unready
  scale_down_utilization_threshold = var.scale_down_utilization_threshold

  tags        = var.tags
  node_labels = var.node_labels

  # Addons node pool
  node_pools = var.node_pools
}


}
############################################################################
# Provider

resource_group_name = "myproject-dev"

#############################################################################
# Networking

virtual_network_name = "myproject-dev"
subnet_name = "myproject-dev-aks-nodes"

############################################################################
# AKS

cluster_name = "myproject-dev-aks"

location = "francecentral"

kubernetes_version = "1.18.8"

rbac = true
pod_security_policy  = false

tags = {
    "env" = "dev"
    "project" = "myproject"
    "service" = "kubernetes"
    "made-by" = "terraform"
}

#############################################################################
# Default node pool

node_count = 2
node_vm_size = "Standard_D2s_v3"
os_disk_size_gb = 50
enable_auto_scaling = true
node_min_count = 1
node_max_count = 4
node_max_pods = 110
node_availability_zones = [1, 2, 3]
node_taints = []
node_labels = {
    "service" = "kubernetes"
    "env"     = "dev"
    "project" = "myproject"
}

#############################################################################
# Network profile

network_plugin = "azure"
network_policy = "calico"
pod_cidr       = "10.0.16.0/20"
service_cidr   = "10.0.32.0/20"
dns_service_ip = "10.0.32.10"
docker_bridge_cidr = "172.0.0.1/8"

#############################################################################
# Addon profile

http_application_routing = false
kube_dashboard = false
aci_connector_linux = false
azure_policy = false

#############################################################################
# Auto-scaler profile

#############################################################################
# Addons node pool

node_pools = [
  {
    name = "spot"
    vm_size = "Standard_D2s_v3"
    os_disk_size_gb = 50
    enable_auto_scaling = true
    node_count = 1
    min_count = 1
    max_count = 4
    max_pods = 110
    node_labels = {
      "kubernetes.azure.com/scalesetpriority" = "spot"
    },
    node_taints = [
      "kubernetes.azure.com/scalesetpriority=spot:NoSchedule"
    ],
  }
]

This module creates :

  • a Kubernetes cluster

Documentation

Providers

Name Version
azurerm ~> 2.3

Inputs

Name Description Type Default Required
aci_connector_linux n/a bool n/a yes
api_server_authorized_ip_ranges The IP ranges to whitelist for incoming traffic to the masters. list(string) n/a yes
azure_policy n/a bool n/a yes
balance_similar_node_groups n/a bool false no
cluster_name Name of the AKS cluster string n/a yes
dns_service_ip IP address within the Kubernetes service address range that will be used by cluster service discovery string n/a yes
docker_bridge_cidr IP address (in CIDR notation) used as the Docker bridge IP address on nodes string n/a yes
enable_auto_scaling Enable autoscaling on the default node pool bool n/a yes
http_application_routing n/a bool n/a yes
kube_dashboard n/a bool n/a yes
kubernetes_version The AKS Kubernetes version string n/a yes
location The Azure Region where the Resource Group should exist. string n/a yes
log_analytics_workspace_name The name of the resource group in which the Log Analytics workspace is created string n/a yes
log_analytics_workspace_sku Specifies the Sku of the Log Analytics Workspace. string "PerNode" no
max_graceful_termination_sec n/a string "600" no
network_plugin The CNI network plugin to use (only azure, or kubenet) string "kubenet" no
network_policy The network polcy for the CNI. Only used when network_plugin is set to azure. Supported values: calico, azure any n/a yes
node_availability_zones The availability zones to place the node pool instances list
[
1,
2,
3
]
no
node_count The default node pool instance count number n/a yes
node_labels n/a map
{
"service": "kubernetes"
}
no
node_max_count Default node pool max count (use with autoscaling) number 10 no
node_max_pods Total amount of pods allowed per node number 110 no
node_min_count Default node pool intial count (used with autoscaling) number 1 no
node_pools Addons node pools
list(object({
name = string
vm_size = string
os_disk_size_gb = number
enable_auto_scaling = bool
node_count = number
min_count = number
max_count = number
max_pods = number
node_taints = list(string)
node_labels = map(string)
}))
[] no
node_taints Taints for default pool nodes list(string) n/a yes
node_vm_size The Azure VM instance type string n/a yes
os_disk_size_gb Default node pool disk size number 50 no
pod_cidr The CIDR for the pod network string n/a yes
pod_security_policy Enable PodSecurityPolicy the Kubernetes API bool n/a yes
rbac Enable RBAC on the Kubernetes API bool true no
resource_group_name The Name which should be used for this Resource Group string n/a yes
retention_in_days The workspace data retention in days string n/a yes
scale_down_delay_after_add n/a string "10m" no
scale_down_delay_after_delete n/a string "10s" no
scale_down_delay_after_failure n/a string "10m" no
scale_down_unneeded n/a string "10m" no
scale_down_unready n/a string "10m" no
scale_down_utilization_threshold n/a string "0.5" no
scan_interval n/a string "10s" no
service_cidr The CIDR for kubernetes services string n/a yes
subnet_name Name of the Subnet string n/a yes
subscription_id Specifies the ID of the subscription string n/a yes
tags n/a map
{
"made-by": "terraform"
}
no
virtual_network_name Name of the Virtual Network this Subnet is located within string n/a yes

Outputs

Name Description
aks_clustername n/a
aks_kube_config n/a
pod_cidr n/a
service_cidr n/a

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.