-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0374785
commit d63d711
Showing
16 changed files
with
373 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
provider "azurerm" { | ||
features {} | ||
} | ||
|
||
data "terraform_remote_state" "cluster" { | ||
backend = "local" | ||
|
||
config = { | ||
path = "../terraform.tfstate" | ||
} | ||
|
||
depends_on = [null_resource.deployment_trigger] | ||
} | ||
|
||
# data "azurerm_kubernetes_cluster" "cluster" { | ||
# name = "dev2-aks-cluster-aks" | ||
# resource_group_name = "${var.environment}-aks-env-out" | ||
|
||
# depends_on = [null_resource.deployment_trigger] | ||
# } | ||
|
||
resource "null_resource" "deployment_trigger" {} | ||
|
||
provider "helm" { | ||
kubernetes { | ||
host = "https://${data.terraform_remote_state.cluster.outputs.host}" | ||
client_certificate = base64decode(data.terraform_remote_state.cluster.outputs.client_certificate) | ||
client_key = base64decode(data.terraform_remote_state.cluster.outputs.client_key) | ||
cluster_ca_certificate = base64decode(data.terraform_remote_state.cluster.outputs.cluster_ca_certificate) | ||
} | ||
} | ||
|
||
resource "helm_release" "flux" { | ||
repository = "https://fluxcd-community.github.io/helm-charts" | ||
chart = "flux2" | ||
name = "flux2" | ||
namespace = "flux-system" | ||
create_namespace = true | ||
|
||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
stack { | ||
name = "02_flux" | ||
description = "Flux Controller deployed via Helm in Kubernetes" | ||
id = "2ac5c655-b876-44dd-8ab7-137d07e67097" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
terraform { | ||
required_providers { | ||
azurerm = { | ||
source = "hashicorp/azurerm" | ||
version = "~> 3.0" | ||
} | ||
helm = { | ||
source = "hashicorp/helm" | ||
version = "~>2.0" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
variable "environment" { | ||
type = string | ||
description = "Environment to deploy (dev, test, prod)." | ||
default = "dev2" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
provider "azurerm" { | ||
features {} | ||
} | ||
|
||
resource "azurerm_resource_group" "main" { | ||
name = "${var.environment}-aks-env-out" | ||
location = var.location | ||
|
||
} | ||
|
||
resource "random_id" "name" { | ||
byte_length = 8 | ||
} | ||
|
||
# data "azurerm_virtual_network" "network" { | ||
# name = "${var.environment}-env-out" | ||
# resource_group_name = "${var.environment}-env-out" | ||
|
||
# depends_on = [null_resource.deployment_trigger] | ||
# } | ||
|
||
data "terraform_remote_state" "vpc" { | ||
backend = "local" | ||
|
||
config = { | ||
path = "../terraform.tfstate" | ||
} | ||
|
||
depends_on = [null_resource.deployment_trigger] | ||
} | ||
|
||
resource "null_resource" "deployment_trigger" {} | ||
|
||
module "cluster" { | ||
source = "Azure/aks/azurerm" | ||
version = "8.0.0" | ||
|
||
# Cluster base config | ||
resource_group_name = azurerm_resource_group.main.name | ||
prefix = "dev2-aks-cluster" | ||
sku_tier = "Standard" | ||
node_os_channel_upgrade = "NodeImage" | ||
|
||
# Cluster system pool | ||
agents_availability_zones = [1, 2, 3] | ||
enable_auto_scaling = true | ||
agents_max_count = 4 | ||
agents_min_count = 3 | ||
|
||
# Cluster networking | ||
# vnet_subnet_id = var.vnet_subnet_id | ||
vnet_subnet_id = data.terraform_remote_state.vpc.outputs.aks_subnet_id | ||
network_plugin = "azure" | ||
|
||
# Cluster node pools | ||
node_pools = { | ||
nodepool1 = { | ||
name = "pool1" | ||
vm_size = "Standard_DS3_v2" | ||
enable_auto_scaling = true | ||
max_count = 4 | ||
min_count = 1 | ||
# vnet_subnet_id = var.vnet_subnet_id | ||
vnet_subnet_id = data.terraform_remote_state.vpc.outputs.aks_subnet_id | ||
zones = [1, 2, 3] | ||
} | ||
} | ||
|
||
# Cluster Authentication | ||
role_based_access_control_enabled = true | ||
rbac_aad = false | ||
|
||
depends_on = [azurerm_resource_group.main] | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
output "host" { | ||
value = module.cluster.cluster_fqdn | ||
sensitive = false | ||
} | ||
|
||
output "client_certificate" { | ||
value = module.cluster.client_certificate | ||
sensitive = true | ||
} | ||
|
||
output "client_key" { | ||
value = module.cluster.client_key | ||
sensitive = true | ||
} | ||
|
||
output "cluster_ca_certificate" { | ||
value = module.cluster.cluster_ca_certificate | ||
sensitive = true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
stack { | ||
name = "02_aks" | ||
description = "Managed Kubernetes cluster on Azure" | ||
id = "5d97b4f1-4e0a-4831-8ea8-ad2d1b90f7b5" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
variable "location" { | ||
type = string | ||
description = "Azure region to use." | ||
default = "eastus" | ||
} | ||
|
||
variable "environment" { | ||
type = string | ||
description = "Environment to deploy (dev, test, prod)." | ||
default = "dev2" | ||
} | ||
|
||
# variable "vnet_subnet_id" { | ||
# type = string | ||
# description = "ID of the subnet to deploy the AKS cluster into." | ||
# } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
provider "azurerm" { | ||
features {} | ||
|
||
} | ||
|
||
resource "azurerm_resource_group" "main" { | ||
name = "${var.environment}-env-out" | ||
location = var.location | ||
} | ||
|
||
module "network" { | ||
source = "Azure/vnet/azurerm" | ||
version = "4.1.0" | ||
|
||
resource_group_name = azurerm_resource_group.main.name | ||
vnet_location = azurerm_resource_group.main.location | ||
vnet_name = azurerm_resource_group.main.name | ||
use_for_each = true | ||
address_space = [var.cidr] | ||
|
||
subnet_names = keys(var.subnet_prefixes) | ||
subnet_prefixes = values(var.subnet_prefixes) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
output "subnet_ids" { | ||
description = "Map of subnet names to IDs." | ||
value = module.network.vnet_subnets_name_id | ||
} | ||
|
||
output "aks_subnet_id" { | ||
description = "ID of the subnet to deploy the AKS cluster into." | ||
value = module.network.vnet_subnets_name_id["aks"] | ||
} | ||
|
||
output "vnet_id" { | ||
description = "VNet ID." | ||
value = module.network.vnet_id | ||
} | ||
|
||
output "environment" { | ||
description = "Environment used for deployment" | ||
value = var.environment | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
stack { | ||
name = "02_network" | ||
description = "Main VPC managed on Azure" | ||
id = "5999e860-86d6-49b6-aa18-c91df7586483" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
terraform { | ||
required_providers { | ||
azurerm = { | ||
source = "hashicorp/azurerm" | ||
version = "~> 3.0" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
variable "location" { | ||
type = string | ||
description = "Azure region to use." | ||
default = "eastus" | ||
} | ||
|
||
variable "environment" { | ||
type = string | ||
description = "Environment to deploy (dev, test, prod)." | ||
default = "dev2" | ||
} | ||
|
||
variable "cidr" { | ||
type = string | ||
description = "CIDR block for the virtual network." | ||
default = "10.10.0.0/16" | ||
} | ||
|
||
variable "subnet_prefixes" { | ||
type = map(string) | ||
description = "Map of CIDR blocks for the subnets." | ||
|
||
default = { | ||
aks = "10.10.0.0/24" | ||
} | ||
} |
Oops, something went wrong.