Skip to content

Commit

Permalink
Add azure kubernetes policy add-on (#2888)
Browse files Browse the repository at this point in the history
  • Loading branch information
viniciusdc authored Jan 6, 2025
1 parent 6eb248f commit 5c90b2e
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/_nebari/stages/infrastructure/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class AzureInputVars(schema.Base):
tags: Dict[str, str] = {}
max_pods: Optional[int] = None
network_profile: Optional[Dict[str, str]] = None
azure_policy_enabled: bool = None
workload_identity_enabled: bool = False


Expand Down Expand Up @@ -809,6 +810,7 @@ def input_vars(self, stage_outputs: Dict[str, Dict[str, Any]]):
network_profile=self.config.azure.network_profile,
max_pods=self.config.azure.max_pods,
workload_identity_enabled=self.config.azure.workload_identity_enabled,
azure_policy_enabled=self.config.azure.azure_policy_enabled,
).model_dump()
elif self.config.provider == schema.ProviderEnum.aws:
return AWSInputVars(
Expand Down
1 change: 1 addition & 0 deletions src/_nebari/stages/infrastructure/template/azure/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ module "kubernetes" {
vnet_subnet_id = var.vnet_subnet_id
private_cluster_enabled = var.private_cluster_enabled
workload_identity_enabled = var.workload_identity_enabled
azure_policy_enabled = var.azure_policy_enabled
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ resource "azurerm_kubernetes_cluster" "main" {
# Azure requires that a new, non-existent Resource Group is used, as otherwise the provisioning of the Kubernetes Service will fail.
node_resource_group = var.node_resource_group_name
private_cluster_enabled = var.private_cluster_enabled
# https://learn.microsoft.com/en-ie/azure/governance/policy/concepts/policy-for-kubernetes
azure_policy_enabled = var.azure_policy_enabled


dynamic "network_profile" {
for_each = var.network_profile != null ? [var.network_profile] : []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,9 @@ variable "workload_identity_enabled" {
type = bool
default = false
}

variable "azure_policy_enabled" {
description = "Enable Azure Policy"
type = bool
default = false
}
5 changes: 5 additions & 0 deletions src/_nebari/stages/infrastructure/template/azure/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,8 @@ variable "workload_identity_enabled" {
type = bool
default = false
}

variable "azure_policy_enabled" {
description = "Enable Azure Policy"
type = bool
}

0 comments on commit 5c90b2e

Please sign in to comment.