Skip to content

Commit aa13c50

Browse files
committed
cleanup
1 parent c41d40b commit aa13c50

File tree

7 files changed

+52
-58
lines changed

7 files changed

+52
-58
lines changed

terraform/azure/azure-aks-k8s/README.md

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,36 @@
1-
# Azure Kubernetes Service (AKS) Terraform Example
1+
# azure-aks-k8s
22

3-
This example demonstrates how to deploy an Azure Kubernetes Service (AKS) cluster using Terraform. The configuration includes:
3+
This example creates the following:
44

5-
- Resource Group
6-
- Virtual Network and Subnet
7-
- AKS Cluster with default node pool
8-
- System-assigned managed identity
9-
- Azure CNI networking
5+
- a Virtual Network with appropriate subnets using the [Azure RM Module for Network](https://registry.terraform.io/modules/Azure/network/azurerm/latest)
6+
from the Terraform Registry
7+
- an Azure Kubernetes Service (AKS) cluster with default node pool
8+
- a system-assigned managed identity for the AKS cluster
9+
- Azure CNI networking for better network performance
10+
- Optional Log Analytics workspace for monitoring
1011

1112
## Prerequisites
1213

13-
1. [Azure CLI](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli) installed
14-
2. [Terraform](https://www.terraform.io/downloads.html) installed (version >= 1.0)
15-
3. Azure subscription and appropriate permissions
14+
- [Azure CLI](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli) installed
15+
- [Terraform](https://www.terraform.io/downloads.html) installed (version >= 1.0)
16+
- Azure subscription and appropriate permissions
1617

17-
## Authentication
18+
## To use
1819

19-
Before running Terraform, you need to authenticate with Azure. You can do this by running:
20+
Follow the documentation to configure the Azure provider:
2021

21-
```bash
22-
az login
23-
```
22+
- [Azure](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs)
2423

25-
## Usage
24+
### Deploy
2625

27-
1. Initialize Terraform:
28-
```bash
26+
```shell
2927
terraform init
30-
```
31-
32-
2. Review the planned changes:
33-
```bash
34-
terraform plan
35-
```
36-
37-
3. Apply the configuration:
38-
```bash
3928
terraform apply
4029
```
4130

42-
4. To destroy the infrastructure:
43-
```bash
31+
## To destroy
32+
33+
```shell
4434
terraform destroy
4535
```
4636

terraform/azure/azure-aks-k8s/cluster.tf

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
1-
locals {
2-
name = var.cluster_name != "" ? var.cluster_name : "example-${basename(path.cwd)}"
3-
4-
tags = merge({
5-
Name = local.name
6-
Environment = var.environment
7-
ManagedBy = "Terraform"
8-
}, var.tags)
9-
}
1+
# AKS Resources
102

113
resource "azurerm_resource_group" "aks" {
124
name = "${local.name}-rg"
@@ -23,10 +15,10 @@ module "vpc" {
2315
location = var.location
2416
resource_group_name = azurerm_resource_group.aks.name
2517

26-
cidrs = var.vnet_address_space
27-
subnet_cidrs = var.subnet_address_prefixes
28-
subnet_name_public = "aks-nodes"
29-
subnet_name_private = "aks-private"
18+
cidrs = var.vnet_address_space
19+
subnet_cidrs = var.subnet_address_prefixes
20+
subnet_name_public = "aks-nodes"
21+
subnet_name_private = "aks-private"
3022
subnet_name_private_dns_resolver = "dns-resolver"
3123
}
3224

@@ -37,7 +29,7 @@ resource "azurerm_kubernetes_cluster" "aks" {
3729
resource_group_name = azurerm_resource_group.aks.name
3830
dns_prefix = local.name
3931
kubernetes_version = var.kubernetes_version
40-
32+
4133
# Add node resource group name
4234
node_resource_group = "${local.name}-node-rg"
4335

@@ -57,10 +49,10 @@ resource "azurerm_kubernetes_cluster" "aks" {
5749
}
5850

5951
network_profile {
60-
network_plugin = "azure"
61-
service_cidr = var.service_cidr
62-
dns_service_ip = var.dns_service_ip
63-
load_balancer_sku = "standard"
52+
network_plugin = "azure"
53+
service_cidr = var.service_cidr
54+
dns_service_ip = var.dns_service_ip
55+
load_balancer_sku = "standard"
6456
}
6557

6658
# Use oms_agent addon directly instead of addon_profile
Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
terraform {
2-
required_providers {
3-
azurerm = {
4-
source = "hashicorp/azurerm"
5-
version = "~> 3.0"
6-
}
7-
}
8-
}
1+
locals {
2+
name = var.cluster_name != "" ? var.cluster_name : "example-${basename(path.cwd)}"
93

10-
provider "azurerm" {
11-
features {}
4+
tags = merge({
5+
Name = local.name
6+
Environment = var.environment
7+
ManagedBy = "Terraform"
8+
}, var.tags)
129
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
provider "azurerm" {
2+
skip_provider_registration = true
3+
features {
4+
resource_group {
5+
prevent_deletion_if_contains_resources = false
6+
}
7+
}
8+
}
13.4 KB
Binary file not shown.

terraform/azure/azure-aks-k8s/variables.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ variable "location" {
77
variable "cluster_name" {
88
description = "Name of the AKS cluster (will generate one if empty)"
99
type = string
10-
default = "raj"
1110
}
1211

1312
variable "environment" {
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
terraform {
2+
required_providers {
3+
azurerm = {
4+
source = "hashicorp/azurerm"
5+
version = "~> 3.0"
6+
}
7+
}
8+
}

0 commit comments

Comments
 (0)