Skip to content

Commit

Permalink
refact: clean custom flags feature
Browse files Browse the repository at this point in the history
  • Loading branch information
xunleii committed Nov 27, 2019
1 parent d47cff4 commit 14ec6b0
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 22 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,15 @@ module "k3s" {
cluster_service_cidr = "10.1.0.0/16"
additional_tls_san = ["k3s.my.domain.com"]
custom_server_args = ["-v 10"]
additional_flags = {
master = []
minion = [
"--node-label node-role.kubernetes.io/minion='true'",
]
common = [
"--no-flannel"
]
}
master_node = {
# This IP will be used as k3s master node IP.... if you want to use a public
Expand Down
16 changes: 9 additions & 7 deletions examples/hcloud-k3s/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ module "k3s" {
cluster_service_cidr = "10.1.0.0/16"
drain_timeout = "30s"

custom_server_args = [
"--kube-cloud-controller-manager-arg hcloud"
]
custom_agent_args = [
"-v 10",
"--no-flannel"
]
additional_flags = {
master = []
minion = [
"--node-label node-role.kubernetes.io/minion='true'",
]
common = [
"--no-flannel"
]
}

master_node = {
ip = hcloud_server_network.master_network.ip
Expand Down
4 changes: 2 additions & 2 deletions master.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ locals {
"--service-cidr ${var.cluster_service_cidr}",
local.tls_san_opts,
],
var.custom_server_args,
var.custom_agent_args
var.additional_flags.master,
var.additional_flags.common,
)
master_install_args = join(" ", local.master_install_arg_list)

Expand Down
7 changes: 5 additions & 2 deletions minions.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
locals {
minion_install_arg_list = var.custom_agent_args
minion_install_args = join(" ", local.minion_install_arg_list)
minion_install_arg_list = concat(
var.additional_flags.minion,
var.additional_flags.common,
)
minion_install_args = join(" ", local.minion_install_arg_list)

minion_install_env_list = [
"INSTALL_K3S_VERSION=${local.k3s_version}",
Expand Down
22 changes: 12 additions & 10 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,18 @@ variable "additional_tls_san" {
default = []
}

variable "custom_server_args" {
description = "Additional K3S server commands. (see https://rancher.com/docs/k3s/latest/en/installation/install-options/#k3s-server)"
type = list(string)
default = []
}

variable "custom_agent_args" {
description = "Additional K3S agent commands. (see https://rancher.com/docs/k3s/latest/en/installation/install-options/#k3s-agent)"
type = list(string)
default = []
variable "additional_flags" {
description = "Add additional flags during the k3s installation (see https://rancher.com/docs/k3s/latest/en/installation/install-options/)."
type = object({
master = list(string)
minion = list(string)
common = list(string)
})
default = {
master = []
minion = []
common = []
}
}

variable "master_node" {
Expand Down

0 comments on commit 14ec6b0

Please sign in to comment.