Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Baremetal: Generate CR to configure baremetal. #2958

Merged
merged 1 commit into from
Jan 23, 2020
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: metal3.io/v1alpha1
kind: Provisioning
metadata:
name: provisioning-configuration
spec:
provisioningInterface: {{.ProvisioningNetworkInterface}}
provisioningIP: {{.ClusterProvisioningIP}}
provisioningNetworkCIDR: {{.ProvisioningNetworkCIDR}}
provisioningDHCPExternal: {{.ProvisioningDHCPExternal}}
provisioningDHCPRange: {{.ProvisioningDHCPRange}}
9 changes: 8 additions & 1 deletion pkg/asset/manifests/openshift.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/openshift/installer/pkg/types"
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"
ovirttypes "github.com/openshift/installer/pkg/types/ovirt"
Expand Down Expand Up @@ -60,6 +61,7 @@ func (o *Openshift) Dependencies() []asset.Asset {
&openshift.KubeadminPasswordSecret{},
&openshift.RoleCloudCredsSecretReader{},
&openshift.PrivateClusterOutbound{},
&openshift.BaremetalConfig{},
}
}

Expand Down Expand Up @@ -179,10 +181,13 @@ func (o *Openshift) Generate(dependencies asset.Parents) error {
cloudCredsSecret := &openshift.CloudCredsSecret{}
kubeadminPasswordSecret := &openshift.KubeadminPasswordSecret{}
roleCloudCredsSecretReader := &openshift.RoleCloudCredsSecretReader{}
baremetalConfig := &openshift.BaremetalConfig{}

dependencies.Get(
cloudCredsSecret,
kubeadminPasswordSecret,
roleCloudCredsSecretReader)
roleCloudCredsSecretReader,
baremetalConfig)

assetData := map[string][]byte{
"99_kubeadmin-password-secret.yaml": applyTemplateData(kubeadminPasswordSecret.Files()[0].Data, templateData),
Expand All @@ -192,6 +197,8 @@ func (o *Openshift) Generate(dependencies asset.Parents) error {
case awstypes.Name, openstacktypes.Name, vspheretypes.Name, azuretypes.Name, gcptypes.Name, ovirttypes.Name:
assetData["99_cloud-creds-secret.yaml"] = applyTemplateData(cloudCredsSecret.Files()[0].Data, templateData)
assetData["99_role-cloud-creds-secret-reader.yaml"] = applyTemplateData(roleCloudCredsSecretReader.Files()[0].Data, templateData)
case baremetaltypes.Name:
assetData["99_baremetal-provisioning-config.yaml"] = applyTemplateData(baremetalConfig.Files()[0].Data, *installConfig.Config.Platform.BareMetal)
}

if platform == azuretypes.Name && installConfig.Config.Publish == types.InternalPublishingStrategy {
Expand Down
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 (
baremetalConfigFilename = "baremetal-provisioning-config.yaml.template"
)

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

// BaremetalConfig is the custom resource definitions for the baremetal deployment
type BaremetalConfig struct {
FileList []*asset.File
}

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

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

// Generate generates the actual files by this asset
func (t *BaremetalConfig) Generate(parents asset.Parents) error {
fileName := baremetalConfigFilename
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 *BaremetalConfig) Files() []*asset.File {
return t.FileList
}

// Load returns the asset from disk.
func (t *BaremetalConfig) Load(f asset.FileFetcher) (bool, error) {
file, err := f.FetchByName(filepath.Join(content.TemplateDir, baremetalConfigFilename))
if err != nil {
if os.IsNotExist(err) {
return false, nil
}
return false, err
}
t.FileList = append(t.FileList, file)
return true, nil
}