-
Notifications
You must be signed in to change notification settings - Fork 818
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It provisions all necessary resouces and firewall rules. Helm provider left in TODO, because adding it makes "terraform destroy" fail.
- Loading branch information
Showing
10 changed files
with
399 additions
and
5 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,72 @@ | ||
// Copyright 2019 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. | ||
|
||
|
||
// Run: | ||
// terraform apply [-var agones_version="1.0.0"] | ||
|
||
// Install latest version of agones | ||
variable "agones_version" { | ||
default = "1.0.0" | ||
} | ||
variable "cluster_name" { | ||
default = "agones-cluster" | ||
} | ||
|
||
variable "region" { | ||
default = "us-west-2" | ||
} | ||
|
||
provider "aws" { | ||
version = "~> 2.8" | ||
region = var.region | ||
} | ||
|
||
variable "machine_type" { default = "t2.large" } | ||
|
||
module "eks_cluster" { | ||
source = "git::https://github.com/googleforgames/agones.git//install/terraform/modules/eks/?ref=master" | ||
|
||
machine_type = "${var.machine_type}" | ||
cluster_name = "${var.cluster_name}" | ||
} | ||
|
||
data "aws_eks_cluster_auth" "example" { | ||
name = "${var.cluster_name}" | ||
} | ||
|
||
// TODO(alekser): Add Helm submodule | ||
// When next Helm module is used, "terraform destroy" would not succeed. | ||
// This section is waiting till EKS Terraform provider will be fixed. | ||
// Currently "helm install" should be executed from the CLI. | ||
/* | ||
module "helm_agones" { | ||
source = "git::https://github.com/googleforgames/agones.git//install/terraform/modules/helm/?ref=master" | ||
udp_expose = "false" | ||
agones_version = "${var.agones_version}" | ||
values_file = "" | ||
chart = "agones" | ||
host = "${module.eks_cluster.host}" | ||
token = "${data.aws_eks_cluster_auth.example.token}" | ||
cluster_ca_certificate = "${module.eks_cluster.cluster_ca_certificate}" | ||
} | ||
*/ | ||
|
||
output "host" { | ||
value = "${module.eks_cluster.host}" | ||
} | ||
output "cluster_ca_certificate" { | ||
value = "${module.eks_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,112 @@ | ||
# Copyright 2019 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. | ||
|
||
|
||
terraform { | ||
required_version = ">= 0.12.6" | ||
} | ||
|
||
provider "aws" { | ||
version = "~> 2.8" | ||
region = var.region | ||
} | ||
|
||
data "aws_availability_zones" "available" { | ||
} | ||
|
||
resource "aws_security_group" "worker_group_mgmt_one" { | ||
name_prefix = "worker_group_mgmt_one" | ||
vpc_id = module.vpc.vpc_id | ||
|
||
ingress { | ||
from_port = 22 | ||
to_port = 22 | ||
protocol = "tcp" | ||
|
||
cidr_blocks = [ | ||
"10.0.0.0/8", | ||
] | ||
} | ||
ingress { | ||
from_port = 7000 | ||
to_port = 8000 | ||
protocol = "udp" | ||
|
||
cidr_blocks = [ | ||
"0.0.0.0/0", | ||
] | ||
} | ||
|
||
egress { | ||
from_port = 0 | ||
to_port = 0 | ||
protocol = "-1" | ||
cidr_blocks = ["0.0.0.0/0"] | ||
} | ||
} | ||
|
||
module "vpc" { | ||
source = "terraform-aws-modules/vpc/aws" | ||
version = "2.21.0" | ||
|
||
name = "test-vpc-lt" | ||
cidr = "10.0.0.0/16" | ||
azs = data.aws_availability_zones.available.names | ||
public_subnets = ["10.0.4.0/24", "10.0.5.0/24", "10.0.6.0/24"] | ||
enable_dns_hostnames = false | ||
|
||
tags = { | ||
"kubernetes.io/cluster/${var.cluster_name}" = "shared" | ||
} | ||
|
||
public_subnet_tags = { | ||
"kubernetes.io/cluster/${var.cluster_name}" = "shared" | ||
"kubernetes.io/role/elb" = "1" | ||
} | ||
} | ||
|
||
module "eks" { | ||
source = "git::github.com/terraform-aws-modules/terraform-aws-eks.git?ref=v7.0.1" | ||
cluster_name = "${var.cluster_name}" | ||
subnets = module.vpc.public_subnets | ||
vpc_id = module.vpc.vpc_id | ||
cluster_version = "1.13" | ||
|
||
worker_groups_launch_template = [ | ||
{ | ||
name = "default" | ||
instance_type = "${var.machine_type}" | ||
asg_desired_capacity = 4 | ||
asg_min_size = 4 | ||
asg_max_size = 4 | ||
additional_security_group_ids = [aws_security_group.worker_group_mgmt_one.id] | ||
public_ip = true | ||
}, | ||
// Node Pools with taints for metrics and system | ||
{ | ||
name = "agones-system" | ||
instance_type = "${var.machine_type}" | ||
asg_desired_capacity = 1 | ||
kubelet_extra_args = "--node-labels=agones.dev/agones-system=true --register-with-taints=agones.dev/agones-system=true:NoExecute" | ||
public_ip = true | ||
}, | ||
{ | ||
name = "agones-metrics" | ||
instance_type = "${var.machine_type}" | ||
asg_desired_capacity = 1 | ||
kubelet_extra_args = "--node-labels=agones.dev/agones-metrics=true --register-with-taints=agones.dev/agones-metrics=true:NoExecute" | ||
public_ip = true | ||
} | ||
] | ||
} |
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,48 @@ | ||
# Copyright 2019 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. | ||
output "cluster_endpoint" { | ||
description = "Endpoint for EKS control plane." | ||
value = module.eks.cluster_endpoint | ||
} | ||
|
||
output "cluster_security_group_id" { | ||
description = "Security group ids attached to the cluster control plane." | ||
value = module.eks.cluster_security_group_id | ||
} | ||
|
||
output "kubectl_config" { | ||
description = "kubectl config as generated by the module." | ||
value = module.eks.kubeconfig | ||
} | ||
|
||
output "config_map_aws_auth" { | ||
description = "A kubernetes configuration to authenticate to this EKS cluster." | ||
value = module.eks.config_map_aws_auth | ||
} | ||
|
||
output "region" { | ||
description = "AWS region." | ||
value = var.region | ||
} | ||
|
||
|
||
|
||
output "cluster_ca_certificate" { | ||
value = "${base64decode(module.eks.cluster_certificate_authority_data)}" | ||
} | ||
|
||
output "host" { | ||
depends_on = ["module.eks"] | ||
value = "${module.eks.cluster_endpoint}" | ||
} |
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,66 @@ | ||
# Copyright 2019 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 "cluster_name" { | ||
default = "test-cluster" | ||
} | ||
|
||
variable "region" { | ||
default = "us-west-2" | ||
} | ||
|
||
variable "machine_type" { | ||
default = "t2.large" | ||
} | ||
|
||
variable "map_accounts" { | ||
description = "Additional AWS account numbers to add to the aws-auth configmap." | ||
type = list(string) | ||
|
||
default = [ | ||
"777777777777", | ||
"888888888888", | ||
] | ||
} | ||
|
||
variable "map_roles" { | ||
description = "Additional IAM roles to add to the aws-auth configmap." | ||
type = list(map(string)) | ||
|
||
default = [ | ||
{ | ||
role_arn = "arn:aws:iam::66666666666:role/role1" | ||
username = "role1" | ||
group = "system:masters" | ||
}, | ||
] | ||
} | ||
|
||
variable "map_users" { | ||
description = "Additional IAM users to add to the aws-auth configmap." | ||
type = list(map(string)) | ||
|
||
default = [ | ||
{ | ||
user_arn = "arn:aws:iam::66666666666:user/user1" | ||
username = "user1" | ||
group = "system:masters" | ||
}, | ||
{ | ||
user_arn = "arn:aws:iam::66666666666:user/user2" | ||
username = "user2" | ||
group = "system:masters" | ||
}, | ||
] | ||
} |
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
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
Oops, something went wrong.