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: create machines and machineset linked to cluster #3935

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 4 additions & 5 deletions pkg/asset/machines/baremetal/machines.go
Expand Up @@ -27,14 +27,13 @@ func Machines(clusterID string, config *types.InstallConfig, pool *types.Machine
if poolPlatform := pool.Platform.Name(); poolPlatform != baremetal.Name {
return nil, fmt.Errorf("non bare metal machine-pool: %q", poolPlatform)
}
clustername := config.ObjectMeta.Name
platform := config.Platform.BareMetal

total := int64(1)
if pool.Replicas != nil {
total = *pool.Replicas
}
provider, err := provider(clustername, platform, osImage, userDataSecret)
provider, err := provider(platform, osImage, userDataSecret)
if err != nil {
return nil, errors.Wrap(err, "failed to create provider")
}
Expand All @@ -47,9 +46,9 @@ func Machines(clusterID string, config *types.InstallConfig, pool *types.Machine
},
ObjectMeta: metav1.ObjectMeta{
Namespace: "openshift-machine-api",
Name: fmt.Sprintf("%s-%s-%d", clustername, pool.Name, idx),
Name: fmt.Sprintf("%s-%s-%d", clusterID, pool.Name, idx),
Labels: map[string]string{
"machine.openshift.io/cluster-api-cluster": clustername,
"machine.openshift.io/cluster-api-cluster": clusterID,
"machine.openshift.io/cluster-api-machine-role": role,
"machine.openshift.io/cluster-api-machine-type": role,
},
Expand All @@ -67,7 +66,7 @@ func Machines(clusterID string, config *types.InstallConfig, pool *types.Machine
return machines, nil
}

func provider(clusterName string, platform *baremetal.Platform, osImage string, userDataSecret string) (*baremetalprovider.BareMetalMachineProviderSpec, error) {
func provider(platform *baremetal.Platform, osImage string, userDataSecret string) (*baremetalprovider.BareMetalMachineProviderSpec, error) {
// The machine-os-downloader container launched by the baremetal-operator downloads the image,
// compresses it to speed up deployments and makes it available on platform.ClusterProvisioningIP, via http
// osImage looks like:
Expand Down
11 changes: 5 additions & 6 deletions pkg/asset/machines/baremetal/machinesets.go
Expand Up @@ -23,7 +23,6 @@ func MachineSets(clusterID string, config *types.InstallConfig, pool *types.Mach
if poolPlatform := pool.Platform.Name(); poolPlatform != "" && poolPlatform != baremetal.Name {
return nil, fmt.Errorf("non bare metal machine-pool: %q", poolPlatform)
}
clustername := config.ObjectMeta.Name
platform := config.Platform.BareMetal
// FIXME: bare metal actuator does not support any options from machinepool.
// mpool := pool.Platform.BareMetal
Expand All @@ -33,11 +32,11 @@ func MachineSets(clusterID string, config *types.InstallConfig, pool *types.Mach
total = *pool.Replicas
}

provider, err := provider(clustername, platform, osImage, userDataSecret)
provider, err := provider(platform, osImage, userDataSecret)
if err != nil {
return nil, errors.Wrap(err, "failed to create provider")
}
name := fmt.Sprintf("%s-%s-%d", clustername, pool.Name, 0)
name := fmt.Sprintf("%s-%s-%d", clusterID, pool.Name, 0)
mset := &machineapi.MachineSet{
TypeMeta: metav1.TypeMeta{
APIVersion: "machine.openshift.io/v1beta1",
Expand All @@ -47,7 +46,7 @@ func MachineSets(clusterID string, config *types.InstallConfig, pool *types.Mach
Namespace: "openshift-machine-api",
Name: name,
Labels: map[string]string{
"machine.openshift.io/cluster-api-cluster": clustername,
"machine.openshift.io/cluster-api-cluster": clusterID,
"machine.openshift.io/cluster-api-machine-role": role,
"machine.openshift.io/cluster-api-machine-type": role,
},
Expand All @@ -57,14 +56,14 @@ func MachineSets(clusterID string, config *types.InstallConfig, pool *types.Mach
Selector: metav1.LabelSelector{
MatchLabels: map[string]string{
"machine.openshift.io/cluster-api-machineset": name,
"machine.openshift.io/cluster-api-cluster": clustername,
"machine.openshift.io/cluster-api-cluster": clusterID,
},
},
Template: machineapi.MachineTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
"machine.openshift.io/cluster-api-machineset": name,
"machine.openshift.io/cluster-api-cluster": clustername,
"machine.openshift.io/cluster-api-cluster": clusterID,
"machine.openshift.io/cluster-api-machine-role": role,
"machine.openshift.io/cluster-api-machine-type": role,
},
Expand Down