Skip to content
This repository has been archived by the owner on Jun 29, 2022. It is now read-only.

baremetal: remove enable_tls_bootstrap variable #1380

Merged
merged 1 commit into from
Feb 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ module "bootkube" {
# Disable the self hosted kubelet.
disable_self_hosted_kubelet = var.disable_self_hosted_kubelet

bootstrap_tokens = var.enable_tls_bootstrap ? [local.controller_bootstrap_token, local.worker_bootstrap_token] : []
enable_tls_bootstrap = var.enable_tls_bootstrap
bootstrap_tokens = [local.controller_bootstrap_token, local.worker_bootstrap_token]
enable_tls_bootstrap = true
encrypt_pod_traffic = var.encrypt_pod_traffic

ignore_x509_cn_check = var.ignore_x509_cn_check
Expand Down
Original file line number Diff line number Diff line change
@@ -1,46 +1,38 @@
locals {
controller_bootstrap_token = var.enable_tls_bootstrap ? {
token_id = random_string.bootstrap_token_id_controller[0].result
token_secret = random_string.bootstrap_token_secret_controller[0].result
} : {}

worker_bootstrap_token = var.enable_tls_bootstrap ? {
token_id = random_string.bootstrap_token_id_worker[0].result
token_secret = random_string.bootstrap_token_secret_worker[0].result
} : {}
controller_bootstrap_token = {
token_id = random_string.bootstrap_token_id_controller.result
token_secret = random_string.bootstrap_token_secret_controller.result
}

worker_bootstrap_token = {
token_id = random_string.bootstrap_token_id_worker.result
token_secret = random_string.bootstrap_token_secret_worker.result
}
}

# Generate a cryptographically random token id (public).
resource "random_string" "bootstrap_token_id_controller" {
count = var.enable_tls_bootstrap == true ? 1 : 0

length = 6
upper = false
special = false
}

# Generate a cryptographically random token secret.
resource "random_string" "bootstrap_token_secret_controller" {
count = var.enable_tls_bootstrap == true ? 1 : 0

length = 16
upper = false
special = false
}

# Generate a cryptographically random token id (public).
resource "random_string" "bootstrap_token_id_worker" {
count = var.enable_tls_bootstrap == true ? 1 : 0

length = 6
upper = false
special = false
}

# Generate a cryptographically random token secret.
resource "random_string" "bootstrap_token_secret_worker" {
count = var.enable_tls_bootstrap == true ? 1 : 0

length = 16
upper = false
special = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,9 @@ systemd:
--config=/etc/kubernetes/kubelet.config \
--exit-on-lock-contention \
--hostname-override=${domain_name} \
%{~ if enable_tls_bootstrap ~}
--kubeconfig=/var/lib/kubelet/kubeconfig \
--bootstrap-kubeconfig=/etc/kubernetes/kubeconfig \
--rotate-certificates \
%{~ else ~}
--kubeconfig=/etc/kubernetes/kubeconfig \
%{~ endif ~}
--lock-file=/var/run/lock/kubelet.lock \
--network-plugin=cni \
--node-labels=$${NODE_LABELS} \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,9 @@ systemd:
--config=/etc/kubernetes/kubelet.config \
--exit-on-lock-contention \
--hostname-override=${domain_name} \
%{~ if enable_tls_bootstrap ~}
--kubeconfig=/var/lib/kubelet/kubeconfig \
--bootstrap-kubeconfig=/etc/kubernetes/kubeconfig \
--rotate-certificates \
%{~ else ~}
--kubeconfig=/etc/kubernetes/kubeconfig \
%{~ endif ~}
--lock-file=/var/run/lock/kubelet.lock \
--network-plugin=cni \
--node-labels=$${NODE_LABELS} \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ data "ct_config" "controller-ignitions" {
cluster_dns_service_ip = module.bootkube.cluster_dns_service_ip
cluster_domain_suffix = var.cluster_domain_suffix
ssh_keys = jsonencode(var.ssh_keys)
enable_tls_bootstrap = var.enable_tls_bootstrap
})
pretty_print = false

Expand All @@ -126,7 +125,6 @@ data "ct_config" "worker-ignitions" {
cluster_domain_suffix = var.cluster_domain_suffix
ssh_keys = jsonencode(var.ssh_keys)
kubelet_labels = merge({ "node.kubernetes.io/node" = "" }, var.labels),
enable_tls_bootstrap = var.enable_tls_bootstrap
})
pretty_print = false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ resource "null_resource" "copy-controller-secrets" {
}

provisioner "file" {
content = var.enable_tls_bootstrap ? templatefile("${path.module}/cl/bootstrap-kubeconfig.yaml.tmpl", {
token_id = random_string.bootstrap_token_id_controller[0].result
token_secret = random_string.bootstrap_token_secret_controller[0].result
content = templatefile("${path.module}/cl/bootstrap-kubeconfig.yaml.tmpl", {
token_id = random_string.bootstrap_token_id_controller.result
token_secret = random_string.bootstrap_token_secret_controller.result
ca_cert = module.bootkube.ca_cert
server = "https://${var.k8s_domain_name}:6443"
}) : module.bootkube.kubeconfig-kubelet
})
destination = "$HOME/kubeconfig"
}

Expand Down Expand Up @@ -99,12 +99,12 @@ resource "null_resource" "copy-worker-secrets" {
}

provisioner "file" {
content = var.enable_tls_bootstrap ? templatefile("${path.module}/cl/bootstrap-kubeconfig.yaml.tmpl", {
token_id = random_string.bootstrap_token_id_worker[0].result
token_secret = random_string.bootstrap_token_secret_worker[0].result
content = templatefile("${path.module}/cl/bootstrap-kubeconfig.yaml.tmpl", {
token_id = random_string.bootstrap_token_id_worker.result
token_secret = random_string.bootstrap_token_secret_worker.result
ca_cert = module.bootkube.ca_cert
server = "https://${var.k8s_domain_name}:6443"
}) : module.bootkube.kubeconfig-kubelet
})
destination = "$HOME/kubeconfig"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,6 @@ variable "disable_self_hosted_kubelet" {
type = bool
}

variable "enable_tls_bootstrap" {
description = "Enable TLS Bootstrap for Kubelet."
type = bool
}

# Certificates

variable "certs_validity_period_hours" {
Expand Down
3 changes: 0 additions & 3 deletions docs/configuration-reference/platforms/baremetal.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ cluster "bare-metal" {

os_channel = "stable"

enable_tls_bootstrap = true

encrypt_pod_traffic = true

conntrack_max_per_core = 32768
Expand Down Expand Up @@ -170,7 +168,6 @@ os_version = var.custom_default_os_version
| `ssh_pubkeys` | List of SSH public keys for user `core`. Each element must be specified in a valid OpenSSH public key format, as defined in RFC 4253 Section 6.6, e.g. "ssh-rsa AAAAB3N...". | - | list(string) | true |
| `os_version` | Flatcar Container Linux version to install. Version such as "2303.3.1" or "current". | "current" | string | false |
| `os_channel` | Flatcar Container Linux channel to install from ("stable", "beta", "alpha", "edge"). | "stable" | string | false |
| `enable_tls_bootstrap` | Enable TLS bootstraping for Kubelet. | true | bool | false |
| `encrypt_pod_traffic` | Enable in-cluster pod traffic encryption. If true `network_mtu` is reduced by 60 to make room for the encryption header. | false | bool | false |
| `ignore_x509_cn_check` | Ignore check of common name in x509 certificates. If any application is built pre golang 1.15 then API server rejects x509 from such application, enable this to get around apiserver. | false | bool | false |
| `install_to_smallest_disk` | Installs Flatcar Container Linux to the smallest disk. | false | bool | false |
Expand Down
28 changes: 14 additions & 14 deletions pkg/assets/generated_assets.go

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions pkg/platform/baremetal/baremetal.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ type config struct {
WorkerDomains []string `hcl:"worker_domains"`
Labels map[string]string `hcl:"labels,optional"`
OIDC *oidc.Config `hcl:"oidc,block"`
EnableTLSBootstrap bool `hcl:"enable_tls_bootstrap,optional"`
EncryptPodTraffic bool `hcl:"encrypt_pod_traffic,optional"`
IgnoreX509CNCheck bool `hcl:"ignore_x509_cn_check,optional"`
ConntrackMaxPerCore int `hcl:"conntrack_max_per_core,optional"`
Expand Down Expand Up @@ -97,7 +96,6 @@ func NewConfig() *config {
CachedInstall: "false",
OSChannel: "stable",
OSVersion: "current",
EnableTLSBootstrap: true,
NetworkMTU: platform.NetworkMTU,
ConntrackMaxPerCore: platform.ConntrackMaxPerCore,
DownloadProtocol: "https",
Expand Down Expand Up @@ -223,7 +221,6 @@ func createTerraformConfigFile(cfg *config, terraformPath string) error {
DisableSelfHostedKubelet bool
KubeAPIServerExtraFlags []string
Labels map[string]string
EnableTLSBootstrap bool
EncryptPodTraffic bool
IgnoreX509CNCheck bool
ConntrackMaxPerCore int
Expand Down Expand Up @@ -255,7 +252,6 @@ func createTerraformConfigFile(cfg *config, terraformPath string) error {
DisableSelfHostedKubelet: cfg.DisableSelfHostedKubelet,
KubeAPIServerExtraFlags: cfg.KubeAPIServerExtraFlags,
Labels: cfg.Labels,
EnableTLSBootstrap: cfg.EnableTLSBootstrap,
EncryptPodTraffic: cfg.EncryptPodTraffic,
IgnoreX509CNCheck: cfg.IgnoreX509CNCheck,
ConntrackMaxPerCore: cfg.ConntrackMaxPerCore,
Expand Down
3 changes: 0 additions & 3 deletions pkg/platform/baremetal/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ module "bare-metal-{{.ClusterName}}" {
# Disable self hosted kubelet
disable_self_hosted_kubelet = {{ .DisableSelfHostedKubelet }}

# Enable TLS Bootstrap
enable_tls_bootstrap = {{ .EnableTLSBootstrap }}

{{- if .EncryptPodTraffic }}
encrypt_pod_traffic = {{ .EncryptPodTraffic }}
{{- end }}
Expand Down