Skip to content
Closed
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
6 changes: 3 additions & 3 deletions config.tf
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,9 @@ variable "tectonic_kubelet_debug_config" {
description = "(internal) debug flags for the kubelet (used in CI only)"
}

variable "tectonic_ignition_masters" {
type = "list"
default = []
variable "tectonic_ignition_master" {
type = "string"
default = ""

description = <<EOF
(internal) Ignition config file paths. This is automatically generated by the installer.
Expand Down
62 changes: 24 additions & 38 deletions installer/pkg/config-generator/ignition.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,57 +19,43 @@ const (

// GenerateIgnConfig generates Ignition configs for the workers and masters.
func (c *ConfigGenerator) GenerateIgnConfig(clusterDir string) error {
var masters config.NodePool
var workers config.NodePool
pools := map[string]config.NodePool{}
for _, pool := range c.NodePools {
switch pool.Name {
case "master":
masters = pool
case "worker":
workers = pool
case "etcd": // FIXME: ignore these until openshift/release stops defining them
default:
return fmt.Errorf("unrecognized role: %s", pool.Name)
}
pools[pool.Name] = pool
}

ca, err := ioutil.ReadFile(filepath.Join(clusterDir, caPath))
if err != nil {
return err
}

workerCfg, err := parseIgnFile(workers.IgnitionFile)
if err != nil {
return fmt.Errorf("failed to parse Ignition config for workers: %v", err)
}

// XXX(crawford): The SSH key should only be added to the bootstrap
// node. After that, MCO should be responsible for
// distributing SSH keys.
c.embedUserBlock(&workerCfg)
c.appendCertificateAuthority(&workerCfg, ca)
c.embedAppendBlock(&workerCfg, "worker", "")

if err = ignCfgToFile(workerCfg, filepath.Join(clusterDir, config.IgnitionPathWorker)); err != nil {
return err
}

masterCfg, err := parseIgnFile(masters.IgnitionFile)
if err != nil {
return fmt.Errorf("failed to parse Ignition config for masters: %v", err)
}

for i := 0; i < masters.Count; i++ {
ignCfg := masterCfg
for _, role := range []struct {
name string
path string
}{
{
name: "master",
path: config.IgnitionPathMaster,
},
{
name: "worker",
path: config.IgnitionPathWorker,
},
} {
pool := pools[role.name]
ignCfg, err := parseIgnFile(pool.IgnitionFile)
if err != nil {
return fmt.Errorf("failed to parse Ignition config for %s: %v", role.name, err)
}

// XXX(crawford): The SSH key should only be added to the bootstrap
// node. After that, MCO should be responsible for
// distributing SSH keys.
c.embedUserBlock(&ignCfg)
c.appendCertificateAuthority(&ignCfg, ca)
c.embedAppendBlock(&ignCfg, "master", fmt.Sprintf("etcd_index=%d", i))
c.embedAppendBlock(&ignCfg, role.name)

if err = ignCfgToFile(ignCfg, filepath.Join(clusterDir, fmt.Sprintf(config.IgnitionPathMaster, i))); err != nil {
if err = ignCfgToFile(ignCfg, filepath.Join(clusterDir, role.path)); err != nil {
return err
}
}
Expand Down Expand Up @@ -99,9 +85,9 @@ func parseIgnFile(filePath string) (ignconfigtypes.Config, error) {
return cfg, nil
}

func (c *ConfigGenerator) embedAppendBlock(ignCfg *ignconfigtypes.Config, role string, query string) {
func (c *ConfigGenerator) embedAppendBlock(ignCfg *ignconfigtypes.Config, role string) {
appendBlock := ignconfigtypes.ConfigReference{
Source: c.getTNCURL(role, query),
Source: c.getTNCURL(role, ""),
Verification: ignconfigtypes.Verification{Hash: nil},
}
ignCfg.Ignition.Config.Append = append(ignCfg.Ignition.Config.Append, appendBlock)
Expand Down
12 changes: 4 additions & 8 deletions installer/pkg/config/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import (

const (
// IgnitionPathMaster is the relative path to the ign master cfg from the tf working directory
// This is a format string so that the index can be populated later
IgnitionPathMaster = "master-%d.ign"
IgnitionPathMaster = "master.ign"
// IgnitionPathWorker is the relative path to the ign worker cfg from the tf working directory
IgnitionPathWorker = "worker.ign"
// PlatformAWS is the platform for a cluster launched on AWS.
Expand Down Expand Up @@ -79,8 +78,8 @@ type Cluster struct {
BaseDomain string `json:"tectonic_base_domain,omitempty" yaml:"baseDomain,omitempty"`
CA `json:",inline" yaml:"CA,omitempty"`
ContainerLinux `json:",inline" yaml:"containerLinux,omitempty"`
IgnitionMasters []string `json:"tectonic_ignition_masters,omitempty" yaml:"-"`
IgnitionWorker string `json:"tectonic_ignition_worker,omitempty" yaml:"-"`
IgnitionMaster string `json:"tectonic_ignition_master,omitempty" yaml:"-"`
IgnitionWorker string `json:"tectonic_ignition_worker,omitempty" yaml:"-"`
Internal `json:",inline" yaml:"-"`
libvirt.Libvirt `json:",inline" yaml:"libvirt,omitempty"`
LicensePath string `json:"tectonic_license_path,omitempty" yaml:"licensePath,omitempty"`
Expand Down Expand Up @@ -113,10 +112,7 @@ func (c *Cluster) TFVars() (string, error) {
c.Master.Count = c.NodeCount(c.Master.NodePools)
c.Worker.Count = c.NodeCount(c.Worker.NodePools)

for i := 0; i < c.Master.Count; i++ {
c.IgnitionMasters = append(c.IgnitionMasters, fmt.Sprintf(IgnitionPathMaster, i))
}

c.IgnitionMaster = IgnitionPathMaster
c.IgnitionWorker = IgnitionPathWorker

// fill in master ips
Expand Down
5 changes: 1 addition & 4 deletions installer/pkg/workflow/fixtures/terraform.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@
"tectonic_base_domain": "tectonic-ci.de",
"tectonic_container_linux_channel": "beta",
"tectonic_container_linux_version": "latest",
"tectonic_ignition_masters": [
"master-0.ign",
"master-1.ign"
],
"tectonic_ignition_master": "master.ign",
"tectonic_ignition_worker": "worker.ign",
"tectonic_libvirt_network_if": "osbr0",
"tectonic_libvirt_resolver": "8.8.8.8",
Expand Down
2 changes: 1 addition & 1 deletion modules/aws/master/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ resource "aws_instance" "master" {
iam_instance_profile = "${aws_iam_instance_profile.master.name}"
instance_type = "${var.ec2_type}"
subnet_id = "${element(var.subnet_ids, count.index)}"
user_data = "${file(format("%s/%s", path.cwd, var.user_data_igns[count.index]))}"
user_data = "${file(format("%s/%s", path.cwd, var.user_data_ign))}"

vpc_security_group_ids = ["${var.master_sg_ids}"]
associate_public_ip_address = "${var.public_endpoints}"
Expand Down
4 changes: 2 additions & 2 deletions modules/aws/master/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,6 @@ variable "kubeconfig_content" {
default = ""
}

variable "user_data_igns" {
type = "list"
variable "user_data_ign" {
type = "string"
}
2 changes: 1 addition & 1 deletion steps/masters/aws/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ module "masters" {
root_volume_type = "${var.tectonic_aws_master_root_volume_type}"
subnet_ids = "${local.subnet_ids}"
ec2_ami = "${var.tectonic_aws_ec2_ami_override}"
user_data_igns = "${var.tectonic_ignition_masters}"
user_data_ign = "${var.tectonic_ignition_master}"
}

resource "aws_route53_record" "etcd_a_nodes" {
Expand Down
7 changes: 3 additions & 4 deletions steps/masters/libvirt/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ resource "libvirt_volume" "master" {
}

resource "libvirt_ignition" "master" {
count = "${var.tectonic_master_count}"
name = "master-${count.index}.ign"
content = "${file(format("%s/%s", path.cwd, var.tectonic_ignition_masters[count.index]))}"
name = "master.ign"
content = "${file(format("%s/%s", path.cwd, var.tectonic_ignition_master))}"
}

resource "libvirt_domain" "master" {
Expand All @@ -23,7 +22,7 @@ resource "libvirt_domain" "master" {
memory = "2048"
vcpu = "2"

coreos_ignition = "${libvirt_ignition.master.*.id[count.index]}"
coreos_ignition = "${libvirt_ignition.master.id}"

disk {
volume_id = "${element(libvirt_volume.master.*.id, count.index)}"
Expand Down