Skip to content

Commit

Permalink
Merge pull request #3276 from kirankt/baremetal-full-ignition
Browse files Browse the repository at this point in the history
Baremetal: Support to send full ignition to masters
  • Loading branch information
openshift-merge-robot authored Apr 16, 2020
2 parents dae4ef3 + 8c821d2 commit 883bb3a
Show file tree
Hide file tree
Showing 13 changed files with 139 additions and 23 deletions.
16 changes: 9 additions & 7 deletions data/data/baremetal/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ module "bootstrap" {
module "masters" {
source = "./masters"

master_count = var.master_count
ignition = var.ignition_master
hosts = var.hosts
properties = var.properties
root_devices = var.root_devices
driver_infos = var.driver_infos
instance_infos = var.instance_infos
master_count = var.master_count
ignition = var.ignition_master
hosts = var.hosts
properties = var.properties
root_devices = var.root_devices
driver_infos = var.driver_infos
instance_infos = var.instance_infos
ignition_url = var.ignition_url
ignition_url_ca_cert = var.ignition_url_ca_cert
}
5 changes: 3 additions & 2 deletions data/data/baremetal/masters/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ resource "ironic_deployment" "openshift-master-deployment" {
count.index,
)

instance_info = var.instance_infos[count.index]
user_data = var.ignition
instance_info = var.instance_infos[count.index]
user_data_url = var.ignition_url
user_data_url_ca_cert = var.ignition_url_ca_cert
}

10 changes: 10 additions & 0 deletions data/data/baremetal/masters/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,13 @@ variable "instance_infos" {
type = list(map(string))
description = "Instance information for hosts"
}

variable "ignition_url" {
type = string
description = "The URL of the full ignition"
}

variable "ignition_url_ca_cert" {
type = string
description = "Root CA cert of the full ignition URL"
}
10 changes: 10 additions & 0 deletions data/data/baremetal/variables-baremetal.tf
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,13 @@ variable "instance_infos" {
type = list(map(string))
description = "Instance information for hosts"
}

variable "ignition_url" {
type = string
description = "The URL of the full ignition"
}

variable "ignition_url_ca_cert" {
type = string
description = "Root CA cert of the full ignition URL"
}
5 changes: 2 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ require (
github.com/h2non/filetype v1.0.12
github.com/hashicorp/go-azure-helpers v0.10.0
github.com/hashicorp/go-plugin v1.0.1
github.com/hashicorp/go-retryablehttp v0.6.4 // indirect
github.com/hashicorp/logutils v1.0.0
github.com/hashicorp/memberlist v0.1.5 // indirect
github.com/hashicorp/serf v0.8.5 // indirect
Expand All @@ -63,7 +62,7 @@ require (
github.com/metal3-io/cluster-api-provider-baremetal v0.0.0
github.com/mitchellh/cli v1.0.0
github.com/opencontainers/image-spec v1.0.2-0.20190823105129-775207bd45b6 // indirect
github.com/openshift-metal3/terraform-provider-ironic v0.1.9
github.com/openshift-metal3/terraform-provider-ironic v0.2.0
github.com/openshift/api v3.9.1-0.20191111211345-a27ff30ebf09+incompatible
github.com/openshift/client-go v0.0.0-20200116152001-92a2713fa240
github.com/openshift/cloud-credential-operator v0.0.0-20200316201045-d10080b52c9e
Expand Down Expand Up @@ -107,7 +106,7 @@ require (
go.uber.org/multierr v1.4.0 // indirect
go.uber.org/zap v1.13.0 // indirect
golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413
golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f
golang.org/x/lint v0.0.0-20200302205851-738671d3881b
golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6
golang.org/x/sys v0.0.0-20191206220618-eeba5f6aabab
golang.org/x/time v0.0.0-20191024005414-555d28b269f0 // indirect
Expand Down
7 changes: 5 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1760,8 +1760,8 @@ github.com/opencontainers/runtime-tools v0.9.0/go.mod h1:r3f7wjNzSs2extwzU3Y+6pK
github.com/opencontainers/selinux v1.2.2/go.mod h1:+BLncwf63G4dgOzykXAxcmnFlUaOlkDdmw/CqsW6pjs=
github.com/opencontainers/selinux v1.3.0/go.mod h1:+BLncwf63G4dgOzykXAxcmnFlUaOlkDdmw/CqsW6pjs=
github.com/opencontainers/selinux v1.3.1-0.20190929122143-5215b1806f52/go.mod h1:+BLncwf63G4dgOzykXAxcmnFlUaOlkDdmw/CqsW6pjs=
github.com/openshift-metal3/terraform-provider-ironic v0.1.9 h1:8Ylp+ylSX/NtuGel90Ty9Fyg+mq523B2orH1FtC+fG0=
github.com/openshift-metal3/terraform-provider-ironic v0.1.9/go.mod h1:gYfx1ioglruoE8BpF0h8MVbcAAFu6ruz+bD2X9VC0uU=
github.com/openshift-metal3/terraform-provider-ironic v0.2.0 h1:MAImxv6UaTtvf2BkPG9YS+EvIqMsXQhNQNDfV7FE2D0=
github.com/openshift-metal3/terraform-provider-ironic v0.2.0/go.mod h1:G79T6t60oBpYfZK/x960DRzYsNHdz5YVCHINx6QlmtU=
github.com/openshift/api v0.0.0-20200210091934-a0e53e94816b h1:BERD6sZj7w9Tt0RBpuw87AC0+SppyxEUgUG/Of5rI+E=
github.com/openshift/api v0.0.0-20200210091934-a0e53e94816b/go.mod h1:fT6U/JfG8uZzemTRwZA2kBDJP5nWz7v05UHnty/D+pk=
github.com/openshift/baremetal-operator v0.0.0-20200206190020-71b826cc0f0a h1:65ZuRkPnQGh9uo0z93KosrPlwEWJNxUjxnuM9lyGBHc=
Expand Down Expand Up @@ -2350,6 +2350,8 @@ golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHl
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f h1:J5lckAjkw6qYlOZNj90mLYNTEKDvWeuc1yieZ8qUzUE=
golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs=
golang.org/x/lint v0.0.0-20200302205851-738671d3881b h1:Wh+f8QHJXR411sJR8/vRBTZ7YapZaRvUcLFFJhusH0k=
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
golang.org/x/mobile v0.0.0-20190607214518-6fa95d984e88/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
Expand Down Expand Up @@ -2633,6 +2635,7 @@ golang.org/x/tools v0.0.0-20191204011308-9611592c72f6/go.mod h1:b+2E5dAYhXwXZwtn
golang.org/x/tools v0.0.0-20200102140908-9497f49d5709/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200115044656-831fdb1e1868 h1:6VZw2h4iwEB4GwgQU3Jvcsm8l9+yReTrErAEK1k6AC4=
golang.org/x/tools v0.0.0-20200115044656-831fdb1e1868/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200204192400-7124308813f3 h1:Ms82wn6YK4ZycO6Bxyh0kxX3gFFVGo79CCuc52xgcys=
golang.org/x/tools v0.0.0-20200204192400-7124308813f3/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200214201135-548b770e2dfa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
Expand Down
15 changes: 14 additions & 1 deletion pkg/asset/cluster/tfvars.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ package cluster

import (
"context"
"encoding/base64"
"encoding/json"
"fmt"
"io/ioutil"
"net"
"net/url"
"os"

igntypes "github.com/coreos/ignition/config/v2_2/types"
Expand All @@ -29,6 +32,7 @@ import (
"github.com/openshift/installer/pkg/asset/machines"
"github.com/openshift/installer/pkg/asset/openshiftinstall"
"github.com/openshift/installer/pkg/asset/rhcos"
"github.com/openshift/installer/pkg/asset/tls"
"github.com/openshift/installer/pkg/tfvars"
awstfvars "github.com/openshift/installer/pkg/tfvars/aws"
azuretfvars "github.com/openshift/installer/pkg/tfvars/azure"
Expand Down Expand Up @@ -88,6 +92,7 @@ func (t *TerraformVariables) Dependencies() []asset.Asset {
&machine.Master{},
&machines.Master{},
&machines.Worker{},
&tls.RootCA{},
}
}

Expand All @@ -102,7 +107,8 @@ func (t *TerraformVariables) Generate(parents asset.Parents) error {
workersAsset := &machines.Worker{}
rhcosImage := new(rhcos.Image)
rhcosBootstrapImage := new(rhcos.BootstrapImage)
parents.Get(clusterID, installConfig, bootstrapIgnAsset, masterIgnAsset, mastersAsset, workersAsset, rhcosImage, rhcosBootstrapImage)
rootCA := &tls.RootCA{}
parents.Get(clusterID, installConfig, bootstrapIgnAsset, masterIgnAsset, mastersAsset, workersAsset, rhcosImage, rhcosBootstrapImage, rootCA)

platform := installConfig.Config.Platform.Name()
switch platform {
Expand Down Expand Up @@ -388,6 +394,11 @@ func (t *TerraformVariables) Generate(parents asset.Parents) error {
Data: data,
})
case baremetal.Name:
ignitionURL := &url.URL{
Scheme: "https",
Host: net.JoinHostPort(installConfig.Config.Platform.BareMetal.APIVIP, "22623"),
Path: "config/master",
}
data, err = baremetaltfvars.TFVars(
installConfig.Config.Platform.BareMetal.LibvirtURI,
installConfig.Config.Platform.BareMetal.BootstrapProvisioningIP,
Expand All @@ -396,6 +407,8 @@ func (t *TerraformVariables) Generate(parents asset.Parents) error {
installConfig.Config.Platform.BareMetal.ProvisioningBridge,
installConfig.Config.Platform.BareMetal.Hosts,
string(*rhcosImage),
ignitionURL.String(),
base64.StdEncoding.EncodeToString(rootCA.Cert()),
)
if err != nil {
return errors.Wrapf(err, "failed to get %s Terraform variables", platform)
Expand Down
6 changes: 5 additions & 1 deletion pkg/tfvars/baremetal/baremetal.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ type config struct {
BootstrapOSImage string `json:"bootstrap_os_image,omitempty"`
ExternalBridge string `json:"external_bridge,omitempty"`
ProvisioningBridge string `json:"provisioning_bridge,omitempty"`
IgnitionURL string `json:"ignition_url,omitempty"`
IgnitionURLCACert string `json:"ignition_url_ca_cert,omitempty"`

// Data required for control plane deployment - several maps per host, because of terraform's limitations
Hosts []map[string]interface{} `json:"hosts"`
Expand All @@ -32,7 +34,7 @@ type config struct {
}

// TFVars generates bare metal specific Terraform variables.
func TFVars(libvirtURI, bootstrapProvisioningIP, bootstrapOSImage, externalBridge, provisioningBridge string, platformHosts []*baremetal.Host, image string) ([]byte, error) {
func TFVars(libvirtURI, bootstrapProvisioningIP, bootstrapOSImage, externalBridge, provisioningBridge string, platformHosts []*baremetal.Host, image string, ignitionURL string, ignitionURLCACert string) ([]byte, error) {
bootstrapOSImage, err := cache.DownloadImageFile(bootstrapOSImage)
if err != nil {
return nil, errors.Wrap(err, "failed to use cached bootstrap libvirt image")
Expand Down Expand Up @@ -132,6 +134,8 @@ func TFVars(libvirtURI, bootstrapProvisioningIP, bootstrapOSImage, externalBridg
DriverInfos: driverInfos,
RootDevices: rootDevices,
InstanceInfos: instanceInfos,
IgnitionURL: ignitionURL,
IgnitionURLCACert: ignitionURLCACert,
}

return json.MarshalIndent(cfg, "", " ")
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/golang.org/x/lint/go.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions vendor/golang.org/x/lint/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/golang.org/x/lint/lint.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,7 @@ github.com/opencontainers/go-digest
# github.com/opencontainers/image-spec v1.0.2-0.20190823105129-775207bd45b6
github.com/opencontainers/image-spec/specs-go
github.com/opencontainers/image-spec/specs-go/v1
# github.com/openshift-metal3/terraform-provider-ironic v0.1.9
# github.com/openshift-metal3/terraform-provider-ironic v0.2.0
github.com/openshift-metal3/terraform-provider-ironic/ironic
# github.com/openshift/api v3.9.1-0.20191111211345-a27ff30ebf09+incompatible => github.com/openshift/api v0.0.0-20200210091934-a0e53e94816b
github.com/openshift/api/config/v1
Expand Down Expand Up @@ -1408,7 +1408,7 @@ golang.org/x/crypto/ssh/terminal
# golang.org/x/exp v0.0.0-20191129062945-2f5052295587
golang.org/x/exp/apidiff
golang.org/x/exp/cmd/apidiff
# golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f
# golang.org/x/lint v0.0.0-20200302205851-738671d3881b
golang.org/x/lint
golang.org/x/lint/golint
# golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee
Expand Down

0 comments on commit 883bb3a

Please sign in to comment.