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

Add support for openstack application credentials #6534

Merged

Conversation

piequi
Copy link
Contributor

@piequi piequi commented Aug 14, 2020

What type of PR is this?
/kind feature

What this PR does / why we need it:
Add support for OpenStack application credentials to authenticate against Keystone API (instead of using username and password)

Which issue(s) this PR fixes:

Fixes #6533

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

NONE

@k8s-ci-robot k8s-ci-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Aug 14, 2020
@k8s-ci-robot
Copy link
Contributor

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.


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.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Aug 14, 2020
@k8s-ci-robot
Copy link
Contributor

Welcome @piequi!

It looks like this is your first PR to kubernetes-sigs/kubespray 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/kubespray has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot requested review from alijahnas and EppO August 14, 2020 12:17
@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Aug 14, 2020
@k8s-ci-robot
Copy link
Contributor

Hi @piequi. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Aug 14, 2020
@piequi
Copy link
Contributor Author

piequi commented Aug 14, 2020

oops ! CLA is now signed

@floryut
Copy link
Member

floryut commented Aug 14, 2020

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 14, 2020
@piequi
Copy link
Contributor Author

piequi commented Aug 14, 2020

I signed it

@oomichi
Copy link
Contributor

oomichi commented Aug 14, 2020

/check-cla

1 similar comment
@piequi
Copy link
Contributor Author

piequi commented Aug 17, 2020

/check-cla

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Aug 17, 2020
@phpHavok
Copy link

phpHavok commented Aug 19, 2020

I tried out this branch, and I think it'd be better to read the default values from the environment, just like the other variables. In other words, add to roles/kubernetes-apps/external_cloud_controller/openstack/defaults/main.yml:

external_openstack_application_credential_name: "{{ lookup('env','OS_APPLICATION_CREDENTIAL_NAME') }}"
external_openstack_application_credential_id: "{{ lookup('env','OS_APPLICATION_CREDENTIAL_ID') }}"
external_openstack_application_credential_secret: "{{ lookup('env','OS_APPLICATION_CREDENTIAL_SECRET') }}"

Diff: application-credentials.diff.txt
Edit: OpenStack Horizon lets you download a specialized OpenRC file when you create an application credential that already has these variables set (with the exception of the credential name, which seems optional), so this would be the most straightforward for users I think (rather than manually editing the group_vars).

@phpHavok
Copy link

Another issue I found when trying to build. The tenant-id and domain-id are not required when using application credentials. So the credential checker should have a case to check for that.

See: https://github.com/kubernetes/cloud-provider-openstack/blob/master/docs/using-openstack-cloud-controller-manager.md

@piequi
Copy link
Contributor Author

piequi commented Aug 20, 2020

... I think it'd be better to read the default values from the environment, ...
...
Edit: OpenStack Horizon lets you download a specialized OpenRC file when you create an application credential that already has these variables set, so this would be the most straightforward for users I think (rather than manually editing the group_vars).

I'm not totally sure that application credentials are commonly set in user environment variables (compared to username and password). Specifying application credentials in the Ansible environment (in openstack.yml) that will be used along with all other settings by the playbook, is more explicit.

Another issue I found when trying to build. The tenant-id and domain-id are not required when using application credentials. So the credential checker should have a case to check for that.

See: https://github.com/kubernetes/cloud-provider-openstack/blob/master/docs/using-openstack-cloud-controller-manager.md

You are right. I'll update the check regarding tenant-id and domain-id.

Thanks

@piequi piequi force-pushed the support-openstack-application-creds branch from 0da8abb to cadad2f Compare August 20, 2020 13:47
@Miouge1
Copy link
Contributor

Miouge1 commented Aug 27, 2020

I haven't used app credentials yet, @alijahnas and @bl0m1 any feedback on this?

@Miouge1
Copy link
Contributor

Miouge1 commented Aug 27, 2020

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Miouge1, piequi

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 27, 2020
@rptaylor
Copy link
Contributor

rptaylor commented Aug 27, 2020

I was a bit confused at first by the checks in openstack-credential-check.yml ; the logic is a bit hard to understand because of the way the fail task is used. The 'when' conditions combine the variables that need to be checked, and the circumstances in which they need to be checked, all in the same list.

What about using assert instead, with when conditions? That way there is a clear separation between what is being checked, and the condition when that check needs to be done. It would be more readable and understandable and should be easier to write too, like e.g. 'assert that password or secret is defined when ID is defined'

@piequi
Copy link
Contributor Author

piequi commented Aug 27, 2020

@rptaylor replacing fail tasks by assert has nothing to do with application credentials.

If you think this is relevant, feel free to contribute.

@rptaylor
Copy link
Contributor

@piequi It has to do with the way the new application credential functionality is implemented; I am just suggesting it would be a cleaner way.

Copy link

@huxcrux huxcrux left a comment

Choose a reason for hiding this comment

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

LGTM.

I cannot se any reasons not to accept this. looks to be compatible with occm 👍

@Miouge1
Copy link
Contributor

Miouge1 commented Aug 31, 2020

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 31, 2020
@floryut floryut mentioned this pull request Aug 31, 2020
@k8s-ci-robot k8s-ci-robot merged commit 5a8b68a into kubernetes-sigs:master Aug 31, 2020
@piequi piequi deleted the support-openstack-application-creds branch September 7, 2020 16:59
LuckySB pushed a commit to southbridgeio/kubespray that referenced this pull request Jan 12, 2021
* Add support for openstack application credentials

* Add some lines for readability

* Update external_openstack_tenant_id check

Do not check external_openstack_tenant_id when application credentials are defined

* Add check for external_openstack_domain_id

* Fix typo
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for OpenStack application credentials
8 participants