Skip to content

Commit c8369b8

Browse files
authored
Merge pull request #102 from thefirstofthe300/ds/cleanup-test-docs
Clean up for ease of getting started doing local testing
2 parents de467d9 + 7b9c207 commit c8369b8

File tree

31 files changed

+278
-280
lines changed

31 files changed

+278
-280
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,6 @@ test/integration/gcloud/config.sh
4747
test/integration/tmp
4848

4949
credentials.json
50+
51+
# File to populate env vars used by Docker test runs
52+
.envrc

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ docker_create: docker_build_kitchen_terraform
130130
-e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \
131131
-v $(CURDIR):/cft/workdir \
132132
${DOCKER_IMAGE_KITCHEN_TERRAFORM}:${DOCKER_TAG_KITCHEN_TERRAFORM} \
133-
/bin/bash -c "kitchen create"
133+
/bin/bash -c "source test/ci_integration.sh && setup_environment && kitchen create"
134134

135135
.PHONY: docker_converge
136136
docker_converge:
@@ -144,7 +144,7 @@ docker_converge:
144144
-e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \
145145
-v $(CURDIR):/cft/workdir \
146146
${DOCKER_IMAGE_KITCHEN_TERRAFORM}:${DOCKER_TAG_KITCHEN_TERRAFORM} \
147-
/bin/bash -c "kitchen converge && kitchen converge"
147+
/bin/bash -c "source test/ci_integration.sh && setup_environment && kitchen converge && kitchen converge"
148148

149149
.PHONY: docker_verify
150150
docker_verify:
@@ -158,7 +158,7 @@ docker_verify:
158158
-e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \
159159
-v $(CURDIR):/cft/workdir \
160160
${DOCKER_IMAGE_KITCHEN_TERRAFORM}:${DOCKER_TAG_KITCHEN_TERRAFORM} \
161-
/bin/bash -c "kitchen verify"
161+
/bin/bash -c "source test/ci_integration.sh && setup_environment && kitchen verify"
162162

163163
.PHONY: docker_destroy
164164
docker_destroy:
@@ -172,7 +172,7 @@ docker_destroy:
172172
-e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \
173173
-v $(CURDIR):/cft/workdir \
174174
${DOCKER_IMAGE_KITCHEN_TERRAFORM}:${DOCKER_TAG_KITCHEN_TERRAFORM} \
175-
/bin/bash -c "kitchen destroy"
175+
/bin/bash -c "source test/ci_integration.sh && setup_environment && kitchen destroy"
176176

177177
.PHONY: test_integration_docker
178178
test_integration_docker:

README.md

Lines changed: 47 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -92,63 +92,62 @@ Then perform the following commands on the root folder:
9292

9393
[^]: (autogen_docs_start)
9494

95-
9695
## Inputs
9796

9897
| Name | Description | Type | Default | Required |
9998
|------|-------------|:----:|:-----:|:-----:|
100-
| description | The description of the cluster | string | `` | no |
101-
| horizontal_pod_autoscaling | Enable horizontal pod autoscaling addon | string | `true` | no |
102-
| http_load_balancing | Enable httpload balancer addon | string | `true` | no |
103-
| ip_masq_link_local | Whether to masquerade traffic to the link-local prefix (169.254.0.0/16). | string | `false` | no |
104-
| ip_masq_resync_interval | The interval at which the agent attempts to sync its ConfigMap file from the disk. | string | `60s` | no |
105-
| ip_range_pods | The secondary ip range to use for pods | string | - | yes |
106-
| ip_range_services | The secondary ip range to use for pods | string | - | yes |
107-
| kubernetes_dashboard | Enable kubernetes dashboard addon | string | `false` | no |
108-
| 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 |
109-
| 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 |
110-
| maintenance_start_time | Time window specified for daily maintenance operations in RFC3339 format | string | `05:00` | no |
111-
| 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 |
112-
| 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 |
113-
| name | The name of the cluster (required) | string | - | yes |
114-
| network | The VPC network to host the cluster in (required) | string | - | yes |
115-
| network_policy | Enable network policy addon | string | `false` | no |
116-
| network_project_id | The project ID of the shared VPC's host (for shared vpc support) | string | `` | no |
117-
| node_pools | List of maps containing node pools | list | `<list>` | no |
118-
| node_pools_labels | Map of maps containing node labels by node-pool name | map | `<map>` | no |
119-
| node_pools_metadata | Map of maps containing node metadata by node-pool name | map | `<map>` | no |
120-
| node_pools_tags | Map of lists containing node network tags by node-pool name | map | `<map>` | no |
121-
| node_pools_taints | Map of lists containing node taints by node-pool name | map | `<map>` | no |
122-
| 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 |
123-
| non_masquerade_cidrs | List of strings in CIDR notation that specify the IP address ranges that do not use IP masquerading. | list | `<list>` | no |
124-
| project_id | The project ID to host the cluster in (required) | string | - | yes |
125-
| region | The region to host the cluster in (required) | string | - | yes |
126-
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | string | `true` | no |
127-
| remove_default_node_pool | Remove default node pool while setting up the cluster | string | `false` | no |
128-
| service_account | The service account to default running nodes as if not overridden in `node_pools`. Defaults to the compute engine default service account. May also specify `create` to automatically create a cluster-specific service account | string | `` | no |
129-
| 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 |
130-
| subnetwork | The subnetwork to host the cluster in (required) | string | - | yes |
99+
| description | The description of the cluster | string | `""` | no |
100+
| horizontal\_pod\_autoscaling | Enable horizontal pod autoscaling addon | string | `"true"` | no |
101+
| http\_load\_balancing | Enable httpload balancer addon | string | `"true"` | no |
102+
| ip\_masq\_link\_local | Whether to masquerade traffic to the link-local prefix (169.254.0.0/16). | string | `"false"` | no |
103+
| ip\_masq\_resync\_interval | The interval at which the agent attempts to sync its ConfigMap file from the disk. | string | `"60s"` | no |
104+
| ip\_range\_pods | The secondary ip range to use for pods | string | n/a | yes |
105+
| ip\_range\_services | The secondary ip range to use for pods | string | n/a | yes |
106+
| kubernetes\_dashboard | Enable kubernetes dashboard addon | string | `"false"` | no |
107+
| 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 |
108+
| 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 |
109+
| maintenance\_start\_time | Time window specified for daily maintenance operations in RFC3339 format | string | `"05:00"` | no |
110+
| 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 |
111+
| 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 |
112+
| name | The name of the cluster (required) | string | n/a | yes |
113+
| network | The VPC network to host the cluster in (required) | string | n/a | yes |
114+
| network\_policy | Enable network policy addon | string | `"false"` | no |
115+
| network\_project\_id | The project ID of the shared VPC's host (for shared vpc support) | string | `""` | no |
116+
| node\_pools | List of maps containing node pools | list | `<list>` | no |
117+
| node\_pools\_labels | Map of maps containing node labels by node-pool name | map | `<map>` | no |
118+
| node\_pools\_metadata | Map of maps containing node metadata by node-pool name | map | `<map>` | no |
119+
| node\_pools\_tags | Map of lists containing node network tags by node-pool name | map | `<map>` | no |
120+
| node\_pools\_taints | Map of lists containing node taints by node-pool name | map | `<map>` | no |
121+
| 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 |
122+
| non\_masquerade\_cidrs | List of strings in CIDR notation that specify the IP address ranges that do not use IP masquerading. | list | `<list>` | no |
123+
| project\_id | The project ID to host the cluster in (required) | string | n/a | yes |
124+
| region | The region to host the cluster in (required) | string | n/a | yes |
125+
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | string | `"true"` | no |
126+
| remove\_default\_node\_pool | Remove default node pool while setting up the cluster | string | `"false"` | no |
127+
| service\_account | The service account to default running nodes as if not overridden in `node_pools`. Defaults to the compute engine default service account. May also specify `create` to automatically create a cluster-specific service account | string | `""` | no |
128+
| 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 |
129+
| subnetwork | The subnetwork to host the cluster in (required) | string | n/a | yes |
131130
| zones | The zones to host the cluster in (optional if regional cluster / required if zonal) | list | `<list>` | no |
132131

133132
## Outputs
134133

135134
| Name | Description |
136135
|------|-------------|
137-
| ca_certificate | Cluster ca certificate (base64 encoded) |
136+
| ca\_certificate | Cluster ca certificate (base64 encoded) |
138137
| endpoint | Cluster endpoint |
139-
| horizontal_pod_autoscaling_enabled | Whether horizontal pod autoscaling enabled |
140-
| http_load_balancing_enabled | Whether http load balancing enabled |
141-
| kubernetes_dashboard_enabled | Whether kubernetes dashboard enabled |
138+
| horizontal\_pod\_autoscaling\_enabled | Whether horizontal pod autoscaling enabled |
139+
| http\_load\_balancing\_enabled | Whether http load balancing enabled |
140+
| kubernetes\_dashboard\_enabled | Whether kubernetes dashboard enabled |
142141
| location | Cluster location (region if regional cluster, zone if zonal cluster) |
143-
| logging_service | Logging service used |
144-
| master_authorized_networks_config | Networks from which access to master is permitted |
145-
| master_version | Current master kubernetes version |
146-
| min_master_version | Minimum master kubernetes version |
147-
| monitoring_service | Monitoring service used |
142+
| logging\_service | Logging service used |
143+
| master\_authorized\_networks\_config | Networks from which access to master is permitted |
144+
| master\_version | Current master kubernetes version |
145+
| min\_master\_version | Minimum master kubernetes version |
146+
| monitoring\_service | Monitoring service used |
148147
| name | Cluster name |
149-
| network_policy_enabled | Whether network policy enabled |
150-
| node_pools_names | List of node pools names |
151-
| node_pools_versions | List of node pools versions |
148+
| network\_policy\_enabled | Whether network policy enabled |
149+
| node\_pools\_names | List of node pools names |
150+
| node\_pools\_versions | List of node pools versions |
152151
| region | Cluster region |
153152
| type | Cluster type (regional / zonal) |
154153
| zones | List of zones in which the cluster resides |
@@ -181,6 +180,7 @@ following project roles:
181180
- roles/container.developer
182181
- roles/iam.serviceAccountAdmin
183182
- roles/iam.serviceAccountUser
183+
- roles/resourcemanager.projectIamAdmin (only required if `service_account` is set to `create`)
184184

185185
### Enable APIs
186186
In order to operate with the Service Account you must activate the following APIs on the project where the Service Account was created:
@@ -239,6 +239,9 @@ The test-kitchen instances in `test/fixtures/` wrap identically-named examples i
239239

240240
1. Configure the [test fixtures](#test-configuration)
241241
2. Download a Service Account key with the necessary permissions and put it in the module's root directory with the name `credentials.json`.
242+
- Requires the [permissions to run the module](#configure-a-service-account)
243+
- Requires `roles/compute.networkAdmin` to create the test suite's networks
244+
- Requires `roles/resourcemanager.projectIamAdmin` since service account creation is tested
242245
3. Build the Docker container for testing:
243246

244247
```

autogen/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ following project roles:
191191
- roles/container.developer
192192
- roles/iam.serviceAccountAdmin
193193
- roles/iam.serviceAccountUser
194+
- roles/resourcemanager.projectIamAdmin (only required if `service_account` is set to `create`)
194195

195196
### Enable APIs
196197
In order to operate with the Service Account you must activate the following APIs on the project where the Service Account was created:
@@ -249,6 +250,9 @@ The test-kitchen instances in `test/fixtures/` wrap identically-named examples i
249250

250251
1. Configure the [test fixtures](#test-configuration)
251252
2. Download a Service Account key with the necessary permissions and put it in the module's root directory with the name `credentials.json`.
253+
- Requires the [permissions to run the module](#configure-a-service-account)
254+
- Requires `roles/compute.networkAdmin` to create the test suite's networks
255+
- Requires `roles/resourcemanager.projectIamAdmin` since service account creation is tested
252256
3. Build the Docker container for testing:
253257

254258
```

cluster_regional.tf

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ resource "google_container_cluster" "primary" {
8484
service_account = "${lookup(var.node_pools[0], "service_account", local.service_account)}"
8585
}
8686
}
87-
8887
remove_default_node_pool = "${var.remove_default_node_pool}"
8988
}
9089

@@ -155,4 +154,4 @@ resource "null_resource" "wait_for_regional_cluster" {
155154
}
156155

157156
depends_on = ["google_container_cluster.primary", "google_container_node_pool.pools"]
158-
}
157+
}

cluster_zonal.tf

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ resource "google_container_cluster" "zonal_primary" {
8484
service_account = "${lookup(var.node_pools[0], "service_account", local.service_account)}"
8585
}
8686
}
87-
8887
remove_default_node_pool = "${var.remove_default_node_pool}"
8988
}
9089

@@ -155,4 +154,4 @@ resource "null_resource" "wait_for_zonal_cluster" {
155154
}
156155

157156
depends_on = ["google_container_cluster.zonal_primary", "google_container_node_pool.zonal_pools"]
158-
}
157+
}

dns.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,4 @@ EOF
5151
}
5252

5353
depends_on = ["null_resource.delete_default_kube_dns_configmap", "data.google_client_config.default", "google_container_cluster.primary", "google_container_node_pool.pools", "google_container_cluster.zonal_primary", "google_container_node_pool.zonal_pools"]
54-
}
54+
}

examples/deploy_service/README.md

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,36 +10,35 @@ It will:
1010

1111
[^]: (autogen_docs_start)
1212

13-
1413
## Inputs
1514

1615
| Name | Description | Type | Default | Required |
1716
|------|-------------|:----:|:-----:|:-----:|
18-
| cluster_name_suffix | A suffix to append to the default cluster name | string | `` | no |
19-
| compute_engine_service_account | Service account to associate to the nodes in the cluster | string | - | yes |
20-
| credentials_path | The path to the GCP credentials JSON file | string | - | yes |
21-
| ip_range_pods | The secondary ip range to use for pods | string | - | yes |
22-
| ip_range_services | The secondary ip range to use for pods | string | - | yes |
23-
| network | The VPC network to host the cluster in | string | - | yes |
24-
| project_id | The project ID to host the cluster in | string | - | yes |
25-
| region | The region to host the cluster in | string | - | yes |
26-
| subnetwork | The subnetwork to host the cluster in | string | - | yes |
17+
| cluster\_name\_suffix | A suffix to append to the default cluster name | string | `""` | no |
18+
| compute\_engine\_service\_account | Service account to associate to the nodes in the cluster | string | n/a | yes |
19+
| credentials\_path | The path to the GCP credentials JSON file | string | n/a | yes |
20+
| ip\_range\_pods | The secondary ip range to use for pods | string | n/a | yes |
21+
| ip\_range\_services | The secondary ip range to use for pods | string | n/a | yes |
22+
| network | The VPC network to host the cluster in | string | n/a | yes |
23+
| project\_id | The project ID to host the cluster in | string | n/a | yes |
24+
| region | The region to host the cluster in | string | n/a | yes |
25+
| subnetwork | The subnetwork to host the cluster in | string | n/a | yes |
2726

2827
## Outputs
2928

3029
| Name | Description |
3130
|------|-------------|
32-
| ca_certificate | |
33-
| client_token | |
34-
| cluster_name | Cluster name |
35-
| credentials_path | |
36-
| ip_range_pods | The secondary IP range used for pods |
37-
| ip_range_services | The secondary IP range used for services |
38-
| kubernetes_endpoint | |
31+
| ca\_certificate | |
32+
| client\_token | |
33+
| cluster\_name | Cluster name |
34+
| credentials\_path | |
35+
| ip\_range\_pods | The secondary IP range used for pods |
36+
| ip\_range\_services | The secondary IP range used for services |
37+
| kubernetes\_endpoint | |
3938
| location | |
40-
| master_kubernetes_version | The master Kubernetes version |
39+
| master\_kubernetes\_version | The master Kubernetes version |
4140
| network | |
42-
| project_id | |
41+
| project\_id | |
4342
| region | |
4443
| subnetwork | |
4544
| zones | List of zones in which the cluster resides |

0 commit comments

Comments
 (0)