github.com/openshift/installer@v1.4.17/pkg/asset/manifests/topologies.go (about)

     1  package manifests
     2  
     3  import (
     4  	configv1 "github.com/openshift/api/config/v1"
     5  	"github.com/openshift/installer/pkg/types"
     6  )
     7  
     8  // determineTopologies determines the Infrastructure CR's
     9  // infrastructureTopology and controlPlaneTopology given an install config file
    10  func determineTopologies(installConfig *types.InstallConfig) (controlPlaneTopology configv1.TopologyMode, infrastructureTopology configv1.TopologyMode) {
    11  	if installConfig.ControlPlane.Replicas != nil && *installConfig.ControlPlane.Replicas < 3 {
    12  		controlPlaneTopology = configv1.SingleReplicaTopologyMode
    13  	} else {
    14  		controlPlaneTopology = configv1.HighlyAvailableTopologyMode
    15  	}
    16  
    17  	numOfWorkers := int64(0)
    18  	for _, mp := range installConfig.Compute {
    19  		if mp.Replicas != nil {
    20  			numOfWorkers += *mp.Replicas
    21  		}
    22  	}
    23  	switch numOfWorkers {
    24  	case 0:
    25  		infrastructureTopology = controlPlaneTopology
    26  	case 1:
    27  		infrastructureTopology = configv1.SingleReplicaTopologyMode
    28  	default:
    29  		infrastructureTopology = configv1.HighlyAvailableTopologyMode
    30  	}
    31  
    32  	return controlPlaneTopology, infrastructureTopology
    33  }
    34  
    35  func determineCPUPartitioning(installConfig *types.InstallConfig) configv1.CPUPartitioningMode {
    36  	switch installConfig.CPUPartitioning {
    37  	case types.CPUPartitioningAllNodes:
    38  		return configv1.CPUPartitioningAllNodes
    39  	default:
    40  		return configv1.CPUPartitioningNone
    41  	}
    42  }