github.com/openshift/installer@v1.4.17/pkg/types/gcp/platform.go (about) 1 package gcp 2 3 import ( 4 "fmt" 5 ) 6 7 // UserProvisionedDNS indicates whether the DNS solution is provisioned by the Installer or the user. 8 type UserProvisionedDNS string 9 10 const ( 11 // UserProvisionedDNSEnabled indicates that the DNS solution is provisioned and provided by the user. 12 UserProvisionedDNSEnabled UserProvisionedDNS = "Enabled" 13 14 // UserProvisionedDNSDisabled indicates that the DNS solution is provisioned by the Installer. 15 UserProvisionedDNSDisabled UserProvisionedDNS = "Disabled" 16 ) 17 18 // Platform stores all the global configuration that all machinesets 19 // use. 20 type Platform struct { 21 // ProjectID is the the project that will be used for the cluster. 22 ProjectID string `json:"projectID"` 23 24 // Region specifies the GCP region where the cluster will be created. 25 Region string `json:"region"` 26 27 // DefaultMachinePlatform is the default configuration used when 28 // installing on GCP for machine pools which do not define their own 29 // platform configuration. 30 // +optional 31 DefaultMachinePlatform *MachinePool `json:"defaultMachinePlatform,omitempty"` 32 33 // Network specifies an existing VPC where the cluster should be created 34 // rather than provisioning a new one. 35 // +optional 36 Network string `json:"network,omitempty"` 37 38 // NetworkProjectID specifies which project the network and subnets exist in when 39 // they are not in the main ProjectID. 40 // +optional 41 NetworkProjectID string `json:"networkProjectID,omitempty"` 42 43 // ControlPlaneSubnet is an existing subnet where the control plane will be deployed. 44 // The value should be the name of the subnet. 45 // +optional 46 ControlPlaneSubnet string `json:"controlPlaneSubnet,omitempty"` 47 48 // ComputeSubnet is an existing subnet where the compute nodes will be deployed. 49 // The value should be the name of the subnet. 50 // +optional 51 ComputeSubnet string `json:"computeSubnet,omitempty"` 52 53 // userLabels has additional keys and values that the installer will add as 54 // labels to all resources that it creates on GCP. Resources created by the 55 // cluster itself may not include these labels. This is a TechPreview feature 56 // and requires setting CustomNoUpgrade featureSet with GCPLabelsTags featureGate 57 // enabled or TechPreviewNoUpgrade featureSet to configure labels. 58 UserLabels []UserLabel `json:"userLabels,omitempty"` 59 60 // userTags has additional keys and values that the installer will add as 61 // tags to all resources that it creates on GCP. Resources created by the 62 // cluster itself may not include these tags. Tag key and tag value should 63 // be the shortnames of the tag key and tag value resource. This is a TechPreview 64 // feature and requires setting CustomNoUpgrade featureSet with GCPLabelsTags 65 // featureGate enabled or TechPreviewNoUpgrade featureSet to configure tags. 66 UserTags []UserTag `json:"userTags,omitempty"` 67 68 // UserProvisionedDNS indicates if the customer is providing their own DNS solution in place of the default 69 // provisioned by the Installer. 70 // +kubebuilder:default:="Disabled" 71 // +default="Disabled" 72 // +kubebuilder:validation:Enum="Enabled";"Disabled" 73 UserProvisionedDNS UserProvisionedDNS `json:"userProvisionedDNS,omitempty"` 74 } 75 76 // UserLabel is a label to apply to GCP resources created for the cluster. 77 type UserLabel struct { 78 // key is the key part of the label. A label key can have a maximum of 63 characters 79 // and cannot be empty. Label must begin with a lowercase letter, and must contain 80 // only lowercase letters, numeric characters, and the following special characters `_-`. 81 Key string `json:"key"` 82 83 // value is the value part of the label. A label value can have a maximum of 63 characters 84 // and cannot be empty. Value must contain only lowercase letters, numeric characters, and 85 // the following special characters `_-`. 86 Value string `json:"value"` 87 } 88 89 // UserTag is a tag to apply to GCP resources created for the cluster. 90 type UserTag struct { 91 // parentID is the ID of the hierarchical resource where the tags are defined, 92 // e.g. at the Organization or the Project level. To find the Organization ID or Project ID refer to the following pages: 93 // https://cloud.google.com/resource-manager/docs/creating-managing-organization#retrieving_your_organization_id, 94 // https://cloud.google.com/resource-manager/docs/creating-managing-projects#identifying_projects. 95 // An OrganizationID must consist of decimal numbers, and cannot have leading zeroes. 96 // A ProjectID must be 6 to 30 characters in length, can only contain lowercase letters, 97 // numbers, and hyphens, and must start with a letter, and cannot end with a hyphen. 98 ParentID string `json:"parentID"` 99 100 // key is the key part of the tag. A tag key can have a maximum of 63 characters and 101 // cannot be empty. Tag key must begin and end with an alphanumeric character, and 102 // must contain only uppercase, lowercase alphanumeric characters, and the following 103 // special characters `._-`. 104 Key string `json:"key"` 105 106 // value is the value part of the tag. A tag value can have a maximum of 63 characters 107 // and cannot be empty. Tag value must begin and end with an alphanumeric character, and 108 // must contain only uppercase, lowercase alphanumeric characters, and the following 109 // special characters `_-.@%=+:,*#&(){}[]` and spaces. 110 Value string `json:"value"` 111 } 112 113 // DefaultSubnetName sets a default name for the subnet. 114 func DefaultSubnetName(infraID, role string) string { 115 return fmt.Sprintf("%s-%s-subnet", infraID, role) 116 } 117 118 // GetConfiguredServiceAccount returns the service account email from a configured service account for 119 // a control plane or compute node. Returns empty string if not configured. 120 func GetConfiguredServiceAccount(platform *Platform, mpool *MachinePool) string { 121 if mpool != nil && mpool.ServiceAccount != "" { 122 return mpool.ServiceAccount 123 } else if platform.DefaultMachinePlatform != nil { 124 return platform.DefaultMachinePlatform.ServiceAccount 125 } 126 127 return "" 128 } 129 130 // GetDefaultServiceAccount returns the default service account email to use based on role. 131 // The default should be used when an existing service account is not configured. 132 func GetDefaultServiceAccount(platform *Platform, clusterID string, role string) string { 133 return fmt.Sprintf("%s-%s@%s.iam.gserviceaccount.com", clusterID, role[0:1], platform.ProjectID) 134 }