-
Notifications
You must be signed in to change notification settings - Fork 12
/
ha_dns_name.tf
78 lines (62 loc) · 1.52 KB
/
ha_dns_name.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
69
70
71
72
73
74
75
76
77
78
# This example sets up a HA control plane with DNS-based routing.
terraform {
required_providers {
hcloud = {
source = "hetznercloud/hcloud"
version = "~> 1.38"
}
aws = {
source = "hashicorp/aws"
version = "~> 4.66"
}
}
}
variable "hetzner_token" {}
provider "aws" {
region = "eu-west-1"
}
provider "hcloud" {
token = var.hetzner_token
}
resource "hcloud_ssh_key" "key" {
name = "key"
public_key = file("~/.ssh/id_rsa.pub")
}
# Create a server
module "cluster" {
source = "tibordp/dualstack-k8s/hcloud"
name = "k8s"
hcloud_ssh_key = hcloud_ssh_key.key.id
hcloud_token = var.hetzner_token
location = "nbg1"
server_type = "cpx31"
node_count = 3
control_plane_endpoint = "k8s.example.com"
}
module "workers" {
source = "tibordp/dualstack-k8s/hcloud//modules/worker-node"
cluster = module.cluster
count = 3
name = "k8s-worker-${count.index}"
hcloud_ssh_key = hcloud_ssh_key.key.id
location = "nbg1"
server_type = "cpx31"
}
resource "aws_route53_record" "api_server_aaaa" {
name = "k8s.example.com"
records = module.cluster.control_plane_nodes.*.ipv6_address
ttl = "60"
type = "AAAA"
zone_id = "<zone id>"
}
resource "aws_route53_record" "api_server_a" {
name = "k8s.example.com"
records = module.cluster.control_plane_nodes.*.ipv4_address
ttl = "60"
type = "A"
zone_id = "<zone id>"
}
output "kubeconfig" {
value = module.cluster.kubeconfig
sensitive = true
}