-
Notifications
You must be signed in to change notification settings - Fork 12
/
private_network.tf
75 lines (59 loc) · 1.74 KB
/
private_network.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
# A simple dual-stack cluster with Hetzner Cloud private networks
terraform {
required_providers {
hcloud = {
source = "hetznercloud/hcloud"
version = "~> 1.38"
}
}
}
variable "hetzner_token" {}
provider "hcloud" {
token = vars.hetzner_token
}
resource "hcloud_ssh_key" "key" {
name = "key"
public_key = file("~/.ssh/id_rsa.pub")
}
module "cluster" {
source = "tibordp/dualstack-k8s/hcloud"
name = "k8s"
hcloud_ssh_key = hcloud_ssh_key.key.id
hcloud_token = vars.hetzner_token
location = "hel1"
server_type = "cpx31"
# The default pod_cidr_ipv6 is 10.96.0.0/16. This can be customized,
# but it should be within the range of the private network. Also, it should
# not overlap with the subnet specified below, as that subnet is used for nodes.
# pod_cidr_ipv4 = "10.96.0.0/16"
use_hcloud_network = true
hcloud_network_id = hcloud_network.my_net.id
hcloud_subnet_id = hcloud_network_subnet.my_subnet.id
}
module "workers" {
source = "tibordp/dualstack-k8s/hcloud//modules/worker-node"
cluster = module.cluster
count = 2
name = "k8s-worker-${count.index}"
hcloud_ssh_key = hcloud_ssh_key.key.id
location = "hel1"
server_type = "cpx31"
use_hcloud_network = true
hcloud_network_id = hcloud_network.my_net.id
hcloud_subnet_id = hcloud_network_subnet.my_subnet.id
}
resource "hcloud_network" "my_net" {
name = "my-net"
ip_range = "10.0.0.0/8"
}
# This subnet is used for nodes
resource "hcloud_network_subnet" "my_subnet" {
network_id = hcloud_network.my_net.id
type = "cloud"
network_zone = "eu-central"
ip_range = "10.0.0.0/16"
}
output "kubeconfig" {
value = module.cluster.kubeconfig
sensitive = true
}