forked from tibordp/terraform-hcloud-dualstack-k8s
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathha_dns_name.tf
69 lines (55 loc) · 1.29 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
# This example sets up a HA control plane with DNS-based routing.
terraform {
required_providers {
hcloud = {
source = "hetznercloud/hcloud"
version = "1.26.0"
}
aws = {
source = "hashicorp/aws"
version = "~> 3.27"
}
}
required_version = ">= 0.14.9"
}
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 "k8s" {
source = "tibordp/dualstack-k8s/hcloud"
name = "k8s"
hcloud_ssh_key = hcloud_ssh_key.key.id
hcloud_token = var.hetzner_token
location = "nbg1"
master_server_type = "cpx31"
worker_server_type = "cpx31"
worker_count = 3
master_count = 3
control_plane_endpoint = "k8s.example.com"
}
resource "aws_route53_record" "api_server_aaaa" {
name = "k8s.example.com"
records = module.k8s.masters.*.ipv6_address
ttl = "60"
type = "AAAA"
zone_id = "<zone id>"
}
resource "aws_route53_record" "api_server_a" {
name = "k8s.example.com"
records = module.k8s.masters.*.ipv4_address
ttl = "60"
type = "A"
zone_id = "<zone id>"
}
output "kubeconfig" {
value = module.k8s.kubeconfig
}