Skip to content

Commit

Permalink
*: Bump to install-config v0.12.0
Browse files Browse the repository at this point in the history
Catching up with openshift/installer@dafc79f0 (Generate
Network.cluster config instead of NetworkConfig.networkoperator,
2019-01-15, openshift/installer#1013), openshift/installer@3b393da8
(pkg/types/aws/machinepool: Drop IAM-role overrides, 2019-01-30,
openshift/installer#1154), and openshift/installer@9ad20c35
(pkg/destroy/aws: Remove ClusterName consumer, 2019-01-31,
openshift/installer#1170).

The uint32 -> int32 cast is slightly dangerous, because it will
silently wrap overflowing values [1,2].  But I'll try and get the
installer updated to use unsigned types as well, and then we won't
have to worry about converting.

[1]: golang/go#19624
[2]: golang/go#30209
  • Loading branch information
wking committed Feb 14, 2019
1 parent 7fb42d3 commit d3c2b99
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 82 deletions.
15 changes: 0 additions & 15 deletions config/crds/hive_v1alpha1_clusterdeployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ spec:
description: AWS is the configuration used when installing
on AWS.
properties:
iamRoleName:
description: IAMRoleName defines the IAM role associated
with the ec2 instance.
type: string
rootVolume:
description: EC2RootVolume defines the storage for ec2
instance.
Expand Down Expand Up @@ -91,7 +87,6 @@ spec:
type: array
required:
- type
- iamRoleName
- rootVolume
type: object
libvirt:
Expand Down Expand Up @@ -172,10 +167,6 @@ spec:
description: AWS is the configuration used when installing on
AWS.
properties:
iamRoleName:
description: IAMRoleName defines the IAM role associated
with the ec2 instance.
type: string
rootVolume:
description: EC2RootVolume defines the storage for ec2 instance.
properties:
Expand Down Expand Up @@ -207,7 +198,6 @@ spec:
type: array
required:
- type
- iamRoleName
- rootVolume
type: object
libvirt:
Expand Down Expand Up @@ -345,10 +335,6 @@ spec:
used when installing on AWS for machine pools which do not
define their own platform configuration.
properties:
iamRoleName:
description: IAMRoleName defines the IAM role associated
with the ec2 instance.
type: string
rootVolume:
description: EC2RootVolume defines the storage for ec2 instance.
properties:
Expand Down Expand Up @@ -380,7 +366,6 @@ spec:
type: array
required:
- type
- iamRoleName
- rootVolume
type: object
region:
Expand Down
2 changes: 0 additions & 2 deletions config/samples/hive_v1alpha1_clusterdeployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ spec:
platform:
aws:
type: m4.large
iamRoleName: ""
rootVolume:
iops: 100 # TODO
size: 22
Expand All @@ -34,7 +33,6 @@ spec:
platform:
aws:
type: m4.large
iamRoleName: ""
rootVolume:
iops: 100 # TODO
size: 22
Expand Down
2 changes: 0 additions & 2 deletions config/templates/cluster-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ objects:
platform:
aws:
type: m4.large
iamRoleName: ""
rootVolume:
iops: 100 # TODO
size: 22
Expand All @@ -130,7 +129,6 @@ objects:
platform:
aws:
type: m4.large
iamRoleName: ""
rootVolume:
iops: 100 # TODO
size: 22
Expand Down
1 change: 0 additions & 1 deletion contrib/cmd/hiveutil/awstagdeprovision.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ func NewDeprovisionAWSWithTagsCommand() *cobra.Command {
flags := cmd.Flags()
flags.StringVar(&logLevel, "loglevel", "info", "log level, one of: debug, info, warn, error, fatal, panic")
flags.StringVar(&opt.Region, "region", "us-east-1", "AWS region to use")
flags.StringVar(&opt.ClusterName, "cluster-name", "", "Name that cluster was installed with")
return cmd
}

Expand Down
7 changes: 3 additions & 4 deletions contrib/pkg/installmanager/installmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,10 +326,9 @@ func runUninstaller(clusterName, region, clusterID string, logger log.FieldLogge
{kubernetesKeyPrefix + clusterName: "owned"},
}
uninstaller := &aws.ClusterUninstaller{
Filters: filters,
Region: region,
ClusterName: clusterName,
Logger: logger,
Filters: filters,
Region: region,
Logger: logger,
}

return uninstaller.Run()
Expand Down
4 changes: 0 additions & 4 deletions pkg/apis/hive/v1alpha1/machinepools.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ type AWSMachinePoolPlatform struct {
// eg. m4-large
InstanceType string `json:"type"`

// IAMRoleName defines the IAM role associated
// with the ec2 instance.
IAMRoleName string `json:"iamRoleName"`

// EC2RootVolume defines the storage for ec2 instance.
EC2RootVolume `json:"rootVolume"`
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,13 +308,6 @@ func (r *ReconcileRemoteMachineSet) generateMachineSetsFromClusterDeployment(cd
workerPool.Platform.AWS.Zones = azs
}

hivePool := findHiveMachinePool(cd, workerPool.Name)

defaultIAMRole := fmt.Sprintf("%s-worker-role", ic.ObjectMeta.Name)
if hivePool.Platform.AWS.IAMRoleName == "" {
workerPool.Platform.AWS.IAMRoleName = defaultIAMRole
}

icMachineSets, err := installaws.MachineSets(cd.Status.ClusterID, ic, &workerPool, defaultAMI, workerPool.Name, "worker-user-data")
if err != nil {
return nil, err
Expand Down
25 changes: 12 additions & 13 deletions pkg/controller/remotemachineset/remotemachineset_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func TestRemoteMachineSetReconcile(t *testing.T) {
name: "No-op",
localExisting: []runtime.Object{
testClusterDeployment([]hivev1.MachinePool{
testMachinePool("worker", 3, testName+"-worker", []string{}),
testMachinePool("worker", 3, []string{}),
}),
testSecret(adminKubeconfigSecret, adminKubeconfigSecretKey, testName),
testSecret(adminPasswordSecret, adminPasswordSecretKey, testName),
Expand All @@ -130,7 +130,7 @@ func TestRemoteMachineSetReconcile(t *testing.T) {
name: "Update machine set replicas",
localExisting: []runtime.Object{
testClusterDeployment([]hivev1.MachinePool{
testMachinePool("worker", 3, testName+"-worker", []string{}),
testMachinePool("worker", 3, []string{}),
}),
testSecret(adminKubeconfigSecret, adminKubeconfigSecretKey, testName),
testSecret(adminPasswordSecret, adminPasswordSecretKey, testName),
Expand All @@ -156,7 +156,7 @@ func TestRemoteMachineSetReconcile(t *testing.T) {
name: "Create missing machine set",
localExisting: []runtime.Object{
testClusterDeployment([]hivev1.MachinePool{
testMachinePool("worker", 3, testName+"-worker", []string{"us-east-1a", "us-east-1b", "us-east-1c"}),
testMachinePool("worker", 3, []string{"us-east-1a", "us-east-1b", "us-east-1c"}),
}),
testSecret(adminKubeconfigSecret, adminKubeconfigSecretKey, testName),
testSecret(adminPasswordSecret, adminPasswordSecretKey, testName),
Expand All @@ -181,7 +181,7 @@ func TestRemoteMachineSetReconcile(t *testing.T) {
name: "Delete extra machine set",
localExisting: []runtime.Object{
testClusterDeployment([]hivev1.MachinePool{
testMachinePool("worker", 3, testName+"-worker", []string{}),
testMachinePool("worker", 3, []string{}),
}),
testSecret(adminKubeconfigSecret, adminKubeconfigSecretKey, testName),
testSecret(adminPasswordSecret, adminPasswordSecretKey, testName),
Expand All @@ -208,8 +208,8 @@ func TestRemoteMachineSetReconcile(t *testing.T) {
name: "Multiple machineset noop",
localExisting: []runtime.Object{
testClusterDeployment([]hivev1.MachinePool{
testMachinePool("alpha", 3, testName+"-worker", []string{"us-east-1a"}),
testMachinePool("beta", 3, testName+"-worker", []string{"us-east-1b"}),
testMachinePool("alpha", 3, []string{"us-east-1a"}),
testMachinePool("beta", 3, []string{"us-east-1b"}),
}),
testSecret(adminKubeconfigSecret, adminKubeconfigSecretKey, testName),
testSecret(adminPasswordSecret, adminPasswordSecretKey, testName),
Expand All @@ -233,8 +233,8 @@ func TestRemoteMachineSetReconcile(t *testing.T) {
name: "Update multiple machineset replicas",
localExisting: []runtime.Object{
testClusterDeployment([]hivev1.MachinePool{
testMachinePool("alpha", 3, testName+"-worker", []string{"us-east-1a"}),
testMachinePool("beta", 3, testName+"-worker", []string{"us-east-1b"}),
testMachinePool("alpha", 3, []string{"us-east-1a"}),
testMachinePool("beta", 3, []string{"us-east-1b"}),
}),
testSecret(adminKubeconfigSecret, adminKubeconfigSecretKey, testName),
testSecret(adminPasswordSecret, adminPasswordSecretKey, testName),
Expand All @@ -258,8 +258,8 @@ func TestRemoteMachineSetReconcile(t *testing.T) {
name: "Create additional machinepool machinesets",
localExisting: []runtime.Object{
testClusterDeployment([]hivev1.MachinePool{
testMachinePool("alpha", 3, testName+"-worker", []string{}),
testMachinePool("beta", 3, testName+"-worker", []string{}),
testMachinePool("alpha", 3, []string{}),
testMachinePool("beta", 3, []string{}),
}),
testSecret(adminKubeconfigSecret, adminKubeconfigSecretKey, testName),
testSecret(adminPasswordSecret, adminPasswordSecretKey, testName),
Expand Down Expand Up @@ -288,7 +288,7 @@ func TestRemoteMachineSetReconcile(t *testing.T) {
name: "Delete additional machinepool machinesets",
localExisting: []runtime.Object{
testClusterDeployment([]hivev1.MachinePool{
testMachinePool("alpha", 3, testName+"-worker", []string{}),
testMachinePool("alpha", 3, []string{}),
}),
testSecret(adminKubeconfigSecret, adminKubeconfigSecretKey, testName),
testSecret(adminPasswordSecret, adminPasswordSecretKey, testName),
Expand Down Expand Up @@ -391,7 +391,7 @@ func TestRemoteMachineSetReconcile(t *testing.T) {
}
}

func testMachinePool(name string, replicas int, iamRoleName string, zones []string) hivev1.MachinePool {
func testMachinePool(name string, replicas int, zones []string) hivev1.MachinePool {
mpReplicas := int64(replicas)

testMachinePool := hivev1.MachinePool{
Expand All @@ -400,7 +400,6 @@ func testMachinePool(name string, replicas int, iamRoleName string, zones []stri
Platform: hivev1.MachinePoolPlatform{
AWS: &hivev1.AWSMachinePoolPlatform{
InstanceType: "m4.large",
IAMRoleName: iamRoleName,
},
},
}
Expand Down
34 changes: 12 additions & 22 deletions pkg/install/convertconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,14 @@ limitations under the License.
package install

import (
"fmt"

hivev1 "github.com/openshift/hive/pkg/apis/hive/v1alpha1"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

networkv1 "github.com/openshift/cluster-network-operator/pkg/apis/networkoperator/v1"
"github.com/openshift/installer/pkg/ipnet"
"github.com/openshift/installer/pkg/types"
installeraws "github.com/openshift/installer/pkg/types/aws"

netopv1 "github.com/openshift/cluster-network-operator/pkg/apis/networkoperator/v1"
)

// GenerateInstallConfig builds an InstallConfig for the installer from our ClusterDeploymentSpec.
Expand All @@ -38,11 +35,6 @@ import (
func GenerateInstallConfig(cd *hivev1.ClusterDeployment, sshKey, pullSecret string) (*types.InstallConfig, error) {
spec := cd.Spec

networkType, err := convertNetworkingType(spec.Networking.Type)
if err != nil {
return nil, err
}

platform := types.Platform{}
if spec.Platform.AWS != nil {
aws := spec.Platform.AWS
Expand All @@ -53,7 +45,6 @@ func GenerateInstallConfig(cd *hivev1.ClusterDeployment, sshKey, pullSecret stri
if aws.DefaultMachinePlatform != nil {
platform.AWS.DefaultMachinePlatform = &installeraws.MachinePool{
InstanceType: aws.DefaultMachinePlatform.InstanceType,
IAMRoleName: aws.DefaultMachinePlatform.IAMRoleName,
EC2RootVolume: installeraws.EC2RootVolume{
IOPS: aws.DefaultMachinePlatform.EC2RootVolume.IOPS,
Size: aws.DefaultMachinePlatform.EC2RootVolume.Size,
Expand Down Expand Up @@ -84,7 +75,6 @@ func GenerateInstallConfig(cd *hivev1.ClusterDeployment, sshKey, pullSecret stri
if mp.Platform.AWS != nil {
newMP.Platform.AWS = &installeraws.MachinePool{
InstanceType: mp.Platform.AWS.InstanceType,
IAMRoleName: mp.Platform.AWS.IAMRoleName,
EC2RootVolume: installeraws.EC2RootVolume{
IOPS: mp.Platform.AWS.EC2RootVolume.IOPS,
Size: mp.Platform.AWS.EC2RootVolume.Size,
Expand All @@ -101,14 +91,14 @@ func GenerateInstallConfig(cd *hivev1.ClusterDeployment, sshKey, pullSecret stri
Name: spec.ClusterName,
},
TypeMeta: metav1.TypeMeta{
APIVersion: "v1beta1",
APIVersion: types.InstallConfigVersion,
},
SSHKey: sshKey,
BaseDomain: spec.BaseDomain,
Networking: &types.Networking{
Type: networkType,
Type: string(spec.Networking.Type),
ServiceCIDR: parseCIDR(spec.Networking.ServiceCIDR),
ClusterNetworks: spec.Networking.ClusterNetworks,
ClusterNetworks: convertClusterNetworks(spec.Networking.ClusterNetworks),
MachineCIDR: parseCIDR(spec.Networking.MachineCIDR),
},
PullSecret: pullSecret,
Expand All @@ -125,13 +115,13 @@ func parseCIDR(s string) *ipnet.IPNet {
return ipnet.MustParseCIDR(s)
}

func convertNetworkingType(hnt hivev1.NetworkType) (netopv1.NetworkType, error) {
switch hnt {
case hivev1.NetworkTypeOpenshiftOVN:
return netopv1.NetworkTypeOVNKubernetes, nil
case hivev1.NetworkTypeOpenshiftSDN:
return netopv1.NetworkTypeOpenshiftSDN, nil
default:
return "", fmt.Errorf("unknown NetworkType: %s", hnt)
func convertClusterNetworks(networks []networkv1.ClusterNetwork) []types.ClusterNetworkEntry {
output := make([]types.ClusterNetworkEntry, 0, len(networks))
for _, network := range networks {
output = append(output, types.ClusterNetworkEntry{
CIDR: *parseCIDR(network.CIDR),
HostSubnetLength: int32(network.HostSubnetLength),
})
}
return output
}
Loading

0 comments on commit d3c2b99

Please sign in to comment.