Skip to content
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
10 changes: 9 additions & 1 deletion data/data/aws/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ module "masters" {
root_volume_type = "${var.tectonic_aws_master_root_volume_type}"
subnet_ids = "${module.vpc.master_subnet_ids}"
ec2_ami = "${var.tectonic_aws_ec2_ami_override}"
user_data_igns = ["${var.ignition_masters}"]
user_data_ign = "${var.ignition_master}"
}

module "iam" {
Expand Down Expand Up @@ -117,6 +117,14 @@ resource "aws_route53_record" "etcd_a_nodes" {
records = ["${module.masters.ip_addresses[count.index]}"]
}

resource "aws_route53_record" "etcd_cluster" {
type = "SRV"
ttl = "60"
zone_id = "${local.private_zone_id}"
name = "_etcd-server-ssl._tcp"
records = ["${formatlist("0 10 2380 %s", aws_route53_record.etcd_a_nodes.*.fqdn)}"]
}

resource "aws_route53_zone" "tectonic_int" {
count = "${local.private_endpoints ? "${var.tectonic_aws_external_private_zone == "" ? 1 : 0 }" : 0}"
vpc_id = "${module.vpc.vpc_id}"
Expand Down
2 changes: 1 addition & 1 deletion data/data/aws/master/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,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 = "${var.user_data_igns[count.index]}"
user_data = "${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 data/data/aws/master/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@ variable "kubeconfig_content" {
default = ""
}

variable "user_data_igns" {
type = "list"
variable "user_data_ign" {
type = "string"
}
6 changes: 3 additions & 3 deletions data/data/config.tf
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ Note: This field MUST be set manually prior to creating the cluster.
EOF
}

variable "ignition_masters" {
type = "list"
default = []
variable "ignition_master" {
type = "string"
default = ""

description = <<EOF
(internal) Ignition config file contents. This is automatically generated by the installer.
Expand Down
19 changes: 16 additions & 3 deletions data/data/libvirt/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ resource "libvirt_volume" "master" {
}

resource "libvirt_ignition" "master" {
count = "${var.tectonic_master_count}"
name = "master-${count.index}.ign"
content = "${var.ignition_masters[count.index]}"
name = "master.ign"
content = "${var.ignition_master}"
}

resource "libvirt_ignition" "worker" {
Expand All @@ -50,6 +49,10 @@ resource "libvirt_network" "tectonic_net" {
dns = [{
local_only = true

srvs = ["${flatten(list(
data.libvirt_network_dns_srv_template.etcd_cluster.*.rendered,
))}"]

hosts = ["${flatten(list(
data.libvirt_network_dns_host_template.bootstrap.*.rendered,
data.libvirt_network_dns_host_template.masters.*.rendered,
Expand Down Expand Up @@ -116,3 +119,13 @@ data "libvirt_network_dns_host_template" "workers" {
ip = "${var.tectonic_libvirt_worker_ips[count.index]}"
hostname = "${var.tectonic_cluster_name}"
}

data "libvirt_network_dns_srv_template" "etcd_cluster" {
count = "${var.tectonic_master_count}"
service = "etcd-server-ssl"
protocol = "tcp"
domain = "${var.tectonic_base_domain}"
port = 2380
weight = 10
target = "${var.tectonic_cluster_name}-etcd-${count.index}.${var.tectonic_base_domain}"
}
2 changes: 1 addition & 1 deletion data/data/openstack/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ module "masters" {
instance_count = "${var.tectonic_master_count}"
master_sg_ids = "${concat(var.tectonic_openstack_master_extra_sg_ids, list(module.topology.master_sg_id))}"
subnet_ids = "${module.topology.master_subnet_ids}"
user_data_igns = ["${var.ignition_masters}"]
user_data_ign = "${var.ignition_master}"
}

# TODO(shadower) add a dns module here
Expand Down
2 changes: 1 addition & 1 deletion data/data/openstack/masters/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ resource "openstack_compute_instance_v2" "master_conf" {
flavor_id = "${data.openstack_compute_flavor_v2.masters_flavor.id}"
image_id = "${data.openstack_images_image_v2.masters_img.id}"
security_groups = ["${var.master_sg_ids}"]
user_data = "${var.user_data_igns[count.index]}"
user_data = "${var.user_data_ign}"

network = {
port = "${var.subnet_ids[count.index]}"
Expand Down
4 changes: 2 additions & 2 deletions data/data/openstack/masters/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ variable "subnet_ids" {
type = "list"
}

variable "user_data_igns" {
type = "list"
variable "user_data_ign" {
type = "string"
}
9 changes: 2 additions & 7 deletions pkg/asset/cluster/tfvars.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,10 @@ func (t *TerraformVariables) Generate(parents asset.Parents) error {

bootstrapIgn := string(bootstrap.Files()[0].Data)

masterFiles := master.Files()
masterIgns := make([]string, len(masterFiles))
for i, f := range masterFiles {
masterIgns[i] = string(f.Data)
}

masterIgn := string(master.Files()[0].Data)
workerIgn := string(worker.Files()[0].Data)

data, err := tfvars.TFVars(installConfig.Config, bootstrapIgn, masterIgns, workerIgn)
data, err := tfvars.TFVars(installConfig.Config, bootstrapIgn, masterIgn, workerIgn)
if err != nil {
return errors.Wrap(err, "failed to get Tfvars")
}
Expand Down
61 changes: 29 additions & 32 deletions pkg/asset/ignition/machine/master.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package machine

import (
"encoding/json"
"fmt"
"os"

igntypes "github.com/coreos/ignition/config/v2_2/types"
"github.com/pkg/errors"
Expand All @@ -12,10 +12,14 @@ import (
"github.com/openshift/installer/pkg/asset/tls"
)

const (
masterIgnFilename = "master.ign"
)

// Master is an asset that generates the ignition config for master nodes.
type Master struct {
Configs []*igntypes.Config
FileList []*asset.File
Config *igntypes.Config
File *asset.File
}

var _ asset.WritableAsset = (*Master)(nil)
Expand All @@ -34,55 +38,48 @@ func (a *Master) Generate(dependencies asset.Parents) error {
rootCA := &tls.RootCA{}
dependencies.Get(installConfig, rootCA)

a.Configs = make([]*igntypes.Config, installConfig.Config.MasterCount())
for i := range a.Configs {
a.Configs[i] = pointerIgnitionConfig(installConfig.Config, rootCA.Cert(), "master", fmt.Sprintf("etcd_index=%d", i))
}
a.Config = pointerIgnitionConfig(installConfig.Config, rootCA.Cert(), "master")

a.FileList = make([]*asset.File, len(a.Configs))
for i, c := range a.Configs {
data, err := json.Marshal(c)
if err != nil {
return errors.Wrap(err, "failed to marshal ignition config")
}
a.FileList[i] = &asset.File{
Filename: fmt.Sprintf("master-%d.ign", i),
Data: data,
}
data, err := json.Marshal(a.Config)
if err != nil {
return errors.Wrap(err, "failed to get InstallConfig from parents")
}
a.File = &asset.File{
Filename: masterIgnFilename,
Data: data,
}

return nil
}

// Name returns the human-friendly name of the asset.
func (a *Master) Name() string {
return "Master Ignition Config(s)"
return "Master Ignition Config"
}

// Files returns the files generated by the asset.
func (a *Master) Files() []*asset.File {
return a.FileList
if a.File != nil {
return []*asset.File{a.File}
}
return []*asset.File{}
}

// Load returns the master ignitions from disk.
func (a *Master) Load(f asset.FileFetcher) (found bool, err error) {
fileList, err := f.FetchByPattern("master-[0-9]*.ign")
file, err := f.FetchByName(masterIgnFilename)
if err != nil {
return false, nil
}
if len(fileList) == 0 {
return false, nil
}

configs := make([]*igntypes.Config, len(fileList))
for i, file := range fileList {
configs[i] = &igntypes.Config{}
if err := json.Unmarshal(file.Data, configs[i]); err != nil {
return false, errors.Wrapf(err, "failed to unmarshal")
if os.IsNotExist(err) {
return false, nil
}
return false, err
}

a.FileList, a.Configs = fileList, configs
config := &igntypes.Config{}
if err := json.Unmarshal(file.Data, config); err != nil {
return false, errors.Wrapf(err, "failed to unmarshal")
}

a.File, a.Config = file, config
return true, nil
}
4 changes: 1 addition & 3 deletions pkg/asset/ignition/machine/master_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ func TestMasterGenerate(t *testing.T) {
err = master.Generate(parents)
assert.NoError(t, err, "unexpected error generating master asset")
expectedIgnitionConfigNames := []string{
"master-0.ign",
"master-1.ign",
"master-2.ign",
"master.ign",
}
actualFiles := master.Files()
actualIgnitionConfigNames := make([]string, len(actualFiles))
Expand Down
9 changes: 4 additions & 5 deletions pkg/asset/ignition/machine/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,17 @@ import (

// pointerIgnitionConfig generates a config which references the remote config
// served by the machine config server.
func pointerIgnitionConfig(installConfig *types.InstallConfig, rootCA []byte, role string, query string) *ignition.Config {
func pointerIgnitionConfig(installConfig *types.InstallConfig, rootCA []byte, role string) *ignition.Config {
return &ignition.Config{
Ignition: ignition.Ignition{
Version: ignition.MaxVersion.String(),
Config: ignition.IgnitionConfig{
Append: []ignition.ConfigReference{{
Source: func() *url.URL {
return &url.URL{
Scheme: "https",
Host: fmt.Sprintf("%s-api.%s:49500", installConfig.ObjectMeta.Name, installConfig.BaseDomain),
Path: fmt.Sprintf("/config/%s", role),
RawQuery: query,
Scheme: "https",
Host: fmt.Sprintf("%s-api.%s:49500", installConfig.ObjectMeta.Name, installConfig.BaseDomain),
Path: fmt.Sprintf("/config/%s", role),
}
}().String(),
}},
Expand Down
2 changes: 1 addition & 1 deletion pkg/asset/ignition/machine/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (a *Worker) Generate(dependencies asset.Parents) error {
rootCA := &tls.RootCA{}
dependencies.Get(installConfig, rootCA)

a.Config = pointerIgnitionConfig(installConfig.Config, rootCA.Cert(), "worker", "")
a.Config = pointerIgnitionConfig(installConfig.Config, rootCA.Cert(), "worker")

data, err := json.Marshal(a.Config)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/asset/machines/aws/master.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ items:
values:
- "{{$c.ClusterName}}_master_sg"
userDataSecret:
name: "master-user-data-{{$index}}"
name: "master-user-data"
versions:
kubelet: ""
controlPlane: ""
Expand Down
2 changes: 1 addition & 1 deletion pkg/asset/machines/libvirt/master.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ items:
kind: LibvirtMachineProviderConfig
domainMemory: 2048
domainVcpu: 2
ignKey: /var/lib/libvirt/images/master-{{$index}}.ign
ignKey: /var/lib/libvirt/images/master.ign
volume:
poolName: default
baseVolumeID: /var/lib/libvirt/images/coreos_base
Expand Down
14 changes: 5 additions & 9 deletions pkg/asset/machines/master.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import (

// Master generates the machines for the `master` machine pool.
type Master struct {
MachinesRaw []byte
UserDataSecretsRaw []byte
MachinesRaw []byte
UserDataSecretRaw []byte
}

var _ asset.Asset = (*Master)(nil)
Expand All @@ -45,15 +45,11 @@ func (m *Master) Generate(dependencies asset.Parents) error {
mign := &machine.Master{}
dependencies.Get(installconfig, mign)

userDataContent := map[string][]byte{}
for i, file := range mign.FileList {
userDataContent[fmt.Sprintf("master-user-data-%d", i)] = file.Data
}

var err error
m.UserDataSecretsRaw, err = userDataList(userDataContent)
userDataMap := map[string][]byte{"master-user-data": mign.File.Data}
m.UserDataSecretRaw, err = userDataList(userDataMap)
if err != nil {
return errors.Wrap(err, "failed to create user-data secrets for master machines")
return errors.Wrap(err, "failed to create user-data secret for worker machines")
}

ic := installconfig.Config
Expand Down
2 changes: 1 addition & 1 deletion pkg/asset/machines/openstack/master.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ items:
values:
- "{{$c.ClusterName}}_master_sg"
userDataSecret:
name: master-user-data-{{$index}}
name: master-user-data
versions:
kubelet: ""
controlPlane: ""
Expand Down
24 changes: 12 additions & 12 deletions pkg/asset/manifests/tectonic.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,18 @@ func (t *Tectonic) Generate(dependencies asset.Parents) error {
}

assetData := map[string][]byte{
"99_binding-discovery.yaml": []byte(content.BindingDiscovery),
"99_kube-addon-00-appversion.yaml": []byte(content.AppVersionKubeAddon),
"99_kube-addon-01-operator.yaml": applyTemplateData(content.KubeAddonOperator, templateData),
"99_openshift-cluster-api_cluster.yaml": clusterk8sio.Raw,
"99_openshift-cluster-api_master-machines.yaml": master.MachinesRaw,
"99_openshift-cluster-api_master-user-data-secrets.yaml": master.UserDataSecretsRaw,
"99_openshift-cluster-api_worker-machineset.yaml": worker.MachineSetRaw,
"99_openshift-cluster-api_worker-user-data-secret.yaml": worker.UserDataSecretRaw,
"99_role-admin.yaml": []byte(content.RoleAdmin),
"99_role-user.yaml": []byte(content.RoleUser),
"99_tectonic-system-00-binding-admin.yaml": []byte(content.BindingAdmin),
"99_tectonic-system-02-pull.json": applyTemplateData(content.PullTectonicSystem, templateData),
"99_binding-discovery.yaml": []byte(content.BindingDiscovery),
"99_kube-addon-00-appversion.yaml": []byte(content.AppVersionKubeAddon),
"99_kube-addon-01-operator.yaml": applyTemplateData(content.KubeAddonOperator, templateData),
"99_openshift-cluster-api_cluster.yaml": clusterk8sio.Raw,
"99_openshift-cluster-api_master-machines.yaml": master.MachinesRaw,
"99_openshift-cluster-api_master-user-data-secret.yaml": master.UserDataSecretRaw,
"99_openshift-cluster-api_worker-machineset.yaml": worker.MachineSetRaw,
"99_openshift-cluster-api_worker-user-data-secret.yaml": worker.UserDataSecretRaw,
"99_role-admin.yaml": []byte(content.RoleAdmin),
"99_role-user.yaml": []byte(content.RoleUser),
"99_tectonic-system-00-binding-admin.yaml": []byte(content.BindingAdmin),
"99_tectonic-system-02-pull.json": applyTemplateData(content.PullTectonicSystem, templateData),
}

// addon goes to openshift system
Expand Down
Loading