Skip to content
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
2 changes: 1 addition & 1 deletion docs/user/openstack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ EOF
2. Add the Secret to the cluster:

```
$ oc create -n openshift-cluster-api -f secret.yaml
$ oc create -n openshift-machine-api -f secret.yaml
```

## Using an External Load Balancer
Expand Down
2 changes: 1 addition & 1 deletion pkg/asset/cluster/tfvars.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func (t *TerraformVariables) Generate(parents asset.Parents) error {
})
case none.Name:
case openstack.Name:
masters, err := mastersAsset.StructuredMachinesDeprecated()
masters, err := mastersAsset.StructuredMachines()
if err != nil {
return err
}
Expand Down
47 changes: 4 additions & 43 deletions pkg/asset/machines/master.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
awsprovider "sigs.k8s.io/cluster-api-provider-aws/pkg/apis/awsproviderconfig/v1beta1"
openstackapi "sigs.k8s.io/cluster-api-provider-openstack/pkg/apis"
openstackprovider "sigs.k8s.io/cluster-api-provider-openstack/pkg/apis/openstackproviderconfig/v1alpha1"
clusterapi "sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1"
)

// Master generates the machines for the `master` machine pool.
Expand Down Expand Up @@ -78,7 +77,6 @@ func (m *Master) Generate(dependencies asset.Parents) error {

var err error
machines := []machineapi.Machine{}
machinesDeprecated := []clusterapi.Machine{}
ic := installconfig.Config
pool := masterPool(ic.Machines)
switch ic.Platform.Name() {
Expand Down Expand Up @@ -117,11 +115,11 @@ func (m *Master) Generate(dependencies asset.Parents) error {
mpool.Set(pool.Platform.OpenStack)
pool.Platform.OpenStack = &mpool

machinesDeprecated, err = openstack.Machines(clusterID.ClusterID, ic, &pool, string(*rhcosImage), "master", "master-user-data")
machines, err = openstack.Machines(clusterID.ClusterID, ic, &pool, string(*rhcosImage), "master", "master-user-data")
if err != nil {
return errors.Wrap(err, "failed to create master machine objects")
}
openstack.ConfigMasters(machinesDeprecated, ic.ObjectMeta.Name)
openstack.ConfigMasters(machines, ic.ObjectMeta.Name)
default:
return fmt.Errorf("invalid Platform")
}
Expand All @@ -137,22 +135,13 @@ func (m *Master) Generate(dependencies asset.Parents) error {
Data: data,
}}

machinesAll := []runtime.Object{}
for i := range machines {
machinesAll = append(machinesAll, &machines[i])
}

for i := range machinesDeprecated {
machinesAll = append(machinesAll, &machinesDeprecated[i])
}

count := len(machinesAll)
count := len(machines)
if count == 0 {
return errors.New("at least one master machine must be configured")
}

padFormat := fmt.Sprintf("%%0%dd", len(fmt.Sprintf("%d", count)))
for i, machine := range machinesAll {
for i, machine := range machines {
data, err := yaml.Marshal(machine)
if err != nil {
return errors.Wrapf(err, "marshal master %d", i)
Expand Down Expand Up @@ -242,34 +231,6 @@ func (m *Master) StructuredMachines() ([]machineapi.Machine, error) {
return machines, nil
}

// StructuredMachinesDeprecated returns master Machine manifest structures.
func (m *Master) StructuredMachinesDeprecated() ([]clusterapi.Machine, error) {
scheme := runtime.NewScheme()
openstackapi.AddToScheme(scheme)
decoder := serializer.NewCodecFactory(scheme).UniversalDecoder(
openstackprovider.SchemeGroupVersion,
)

machines := []clusterapi.Machine{}
for i, data := range m.Machines() {
machine := &clusterapi.Machine{}
err := yaml.Unmarshal(data, &machine)
if err != nil {
return machines, errors.Wrapf(err, "unmarshal master %d", i)
}

obj, _, err := decoder.Decode(machine.Spec.ProviderSpec.Value.Raw, nil, nil)
if err != nil {
return machines, errors.Wrapf(err, "unmarshal master %d", i)
}

machine.Spec.ProviderSpec.Value = &runtime.RawExtension{Object: obj}
machines = append(machines, *machine)
}

return machines, nil
}

func masterPool(pools []types.MachinePool) types.MachinePool {
for idx, pool := range pools {
if pool.Name == "master" {
Expand Down
16 changes: 8 additions & 8 deletions pkg/asset/machines/openstack/machines.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ package openstack
import (
"fmt"

machineapi "github.com/openshift/cluster-api/pkg/apis/machine/v1beta1"
"github.com/pkg/errors"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
openstackprovider "sigs.k8s.io/cluster-api-provider-openstack/pkg/apis/openstackproviderconfig/v1alpha1"
clusterapi "sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1"

"github.com/openshift/installer/pkg/types"
"github.com/openshift/installer/pkg/types/openstack"
Expand All @@ -28,7 +28,7 @@ const (
)

// Machines returns a list of machines for a machinepool.
func Machines(clusterID string, config *types.InstallConfig, pool *types.MachinePool, osImage, role, userDataSecret string) ([]clusterapi.Machine, error) {
func Machines(clusterID string, config *types.InstallConfig, pool *types.MachinePool, osImage, role, userDataSecret string) ([]machineapi.Machine, error) {
if configPlatform := config.Platform.Name(); configPlatform != openstack.Name {
return nil, fmt.Errorf("non-OpenStack configuration: %q", configPlatform)
}
Expand All @@ -43,16 +43,16 @@ func Machines(clusterID string, config *types.InstallConfig, pool *types.Machine
if pool.Replicas != nil {
total = *pool.Replicas
}
var machines []clusterapi.Machine
var machines []machineapi.Machine
for idx := int64(0); idx < total; idx++ {
az := ""
provider, err := provider(clusterID, clustername, platform, mpool, osImage, az, role, userDataSecret)
if err != nil {
return nil, errors.Wrap(err, "failed to create provider")
}
machine := clusterapi.Machine{
machine := machineapi.Machine{
TypeMeta: metav1.TypeMeta{
APIVersion: "cluster.k8s.io/v1alpha1",
APIVersion: "machine.openshift.io/v1beta1",
Kind: "Machine",
},
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -64,8 +64,8 @@ func Machines(clusterID string, config *types.InstallConfig, pool *types.Machine
"sigs.k8s.io/cluster-api-machine-type": role,
},
},
Spec: clusterapi.MachineSpec{
ProviderSpec: clusterapi.ProviderSpec{
Spec: machineapi.MachineSpec{
ProviderSpec: machineapi.ProviderSpec{
Value: &runtime.RawExtension{Object: provider},
},
// we don't need to set Versions, because we control those via operators.
Expand Down Expand Up @@ -107,7 +107,7 @@ func provider(clusterID, clusterName string, platform *openstack.Platform, mpool
}

// ConfigMasters sets the PublicIP flag and assigns a set of load balancers to the given machines
func ConfigMasters(machines []clusterapi.Machine, clusterName string) {
func ConfigMasters(machines []machineapi.Machine, clusterName string) {
/*for _, machine := range machines {
providerSpec := machine.Spec.ProviderSpec.Value.Object.(*openstackprovider.OpenstackProviderSpec)
}*/
Expand Down
2 changes: 1 addition & 1 deletion pkg/asset/machines/openstack/machinesets.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func MachineSets(clusterID string, config *types.InstallConfig, pool *types.Mach
name := fmt.Sprintf("%s-%s", clustername, pool.Name)
mset := clusterapi.MachineSet{
TypeMeta: metav1.TypeMeta{
APIVersion: "cluster.k8s.io/v1alpha1",
APIVersion: "machine.openshift.io/v1beta1",
Kind: "MachineSet",
},
ObjectMeta: metav1.ObjectMeta{
Expand Down
2 changes: 1 addition & 1 deletion pkg/asset/manifests/cluster_k8s_io.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (c *ClusterK8sIO) Generate(dependencies asset.Parents) error {
},
ObjectMeta: metav1.ObjectMeta{
Name: installconfig.Config.ObjectMeta.Name,
Namespace: "openshift-cluster-api",
Copy link
Copy Markdown
Member

@enxebre enxebre Feb 14, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are using this object on the actuator, you probably need to update the APIVersion version here l51 APIVersion: "cluster.k8s.io/v1alpha1" to be consistent with what the actuator is taking

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be fine. I can prolly change this in a follow-up patch

Namespace: "openshift-machine-api",
},
Spec: clusterv1a1.ClusterSpec{
ClusterNetwork: *clusterNet,
Expand Down