github.com/openshift/installer@v1.4.17/pkg/types/defaults/installconfig.go (about) 1 package defaults 2 3 import ( 4 operv1 "github.com/openshift/api/operator/v1" 5 "github.com/openshift/installer/pkg/ipnet" 6 "github.com/openshift/installer/pkg/types" 7 awsdefaults "github.com/openshift/installer/pkg/types/aws/defaults" 8 "github.com/openshift/installer/pkg/types/azure" 9 azuredefaults "github.com/openshift/installer/pkg/types/azure/defaults" 10 baremetaldefaults "github.com/openshift/installer/pkg/types/baremetal/defaults" 11 gcpdefaults "github.com/openshift/installer/pkg/types/gcp/defaults" 12 ibmclouddefaults "github.com/openshift/installer/pkg/types/ibmcloud/defaults" 13 nonedefaults "github.com/openshift/installer/pkg/types/none/defaults" 14 nutanixdefaults "github.com/openshift/installer/pkg/types/nutanix/defaults" 15 openstackdefaults "github.com/openshift/installer/pkg/types/openstack/defaults" 16 ovirtdefaults "github.com/openshift/installer/pkg/types/ovirt/defaults" 17 powervsdefaults "github.com/openshift/installer/pkg/types/powervs/defaults" 18 vspheredefaults "github.com/openshift/installer/pkg/types/vsphere/defaults" 19 ) 20 21 var ( 22 // DefaultMachineCIDR default machine CIDR applied to MachineNetwork. 23 DefaultMachineCIDR = ipnet.MustParseCIDR("10.0.0.0/16") 24 defaultServiceNetwork = ipnet.MustParseCIDR("172.30.0.0/16") 25 defaultClusterNetwork = ipnet.MustParseCIDR("10.128.0.0/14") 26 defaultHostPrefix = 23 27 defaultNetworkType = string(operv1.NetworkTypeOVNKubernetes) 28 ) 29 30 // SetInstallConfigDefaults sets the defaults for the install config. 31 func SetInstallConfigDefaults(c *types.InstallConfig) { 32 if c.Networking == nil { 33 c.Networking = &types.Networking{} 34 } 35 if len(c.Networking.MachineNetwork) == 0 { 36 c.Networking.MachineNetwork = []types.MachineNetworkEntry{ 37 {CIDR: *DefaultMachineCIDR}, 38 } 39 } 40 if c.Networking.NetworkType == "" { 41 c.Networking.NetworkType = defaultNetworkType 42 } 43 if len(c.Networking.ServiceNetwork) == 0 { 44 c.Networking.ServiceNetwork = []ipnet.IPNet{*defaultServiceNetwork} 45 } 46 if len(c.Networking.ClusterNetwork) == 0 { 47 c.Networking.ClusterNetwork = []types.ClusterNetworkEntry{ 48 { 49 CIDR: *defaultClusterNetwork, 50 HostPrefix: int32(defaultHostPrefix), 51 }, 52 } 53 } 54 55 if c.Publish == "" { 56 c.Publish = types.ExternalPublishingStrategy 57 } 58 59 if c.ControlPlane == nil { 60 c.ControlPlane = &types.MachinePool{} 61 } 62 c.ControlPlane.Name = "master" 63 SetMachinePoolDefaults(c.ControlPlane, c.Platform.Name()) 64 65 defaultComputePoolUndefined := true 66 for _, compute := range c.Compute { 67 if compute.Name == types.MachinePoolComputeRoleName { 68 defaultComputePoolUndefined = false 69 break 70 } 71 } 72 if defaultComputePoolUndefined { 73 c.Compute = append(c.Compute, types.MachinePool{Name: types.MachinePoolComputeRoleName}) 74 } 75 for i := range c.Compute { 76 SetMachinePoolDefaults(&c.Compute[i], c.Platform.Name()) 77 } 78 79 if c.CredentialsMode == "" { 80 if c.Platform.Azure != nil && c.Platform.Azure.CloudName == azure.StackCloud { 81 c.CredentialsMode = types.ManualCredentialsMode 82 } else if c.Platform.Nutanix != nil { 83 c.CredentialsMode = types.ManualCredentialsMode 84 } else if c.Platform.PowerVS != nil { 85 c.CredentialsMode = types.ManualCredentialsMode 86 } 87 } 88 89 switch { 90 case c.Platform.AWS != nil: 91 awsdefaults.SetPlatformDefaults(c.Platform.AWS) 92 case c.Platform.Azure != nil: 93 azuredefaults.SetPlatformDefaults(c.Platform.Azure) 94 case c.Platform.GCP != nil: 95 gcpdefaults.SetPlatformDefaults(c.Platform.GCP) 96 case c.Platform.IBMCloud != nil: 97 ibmclouddefaults.SetPlatformDefaults(c.Platform.IBMCloud) 98 case c.Platform.OpenStack != nil: 99 openstackdefaults.SetPlatformDefaults(c.Platform.OpenStack, c.Networking) 100 case c.Platform.VSphere != nil: 101 vspheredefaults.SetPlatformDefaults(c.Platform.VSphere, c) 102 case c.Platform.BareMetal != nil: 103 baremetaldefaults.SetPlatformDefaults(c.Platform.BareMetal, c) 104 case c.Platform.Ovirt != nil: 105 ovirtdefaults.SetPlatformDefaults(c.Platform.Ovirt) 106 ovirtdefaults.SetControlPlaneDefaults(c.Platform.Ovirt, c.ControlPlane) 107 for i := range c.Compute { 108 ovirtdefaults.SetComputeDefaults(c.Platform.Ovirt, &c.Compute[i]) 109 } 110 case c.Platform.PowerVS != nil: 111 powervsdefaults.SetPlatformDefaults(c.Platform.PowerVS) 112 c.Networking.MachineNetwork = []types.MachineNetworkEntry{ 113 {CIDR: *powervsdefaults.DefaultMachineCIDR}, 114 } 115 case c.Platform.None != nil: 116 nonedefaults.SetPlatformDefaults(c.Platform.None) 117 case c.Platform.Nutanix != nil: 118 nutanixdefaults.SetPlatformDefaults(c.Platform.Nutanix) 119 } 120 121 if c.AdditionalTrustBundlePolicy == "" { 122 c.AdditionalTrustBundlePolicy = types.PolicyProxyOnly 123 } 124 }