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

Commit

Permalink
baremetal: Add a knob to disable self-hosted kubelet
Browse files Browse the repository at this point in the history
This commit adds a boolean variable to controller config called
`disable_self_hosted_kubelet`.

Signed-off-by: Suraj Deshmukh <suraj@kinvolk.io>
  • Loading branch information
surajssd committed May 15, 2020
1 parent a09960d commit 07fe3ca
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ module "bootkube" {
enable_aggregation = var.enable_aggregation

certs_validity_period_hours = var.certs_validity_period_hours

# Disable the self hosted kubelet
disable_self_hosted_kubelet = var.disable_self_hosted_kubelet
}
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ variable "enable_aggregation" {
default = true
}

variable "disable_self_hosted_kubelet" {
description = "Disable the self hosted kubelet installed by default"
type = bool
}

# Certificates

variable "certs_validity_period_hours" {
Expand Down
107 changes: 55 additions & 52 deletions pkg/platform/baremetal/baremetal.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,25 @@ import (
)

type config struct {
AssetDir string `hcl:"asset_dir"`
CachedInstall string `hcl:"cached_install,optional"`
ClusterName string `hcl:"cluster_name"`
ControllerDomains []string `hcl:"controller_domains"`
ControllerMacs []string `hcl:"controller_macs"`
ControllerNames []string `hcl:"controller_names"`
K8sDomainName string `hcl:"k8s_domain_name"`
MatchboxCAPath string `hcl:"matchbox_ca_path"`
MatchboxClientCertPath string `hcl:"matchbox_client_cert_path"`
MatchboxClientKeyPath string `hcl:"matchbox_client_key_path"`
MatchboxEndpoint string `hcl:"matchbox_endpoint"`
MatchboxHTTPEndpoint string `hcl:"matchbox_http_endpoint"`
OSChannel string `hcl:"os_channel,optional"`
OSVersion string `hcl:"os_version,optional"`
SSHPubKeys []string `hcl:"ssh_pubkeys"`
WorkerNames []string `hcl:"worker_names"`
WorkerMacs []string `hcl:"worker_macs"`
WorkerDomains []string `hcl:"worker_domains"`
AssetDir string `hcl:"asset_dir"`
CachedInstall string `hcl:"cached_install,optional"`
ClusterName string `hcl:"cluster_name"`
ControllerDomains []string `hcl:"controller_domains"`
ControllerMacs []string `hcl:"controller_macs"`
ControllerNames []string `hcl:"controller_names"`
DisableSelfHostedKubelet bool `hcl:"disable_self_hosted_kubelet,optional"`
K8sDomainName string `hcl:"k8s_domain_name"`
MatchboxCAPath string `hcl:"matchbox_ca_path"`
MatchboxClientCertPath string `hcl:"matchbox_client_cert_path"`
MatchboxClientKeyPath string `hcl:"matchbox_client_key_path"`
MatchboxEndpoint string `hcl:"matchbox_endpoint"`
MatchboxHTTPEndpoint string `hcl:"matchbox_http_endpoint"`
OSChannel string `hcl:"os_channel,optional"`
OSVersion string `hcl:"os_version,optional"`
SSHPubKeys []string `hcl:"ssh_pubkeys"`
WorkerNames []string `hcl:"worker_names"`
WorkerMacs []string `hcl:"worker_macs"`
WorkerDomains []string `hcl:"worker_domains"`
}

// init registers bare-metal as a platform
Expand Down Expand Up @@ -156,41 +157,43 @@ func createTerraformConfigFile(cfg *config, terraformPath string) error {
}

terraformCfg := struct {
CachedInstall string
ClusterName string
ControllerDomains string
ControllerMacs string
ControllerNames string
K8sDomainName string
MatchboxClientCert string
MatchboxClientKey string
MatchboxCA string
MatchboxEndpoint string
MatchboxHTTPEndpoint string
OSChannel string
OSVersion string
SSHPublicKeys string
WorkerNames string
WorkerMacs string
WorkerDomains string
CachedInstall string
ClusterName string
ControllerDomains string
ControllerMacs string
ControllerNames string
K8sDomainName string
MatchboxClientCert string
MatchboxClientKey string
MatchboxCA string
MatchboxEndpoint string
MatchboxHTTPEndpoint string
OSChannel string
OSVersion string
SSHPublicKeys string
WorkerNames string
WorkerMacs string
WorkerDomains string
DisableSelfHostedKubelet bool
}{
CachedInstall: cfg.CachedInstall,
ClusterName: cfg.ClusterName,
ControllerDomains: string(controllerDomains),
ControllerMacs: string(controllerMacs),
ControllerNames: string(controllerNames),
K8sDomainName: cfg.K8sDomainName,
MatchboxCA: cfg.MatchboxCAPath,
MatchboxClientCert: cfg.MatchboxClientCertPath,
MatchboxClientKey: cfg.MatchboxClientKeyPath,
MatchboxEndpoint: cfg.MatchboxEndpoint,
MatchboxHTTPEndpoint: cfg.MatchboxHTTPEndpoint,
OSChannel: cfg.OSChannel,
OSVersion: cfg.OSVersion,
SSHPublicKeys: string(keyListBytes),
WorkerNames: string(workerNames),
WorkerMacs: string(workerMacs),
WorkerDomains: string(workerDomains),
CachedInstall: cfg.CachedInstall,
ClusterName: cfg.ClusterName,
ControllerDomains: string(controllerDomains),
ControllerMacs: string(controllerMacs),
ControllerNames: string(controllerNames),
K8sDomainName: cfg.K8sDomainName,
MatchboxCA: cfg.MatchboxCAPath,
MatchboxClientCert: cfg.MatchboxClientCertPath,
MatchboxClientKey: cfg.MatchboxClientKeyPath,
MatchboxEndpoint: cfg.MatchboxEndpoint,
MatchboxHTTPEndpoint: cfg.MatchboxHTTPEndpoint,
OSChannel: cfg.OSChannel,
OSVersion: cfg.OSVersion,
SSHPublicKeys: string(keyListBytes),
WorkerNames: string(workerNames),
WorkerMacs: string(workerMacs),
WorkerDomains: string(workerDomains),
DisableSelfHostedKubelet: cfg.DisableSelfHostedKubelet,
}

if err := t.Execute(f, terraformCfg); err != nil {
Expand Down
3 changes: 3 additions & 0 deletions pkg/platform/baremetal/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ module "bare-metal-{{.ClusterName}}" {
os_channel = "{{.OSChannel}}"
os_version = "{{.OSVersion}}"
# Disable self hosted kubelet
disable_self_hosted_kubelet = {{ .DisableSelfHostedKubelet }}
# configuration
cached_install = "{{.CachedInstall}}"
k8s_domain_name = "{{.K8sDomainName}}"
Expand Down

0 comments on commit 07fe3ca

Please sign in to comment.