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
resource "aws_vpc" "kubernetes" { | |
cidr_block = "10.43.0.0/16" | |
enable_dns_hostnames = true | |
} | |
resource "aws_subnet" "kubernetes" { | |
vpc_id = "${aws_vpc.kubernetes.id}" | |
cidr_block = "10.43.0.0/16" | |
availability_zone = "eu-west-1a" | |
} |
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
resource "aws_internet_gateway" "gw" { | |
vpc_id = "${aws_vpc.kubernetes.id}" | |
} | |
resource "aws_route_table" "kubernetes" { | |
vpc_id = "${aws_vpc.kubernetes.id}" | |
route { | |
cidr_block = "0.0.0.0/0" | |
gateway_id = "${aws_internet_gateway.gw.id}" | |
} |
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
resource "aws_instance" "etcd" { | |
count = 3 | |
ami = "ami-1967056a" // Unbuntu 16.04 LTS HVM, EBS-SSD | |
instance_type = "t2.micro" | |
subnet_id = "${aws_subnet.kubernetes.id}" | |
private_ip = "${cidrhost("10.43.0.0/16", 10 + count.index)}" | |
associate_public_ip_address = true | |
availability_zone = "eu-west-1a" |
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
resource "aws_elb" "kubernetes_api" { | |
name = "kube-api" | |
instances = ["${aws_instance.controller.*.id}"] | |
subnets = ["${aws_subnet.kubernetes.id}"] | |
cross_zone_load_balancing = false | |
security_groups = ["${aws_security_group.kubernetes_api.id}"] | |
listener { | |
lb_port = 6443 |
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
resource "aws_security_group" "kubernetes" { | |
vpc_id = "${aws_vpc.kubernetes.id}" | |
name = "kubernetes" | |
# Allow all outbound | |
egress { | |
from_port = 0 | |
to_port = 0 | |
protocol = "-1" | |
cidr_blocks = ["0.0.0.0/0"] |
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
# Generate Certificates | |
data "template_file" "certificates" { | |
template = "${file("${path.module}/template/kubernetes-csr.json")}" | |
depends_on = ["aws_elb.kubernetes_api","aws_instance.etcd","aws_instance.controller","aws_instance.worker"] | |
vars { | |
kubernetes_api_elb_dns_name = "${aws_elb.kubernetes_api.dns_name}" | |
kubernetes_cluster_dns = "${var.kubernetes_cluster_dns}" | |
etcd0_ip = "${aws_instance.etcd.0.private_ip}" | |
... | |
controller0_ip = "${aws_instance.controller.0.private_ip}" |
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
- hosts: etcd | |
roles: | |
- common | |
- etcd | |
- hosts: controller | |
roles: | |
- common | |
- controller |
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
[ec2] | |
instance_filters = tag:ansibleFilter=Kubernetes01 | |
regions = eu-west-1 | |
destination_variable = ip_address | |
vpc_destination_variable = ip_address | |
hostname_variable = tag_ansibleNodeName |
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
[tag_ansibleNodeType_etcd] | |
[tag_ansibleNodeType_worker] | |
[tag_ansibleNodeType_controller] | |
[etcd:children] | |
tag_ansibleNodeType_etcd | |
[worker:children] | |
tag_ansibleNodeType_worker |
OlderNewer