Skip to content

Instantly share code, notes, and snippets.

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"
- hosts: etcd
roles:
- common
- etcd
- hosts: controller
roles:
- common
- controller
- hosts: all
gather_facts: false
tasks:
- name: Install Python
raw: "apt-get -y -q install python"
become: true
# Expects `kubernetes_api_endpoint` as `--extra-vars "kubernetes_api_endpoint=xxxx"`
- hosts: 127.0.0.1
connection: local
tasks:
- name: Set kubectl endpoint
shell: "kubectl config set-cluster {{ cluster_name }} --certificate-authority={{ playbook_dir }}/../cert/ca.pem --embed-certs=true --server=https://{{ kubernetes_api_endpoint }}:6443"
- name: Set kubectl credentials
shell: "kubectl config set-credentials {{ user }} --token {{ token }}"
- 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:
[defaults]
...
inventory = ./hosts/
...
@nicusX
nicusX / k8snthw-groups
Last active August 11, 2016 10:34
Ansible groups
[tag_ansibleNodeType_etcd]
[tag_ansibleNodeType_worker]
[tag_ansibleNodeType_controller]
[etcd:children]
tag_ansibleNodeType_etcd
[worker:children]
tag_ansibleNodeType_worker
[ec2]
instance_filters = tag:ansibleFilter=Kubernetes01
regions = eu-west-1
destination_variable = ip_address
vpc_destination_variable = ip_address
hostname_variable = tag_ansibleNodeName
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
resource "aws_instance" "worker" {
count = 3
...
tags {
Owner = "Lorenzo"
Name = "worker-${count.index}"
ansibleFilter = "Kubernetes01"
ansibleNodeType = "worker"
ansibleNodeName = "worker${count.index}"
}