This file contains hidden or 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
- name: Create etcd config dir | |
file: path=/etc/etcd state=directory | |
become: true | |
- name: Copy certificates | |
copy: | |
src: "{{ playbook_dir }}/../cert/{{ item }}" | |
dest: "/etc/etcd/" | |
become: true | |
with_items: |
This file contains hidden or 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
[defaults] | |
... | |
inventory = ./hosts/ | |
... |
This file contains hidden or 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 |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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" |