github.com/openshift/installer@v1.4.17/pkg/types/azure/platform.go (about)

     1  package azure
     2  
     3  import (
     4  	"fmt"
     5  	"strings"
     6  )
     7  
     8  // aro is a setting to enable aro-only modifications
     9  var aro bool
    10  
    11  // OutboundType is a strategy for how egress from cluster is achieved.
    12  // +kubebuilder:validation:Enum="";Loadbalancer;NatGateway;UserDefinedRouting
    13  type OutboundType string
    14  
    15  const (
    16  	// LoadbalancerOutboundType uses Standard loadbalancer for egress from the cluster.
    17  	// see https://docs.microsoft.com/en-us/azure/load-balancer/load-balancer-outbound-connections#lb
    18  	LoadbalancerOutboundType OutboundType = "Loadbalancer"
    19  
    20  	// NatGatewayOutboundType uses NAT gateway for egress from the cluster
    21  	// see https://learn.microsoft.com/en-us/azure/virtual-network/nat-gateway/nat-gateway-resource
    22  	NatGatewayOutboundType OutboundType = "NatGateway"
    23  
    24  	// UserDefinedRoutingOutboundType uses user defined routing for egress from the cluster.
    25  	// see https://docs.microsoft.com/en-us/azure/virtual-network/virtual-networks-udr-overview
    26  	UserDefinedRoutingOutboundType OutboundType = "UserDefinedRouting"
    27  )
    28  
    29  // Platform stores all the global configuration that all machinesets
    30  // use.
    31  type Platform struct {
    32  	// Region specifies the Azure region where the cluster will be created.
    33  	Region string `json:"region"`
    34  
    35  	// ARMEndpoint is the endpoint for the Azure API when installing on Azure Stack.
    36  	ARMEndpoint string `json:"armEndpoint,omitempty"`
    37  
    38  	// ClusterOSImage is the url of a storage blob in the Azure Stack environment containing an RHCOS VHD. This field is required for Azure Stack and not applicable to Azure.
    39  	ClusterOSImage string `json:"clusterOSImage,omitempty"`
    40  
    41  	// BaseDomainResourceGroupName specifies the resource group where the Azure DNS zone for the base domain is found. This field is optional when creating a private cluster, otherwise required.
    42  	//
    43  	// +optional
    44  	BaseDomainResourceGroupName string `json:"baseDomainResourceGroupName,omitempty"`
    45  
    46  	// DefaultMachinePlatform is the default configuration used when
    47  	// installing on Azure for machine pools which do not define their own
    48  	// platform configuration.
    49  	// +optional
    50  	DefaultMachinePlatform *MachinePool `json:"defaultMachinePlatform,omitempty"`
    51  
    52  	// NetworkResourceGroupName specifies the network resource group that contains an existing VNet
    53  	//
    54  	// +optional
    55  	NetworkResourceGroupName string `json:"networkResourceGroupName,omitempty"`
    56  
    57  	// VirtualNetwork specifies the name of an existing VNet for the installer to use
    58  	//
    59  	// +optional
    60  	VirtualNetwork string `json:"virtualNetwork,omitempty"`
    61  
    62  	// ControlPlaneSubnet specifies an existing subnet for use by the control plane nodes
    63  	//
    64  	// +optional
    65  	ControlPlaneSubnet string `json:"controlPlaneSubnet,omitempty"`
    66  
    67  	// ComputeSubnet specifies an existing subnet for use by compute nodes
    68  	//
    69  	// +optional
    70  	ComputeSubnet string `json:"computeSubnet,omitempty"`
    71  
    72  	// cloudName is the name of the Azure cloud environment which can be used to configure the Azure SDK
    73  	// with the appropriate Azure API endpoints.
    74  	// If empty, the value is equal to "AzurePublicCloud".
    75  	// +optional
    76  	CloudName CloudEnvironment `json:"cloudName,omitempty"`
    77  
    78  	// OutboundType is a strategy for how egress from cluster is achieved. When not specified default is "Loadbalancer".
    79  	// "NatGateway" is only available in TechPreview.
    80  	//
    81  	// +kubebuilder:default=Loadbalancer
    82  	// +optional
    83  	OutboundType OutboundType `json:"outboundType"`
    84  
    85  	// ResourceGroupName is the name of an already existing resource group where the cluster should be installed.
    86  	// This resource group should only be used for this specific cluster and the cluster components will assume
    87  	// ownership of all resources in the resource group. Destroying the cluster using installer will delete this
    88  	// resource group.
    89  	// This resource group must be empty with no other resources when trying to use it for creating a cluster.
    90  	// If empty, a new resource group will created for the cluster.
    91  	//
    92  	// +optional
    93  	ResourceGroupName string `json:"resourceGroupName,omitempty"`
    94  
    95  	// UserTags has additional keys and values that the installer will add
    96  	// as tags to all resources that it creates on AzurePublicCloud alone.
    97  	// Resources created by the cluster itself may not include these tags.
    98  	// +optional
    99  	UserTags map[string]string `json:"userTags,omitempty"`
   100  
   101  	// CustomerManagedKey has the keys needed to encrypt the storage account.
   102  	CustomerManagedKey *CustomerManagedKey `json:"customerManagedKey,omitempty"`
   103  }
   104  
   105  // KeyVault defines an Azure Key Vault.
   106  type KeyVault struct {
   107  	// ResourceGroup defines the Azure resource group used by the key
   108  	// vault.
   109  	ResourceGroup string `json:"resourceGroup"`
   110  	// Name is the name of the key vault.
   111  	Name string `json:"name"`
   112  	// KeyName is the name of the key vault key.
   113  	KeyName string `json:"keyName"`
   114  }
   115  
   116  // CustomerManagedKey defines the customer managed key settings for encryption of the Azure storage account.
   117  type CustomerManagedKey struct {
   118  	// KeyVault is the keyvault used for the customer created key required for encryption.
   119  	KeyVault KeyVault `json:"keyVault,omitempty"`
   120  	// UserAssignedIdentityKey is the name of the user identity that has access to the managed key.
   121  	UserAssignedIdentityKey string `json:"userAssignedIdentityKey,omitempty"`
   122  }
   123  
   124  // CloudEnvironment is the name of the Azure cloud environment
   125  // +kubebuilder:validation:Enum="";AzurePublicCloud;AzureUSGovernmentCloud;AzureChinaCloud;AzureGermanCloud;AzureStackCloud
   126  type CloudEnvironment string
   127  
   128  const (
   129  	// PublicCloud is the general-purpose, public Azure cloud environment.
   130  	PublicCloud CloudEnvironment = "AzurePublicCloud"
   131  
   132  	// USGovernmentCloud is the Azure cloud environment for the US government.
   133  	USGovernmentCloud CloudEnvironment = "AzureUSGovernmentCloud"
   134  
   135  	// ChinaCloud is the Azure cloud environment used in China.
   136  	ChinaCloud CloudEnvironment = "AzureChinaCloud"
   137  
   138  	// GermanCloud is the Azure cloud environment used in Germany.
   139  	GermanCloud CloudEnvironment = "AzureGermanCloud"
   140  
   141  	// StackCloud is the Azure cloud environment used at the edge and on premises.
   142  	StackCloud CloudEnvironment = "AzureStackCloud"
   143  )
   144  
   145  // Name returns name that Azure uses for the cloud environment.
   146  // See https://github.com/Azure/go-autorest/blob/ec5f4903f77ed9927ac95b19ab8e44ada64c1356/autorest/azure/environments.go#L13
   147  func (e CloudEnvironment) Name() string {
   148  	return string(e)
   149  }
   150  
   151  // SetBaseDomain parses the baseDomainID and sets the related fields on azure.Platform
   152  func (p *Platform) SetBaseDomain(baseDomainID string) error {
   153  	parts := strings.Split(baseDomainID, "/")
   154  	p.BaseDomainResourceGroupName = parts[4]
   155  	return nil
   156  }
   157  
   158  // ClusterResourceGroupName returns the name of the resource group for the cluster.
   159  func (p *Platform) ClusterResourceGroupName(infraID string) string {
   160  	if len(p.ResourceGroupName) > 0 {
   161  		return p.ResourceGroupName
   162  	}
   163  	return fmt.Sprintf("%s-rg", infraID)
   164  }
   165  
   166  // VirtualNetworkName returns the name of the virtual network for the cluster.
   167  func (p *Platform) VirtualNetworkName(infraID string) string {
   168  	if len(p.VirtualNetwork) > 0 {
   169  		return p.VirtualNetwork
   170  	}
   171  	return fmt.Sprintf("%s-vnet", infraID)
   172  }
   173  
   174  // ControlPlaneSubnetName returns the name of the control plane subnet for the
   175  // cluster.
   176  func (p *Platform) ControlPlaneSubnetName(infraID string) string {
   177  	if len(p.ControlPlaneSubnet) > 0 {
   178  		return p.ControlPlaneSubnet
   179  	}
   180  	return fmt.Sprintf("%s-master-subnet", infraID)
   181  }
   182  
   183  // ComputeSubnetName returns the name of the compute subnet for the cluster.
   184  func (p *Platform) ComputeSubnetName(infraID string) string {
   185  	if len(p.ComputeSubnet) > 0 {
   186  		return p.ComputeSubnet
   187  	}
   188  	return fmt.Sprintf("%s-worker-subnet", infraID)
   189  }
   190  
   191  // NetworkSecurityGroupName returns the name of the network security group.
   192  func (p *Platform) NetworkSecurityGroupName(infraID string) string {
   193  	return fmt.Sprintf("%s-nsg", infraID)
   194  }
   195  
   196  // IsARO returns true if ARO-only modifications are enabled
   197  func (p *Platform) IsARO() bool {
   198  	return aro
   199  }