Skip to content

Commit e1bdadf

Browse files
authored
Merge pull request #12 from FairwindsOps/additional-cloud-nat-params
Additional cloud nat params
2 parents ef6b6d3 + 01fc672 commit e1bdadf

File tree

3 files changed

+40
-10
lines changed

3 files changed

+40
-10
lines changed

default/CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,20 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
## 2.2.0
8+
9+
### Added
10+
* added variable for `min_ports_per_vm`
11+
* added variable `cloud_nat_log_config_filter`
12+
13+
### Removed
14+
* removed unused variable `enable_flow_logs`
15+
16+
## 2.1.0
17+
18+
### Removed
19+
* `enable_flow_logs` has been deprecated and removed
20+
721
## 2.0.0
822
### Breaking
923

default/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
### Default module example parameters
2-
The `default` module will create a VPC-native network for Kubernetes clusters. This module can be configured to provision a Cloud NAT gateway. The Cloud NAT gateway can also be configured with `AUTO_ONLY` or `MANUAL_ONLY` options. If `MANUAL_ONLY` is chosen, `cloud_nat_address_count` can be used to select the desired number of public IP addresses.
2+
The `default` module will create a VPC-native network for Kubernetes clusters. This module can be configured to provision a Cloud NAT gateway. The Cloud NAT gateway can also be configured with `AUTO_ONLY` or `MANUAL_ONLY` options. If `MANUAL_ONLY` is chosen, `cloud_nat_address_count` can be used to select the desired number of public IP addresses.
33

4-
Fill out your `network.tf` like so:
4+
Fill out your `network.tf` like so:
55

66
```
77
module "network" {
@@ -13,13 +13,13 @@ module "network" {
1313
enable_flow_logs = "false"
1414
1515
//specify the staging subnetwork primary and secondary CIDRs for IP aliasing
16-
subnetwork_range = "10.128.0.0/20"
17-
subnetwork_pods = "10.128.64.0/18"
18-
subnetwork_services = "10.128.32.0/20"
16+
subnetwork_range = "10.64.0.0/20"
17+
subnetwork_pods = "10.128.0.0/12"
18+
subnetwork_services = "10.64.32.0/19"
1919
2020
//optional cloud-nat inputs
2121
enable_cloud_nat = true
2222
nat_ip_allocation_option = "MANUAL_ONLY"
2323
cloud_nat_ip_count = 2
2424
}
25-
```
25+
```

default/main.tf

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@ variable "region" {
2626
description = "region to use"
2727
}
2828

29-
variable "enable_flow_logs" {
30-
description = "whether to turn on flow logs or not"
31-
}
32-
3329
variable "enable_cloud_nat" {
3430
# https://cloud.google.com/nat/docs/overview#ip_address_allocation
3531
description = "Setup Cloud NAT gateway for VPC"
@@ -50,6 +46,17 @@ variable "cloud_nat_address_count" {
5046
default = 1
5147
}
5248

49+
variable "cloud_nat_min_ports_per_vm" {
50+
description = "Minimum number of ports allocated to a VM from this NAT."
51+
type = number
52+
default = 64
53+
}
54+
55+
variable "cloud_nat_log_config_filter" {
56+
description = "Specifies the desired filtering of logs on this NAT"
57+
default = null
58+
}
59+
5360
locals {
5461
## the following locals modify resource creation behavior depending on var.nat_ip_allocate_option
5562
enable_cloud_nat = var.enable_cloud_nat == true ? 1 : 0
@@ -114,7 +121,16 @@ resource "google_compute_router_nat" "nat_router" {
114121
region = var.region
115122
nat_ip_allocate_option = var.nat_ip_allocate_option
116123
nat_ips = local.nat_ips
124+
min_ports_per_vm = var.cloud_nat_min_ports_per_vm
117125
source_subnetwork_ip_ranges_to_nat = "ALL_SUBNETWORKS_ALL_IP_RANGES"
126+
127+
dynamic "log_config" {
128+
for_each = var.cloud_nat_log_config_filter == null ? [] : list(true)
129+
content {
130+
enable = var.cloud_nat_log_config_filter == null ? false : true
131+
filter = var.cloud_nat_log_config_filter
132+
}
133+
}
118134
}
119135

120136
/** provide outputs to be used in GKE cluster creation **/

0 commit comments

Comments
 (0)