Skip to content

Commit c821e36

Browse files
committed
ready to merge calico addition
1 parent 31f4eff commit c821e36

File tree

7 files changed

+13
-13
lines changed

7 files changed

+13
-13
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ _Please note that we are not affiliated to Hetzner, this is just an open source
3737
- Proper use of the Hetzner private network to minimize latency and remove the need for encryption.
3838
- Automatic HA with the default setting of three control-plane nodes and two agent nodes.
3939
- Super-HA: Nodepools for both control-plane and agent nodes can be in different locations.
40-
- Possibility to have a single node cluster with a proper ingress controller (Traefik).
40+
- Possibility to have a single node cluster with a proper ingress controller.
4141
- Ability to add nodes and nodepools when the cluster running.
4242
- Traefik ingress controller attached to a Hetzner load balancer with proxy protocol turned on.
4343
- Tons of flexible configuration options to suits all needs.

agents.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module "agents" {
22
source = "./modules/host"
33

4-
for_each = local.agent_nodepools
4+
for_each = local.agent_nodes
55

66
name = "${var.use_cluster_name_in_node_name ? "${var.cluster_name}-" : ""}${each.value.nodepool_name}"
77
ssh_keys = [hcloud_ssh_key.k3s.id]
@@ -27,7 +27,7 @@ module "agents" {
2727
}
2828

2929
resource "null_resource" "agents" {
30-
for_each = local.agent_nodepools
30+
for_each = local.agent_nodes
3131

3232
triggers = {
3333
agent_id = module.agents[each.key].id

control_planes.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module "control_planes" {
22
source = "./modules/host"
33

4-
for_each = local.control_plane_nodepools
4+
for_each = local.control_plane_nodes
55

66
name = "${var.use_cluster_name_in_node_name ? "${var.cluster_name}-" : ""}${each.value.nodepool_name}"
77
ssh_keys = [hcloud_ssh_key.k3s.id]
@@ -29,7 +29,7 @@ module "control_planes" {
2929
}
3030

3131
resource "null_resource" "control_planes" {
32-
for_each = local.control_plane_nodepools
32+
for_each = local.control_plane_nodes
3333

3434
triggers = {
3535
control_plane_id = module.control_planes[each.key].id

init.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ resource "null_resource" "first_control_plane" {
1919
kube-controller-manager-arg = "flex-volume-plugin-dir=/var/lib/kubelet/volumeplugins"
2020
node-ip = module.control_planes[keys(module.control_planes)[0]].private_ipv4_address
2121
advertise-address = module.control_planes[keys(module.control_planes)[0]].private_ipv4_address
22-
node-taint = local.control_plane_nodepools[keys(module.control_planes)[0]].taints
23-
node-label = local.control_plane_nodepools[keys(module.control_planes)[0]].labels
22+
node-taint = local.control_plane_nodes[keys(module.control_planes)[0]].taints
23+
node-label = local.control_plane_nodes[keys(module.control_planes)[0]].labels
2424
disable-network-policy = var.cni_plugin == "calico" ? true : var.disable_network_policy
2525
},
2626
var.cni_plugin == "calico" ? {

locals.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ locals {
172172
install_k3s_server = concat(local.common_commands_install_k3s, ["curl -sfL https://get.k3s.io | INSTALL_K3S_SKIP_START=true INSTALL_K3S_SKIP_SELINUX_RPM=true INSTALL_K3S_CHANNEL=${var.initial_k3s_channel} INSTALL_K3S_EXEC=server sh -"], local.apply_k3s_selinux)
173173
install_k3s_agent = concat(local.common_commands_install_k3s, ["curl -sfL https://get.k3s.io | INSTALL_K3S_SKIP_START=true INSTALL_K3S_SKIP_SELINUX_RPM=true INSTALL_K3S_CHANNEL=${var.initial_k3s_channel} INSTALL_K3S_EXEC=agent sh -"], local.apply_k3s_selinux)
174174

175-
control_plane_nodepools = merge([
175+
control_plane_nodes = merge([
176176
for pool_index, nodepool_obj in var.control_plane_nodepools : {
177177
for node_index in range(nodepool_obj.count) :
178178
format("%s-%s-%s", pool_index, node_index, nodepool_obj.name) => {
@@ -186,7 +186,7 @@ locals {
186186
}
187187
]...)
188188

189-
agent_nodepools = merge([
189+
agent_nodes = merge([
190190
for pool_index, nodepool_obj in var.agent_nodepools : {
191191
for node_index in range(nodepool_obj.count) :
192192
format("%s-%s-%s", pool_index, node_index, nodepool_obj.name) => {

main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ resource "hcloud_network" "k3s" {
1616
# We start from the end of the subnets cird array,
1717
# as we would have fewer control plane nodepools, than angent ones.
1818
resource "hcloud_network_subnet" "control_plane" {
19-
count = length(local.control_plane_nodepools)
19+
count = length(var.control_plane_nodepools)
2020
network_id = hcloud_network.k3s.id
2121
type = "cloud"
2222
network_zone = var.network_region
@@ -25,7 +25,7 @@ resource "hcloud_network_subnet" "control_plane" {
2525

2626
# Here we start at the beginning of the subnets cird array
2727
resource "hcloud_network_subnet" "agent" {
28-
count = length(local.agent_nodepools)
28+
count = length(var.agent_nodepools)
2929
network_id = hcloud_network.k3s.id
3030
type = "cloud"
3131
network_zone = var.network_region

terraform.tfvars.example

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ network_region = "eu-central" # change to `us-east` if location is ash
2727
# Once the cluster is created, you can change nodepool count, and even set it to 0 (in the case of the first control-plane nodepool, the minimum is 1),
2828
# you can also rename it (if the count is taken to 0), but do not remove a nodepool from the list after the cluster is created.
2929

30-
# The only nodepools that are safe to remove from the list when you edit it, are the ones at the end of the lists. This is due to how IPs are allocated.
30+
# The only nodepools that are safe to remove from the list when you edit it, are the ones at the end of the lists. This is due to how subnets and IPs are allocated (FILO).
3131
# You can however freely add others nodepools the end of each list if you want! The maximum number of nodepools you can create, combined for both lists is 255.
3232
# Also, before decreasing the count of any nodepools to 0, it's important to drain and cordon it the nodes in question, otherwise it will leave your cluster in a bad state.
3333

@@ -161,7 +161,7 @@ load_balancer_location = "fsn1"
161161

162162
# If you want to configure a different CNI for k3s, use this flag
163163
# possible values: flannel (Default), calico
164-
# cni_plugin = "flannel"
164+
# cni_plugin = "calico"
165165

166166
# If you want to disable the k3s default network policy controller, use this flag
167167
# Calico overrides this value to true automatically

0 commit comments

Comments
 (0)