This repository has been archived by the owner on Jun 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit adds Tinkerbell as a supported platform by the Lokomotive. The Terraform code consumes newly introduced controller and worker Terraform modules, which reduces the amount of code required for introducing this new platform. The commit currently lacks several parts, which will be added at later stage: - Unit tests - Configuration validation rules - CI implementation - Reference documentation - Quick start guide Closes #382. Signed-off-by: Mateusz Gozdek <[email protected]>
- Loading branch information
Showing
40 changed files
with
2,554 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
49 changes: 49 additions & 0 deletions
49
assets/terraform-modules/platforms/tinkerbell/workerpool/main.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
module "worker" { | ||
source = "../../../worker" | ||
|
||
count = var.node_count | ||
count_index = count.index | ||
|
||
cluster_dns_service_ip = var.cluster_dns_service_ip | ||
ssh_keys = var.ssh_keys | ||
cluster_domain_suffix = var.cluster_domain_suffix | ||
host_dns_ip = var.host_dns_ip | ||
ca_cert = var.ca_cert | ||
apiserver = var.apiserver | ||
|
||
clc_snippets = concat(var.clc_snippets, [ | ||
<<EOF | ||
storage: | ||
files: | ||
- path: /etc/hostname | ||
filesystem: root | ||
mode: 0644 | ||
contents: | ||
inline: | | ||
${var.cluster_name}-worker-${var.name}-${count.index} | ||
EOF | ||
, | ||
]) | ||
} | ||
|
||
resource "tinkerbell_template" "main" { | ||
count = var.node_count | ||
|
||
name = "${var.cluster_name}-worker-${var.name}-${count.index}" | ||
|
||
content = templatefile("${path.module}/templates/flatcar-install.tmpl", { | ||
ignition_config = module.worker[count.index].clc_config | ||
flatcar_install_base_url = var.flatcar_install_base_url | ||
os_version = var.os_version | ||
os_channel = var.os_channel | ||
}) | ||
} | ||
|
||
resource "tinkerbell_workflow" "main" { | ||
count = var.node_count | ||
|
||
hardwares = <<EOF | ||
{"device_1": "${var.ip_addresses[count.index]}"} | ||
EOF | ||
template = tinkerbell_template.main[count.index].id | ||
} |
3 changes: 3 additions & 0 deletions
3
assets/terraform-modules/platforms/tinkerbell/workerpool/output.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
output "bootstrap_tokens" { | ||
value = module.worker.*.bootstrap_token | ||
} |
1 change: 1 addition & 0 deletions
1
assets/terraform-modules/platforms/tinkerbell/workerpool/templates/flatcar-install.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../controllers/templates/flatcar-install.tmpl |
79 changes: 79 additions & 0 deletions
79
assets/terraform-modules/platforms/tinkerbell/workerpool/variables.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
variable "cluster_name" { | ||
type = string | ||
} | ||
|
||
variable "name" { | ||
type = string | ||
} | ||
|
||
variable "ip_addresses" { | ||
type = list(string) | ||
} | ||
|
||
variable "flatcar_install_base_url" { | ||
type = string | ||
default = "" | ||
} | ||
|
||
variable "os_version" { | ||
type = string | ||
default = "" | ||
} | ||
|
||
variable "os_channel" { | ||
type = string | ||
default = "" | ||
} | ||
|
||
variable "kubeconfig" { | ||
type = string | ||
description = "Content of kubelet's kubeconfig file" | ||
} | ||
|
||
# Required variables. | ||
variable "ssh_keys" { | ||
type = list(string) | ||
description = "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...'." | ||
default = [] | ||
} | ||
|
||
# Optional variables. | ||
variable "node_count" { | ||
type = number | ||
description = "Number of nodes to create." | ||
default = 1 | ||
} | ||
|
||
variable "cluster_dns_service_ip" { | ||
type = string | ||
description = "IP address of cluster DNS Service. Passed to kubelet as --cluster_dns parameter." | ||
default = "10.3.0.10" | ||
} | ||
|
||
variable "clc_snippets" { | ||
type = list(string) | ||
description = "Extra CLC snippets to include in the configuration." | ||
default = [] | ||
} | ||
|
||
variable "cluster_domain_suffix" { | ||
type = string | ||
description = "Cluster domain suffix. Passed to kubelet as --cluster_domain flag." | ||
default = "cluster.local" | ||
} | ||
|
||
variable "host_dns_ip" { | ||
type = string | ||
description = "IP address of DNS server to configure on the nodes." | ||
default = "8.8.8.8" | ||
} | ||
|
||
variable "ca_cert" { | ||
description = "Kubernetes CA certificate needed in the kubeconfig file." | ||
type = string | ||
} | ||
|
||
variable "apiserver" { | ||
description = "Apiserver private endpoint needed in the kubeconfig file." | ||
type = string | ||
} |
12 changes: 12 additions & 0 deletions
12
assets/terraform-modules/platforms/tinkerbell/workerpool/versions.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Terraform version and plugin versions | ||
|
||
terraform { | ||
required_version = ">= 0.13" | ||
|
||
required_providers { | ||
tinkerbell = { | ||
source = "tinkerbell/tinkerbell" | ||
version = "0.1.0" | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
assets/terraform-modules/tinkerbell-sandbox/assets/deploy/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
state |
76 changes: 76 additions & 0 deletions
76
assets/terraform-modules/tinkerbell-sandbox/assets/deploy/db/tinkerbell-init.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
SET ROLE tinkerbell; | ||
|
||
CREATE TABLE IF NOT EXISTS hardware ( | ||
id UUID UNIQUE | ||
, inserted_at TIMESTAMPTZ | ||
, deleted_at TIMESTAMPTZ | ||
, data JSONB | ||
); | ||
|
||
CREATE INDEX IF NOT EXISTS idx_id ON hardware (id); | ||
CREATE INDEX IF NOT EXISTS idx_deleted_at ON hardware (deleted_at NULLS FIRST); | ||
CREATE INDEX IF NOT EXISTS idxgin_type ON hardware USING GIN (data JSONB_PATH_OPS); | ||
|
||
CREATE TABLE IF NOT EXISTS template ( | ||
id UUID UNIQUE NOT NULL | ||
, name VARCHAR(200) NOT NULL | ||
, created_at TIMESTAMPTZ | ||
, updated_at TIMESTAMPTZ | ||
, deleted_at TIMESTAMPTZ | ||
, data BYTEA | ||
|
||
CONSTRAINT CK_name CHECK (name ~ '^[a-zA-Z0-9_-]*$') | ||
); | ||
|
||
CREATE INDEX IF NOT EXISTS idx_tid ON template (id); | ||
CREATE INDEX IF NOT EXISTS idx_tdeleted_at ON template (deleted_at NULLS FIRST); | ||
|
||
CREATE TABLE IF NOT EXISTS workflow ( | ||
id UUID UNIQUE NOT NULL | ||
, template UUID NOT NULL | ||
, devices JSONB NOT NULL | ||
, created_at TIMESTAMPTZ | ||
, updated_at TIMESTAMPTZ | ||
, deleted_at TIMESTAMPTZ | ||
); | ||
|
||
CREATE INDEX IF NOT EXISTS idx_wid ON workflow (id); | ||
CREATE INDEX IF NOT EXISTS idx_wdeleted_at ON workflow (deleted_at NULLS FIRST); | ||
|
||
CREATE TABLE IF NOT EXISTS workflow_state ( | ||
workflow_id UUID UNIQUE NOT NULL | ||
, current_task_name VARCHAR(200) | ||
, current_action_name VARCHAR(200) | ||
, current_action_state SMALLINT | ||
, current_worker VARCHAR(200) | ||
, action_list JSONB | ||
, current_action_index int | ||
, total_number_of_actions INT | ||
); | ||
|
||
CREATE INDEX IF NOT EXISTS idx_wfid ON workflow_state (workflow_id); | ||
|
||
CREATE TABLE IF NOT EXISTS workflow_event ( | ||
workflow_id UUID NOT NULL | ||
, worker_id UUID NOT NULL | ||
, task_name VARCHAR(200) | ||
, action_name VARCHAR(200) | ||
, execution_time int | ||
, message VARCHAR(200) | ||
, status SMALLINT | ||
, created_at TIMESTAMPTZ | ||
); | ||
|
||
CREATE INDEX IF NOT EXISTS idx_event ON workflow_event (created_at); | ||
|
||
CREATE TABLE IF NOT EXISTS workflow_worker_map ( | ||
workflow_id UUID NOT NULL | ||
, worker_id UUID NOT NULL | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS workflow_data ( | ||
workflow_id UUID NOT NULL | ||
, version INT | ||
, metadata JSONB | ||
, data JSONB | ||
); |
Oops, something went wrong.