forked from googleforgames/agones
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix failing GKE cluster creation in custom VPC (Terraform)
When creating a GKE cluster in terraform with a non-default (custom) VPC the subnetwork must be specified otherwise the operation will fail with an expected error. Expected error when subnetwork isn't set: - "Error: googleapi: Error 400: Network "MY-VPC-NAME" requires specifying a subnetwork., badRequest" User should follow the instructions in README.md and specify the required fields based on whether the cluster will run in a default VPC or custom VPC. Tests performed: - Able to create cluster in default VPC in a backwards compatible way - passed - Able to create cluster in a user defined non-default network and subnetwork - passed Reference - googleforgames#1641 - https://www.terraform.io/docs/providers/google/r/container_cluster.html
- Loading branch information
Moe Sy
committed
Jun 25, 2020
1 parent
c8d6dd4
commit 7a6b608
Showing
8 changed files
with
149 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
development.tfvars | ||
production.tfvars |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
This terraform module creates an Agones cluster on GKE. | ||
|
||
# Prerequisites | ||
- Terraform 0.12.x | ||
- Helm 2.x | ||
- An existing GCP Project | ||
- Enabled service API(s) | ||
|
||
# Enabling Service APIs | ||
|
||
Enable each required API below by following [the enabling APIs guide](https://cloud.google.com/endpoints/docs/openapi/enable-api#gcloud). | ||
|
||
Required APIs: | ||
- container.googleapis.com (Kubernetes) | ||
|
||
# Examples | ||
|
||
## Create an Agones in a default VPC. | ||
|
||
|
||
Required fields: | ||
- project | ||
|
||
```terraform apply -var project="<YOUR_GCP_ProjectID>" [-var agones_version="1.6.0"]``` | ||
|
||
## Create an Agones cluster in a custom VPC. | ||
Required fields: | ||
- project | ||
- network | ||
- subnetwork | ||
|
||
|
||
```terraform apply -var project="<YOUR_GCP_ProjectID>" -var network="<YOUR_NETWORK_NAME>" -var subnetwork="<YOUR_SUBNETWORK_NAME>" [-var agones_version="1.6.0"]``` | ||
|
||
# Troubleshooting | ||
|
||
## Unknown command "init" for "helm" | ||
```Error: Error running command 'helm init --client-only': exit status 1. Output: Error: unknown command "init" for "helm``` | ||
|
||
The above error occurs when helm3 is installed instead of helm2. You must use helm v2.x. Validate your version by running the command bellow: | ||
|
||
```helm version``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
// Copyright 2020 Google LLC All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
provider "google" { | ||
version = "~> 2.10" | ||
} | ||
|
||
provider "google-beta" { | ||
version = "~> 2.10" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
output "host" { | ||
value = module.gke_cluster.host | ||
} | ||
output "token" { | ||
value = module.gke_cluster.token | ||
} | ||
output "cluster_ca_certificate" { | ||
value = module.gke_cluster.cluster_ca_certificate | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright 2020 Google LLC All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
variable "project" { | ||
default = "" | ||
} | ||
|
||
variable "name" { | ||
default = "agones-terraform-example" | ||
} | ||
|
||
// Install latest version of agones | ||
variable "agones_version" { | ||
default = "" | ||
} | ||
|
||
variable "machine_type" { | ||
default = "n1-standard-4" | ||
} | ||
|
||
// Note: This is the number of gameserver nodes. The Agones module will automatically create an additional | ||
// two node pools with 1 node each for "agones-system" and "agones-metrics". | ||
variable "node_count" { | ||
default = "4" | ||
description = "The number of gameserver nodes." | ||
} | ||
|
||
variable "zone" { | ||
default = "us-west1-c" | ||
description = "The GCP zone to create the cluster in" | ||
} | ||
|
||
variable "network" { | ||
description = "The name of the VPC network to attach the cluster and firewall rule to" | ||
} | ||
|
||
variable "subnetwork" { | ||
default = "" | ||
description = "The subnetwork to host the cluster in. Required field if network value isn't 'default'." | ||
} | ||
|
||
variable "log_level" { | ||
default = "info" | ||
} | ||
|
||
variable "feature_gates" { | ||
default = "" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters