-
Notifications
You must be signed in to change notification settings - Fork 1.5k
CORS-4420, CORS-4421, CORS-4422, CORS-4449, CORS-4514, CORS-4515: Add GCP Germany Sovereign Cloud support #10630
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
barbacbd
wants to merge
4
commits into
openshift:main
Choose a base branch
from
barbacbd:installer_config_updates_gcd
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+174
−27
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
2fdfa16
gcp: Add universe domain field for sovereign cloud support
barbacbd c22f47e
gcp: Apply universe domain from credentials to GCP API clients
barbacbd e27ab7d
gcp: Set sovereign cloud defaults for machine types
barbacbd 7ac111d
gcp: Set universe domain environment variable for CAPI provider
barbacbd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,9 @@ package gcp | |
|
|
||
| import ( | ||
| "fmt" | ||
| "strings" | ||
|
|
||
| "k8s.io/apimachinery/pkg/util/sets" | ||
|
|
||
| "github.com/openshift/installer/pkg/types/dns" | ||
| ) | ||
|
|
@@ -17,6 +20,18 @@ const ( | |
| // UnmanagedFirewallRules indicates that the firewall rules should be managed by the user. The | ||
| // firewall rules should exist prior to the installation occurs. | ||
| UnmanagedFirewallRules FirewallRulesManagementPolicy = "Unmanaged" | ||
|
|
||
| // CloudEnvironmentSovereign is the cloud environment identifier for GCP sovereign clouds. | ||
| CloudEnvironmentSovereign = "sovereign" | ||
| ) | ||
|
|
||
| var ( | ||
| // sovereignCloudProjectPrefixes contains known project ID prefixes for sovereign clouds. | ||
| // Project IDs in sovereign clouds use the format: <prefix>:<project-id> | ||
| // This list helps distinguish from organization-scoped public GCP projects (orgname:project-id). | ||
| sovereignCloudProjectPrefixes = []string{ | ||
| "eu0", // European sovereign cloud (Germany) | ||
| } | ||
| ) | ||
|
|
||
| // DNS contains the gcp dns zone information for the cluster. | ||
|
|
@@ -126,6 +141,12 @@ type Platform struct { | |
| // and the firewall rules before the installation. | ||
| // +optional | ||
| FirewallRulesManagement FirewallRulesManagementPolicy `json:"firewallRulesManagement,omitempty"` | ||
|
|
||
| // UniverseDomain is the Google Cloud universe domain for the cluster. | ||
| // When no value is set, GCP APIs use a default value: googleapis.com. | ||
| // Universe Domain may be required to configure Sovereign Cloud environments. | ||
| // +optional | ||
| UniverseDomain string `json:"universeDomain,omitempty"` | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like you need another |
||
| } | ||
|
|
||
| // UserLabel is a label to apply to GCP resources created for the cluster. | ||
|
|
@@ -184,12 +205,51 @@ func GetConfiguredServiceAccount(platform *Platform, mpool *MachinePool) string | |
|
|
||
| // GetDefaultServiceAccount returns the default service account email to use based on role. | ||
| // The default should be used when an existing service account is not configured. | ||
| // For sovereign cloud project IDs (e.g., eu0:project-id), the service account email format is: | ||
| // | ||
| // service-account-name@project-id.eu0.iam.gserviceaccount.com | ||
| // | ||
| // For standard project IDs, the format is: | ||
| // | ||
| // service-account-name@project-id.iam.gserviceaccount.com | ||
| func GetDefaultServiceAccount(platform *Platform, clusterID string, role string) string { | ||
| return fmt.Sprintf("%s-%s@%s.iam.gserviceaccount.com", clusterID, role[0:1], platform.ProjectID) | ||
| projectID := platform.ProjectID | ||
|
|
||
| // For sovereign cloud project IDs in format "prefix:project-id", swap to "project-id.prefix" | ||
| if strings.Contains(projectID, ":") { | ||
| parts := strings.SplitN(projectID, ":", 2) | ||
| if len(parts) == 2 && sets.New(sovereignCloudProjectPrefixes...).Has(parts[0]) { | ||
| // Sovereign cloud: swap to project-id.prefix format | ||
| // Example: "eu0:openshift" becomes "openshift.eu0" | ||
| projectID = fmt.Sprintf("%s.%s", parts[1], parts[0]) | ||
| } | ||
| // For organization-scoped projects (e.g., "google.com:project-id"), | ||
| // keep the full projectID unchanged and let GCP handle the format | ||
| } | ||
|
|
||
| return fmt.Sprintf("%s-%s@%s.iam.gserviceaccount.com", clusterID, role[0:1], projectID) | ||
| } | ||
|
|
||
| // ShouldUseEndpointForInstaller returns true when the endpoint should be used for GCP api endpoint overrides in the | ||
| // installer. | ||
| func ShouldUseEndpointForInstaller(endpoint *PSCEndpoint) bool { | ||
| return endpoint != nil && endpoint.ClusterUseOnly != nil && !(*endpoint.ClusterUseOnly) | ||
| } | ||
|
|
||
| // GetCloudEnvironment determines the cloud environment from the project ID format. | ||
| // Returns CloudEnvironmentSovereign for sovereign cloud environments, empty string for public GCP. | ||
| // Uses known sovereign cloud project ID prefixes to distinguish from organization-scoped | ||
| // public GCP projects (orgname:project-id). | ||
| func GetCloudEnvironment(projectID string) string { | ||
| // Check if project ID has a known sovereign cloud prefix | ||
| if strings.Contains(projectID, ":") { | ||
|
barbacbd marked this conversation as resolved.
|
||
| parts := strings.SplitN(projectID, ":", 2) | ||
| if len(parts) == 2 && sets.New(sovereignCloudProjectPrefixes...).Has(parts[0]) { | ||
| // Known sovereign prefix is definitive - this IS a sovereign cloud project | ||
| return CloudEnvironmentSovereign | ||
| } | ||
| } | ||
|
|
||
| // No known sovereign prefix found | ||
| return "" | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think
CredentialsFromJSONinternally callsCredentialsFromJSONWithParamsalready, right?