-
Notifications
You must be signed in to change notification settings - Fork 0
/
controller.tf
68 lines (59 loc) · 1.94 KB
/
controller.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
resource "aws_instance" "cluster-controller" {
count = var.controller_count
ami = data.aws_ami.ubuntu.id
instance_type = var.controller_flavor
tags = {
Name = "${var.cluster_name}-controller-${count.index + 1}",
"Role" = "controller+worker",
"kubernetes.io/cluster/${var.cluster_name}" = "owned",
"Creator" = "[email protected]"
}
key_name = aws_key_pair.cluster-key.key_name
vpc_security_group_ids = [aws_security_group.cluster_allow_ssh.id]
iam_instance_profile = "${var.iam_instance_profile}"
associate_public_ip_address = true
ebs_optimized = true
user_data = <<EOF
#!/bin/bash
# Use full qualified private DNS name for the host name. Kube wants it this way.
HOSTNAME=$(curl http://169.254.169.254/latest/meta-data/hostname)
echo $HOSTNAME > /etc/hostname
sed -i "s|\(127\.0\..\.. *\)localhost|\1$HOSTNAME|" /etc/hosts
hostname $HOSTNAME
EOF
lifecycle {
ignore_changes = [ami]
}
root_block_device {
volume_type = "gp2"
volume_size = 50
}
provisioner "remote-exec" {
inline = ["sudo mkdir -p /var/lib/k0s/manifests/aws"]
connection {
type = "ssh"
user = "ubuntu"
private_key = tls_private_key.k0sctl.private_key_pem
host = self.public_ip
}
}
provisioner "file" {
source = "./manifests/aws-ebs-storageclass.yaml"
destination = "/tmp/aws-ebs-storageclass.yaml"
connection {
type = "ssh"
user = "ubuntu"
private_key = tls_private_key.k0sctl.private_key_pem
host = self.public_ip
}
}
provisioner "remote-exec" {
inline = ["sudo mv /tmp/aws-ebs-storageclass.yaml /var/lib/k0s/manifests/aws/aws-ebs-storageclass.yaml"]
connection {
type = "ssh"
user = "ubuntu"
private_key = tls_private_key.k0sctl.private_key_pem
host = self.public_ip
}
}
}