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
16 changes: 16 additions & 0 deletions data/data/manifests/openshift/metal3-configmap.yaml.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
kind: ConfigMap
apiVersion: v1
metadata:
name: metal3-configmap
namespace: openshift-machine-api
data:
http_port: "6180"
provisioning_interface: {{.ProvisioningInterface}}
provisioning_ip: "172.22.0.3/24"
dhcp_range: "172.22.0.10,172.22.0.100"
deploy_kernel_url: "http://172.22.0.3:6180/images/ironic-python-agent.kernel"
deploy_ramdisk_url: "http://172.22.0.3:6180/images/ironic-python-agent.initramfs"
ironic_endpoint: "http://172.22.0.3:6385/v1/"
ironic_inspector_endpoint: "http://172.22.0.3:5050/v1/"
cache_url: "http://192.168.111.1/images"
rhcos_image_url: {{.RhcosImage}}
15 changes: 14 additions & 1 deletion pkg/asset/manifests/openshift.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/openshift/installer/pkg/asset/templates/content/openshift"
awstypes "github.com/openshift/installer/pkg/types/aws"
azuretypes "github.com/openshift/installer/pkg/types/azure"
baremetaltypes "github.com/openshift/installer/pkg/types/baremetal"
gcptypes "github.com/openshift/installer/pkg/types/gcp"
openstacktypes "github.com/openshift/installer/pkg/types/openstack"
vspheretypes "github.com/openshift/installer/pkg/types/vsphere"
Expand Down Expand Up @@ -56,6 +57,7 @@ func (o *Openshift) Dependencies() []asset.Asset {
&openshift.KubeadminPasswordSecret{},
&openshift.RoleCloudCredsSecretReader{},
&openshift.RoleBindingCloudCredsSecretReader{},
&openshift.Metal3ConfigMap{},
}
}

Expand Down Expand Up @@ -161,11 +163,13 @@ func (o *Openshift) Generate(dependencies asset.Parents) error {
kubeadminPasswordSecret := &openshift.KubeadminPasswordSecret{}
roleCloudCredsSecretReader := &openshift.RoleCloudCredsSecretReader{}
roleBindingCloudCredsSecretReader := &openshift.RoleBindingCloudCredsSecretReader{}
metal3ConfigMap := &openshift.Metal3ConfigMap{}
dependencies.Get(
cloudCredsSecret,
kubeadminPasswordSecret,
roleCloudCredsSecretReader,
roleBindingCloudCredsSecretReader)
roleBindingCloudCredsSecretReader,
metal3ConfigMap)

assetData := map[string][]byte{
"99_kubeadmin-password-secret.yaml": applyTemplateData(kubeadminPasswordSecret.Files()[0].Data, templateData),
Expand All @@ -182,6 +186,15 @@ func (o *Openshift) Generate(dependencies asset.Parents) error {
assetData["99_rolebinding-cloud-creds-secret-reader.yaml"] = applyTemplateData(roleBindingCloudCredsSecretReader.Files()[0].Data, templateData)
}

switch platform {
case baremetaltypes.Name:
baremetalTemplateData := &baremetalTemplateData{
ProvisioningInterface: installConfig.Config.Platform.BareMetal.ProvisioningInterface,
RhcosImage: installConfig.Config.Platform.BareMetal.RhcosImage,
}
assetData["99_metal3-configmap.yaml"] = applyTemplateData(metal3ConfigMap.Files()[0].Data, baremetalTemplateData)
}

o.FileList = []*asset.File{}
for name, data := range assetData {
if len(data) == 0 {
Expand Down
5 changes: 5 additions & 0 deletions pkg/asset/manifests/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ type cloudCredsSecretData struct {
VSphere *VSphereCredsSecretData
}

type baremetalTemplateData struct {
ProvisioningInterface string
RhcosImage string
}

type bootkubeTemplateData struct {
CVOClusterID string
EtcdCaBundle string
Expand Down
64 changes: 64 additions & 0 deletions pkg/asset/templates/content/openshift/metal3-configmap.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package openshift

import (
"os"
"path/filepath"

"github.com/openshift/installer/pkg/asset"
"github.com/openshift/installer/pkg/asset/templates/content"
)

const (
metal3ConfigMapFileName = "metal3-configmap.yaml.template"
)

var _ asset.WritableAsset = (*Metal3ConfigMap)(nil)

// Metal3ConfigMap file list.
type Metal3ConfigMap struct {
FileList []*asset.File
}

// Dependencies returns all of the dependencies directly needed by the asset
func (t *Metal3ConfigMap) Dependencies() []asset.Asset {
return []asset.Asset{}
}

// Name returns the human-friendly name of the asset.
func (t *Metal3ConfigMap) Name() string {
return "Metal3ConfigMap"
}

// Generate generates the actual files by this asset
func (t *Metal3ConfigMap) Generate(parents asset.Parents) error {
fileName := metal3ConfigMapFileName
data, err := content.GetOpenshiftTemplate(fileName)
if err != nil {
return err
}
t.FileList = []*asset.File{
{
Filename: filepath.Join(content.TemplateDir, fileName),
Data: []byte(data),
},
}
return nil
}

// Files returns the files generated by the asset.
func (t *Metal3ConfigMap) Files() []*asset.File {
return t.FileList
}

// Load returns the asset from disk.
func (t *Metal3ConfigMap) Load(f asset.FileFetcher) (bool, error) {
file, err := f.FetchByName(filepath.Join(content.TemplateDir, metal3ConfigMapFileName))
if err != nil {
if os.IsNotExist(err) {
return false, nil
}
return false, err
}
t.FileList = []*asset.File{file}
return true, nil
}
8 changes: 8 additions & 0 deletions pkg/types/baremetal/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,12 @@ type Platform struct {

// DNSVIP is the VIP to use for internal DNS communication
DNSVIP string `json:"dnsVIP"`

// ProvisioningInterface specifies the name of the interface on the
// baremetal platform to use for provisioning. Specifies where ironic,
// dhcp, pxe etc runs.
ProvisioningInterface string `json:"provisioningInterface"`

// RhcosImage is the image to use for provisioning new workers/masters.
RhcosImage string `json:"rhcosImage"`
}
9 changes: 9 additions & 0 deletions pkg/types/baremetal/validation/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,14 @@ func ValidatePlatform(p *baremetal.Platform, fldPath *field.Path) field.ErrorLis
if err := validate.IP(p.DNSVIP); err != nil {
allErrs = append(allErrs, field.Invalid(fldPath.Child("dnsVIP"), p.DNSVIP, err.Error()))
}

if p.ProvisioningInterface == "" {
allErrs = append(allErrs, field.Required(fldPath.Child("provisioningInterface"), "provisioningInterface is required"))
}

if err := validate.URI(p.RhcosImage); err != nil {
allErrs = append(allErrs, field.Invalid(fldPath.Child("rhcosImage"), p.RhcosImage, err.Error()))
}

return allErrs
}