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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ replace sigs.k8s.io/controller-tools => sigs.k8s.io/controller-tools v0.3.1-0.20

// Override the OpenShift API version in hive

replace github.com/openshift/api => github.com/openshift/api v0.0.0-20230531161518-2346bf94f19e
replace github.com/openshift/api => github.com/shiftstack/api v0.0.0-20230606024040-fe46f4152f31

replace github.com/terraform-providers/terraform-provider-nutanix => github.com/nutanix/terraform-provider-nutanix v1.5.0

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1056,8 +1056,6 @@ github.com/opencontainers/runtime-spec v1.0.3-0.20200929063507-e6143ca7d51d/go.m
github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
github.com/opencontainers/selinux v1.5.2/go.mod h1:yTcKuYAh6R95iDpefGLQaPaRwJFwyzAJufJyiTt7s0g=
github.com/opencontainers/selinux v1.8.2/go.mod h1:MUIHuUEvKB1wtJjQdOyYRgOnLD2xAPP8dBsCoU0KuF8=
github.com/openshift/api v0.0.0-20230531161518-2346bf94f19e h1:ELcgpoysjPXc3Gf4TrlP/OAJMgZeDUaQAFpfcnNdw2o=
github.com/openshift/api v0.0.0-20230531161518-2346bf94f19e/go.mod h1:4VWG+W22wrB4HfBL88P40DxLEpSOaiBVxUnfalfJo9k=
github.com/openshift/assisted-image-service v0.0.0-20220506122314-2f689a1084b8 h1:oZ3VAWiM8tPRBM+vYI4GBmlrqyoqizcgZ7pBy5EX2K8=
github.com/openshift/assisted-image-service v0.0.0-20220506122314-2f689a1084b8/go.mod h1:bH4+AsmPy8mQQvtgedBm2Crs93TDWeXEMlIPrlEMpjA=
github.com/openshift/assisted-service v0.0.0-20220928142635-a40422bdea61 h1:HtUYJBAdRgfVYide0bq3GsT/4n5uPWteA1rIZVXEL7k=
Expand Down Expand Up @@ -1184,6 +1182,8 @@ github.com/seccomp/libseccomp-golang v0.9.1/go.mod h1:GbW5+tmTXfcxTToHLXlScSlAvW
github.com/securego/gosec v0.0.0-20191002120514-e680875ea14d/go.mod h1:w5+eXa0mYznDkHaMCXA4XYffjlH+cy1oyKbfzJXa2Do=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
github.com/shiftstack/api v0.0.0-20230606024040-fe46f4152f31 h1:ShjibwSBh/ZA5oyDh2e3xXj0Pb7o0lnpL0OqlwQ5xnA=
github.com/shiftstack/api v0.0.0-20230606024040-fe46f4152f31/go.mod h1:4VWG+W22wrB4HfBL88P40DxLEpSOaiBVxUnfalfJo9k=
github.com/shirou/gopsutil v0.0.0-20180427012116-c95755e4bcd7/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4/go.mod h1:qsXQc7+bwAM3Q1u/4XEfrquwF8Lw7D7y5cD8CuHnfIc=
github.com/shurcooL/go v0.0.0-20180423040247-9e1955d9fb6e/go.mod h1:TDJrrUr11Vxrven61rcy3hJMUqaf/CLWYhHNPmT14Lk=
Expand Down
2 changes: 1 addition & 1 deletion pkg/asset/machines/master.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ func (m *Master) Generate(dependencies asset.Parents) error {

imageName, _ := rhcosutils.GenerateOpenStackImageName(string(*rhcosImage), clusterID.InfraID)

machines, err = openstack.Machines(clusterID.InfraID, ic, &pool, imageName, "master", masterUserDataSecretName)
machines, controlPlaneMachineSet, err = openstack.Machines(clusterID.InfraID, ic, &pool, imageName, "master", masterUserDataSecretName)
if err != nil {
return errors.Wrap(err, "failed to create master machine objects")
}
Expand Down
69 changes: 61 additions & 8 deletions pkg/asset/machines/openstack/machines.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"

v1 "github.com/openshift/api/config/v1"
machinev1 "github.com/openshift/api/machine/v1"
machinev1alpha1 "github.com/openshift/api/machine/v1alpha1"
machineapi "github.com/openshift/api/machine/v1beta1"
"github.com/openshift/installer/pkg/types"
Expand All @@ -31,19 +33,19 @@ const (
)

// Machines returns a list of machines for a machinepool.
func Machines(clusterID string, config *types.InstallConfig, pool *types.MachinePool, osImage, role, userDataSecret string) ([]machineapi.Machine, error) {
func Machines(clusterID string, config *types.InstallConfig, pool *types.MachinePool, osImage, role, userDataSecret string) ([]machineapi.Machine, *machinev1.ControlPlaneMachineSet, error) {
if configPlatform := config.Platform.Name(); configPlatform != openstack.Name {
return nil, fmt.Errorf("non-OpenStack configuration: %q", configPlatform)
return nil, nil, fmt.Errorf("non-OpenStack configuration: %q", configPlatform)
}
if poolPlatform := pool.Platform.Name(); poolPlatform != openstack.Name {
return nil, fmt.Errorf("non-OpenStack machine-pool: %q", poolPlatform)
return nil, nil, fmt.Errorf("non-OpenStack machine-pool: %q", poolPlatform)
}

mpool := pool.Platform.OpenStack
platform := config.Platform.OpenStack
trunkSupport, err := checkNetworkExtensionAvailability(platform.Cloud, "trunk", nil)
if err != nil {
return nil, err
return nil, nil, err
}

volumeAZs := openstackdefaults.DefaultRootVolumeAZ()
Expand All @@ -56,6 +58,8 @@ func Machines(clusterID string, config *types.InstallConfig, pool *types.Machine
total = *pool.Replicas
}
machines := make([]machineapi.Machine, 0, total)
machineSetProvider := &machinev1alpha1.OpenstackProviderSpec{}
var failureDomains []machinev1.OpenStackFailureDomain
for idx := int64(0); idx < total; idx++ {
var failureDomain openstack.FailureDomain

Expand All @@ -67,7 +71,9 @@ func Machines(clusterID string, config *types.InstallConfig, pool *types.Machine
failureDomain.StorageAvailabilityZone = volumeAZs[uint(idx)%uint(len(volumeAZs))]
}

var provider *machinev1alpha1.OpenstackProviderSpec
if failureDomain.ComputeAvailabilityZone != "" || failureDomain.StorageAvailabilityZone != "" {
failureDomains = append(failureDomains, failureDomain.OpenStackFailureDomain)
}

provider, err := generateProvider(
clusterID,
Expand All @@ -80,9 +86,9 @@ func Machines(clusterID string, config *types.InstallConfig, pool *types.Machine
failureDomain,
)
if err != nil {
return nil, err
return nil, nil, err
}

*machineSetProvider = *provider
machine := machineapi.Machine{
TypeMeta: metav1.TypeMeta{
APIVersion: "machine.openshift.io/v1beta1",
Expand All @@ -107,7 +113,54 @@ func Machines(clusterID string, config *types.InstallConfig, pool *types.Machine
machines = append(machines, machine)
}

return machines, nil
replicas := int32(total)

controlPlaneMachineSet := &machinev1.ControlPlaneMachineSet{
TypeMeta: metav1.TypeMeta{
APIVersion: "machine.openshift.io/v1",
Kind: "ControlPlaneMachineSet",
},
ObjectMeta: metav1.ObjectMeta{
Namespace: "openshift-machine-api",
Name: "cluster",
Labels: map[string]string{
"machine.openshift.io/cluster-api-cluster": clusterID,
},
},
Spec: machinev1.ControlPlaneMachineSetSpec{
State: machinev1.ControlPlaneMachineSetStateActive,
Replicas: &replicas,
Selector: metav1.LabelSelector{
MatchLabels: map[string]string{
"machine.openshift.io/cluster-api-cluster": clusterID,
"machine.openshift.io/cluster-api-machine-role": role,
"machine.openshift.io/cluster-api-machine-type": role,
},
},
Template: machinev1.ControlPlaneMachineSetTemplate{
MachineType: machinev1.OpenShiftMachineV1Beta1MachineType,
OpenShiftMachineV1Beta1Machine: &machinev1.OpenShiftMachineV1Beta1MachineTemplate{
FailureDomains: machinev1.FailureDomains{
Platform: v1.OpenStackPlatformType,
OpenStack: &failureDomains,
},
ObjectMeta: machinev1.ControlPlaneMachineSetTemplateObjectMeta{
Labels: map[string]string{
"machine.openshift.io/cluster-api-cluster": clusterID,
"machine.openshift.io/cluster-api-machine-role": role,
"machine.openshift.io/cluster-api-machine-type": role,
},
},
Spec: machineapi.MachineSpec{
ProviderSpec: machineapi.ProviderSpec{
Value: &runtime.RawExtension{Object: machineSetProvider},
},
},
},
},
},
}
return machines, controlPlaneMachineSet, nil
}

func generateProvider(clusterID string, platform *openstack.Platform, mpool *openstack.MachinePool, osImage string, role, userDataSecret string, trunkSupport bool, failureDomain openstack.FailureDomain) (*machinev1alpha1.OpenstackProviderSpec, error) {
Expand Down
8 changes: 5 additions & 3 deletions pkg/asset/machines/openstack/machinesets.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"

machinev1 "github.com/openshift/api/machine/v1"
clusterapi "github.com/openshift/api/machine/v1beta1"
"github.com/openshift/installer/pkg/types"
"github.com/openshift/installer/pkg/types/openstack"
Expand Down Expand Up @@ -56,9 +57,10 @@ func MachineSets(clusterID string, config *types.InstallConfig, pool *types.Mach
userDataSecret,
trunkSupport,
openstack.FailureDomain{
ComputeAvailabilityZone: az,
StorageAvailabilityZone: volumeAZs[idx%len(volumeAZs)],
},
OpenStackFailureDomain: machinev1.OpenStackFailureDomain{
ComputeAvailabilityZone: az,
StorageAvailabilityZone: volumeAZs[idx%len(volumeAZs)],
}},
)
if err != nil {
return nil, err
Expand Down
16 changes: 6 additions & 10 deletions pkg/types/openstack/machinepool.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package openstack

import machinev1alpha1 "github.com/openshift/api/machine/v1alpha1"
import (
machinev1 "github.com/openshift/api/machine/v1"
machinev1alpha1 "github.com/openshift/api/machine/v1alpha1"
)

// MachinePool stores the configuration for a machine pool installed
// on OpenStack.
Expand Down Expand Up @@ -103,15 +106,8 @@ type RootVolume struct {
// FailureDomain defines a set of correlated fault domains across different
// OpenStack services: compute, storage, and network.
type FailureDomain struct {
// ComputeAvailabilityZone is the name of a valid nova availability zone. The server will be created in this availability zone.
// +optional
ComputeAvailabilityZone string `json:"computeAvailabilityZone"`

// StorageAvailabilityZone is the name of a valid cinder availability
// zone. This will be the availability zone of the root volume if one is
// specified.
// +optional
StorageAvailabilityZone string `json:"storageAvailabilityZone"`
// OpenStackFailureDomain embeds the openshift/api definition for a Failure domain.
machinev1.OpenStackFailureDomain `json:",inline"`

// Ports defines a set of port targets which can be referenced by machines in this failure domain.
//
Expand Down

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

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

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

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

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

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

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

Loading