Skip to content

Commit 0aefd6d

Browse files
authored
Merge branch 'main' into kubelet_disk_type_temp
2 parents 5515edb + df730eb commit 0aefd6d

File tree

11 files changed

+73
-8
lines changed

11 files changed

+73
-8
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARG TERRAFORM_VERSION=1.7.3
1+
ARG TERRAFORM_VERSION=1.8.2
22
ARG AZURECLI_VERSION=2.59.0
33

44
FROM hashicorp/terraform:$TERRAFORM_VERSION as terraform

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ This project supports two options for running Terraform scripts:
5757
Access to an **Azure Subscription** and an [**Identity**](./docs/user/TerraformAzureAuthentication.md) with the *Contributor* role are required.
5858

5959
#### Terraform Requirements:
60-
- [Terraform](https://www.terraform.io/downloads.html) - v1.7.3
60+
- [Terraform](https://www.terraform.io/downloads.html) - v1.8.2
6161
- [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl) - v1.28.7
6262
- [jq](https://stedolan.github.io/jq/) - v1.6
6363
- [Azure CLI](https://docs.microsoft.com/en-us/cli/azure) - (optional - useful as an alternative to the Azure Portal) - v2.59.0

container-structure-test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ commandTests:
1717
- name: "terraform version"
1818
command: "terraform"
1919
args: ["--version"]
20-
expectedOutput: ["Terraform v1.7.3"]
20+
expectedOutput: ["Terraform v1.8.2"]
2121
- name: "python version"
2222
command: "python3"
2323
args: ["--version"]

docs/CONFIG-VARS.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Supported configuration variables are listed in the tables below. All variables
88
- [Table of Contents](#table-of-contents)
99
- [Required Variables](#required-variables)
1010
- [Azure Authentication](#azure-authentication)
11+
- [Role Based Access Control](#role-based-access-control)
1112
- [Admin Access](#admin-access)
1213
- [Security](#security)
1314
- [Networking](#networking)
@@ -53,6 +54,20 @@ For details on how to retrieve that information, see [Azure Help Topics](./user/
5354

5455
For recommendations on how to set these variables in your environment, see [Authenticating Terraform to Access Azure](./user/TerraformAzureAuthentication.md).
5556

57+
## Role Based Access Control
58+
59+
The ability to manage RBAC for Kubernetes resources from Azure gives you the choice to manage RBAC for the cluster resources either using Azure or native Kubernetes mechanisms. For details see [Azure role-based access control](https://docs.microsoft.com/en-us/azure/aks/concepts-identity#azure-rbac-for-kubernetes-authorization).
60+
61+
Following are the possible ways to configure Authentication and Authorization in an AKS cluster:
62+
1. Authentication using local accounts with Kubernetes RBAC. This is traditionally used and current default, see details [here](https://learn.microsoft.com/en-us/azure/aks/concepts-identity#kubernetes-rbac)
63+
2. Microsoft Entra authentication with Kubernetes RBAC. See details [here](https://learn.microsoft.com/en-us/azure/aks/azure-ad-rbac)
64+
65+
| Name | Description | Type | Default |
66+
| :--- | ---: | ---: | ---: |
67+
| rbac_aad_enabled | Enables Azure Active Directory integration with Kubernetes RBAC. | bool | false |
68+
| rbac_aad_admin_group_object_ids | A list of Object IDs of Azure Active Directory Groups which should have Admin Role on the Cluster. | list(string) | null |
69+
| rbac_aad_tenant_id | (Optional) The Tenant ID used for Azure Active Directory Application. If this isn't specified the Tenant ID of the current Subscription is used.| string | |
70+
5671
## Admin Access
5772

5873
By default, the public endpoints of the Azure resources that are being created
70.3 KB
Loading

main.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ module "aks" {
167167
aks_uai_id = local.aks_uai_id
168168
client_id = var.client_id
169169
client_secret = var.client_secret
170+
rbac_aad_tenant_id = var.rbac_aad_tenant_id
171+
rbac_aad_enabled = var.rbac_aad_enabled
172+
rbac_aad_admin_group_object_ids = var.rbac_aad_admin_group_object_ids
170173
aks_private_cluster = var.cluster_api_mode == "private" ? true : false
171174
depends_on = [module.vnet]
172175
}

modules/azure_aks/main.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,16 @@ resource "azurerm_kubernetes_cluster" "aks" {
5252
}
5353
}
5454

55+
dynamic "azure_active_directory_role_based_access_control" {
56+
for_each = var.rbac_aad_enabled ? [1] : []
57+
content {
58+
managed = true
59+
tenant_id = var.rbac_aad_tenant_id
60+
admin_group_object_ids = var.rbac_aad_admin_group_object_ids
61+
azure_rbac_enabled = false
62+
}
63+
}
64+
5565
default_node_pool {
5666
name = "system"
5767
vm_size = var.aks_cluster_node_vm_size

modules/azure_aks/outputs.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
output "client_key" {
5-
value = azurerm_kubernetes_cluster.aks.kube_config[0].client_key
5+
value = var.rbac_aad_enabled ? azurerm_kubernetes_cluster.aks.kube_admin_config[0].client_key : azurerm_kubernetes_cluster.aks.kube_config[0].client_key
66
}
77

88
output "client_certificate" {
9-
value = azurerm_kubernetes_cluster.aks.kube_config[0].client_certificate
9+
value = var.rbac_aad_enabled ? azurerm_kubernetes_cluster.aks.kube_admin_config[0].client_certificate : azurerm_kubernetes_cluster.aks.kube_config[0].client_certificate
1010
}
1111

1212
output "cluster_ca_certificate" {
13-
value = azurerm_kubernetes_cluster.aks.kube_config[0].cluster_ca_certificate
13+
value = var.rbac_aad_enabled ? azurerm_kubernetes_cluster.aks.kube_admin_config[0].cluster_ca_certificate : azurerm_kubernetes_cluster.aks.kube_config[0].cluster_ca_certificate
1414
}
1515

1616
output "cluster_username" {
1717
value = azurerm_kubernetes_cluster.aks.kube_config[0].username
1818
}
1919

2020
output "cluster_password" {
21-
value = azurerm_kubernetes_cluster.aks.kube_config[0].password
21+
value = var.rbac_aad_enabled ? azurerm_kubernetes_cluster.aks.kube_admin_config[0].password : azurerm_kubernetes_cluster.aks.kube_config[0].password
2222
}
2323

2424
output "kube_config" {

modules/azure_aks/variables.tf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,24 @@ variable "aks_cluster_location" {
2222
default = "eastus"
2323
}
2424

25+
variable "rbac_aad_enabled" {
26+
type = bool
27+
description = "Enables Azure Active Directory integration with Kubernetes RBAC."
28+
default = false
29+
}
30+
31+
variable "rbac_aad_admin_group_object_ids" {
32+
type = list(string)
33+
description = "A list of Object IDs of Azure Active Directory Groups which should have Admin Role on the Cluster."
34+
default = null
35+
}
36+
37+
variable "rbac_aad_tenant_id" {
38+
type = string
39+
description = "(Optional) The Tenant ID used for Azure Active Directory Application. If this isn't specified the Tenant ID of the current Subscription is used."
40+
default = null
41+
}
42+
2543
variable "aks_cluster_sku_tier" {
2644
description = "The SKU Tier that should be used for this Kubernetes Cluster. Possible values are Free, Standard (which includes the Uptime SLA) and Premium. Defaults to Free"
2745
type = string

variables.tf

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,25 @@ variable "location" {
5858
default = "eastus"
5959
}
6060

61+
## Azure AD
62+
variable "rbac_aad_enabled" {
63+
type = bool
64+
description = "Enables Azure Active Directory integration with Kubernetes RBAC."
65+
default = false
66+
}
67+
68+
variable "rbac_aad_admin_group_object_ids" {
69+
type = list(string)
70+
description = "A list of Object IDs of Azure Active Directory Groups which should have Admin Role on the Cluster."
71+
default = null
72+
}
73+
74+
variable "rbac_aad_tenant_id" {
75+
type = string
76+
description = "(Optional) The Tenant ID used for Azure Active Directory Application. If this isn't specified the Tenant ID of the current Subscription is used."
77+
default = null
78+
}
79+
6180
variable "aks_cluster_sku_tier" {
6281
description = "The SKU Tier that should be used for this Kubernetes Cluster. Possible values are Free, Standard (which includes the Uptime SLA) and Premium. Defaults to Free"
6382
type = string

0 commit comments

Comments
 (0)