Skip to content

Commit

Permalink
add network_plugin_mode Overlay
Browse files Browse the repository at this point in the history
  • Loading branch information
AleDore committed Nov 15, 2023
1 parent ae4bf53 commit 0937b40
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
15 changes: 8 additions & 7 deletions kubernetes_cluster/01_main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,13 @@ resource "azurerm_kubernetes_cluster" "this" {
for_each = var.network_profile != null ? [var.network_profile] : []
iterator = p
content {
dns_service_ip = p.value.dns_service_ip
network_policy = p.value.network_policy
network_plugin = p.value.network_plugin
outbound_type = p.value.outbound_type
service_cidr = p.value.service_cidr
load_balancer_sku = "standard"
dns_service_ip = p.value.dns_service_ip
network_policy = p.value.network_policy
network_plugin = p.value.network_plugin
network_plugin_mode = p.value.network_plugin_mode
outbound_type = p.value.outbound_type
service_cidr = p.value.service_cidr
load_balancer_sku = "standard"
load_balancer_profile {
outbound_ip_address_ids = var.outbound_ip_address_ids
}
Expand Down Expand Up @@ -176,7 +177,7 @@ resource "azurerm_kubernetes_cluster_node_pool" "this" {
node_taints = var.user_node_pool_node_taints

### networking
vnet_subnet_id = var.network_profile.network_plugin == "azure" ? var.vnet_subnet_id : var.vnet_user_subnet_id
vnet_subnet_id = var.network_profile.network_plugin_mode == "Overlay" ? var.vnet_user_subnet_id : var.vnet_subnet_id
enable_node_public_ip = false

upgrade_settings {
Expand Down
22 changes: 12 additions & 10 deletions kubernetes_cluster/99_variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -263,18 +263,20 @@ variable "api_server_authorized_ip_ranges" {

variable "network_profile" {
type = object({
dns_service_ip = string # e.g. '10.2.0.10'. IP address within the Kubernetes service address range that will be used by cluster service discovery (kube-dns)
network_policy = string # e.g. 'azure'. Sets up network policy to be used with Azure CNI. Currently supported values are calico and azure.
network_plugin = string # e.g. 'azure'. Network plugin to use for networking. Currently supported values are azure and kubenet
outbound_type = string # e.g. 'loadBalancer'. The outbound (egress) routing method which should be used for this Kubernetes Cluster. Possible values are loadBalancer, userDefinedRouting, managedNATGateway and userAssignedNATGateway. Defaults to loadBalancer
service_cidr = string # e.g. '10.2.0.0/16'. The Network Range used by the Kubernetes service
dns_service_ip = string # e.g. '10.2.0.10'. IP address within the Kubernetes service address range that will be used by cluster service discovery (kube-dns)
network_policy = string # e.g. 'azure'. Sets up network policy to be used with Azure CNI. Currently supported values are calico and azure.
network_plugin = string # e.g. 'azure'. Network plugin to use for networking. Currently supported values are azure and kubenet
network_plugin_mode = string # e.g. 'azure'. Network plugin mode to use for networking. Currently supported value is Overlay
outbound_type = string # e.g. 'loadBalancer'. The outbound (egress) routing method which should be used for this Kubernetes Cluster. Possible values are loadBalancer, userDefinedRouting, managedNATGateway and userAssignedNATGateway. Defaults to loadBalancer
service_cidr = string # e.g. '10.2.0.0/16'. The Network Range used by the Kubernetes service
})
default = {
dns_service_ip = "10.2.0.10"
network_policy = "azure"
network_plugin = "azure"
outbound_type = "loadBalancer"
service_cidr = "10.2.0.0/16"
dns_service_ip = "10.2.0.10"
network_policy = "azure"
network_plugin = "azure"
network_plugin_mode = ""
outbound_type = "loadBalancer"
service_cidr = "10.2.0.0/16"
}
description = "See variable description to understand how to use it, and see examples"
}
Expand Down
3 changes: 2 additions & 1 deletion kubernetes_cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ No modules.
| <a name="input_log_analytics_workspace_id"></a> [log\_analytics\_workspace\_id](#input\_log\_analytics\_workspace\_id) | The ID of the Log Analytics Workspace which the OMS Agent should send data to. | `string` | `null` | no |
| <a name="input_microsoft_defender_log_analytics_workspace_id"></a> [microsoft\_defender\_log\_analytics\_workspace\_id](#input\_microsoft\_defender\_log\_analytics\_workspace\_id) | Specifies the ID of the Log Analytics Workspace where the audit logs collected by Microsoft Defender should be sent to | `string` | `null` | no |
| <a name="input_name"></a> [name](#input\_name) | (Required) Cluster name | `string` | n/a | yes |
| <a name="input_network_profile"></a> [network\_profile](#input\_network\_profile) | See variable description to understand how to use it, and see examples | <pre>object({<br> dns_service_ip = string # e.g. '10.2.0.10'. IP address within the Kubernetes service address range that will be used by cluster service discovery (kube-dns)<br> network_policy = string # e.g. 'azure'. Sets up network policy to be used with Azure CNI. Currently supported values are calico and azure.<br> network_plugin = string # e.g. 'azure'. Network plugin to use for networking. Currently supported values are azure and kubenet<br> outbound_type = string # e.g. 'loadBalancer'. The outbound (egress) routing method which should be used for this Kubernetes Cluster. Possible values are loadBalancer, userDefinedRouting, managedNATGateway and userAssignedNATGateway. Defaults to loadBalancer<br> service_cidr = string # e.g. '10.2.0.0/16'. The Network Range used by the Kubernetes service<br> })</pre> | <pre>{<br> "dns_service_ip": "10.2.0.10",<br> "network_plugin": "azure",<br> "network_policy": "azure",<br> "outbound_type": "loadBalancer",<br> "service_cidr": "10.2.0.0/16"<br>}</pre> | no |
| <a name="input_network_profile"></a> [network\_profile](#input\_network\_profile) | See variable description to understand how to use it, and see examples | <pre>object({<br> dns_service_ip = string # e.g. '10.2.0.10'. IP address within the Kubernetes service address range that will be used by cluster service discovery (kube-dns)<br> network_policy = string # e.g. 'azure'. Sets up network policy to be used with Azure CNI. Currently supported values are calico and azure.<br> network_plugin = string # e.g. 'azure'. Network plugin to use for networking. Currently supported values are azure and kubenet<br> network_plugin_mode = string # e.g. 'azure'. Network plugin mode to use for networking. Currently supported value is Overlay<br> outbound_type = string # e.g. 'loadBalancer'. The outbound (egress) routing method which should be used for this Kubernetes Cluster. Possible values are loadBalancer, userDefinedRouting, managedNATGateway and userAssignedNATGateway. Defaults to loadBalancer<br> service_cidr = string # e.g. '10.2.0.0/16'. The Network Range used by the Kubernetes service<br> })</pre> | <pre>{<br> "dns_service_ip": "10.2.0.10",<br> "network_plugin": "azure",<br> "network_plugin_mode": "",<br> "network_policy": "azure",<br> "outbound_type": "loadBalancer",<br> "service_cidr": "10.2.0.0/16"<br>}</pre> | no |
| <a name="input_outbound_ip_address_ids"></a> [outbound\_ip\_address\_ids](#input\_outbound\_ip\_address\_ids) | The ID of the Public IP Addresses which should be used for outbound communication for the cluster load balancer. | `list(string)` | `[]` | no |
| <a name="input_private_cluster_enabled"></a> [private\_cluster\_enabled](#input\_private\_cluster\_enabled) | (Optional) Provides a Private IP Address for the Kubernetes API on the Virtual Network where the Kubernetes Cluster is located. | `bool` | `false` | no |
| <a name="input_rbac_enabled"></a> [rbac\_enabled](#input\_rbac\_enabled) | Is Role Based Access Control Enabled? | `bool` | `true` | no |
Expand Down Expand Up @@ -747,6 +747,7 @@ No modules.
| <a name="input_user_node_pool_vm_size"></a> [user\_node\_pool\_vm\_size](#input\_user\_node\_pool\_vm\_size) | (Required) The size of the Virtual Machine, such as Standard\_B4ms or Standard\_D4s\_vX. See https://pagopa.atlassian.net/wiki/spaces/DEVOPS/pages/134840344/Best+practice+su+prodotti | `string` | n/a | yes |
| <a name="input_vnet_id"></a> [vnet\_id](#input\_vnet\_id) | (Required) Virtual network id, where the k8s cluster is deployed. | `string` | n/a | yes |
| <a name="input_vnet_subnet_id"></a> [vnet\_subnet\_id](#input\_vnet\_subnet\_id) | (Optional) The ID of a Subnet where the Kubernetes Node Pool should exist. Changing this forces a new resource to be created. | `string` | `null` | no |
| <a name="input_vnet_user_subnet_id"></a> [vnet\_user\_subnet\_id](#input\_vnet\_user\_subnet\_id) | (Optional) The ID of a Subnet where the Kubernetes User Node Pool should exist. Changing this forces a new resource to be created. | `string` | `null` | no |

## Outputs

Expand Down

0 comments on commit 0937b40

Please sign in to comment.