Skip to content
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

GCP: allow environmental authentication #6330

Merged
merged 4 commits into from
Sep 16, 2022

Conversation

patrickdillon
Copy link
Contributor

@patrickdillon patrickdillon commented Sep 11, 2022

Enables environmental authentication, so that the Installer when running on a GCP VM can authenticate with the VM's service account without requiring a service account in a JSON file.

The ability to authenticate through the GCP environment was added in the original commit for GCP auth (05924cb). This PR builds on that work to enable the full deployment of a cluster. Prior to this change, the cluster secret would be invalid and provisioning infrastructure would fail, if no service account JSON object is present.

The biggest challenge here is that the signed URLs used to enable accessing bootstrap ignition require the private key from a service account JSON file in order to sign the URL. To solve this, I updated terraform to create a service account specifically for bootstrapping, and use the private key from that.

I explored the idea of granting explicit permission for the bootstrap node to access the bootstrap ignition object, but there is not a clear way to do this. Unless the object is public, the bootstrap node would need to pass an authentication token in the header when requesting access to the object, but the Terraform ignition provider does not support adding headers: so there is no way to pass the token when making the request.

The current solution is more in-line with the existing install procedure, which already uses signed urls.

https://issues.redhat.com/browse/CORS-2050

Make service account optional to allow for authentication through
service accounts when running on GCP.

cf: https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference#primary-authentication
Signed URLs, which are used to provide access to the bootstrap
ignition storage object, require a service account key (the private
key is used to sign the url). This works fine when the installer is
authenticated with a service account json file.

In order to allow authentication of the installer with other methods,
this commit creates a service account for the bootstrap process,
and uses that private key to sign the url.
@patrickdillon
Copy link
Contributor Author

Reworked the validation logic to allow better unit testing.

When authenticating with any method other than a JSON service account
file, the Installer should require manual mode. Prior to this change,
the Installer is silently writing an empty cluster credential file .
Updates unit tests to add new GetCredentials method.
allErrs := field.ErrorList{}
creds := client.GetCredentials()

if creds.JSON == nil && ic.CredentialsMode != types.ManualCredentialsMode {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we check the credentials mode first? If the creds mode is not correct error immediately without calling GetCredentials().

Copy link
Contributor Author

@patrickdillon patrickdillon Sep 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "correctness" of the credentials mode depends on the credential contents, so we have to grab them.

@patrickdillon
Copy link
Contributor Author

Updated PR description

@sadasu
Copy link
Contributor

sadasu commented Sep 14, 2022

/retest-required

@sadasu
Copy link
Contributor

sadasu commented Sep 14, 2022

/approve

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 14, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sadasu

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 14, 2022
@jstuever
Copy link
Contributor

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Sep 15, 2022
@openshift-ci-robot
Copy link
Contributor

/retest-required

Remaining retests: 0 against base HEAD 609a627 and 2 for PR HEAD 79851cb in total

@openshift-ci-robot
Copy link
Contributor

/retest-required

Remaining retests: 0 against base HEAD 1a7b474 and 1 for PR HEAD 79851cb in total

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 16, 2022

@patrickdillon: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-gcp-ovn-shared-vpc 79851cb link false /test e2e-gcp-ovn-shared-vpc
ci/prow/okd-e2e-gcp-ovn-upgrade 79851cb link false /test okd-e2e-gcp-ovn-upgrade

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@openshift-ci-robot
Copy link
Contributor

/retest-required

Remaining retests: 0 against base HEAD d1f6f04 and 0 for PR HEAD 79851cb in total

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants