Skip to content

Commit 6198a19

Browse files
committed
Welcome to Stack Simplify
1 parent 5e8fa0f commit 6198a19

File tree

16 files changed

+233
-120
lines changed

16 files changed

+233
-120
lines changed

24-Azure-AKS-Terraform/24-05-Create-AKS-Cluster-Custom-VNET/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ terraform apply
8989
# List Node Pools
9090
az aks nodepool list --resource-group terraform-aks-dev2 --cluster-name terraform-aks-dev2-cluster --output table
9191
92+
# Configure kubectl with Default Admin Credentials
93+
az aks get-credentials --resource-group terraform-aks-dev2 --name terraform-aks-dev2-cluster --admin
94+
9295
# List Nodes using Labels
9396
kubectl get nodes -o wide
9497
kubectl get nodes -o wide -l nodepoolos=linux

24-Azure-AKS-Terraform/24-05-Create-AKS-Cluster-Custom-VNET/terraform-manifests-aks-custom-vnet/01-main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ terraform {
3131
resource_group_name = "terraform-storage-rg"
3232
storage_account_name = "terraformstatexlrwdrzs"
3333
container_name = "tfstatefiles"
34-
key = "dev.terraform.tfstate"
34+
key = "terraform-custom-vnet.tfstate"
3535
}
3636
}
3737

24-Azure-AKS-Terraform/24-05-Create-AKS-Cluster-Custom-VNET/terraform-manifests-aks-custom-vnet/02-variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ variable "resource_group_name" {
2121
variable "environment" {
2222
type = string
2323
description = "This variable defines the Environment"
24-
default = "dev"
24+
default = "dev2"
2525
}
2626

2727

24-Azure-AKS-Terraform/24-05-Create-AKS-Cluster-Custom-VNET/terraform-manifests-aks-custom-vnet/07-aks-cluster.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ resource "azurerm_kubernetes_cluster" "aks_cluster" {
4242
min_count = 1
4343
os_disk_size_gb = 30
4444
type = "VirtualMachineScaleSets"
45+
vnet_subnet_id = azurerm_subnet.aks-default.id
4546
node_labels = {
4647
"nodepool-type" = "system"
4748
"environment" = "dev"

24-Azure-AKS-Terraform/24-05-Create-AKS-Cluster-Custom-VNET/terraform-manifests-aks-custom-vnet/09-aks-cluster-linux-user-nodepools.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ resource "azurerm_kubernetes_cluster_node_pool" "linux101" {
1212
os_type = "Linux" # Default is Linux, we can change to Windows
1313
vm_size = "Standard_DS2_v2"
1414
priority = "Regular" # Default is Regular, we can change to Spot with additional settings like eviction_policy, spot_max_price, node_labels and node_taints
15+
vnet_subnet_id = azurerm_subnet.aks-default.id
1516
node_labels = {
1617
"nodepool-type" = "user"
1718
"environment" = var.environment

24-Azure-AKS-Terraform/24-05-Create-AKS-Cluster-Custom-VNET/terraform-manifests-aks-custom-vnet/10-aks-cluster-windows-user-nodepools.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ resource "azurerm_kubernetes_cluster_node_pool" "win101" {
1212
os_type = "Windows" # Default is Linux, we can change to Windows
1313
vm_size = "Standard_DS2_v2"
1414
priority = "Regular" # Default is Regular, we can change to Spot with additional settings like eviction_policy, spot_max_price, node_labels and node_taints
15+
vnet_subnet_id = azurerm_subnet.aks-default.id
1516
node_labels = {
1617
"nodepool-type" = "user"
1718
"environment" = var.environment

25-Azure-DevOps-Terraform-Azure-AKS/25-01-Provision-AKS-Cluster-using-Azure-DevOps-and-Terraform/Git-Repo-Files/pipeline-backups/05-terraform-provision-aks-cluster-pipeline.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ stages:
5555

5656

5757

58-
# Stage-2: Deploy Stage
58+
# Stage-2: Deploy Stage for Dev
5959
## Step-1: Download Secure File
6060
## Step-2: Terraform Initialize (State Storage to store in Azure Storage Account)
6161
## Step-3: Terraform Plan
@@ -107,6 +107,11 @@ stages:
107107
commandOptions: '$(Pipeline.Workspace)/terraform-manifests-out/$(DEV_ENVIRONMENT)-$(Build.BuildId).out'
108108
allowTelemetryCollection: false
109109

110+
# Stage-2: Deploy for QA
111+
## Step-1: Download Secure File
112+
## Step-2: Terraform Initialize (State Storage to store in Azure Storage Account)
113+
## Step-3: Terraform Plan
114+
## Step-4: Terraform Apply
110115

111116
- deployment: DeployQA
112117
dependsOn: DeployDev

25-Azure-DevOps-Terraform-Azure-AKS/25-01-Provision-AKS-Cluster-using-Azure-DevOps-and-Terraform/Git-Repo-Files/terraform-manifests/01-main.tf

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,51 @@
1-
# Define Terraform Providers required for us
1+
# We will define
2+
# 1. Terraform Settings Block
3+
# 1. Required Version Terraform
4+
# 2. Required Terraform Providers
5+
# 3. Terraform Remote State Storage with Azure Storage Account (last step of this section)
6+
# 2. Terraform Provider Block for AzureRM
7+
# 3. Terraform Resource Block: Define a Random Pet Resource
8+
9+
# 1. Terraform Settings Block
210
terraform {
3-
# Use a recent version of Terraform
11+
# 1. Required Version Terraform
412
required_version = ">= 0.13"
5-
6-
# Map providers to thier sources, required in Terraform 13+
13+
# 2. Required Terraform Providers
714
required_providers {
8-
# Azure Resource Manager 2.x (Base Azure RM Module)
915
azurerm = {
1016
source = "hashicorp/azurerm"
1117
version = "~> 2.0"
1218
}
13-
# Azure Active Directory 1.x (required for AKS and Azure AD Integration)
1419
azuread = {
1520
source = "hashicorp/azuread"
1621
version = "~> 1.0"
1722
}
18-
# Random 3.x (Required to generate random names for Log Analytics Workspace)
1923
random = {
2024
source = "hashicorp/random"
2125
version = "~> 3.0"
2226
}
2327
}
28+
29+
# Terraform State Storage to Azure Storage Container
30+
backend "azurerm" {
31+
#resource_group_name = "terraform-storage-rg"
32+
#storage_account_name = "terraformstatexlrwdrzs"
33+
#container_name = "tfstatefiles"
34+
#key = "terraform-custom-vnet.tfstate"
35+
}
2436
}
2537

2638

27-
# Terraform Provider Block: Define Provider
28-
provider azurerm {
29-
# v2.x azurerm requires "features" block
30-
features {}
39+
40+
# 2. Terraform Provider Block for AzureRM
41+
provider "azurerm" {
42+
features {
43+
44+
}
3145
}
3246

33-
# Terraform Resource Block: Create Random pet resource
34-
resource "random_pet" "aksrandom" {}
47+
# 3. Terraform Resource Block: Define a Random Pet Resource
48+
resource "random_pet" "aksrandom" {
3549

50+
}
3651

37-
# Configure Terraform State Storage
38-
terraform {
39-
backend "azurerm" {
40-
#resource_group_name = "terraform-storage-rg"
41-
#storage_account_name = "terraformstatexlrwdrzs"
42-
#container_name = "prodtfstate"
43-
#key = "terraform.tfstate"
44-
}
45-
}

25-Azure-DevOps-Terraform-Azure-AKS/25-01-Provision-AKS-Cluster-using-Azure-DevOps-and-Terraform/Git-Repo-Files/terraform-manifests/02-variables.tf

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
# https://www.terraform.io/docs/configuration/variables.html
2-
# Input Variables
3-
# Output Values
4-
# Local Values (Optional)
5-
61
# Define Input Variables
72
# 1. Azure Location (CentralUS)
83
# 2. Azure Resource Group Name
@@ -26,10 +21,12 @@ variable "resource_group_name" {
2621
variable "environment" {
2722
type = string
2823
description = "This variable defines the Environment"
29-
#default = "prod"
24+
default = "dev2"
3025
}
3126

32-
# V2 Changes
27+
28+
# AKS Input Variables
29+
3330
# SSH Public Key for Linux VMs
3431
variable "ssh_public_key" {
3532
#default = "~/.ssh/aks-prod-sshkeys-terraform/aksprodsshkey.pub"
@@ -50,12 +47,3 @@ variable "windows_admin_password" {
5047
description = "This variable defines the Windows admin password k8s Worker nodes"
5148
}
5249

53-
54-
55-
# Locals (Optional) # We will not use them, just for learning as an example
56-
locals {
57-
aks_cluster_name = "${local.resource_group_name}-${local.environment}"
58-
location = "centralus"
59-
resource_group_name = "terraform-aks"
60-
environment = "prod"
61-
}
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
# Terraform Resource to Create Azure Resource Group with Input Variables defined in variables.tf
22
resource "azurerm_resource_group" "aks_rg" {
3+
name = "${var.resource_group_name}-${var.environment}"
34
location = var.location
4-
name = "${var.resource_group_name}-${var.environment}"
55
}
66

7-
# Terraform Resource to Create Resource Group with Local Variables
8-
# Optional - If you use local variables
9-
#resource "azurerm_resource_group" "aks" {
10-
# location = local.location
11-
# name = local.resource_group_name
12-
#}
7+

0 commit comments

Comments
 (0)