Skip to content

Commit d8e7850

Browse files
authored
Merge pull request #184 from marko7460/drift
Drift after running make generate
2 parents be765c9 + 2d8ed18 commit d8e7850

39 files changed

+462
-107
lines changed

cluster_regional.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ resource "google_container_cluster" "primary" {
100100
service_account = "${lookup(var.node_pools[0], "service_account", local.service_account)}"
101101
}
102102
}
103-
104103
remove_default_node_pool = "${var.remove_default_node_pool}"
105104
}
106105

cluster_zonal.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ resource "google_container_cluster" "zonal_primary" {
100100
service_account = "${lookup(var.node_pools[0], "service_account", local.service_account)}"
101101
}
102102
}
103-
104103
remove_default_node_pool = "${var.remove_default_node_pool}"
105104
}
106105

examples/simple_regional_beta/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ This example illustrates how to create a simple cluster with beta features.
88

99
| Name | Description | Type | Default | Required |
1010
|------|-------------|:----:|:-----:|:-----:|
11+
| cloudrun | Boolean to enable / disable CloudRun | string | `"true"` | no |
1112
| cluster\_name\_suffix | A suffix to append to the default cluster name | string | `""` | no |
1213
| compute\_engine\_service\_account | Service account to associate to the nodes in the cluster | string | n/a | yes |
1314
| credentials\_path | The path to the GCP credentials JSON file | string | n/a | yes |
1415
| ip\_range\_pods | The secondary ip range to use for pods | string | n/a | yes |
1516
| ip\_range\_services | The secondary ip range to use for pods | string | n/a | yes |
17+
| istio | Boolean to enable / disable Istio | string | `"true"` | no |
1618
| network | The VPC network to host the cluster in | string | n/a | yes |
1719
| project\_id | The project ID to host the cluster in | string | n/a | yes |
1820
| region | The region to host the cluster in | string | n/a | yes |

examples/simple_regional_private_beta/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ This example illustrates how to create a simple private cluster with beta featur
88

99
| Name | Description | Type | Default | Required |
1010
|------|-------------|:----:|:-----:|:-----:|
11+
| cloudrun | Boolean to enable / disable CloudRun | string | `"true"` | no |
1112
| cluster\_name\_suffix | A suffix to append to the default cluster name | string | `""` | no |
1213
| compute\_engine\_service\_account | Service account to associate to the nodes in the cluster | string | n/a | yes |
1314
| credentials\_path | The path to the GCP credentials JSON file | string | n/a | yes |
1415
| ip\_range\_pods | The secondary ip range to use for pods | string | n/a | yes |
1516
| ip\_range\_services | The secondary ip range to use for pods | string | n/a | yes |
17+
| istio | Boolean to enable / disable Istio | string | `"true"` | no |
1618
| network | The VPC network to host the cluster in | string | n/a | yes |
1719
| project\_id | The project ID to host the cluster in | string | n/a | yes |
1820
| region | The region to host the cluster in | string | n/a | yes |

main.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ data "google_container_engine_versions" "zone" {
161161
//
162162
// data.google_container_engine_versions.zone: Cannot determine zone: set in this resource, or set provider-level zone.
163163
//
164-
zone = "${var.zones[0] == "" ? data.google_compute_zones.available.names[0] : var.zones[0]}"
165-
project = "${var.project_id}"
164+
zone = "${var.zones[0] == "" ? data.google_compute_zones.available.names[0] : var.zones[0]}"
165+
166+
project = "${var.project_id}"
166167
}

modules/beta-private-cluster/README.md

Lines changed: 100 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ The resources/services/activations/deletions that this module will create/trigge
88
- Activate network policy if `network_policy` is true
99
- Add `ip-masq-agent` configmap with provided `non_masquerade_cidrs` if `network_policy` is true
1010

11+
**Note**: You must run Terraform from a VM on the same VPC as your cluster, otherwise there will be issues connecting to the GKE master.
12+
1113
## Usage
1214
There are multiple examples included in the [examples](./examples/) folder but simple usage is as follows:
1315

@@ -49,6 +51,14 @@ module "gke" {
4951
},
5052
]
5153
54+
node_pools_oauth_scopes = {
55+
all = []
56+
57+
default-node-pool = [
58+
"https://www.googleapis.com/auth/cloud-platform",
59+
]
60+
}
61+
5262
node_pools_labels = {
5363
all = {}
5464
@@ -94,13 +104,98 @@ Then perform the following commands on the root folder:
94104
- `terraform apply` to apply the infrastructure build
95105
- `terraform destroy` to destroy the built infrastructure
96106

107+
## Upgrade to v2.0.0
108+
109+
v2.0.0 is a breaking release. Refer to the
110+
[Upgrading to v2.0 guide][upgrading-to-v2.0] for details.
111+
97112
## Upgrade to v1.0.0
98113

99114
Version 1.0.0 of this module introduces a breaking change: adding the `disable-legacy-endpoints` metadata field to all node pools. This metadata is required by GKE and [determines whether the `/0.1/` and `/v1beta1/` paths are available in the nodes' metadata server](https://cloud.google.com/kubernetes-engine/docs/how-to/protecting-cluster-metadata#disable-legacy-apis). If your applications do not require access to the node's metadata server, you can leave the default value of `true` provided by the module. If your applications require access to the metadata server, be sure to read the linked documentation to see if you need to set the value for this field to `false` to allow your applications access to the above metadata server paths.
100115

101116
In either case, upgrading to module version `v1.0.0` will trigger a recreation of all node pools in the cluster.
102117

103118
[^]: (autogen_docs_start)
119+
120+
## Inputs
121+
122+
| Name | Description | Type | Default | Required |
123+
|------|-------------|:----:|:-----:|:-----:|
124+
| basic\_auth\_password | The password to be used with Basic Authentication. | string | `""` | no |
125+
| basic\_auth\_username | The username to be used with Basic Authentication. An empty value will disable Basic Authentication, which is the recommended configuration. | string | `""` | no |
126+
| cloudrun | (Beta) Enable CloudRun addon | string | `"false"` | no |
127+
| deploy\_using\_private\_endpoint | (Beta) A toggle for Terraform and kubectl to connect to the master's internal IP address during deployment. | string | `"false"` | no |
128+
| description | The description of the cluster | string | `""` | no |
129+
| disable\_legacy\_metadata\_endpoints | Disable the /0.1/ and /v1beta1/ metadata server endpoints on the node. Changing this value will cause all node pools to be recreated. | string | `"true"` | no |
130+
| enable\_binary\_authorization | Enable BinAuthZ Admission controller | string | `"false"` | no |
131+
| enable\_private\_endpoint | (Beta) Whether the master's internal IP address is used as the cluster endpoint | string | `"false"` | no |
132+
| enable\_private\_nodes | (Beta) Whether nodes have internal IP addresses only | string | `"false"` | no |
133+
| horizontal\_pod\_autoscaling | Enable horizontal pod autoscaling addon | string | `"true"` | no |
134+
| http\_load\_balancing | Enable httpload balancer addon | string | `"true"` | no |
135+
| initial\_node\_count | The number of nodes to create in this cluster's default node pool. | string | `"0"` | no |
136+
| ip\_masq\_link\_local | Whether to masquerade traffic to the link-local prefix (169.254.0.0/16). | string | `"false"` | no |
137+
| ip\_masq\_resync\_interval | The interval at which the agent attempts to sync its ConfigMap file from the disk. | string | `"60s"` | no |
138+
| ip\_range\_pods | The _name_ of the secondary subnet ip range to use for pods | string | n/a | yes |
139+
| ip\_range\_services | The _name_ of the secondary subnet range to use for services | string | n/a | yes |
140+
| issue\_client\_certificate | Issues a client certificate to authenticate to the cluster endpoint. To maximize the security of your cluster, leave this option disabled. Client certificates don't automatically rotate and aren't easily revocable. WARNING: changing this after cluster creation is destructive! | string | `"false"` | no |
141+
| istio | (Beta) Enable Istio addon | string | `"false"` | no |
142+
| kubernetes\_dashboard | Enable kubernetes dashboard addon | string | `"false"` | no |
143+
| kubernetes\_version | The Kubernetes version of the masters. If set to 'latest' it will pull latest available version in the selected region. | string | `"latest"` | no |
144+
| logging\_service | The logging service that the cluster should write logs to. Available options include logging.googleapis.com, logging.googleapis.com/kubernetes (beta), and none | string | `"logging.googleapis.com"` | no |
145+
| maintenance\_start\_time | Time window specified for daily maintenance operations in RFC3339 format | string | `"05:00"` | no |
146+
| master\_authorized\_networks\_config | The desired configuration options for master authorized networks. Omit the nested cidr_blocks attribute to disallow external access (except the cluster node IPs, which GKE automatically whitelists)<br><br> ### example format ### master_authorized_networks_config = [{ cidr_blocks = [{ cidr_block = "10.0.0.0/8" display_name = "example_network" }], }] | list | `<list>` | no |
147+
| master\_ipv4\_cidr\_block | (Beta) The IP range in CIDR notation to use for the hosted master network | string | `"10.0.0.0/28"` | no |
148+
| monitoring\_service | The monitoring service that the cluster should write metrics to. Automatically send metrics from pods in the cluster to the Google Cloud Monitoring API. VM metrics will be collected by Google Compute Engine regardless of this setting Available options include monitoring.googleapis.com, monitoring.googleapis.com/kubernetes (beta) and none | string | `"monitoring.googleapis.com"` | no |
149+
| name | The name of the cluster (required) | string | n/a | yes |
150+
| network | The VPC network to host the cluster in (required) | string | n/a | yes |
151+
| network\_policy | Enable network policy addon | string | `"false"` | no |
152+
| network\_policy\_provider | The network policy provider. | string | `"CALICO"` | no |
153+
| network\_project\_id | The project ID of the shared VPC's host (for shared vpc support) | string | `""` | no |
154+
| node\_pools | List of maps containing node pools | list | `<list>` | no |
155+
| node\_pools\_labels | Map of maps containing node labels by node-pool name | map | `<map>` | no |
156+
| node\_pools\_metadata | Map of maps containing node metadata by node-pool name | map | `<map>` | no |
157+
| node\_pools\_oauth\_scopes | Map of lists containing node oauth scopes by node-pool name | map | `<map>` | no |
158+
| node\_pools\_tags | Map of lists containing node network tags by node-pool name | map | `<map>` | no |
159+
| node\_pools\_taints | Map of lists containing node taints by node-pool name | map | `<map>` | no |
160+
| node\_version | The Kubernetes version of the node pools. Defaults kubernetes_version (master) variable and can be overridden for individual node pools by setting the `version` key on them. Must be empyty or set the same as master at cluster creation. | string | `""` | no |
161+
| non\_masquerade\_cidrs | List of strings in CIDR notation that specify the IP address ranges that do not use IP masquerading. | list | `<list>` | no |
162+
| pod\_security\_policy\_config | enabled - Enable the PodSecurityPolicy controller for this cluster. If enabled, pods must be valid under a PodSecurityPolicy to be created. | list | `<list>` | no |
163+
| project\_id | The project ID to host the cluster in (required) | string | n/a | yes |
164+
| region | The region to host the cluster in (required) | string | n/a | yes |
165+
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | string | `"true"` | no |
166+
| remove\_default\_node\_pool | Remove default node pool while setting up the cluster | string | `"false"` | no |
167+
| service\_account | The service account to run nodes as if not overridden in `node_pools`. The default value will cause a cluster-specific service account to be created. | string | `"create"` | no |
168+
| stub\_domains | Map of stub domains and their resolvers to forward DNS queries for a certain domain to an external DNS server | map | `<map>` | no |
169+
| subnetwork | The subnetwork to host the cluster in (required) | string | n/a | yes |
170+
| zones | The zones to host the cluster in (optional if regional cluster / required if zonal) | list | `<list>` | no |
171+
172+
## Outputs
173+
174+
| Name | Description |
175+
|------|-------------|
176+
| ca\_certificate | Cluster ca certificate (base64 encoded) |
177+
| cloudrun\_enabled | Whether CloudRun enabled |
178+
| endpoint | Cluster endpoint |
179+
| horizontal\_pod\_autoscaling\_enabled | Whether horizontal pod autoscaling enabled |
180+
| http\_load\_balancing\_enabled | Whether http load balancing enabled |
181+
| istio\_enabled | Whether Istio is enabled |
182+
| kubernetes\_dashboard\_enabled | Whether kubernetes dashboard enabled |
183+
| location | Cluster location (region if regional cluster, zone if zonal cluster) |
184+
| logging\_service | Logging service used |
185+
| master\_authorized\_networks\_config | Networks from which access to master is permitted |
186+
| master\_version | Current master kubernetes version |
187+
| min\_master\_version | Minimum master kubernetes version |
188+
| monitoring\_service | Monitoring service used |
189+
| name | Cluster name |
190+
| network\_policy\_enabled | Whether network policy enabled |
191+
| node\_pools\_names | List of node pools names |
192+
| node\_pools\_versions | List of node pools versions |
193+
| pod\_security\_policy\_enabled | Whether pod security policy is enabled |
194+
| region | Cluster region |
195+
| service\_account | The service account to default running nodes as if not overridden in `node_pools`. |
196+
| type | Cluster type (regional / zonal) |
197+
| zones | List of zones in which the cluster resides |
198+
104199
[^]: (autogen_docs_end)
105200

106201
## Requirements
@@ -119,7 +214,7 @@ The [project factory](https://github.com/terraform-google-modules/terraform-goog
119214
- [kubectl](https://github.com/kubernetes/kubernetes/releases) 1.9.x
120215
#### Terraform and Plugins
121216
- [Terraform](https://www.terraform.io/downloads.html) 0.11.x
122-
- [terraform-provider-google-beta](https://github.com/terraform-providers/terraform-provider-google-beta) v2.0.0
217+
- [terraform-provider-google-beta](https://github.com/terraform-providers/terraform-provider-google-beta) v2.3, v2.6, v2.7
123218

124219
### Configure a Service Account
125220
In order to execute this module you must have a Service Account with the
@@ -161,7 +256,7 @@ The root module is generated by running `make generate`. Changes to this reposit
161256
### Requirements
162257
- [bundler](https://github.com/bundler/bundler)
163258
- [gcloud](https://cloud.google.com/sdk/install)
164-
- [terraform-docs](https://github.com/segmentio/terraform-docs/releases) 0.3.0
259+
- [terraform-docs](https://github.com/segmentio/terraform-docs/releases) 0.6.0
165260

166261
### Autogeneration of documentation from .tf files
167262
Run
@@ -280,4 +375,6 @@ are as follows:
280375
is a compiled language so there is no standard linter.
281376
* Terraform - terraform has a built-in linter in the 'terraform validate'
282377
command.
283-
* Dockerfiles - hadolint. Can be found in homebrew
378+
* Dockerfiles - hadolint. Can be found in homebrew
379+
380+
[upgrading-to-v2.0]: ../../docs/upgrading_to_v2.0.md

modules/beta-private-cluster/auth.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ provider "kubernetes" {
3131
host = "https://${local.cluster_endpoint}"
3232
token = "${data.google_client_config.default.access_token}"
3333
cluster_ca_certificate = "${base64decode(local.cluster_ca_certificate)}"
34-
}
34+
}

modules/beta-private-cluster/cluster_regional.tf

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,35 @@ resource "google_container_cluster" "primary" {
2626
description = "${var.description}"
2727
project = "${var.project_id}"
2828

29-
region = "${var.region}"
30-
additional_zones = ["${coalescelist(compact(var.zones), sort(random_shuffle.available_zones.result))}"]
29+
region = "${var.region}"
30+
node_locations = ["${coalescelist(compact(var.zones), sort(random_shuffle.available_zones.result))}"]
31+
32+
network = "${replace(data.google_compute_network.gke_network.self_link, "https://www.googleapis.com/compute/v1/", "")}"
33+
34+
network_policy {
35+
enabled = "${var.network_policy}"
36+
provider = "${var.network_policy_provider}"
37+
}
3138

32-
network = "${replace(data.google_compute_network.gke_network.self_link, "https://www.googleapis.com/compute/v1/", "")}"
3339
subnetwork = "${replace(data.google_compute_subnetwork.gke_subnetwork.self_link, "https://www.googleapis.com/compute/v1/", "")}"
3440
min_master_version = "${local.kubernetes_version_regional}"
3541

3642
logging_service = "${var.logging_service}"
3743
monitoring_service = "${var.monitoring_service}"
3844

45+
enable_binary_authorization = "${var.enable_binary_authorization}"
46+
pod_security_policy_config = "${var.pod_security_policy_config}"
3947
master_authorized_networks_config = ["${var.master_authorized_networks_config}"]
4048

49+
master_auth {
50+
username = "${var.basic_auth_username}"
51+
password = "${var.basic_auth_password}"
52+
53+
client_certificate_config {
54+
issue_client_certificate = "${var.issue_client_certificate}"
55+
}
56+
}
57+
4158
addons_config {
4259
http_load_balancing {
4360
disabled = "${var.http_load_balancing ? 0 : 1}"
@@ -85,7 +102,8 @@ resource "google_container_cluster" "primary" {
85102
}
86103

87104
node_pool {
88-
name = "default-pool"
105+
name = "default-pool"
106+
initial_node_count = "${var.initial_node_count}"
89107

90108
node_config {
91109
service_account = "${lookup(var.node_pools[0], "service_account", local.service_account)}"
@@ -108,7 +126,7 @@ resource "google_container_node_pool" "pools" {
108126
name = "${lookup(var.node_pools[count.index], "name")}"
109127
project = "${var.project_id}"
110128
region = "${var.region}"
111-
cluster = "${var.name}"
129+
cluster = "${google_container_cluster.primary.name}"
112130
version = "${lookup(var.node_pools[count.index], "auto_upgrade", false) ? "" : lookup(var.node_pools[count.index], "version", local.node_version_regional)}"
113131
initial_node_count = "${lookup(var.node_pools[count.index], "initial_node_count", lookup(var.node_pools[count.index], "min_count", 1))}"
114132

@@ -136,7 +154,8 @@ resource "google_container_node_pool" "pools" {
136154
preemptible = "${lookup(var.node_pools[count.index], "preemptible", false)}"
137155

138156
oauth_scopes = [
139-
"https://www.googleapis.com/auth/cloud-platform",
157+
"${concat(var.node_pools_oauth_scopes["all"],
158+
var.node_pools_oauth_scopes[lookup(var.node_pools[count.index], "name")])}",
140159
]
141160
}
142161

@@ -149,8 +168,6 @@ resource "google_container_node_pool" "pools" {
149168
update = "30m"
150169
delete = "30m"
151170
}
152-
153-
depends_on = ["google_container_cluster.primary"]
154171
}
155172

156173
resource "null_resource" "wait_for_regional_cluster" {
@@ -166,4 +183,4 @@ resource "null_resource" "wait_for_regional_cluster" {
166183
}
167184

168185
depends_on = ["google_container_cluster.primary", "google_container_node_pool.pools"]
169-
}
186+
}

0 commit comments

Comments
 (0)