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

feat(core): Add experimental account storage API #5594

Merged
merged 5 commits into from
Jan 7, 2022

Conversation

jvz
Copy link
Contributor

@jvz jvz commented Dec 8, 2021

This adds an experimental API for storing and loading account
credentials definitions from an external durable store such as a SQL
database. Secrets can be referenced through the existing Kork
SecretEngine API which will be fetched on demand. Initial support is for
Kubernetes accounts given the lack of existing Kubernetes cluster
federation standards compared to other cloud providers, though this API
is made generic to allow for other cloud provider APIs to participate in
this system.

spinnaker/spinnaker#6525

@dbyron-sf
Copy link
Contributor

Hey @jvz I'm probably already supposed to know this, but does this PR enable dynamic refresh of the accounts, or are they still loaded only at startup?

@jvz
Copy link
Contributor Author

jvz commented Dec 14, 2021

Refreshing is done via credentials polling currently. If you enable that, then this gets refreshed along with any other credentials definition sources you have.

@jvz
Copy link
Contributor Author

jvz commented Dec 16, 2021

Alright, I've updated based on most of the feedback so far. I need to dig a little deeper into the SQL implementation to update the deletion behavior documented in spinnaker/gate#1494

@jvz
Copy link
Contributor Author

jvz commented Dec 20, 2021

I've updated the deletion behavior and made the revision history a little better. I've also removed some unused endpoints in the API.

@dbyron-sf
Copy link
Contributor

Thanks @jvz I'm looking forward to taking another look, but at this point I don't think it'll be til the new year.

@jvz
Copy link
Contributor Author

jvz commented Dec 20, 2021

That's what I expected; just wanted to make sure I finished the PR updates before the same new year before I forgot about them!

@jvz
Copy link
Contributor Author

jvz commented Dec 20, 2021

Oh, also helps to push this to my fork and not just a private repo. Pushed!

@dbyron-sf
Copy link
Contributor

@jvz I'm still struggling to catch up from the flood of messages after being off for awhile...this is still very much on my radar though...

@jvz
Copy link
Contributor Author

jvz commented Jan 4, 2022

No worries! I just got back from holidays, so I made sure to leave pings where applicable.

Copy link
Contributor

@german-muzquiz german-muzquiz left a comment

Choose a reason for hiding this comment

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

Is it correct to assume that for this to work, clouddriver.yml needs to enable the poller?

credentials:
  poller:
    enabled: true
    types:
      kubernetes:
        reloadFrequencyMs: 60000

clouddriver-sql/clouddriver-sql.gradle Outdated Show resolved Hide resolved
* @param name account name to look up history for
* @return history of account updates for the given account name
*/
List<Revision> revisionHistory(String name);
Copy link
Contributor

Choose a reason for hiding this comment

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

This is great

This adds an experimental API for storing and loading account
credentials definitions from an external durable store such as a SQL
database. Secrets can be referenced through the existing Kork
SecretEngine API which will be fetched on demand. Initial support is for
Kubernetes accounts given the lack of existing Kubernetes cluster
federation standards compared to other cloud providers, though this API
is made generic to allow for other cloud provider APIs to participate in
this system.
var string = super.deserialize(p, ctxt);
if (EncryptedSecret.isEncryptedSecret(string)) {
return EncryptedSecret.isEncryptedFile(string)
? secretManager.decryptAsFile(string).toString()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should this add a file: prefix, too?

Copy link
Contributor

Choose a reason for hiding this comment

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

Apparently that's only used for SAML related files that may be used in gate or fiat, so I'd say this is fine without the file: prefix.

}

@GetMapping("/{accountName}/history")
@PreAuthorize("hasPermission(#accountName, 'ACCOUNT', 'READ')")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This should probably be changed to WRITE permissions before being exposed in Gate.

@jvz jvz requested a review from german-muzquiz January 7, 2022 00:42
var string = super.deserialize(p, ctxt);
if (EncryptedSecret.isEncryptedSecret(string)) {
return EncryptedSecret.isEncryptedFile(string)
? secretManager.decryptAsFile(string).toString()
Copy link
Contributor

Choose a reason for hiding this comment

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

Apparently that's only used for SAML related files that may be used in gate or fiat, so I'd say this is fine without the file: prefix.

@dbyron-sf dbyron-sf added the ready to merge Approved and ready for a merge label Jan 7, 2022
@mergify mergify bot merged commit 264af19 into spinnaker:master Jan 7, 2022
@mergify mergify bot added the auto merged Merged automatically by a bot label Jan 7, 2022
@jvz jvz deleted the account-api branch January 7, 2022 23:24
nhtzr pushed a commit to armory/clouddriver that referenced this pull request Aug 17, 2022
* feat(core): Add experimental account storage API

This adds an experimental API for storing and loading account
credentials definitions from an external durable store such as a SQL
database. Secrets can be referenced through the existing Kork
SecretEngine API which will be fetched on demand. Initial support is for
Kubernetes accounts given the lack of existing Kubernetes cluster
federation standards compared to other cloud providers, though this API
is made generic to allow for other cloud provider APIs to participate in
this system.

* Combine AccountController with CredentialsController

* Fix account permissions and add comments

* Add alpha annotations

* Use correct annotations for rest APIs
nhtzr pushed a commit to armory/clouddriver that referenced this pull request Aug 18, 2022
* feat(core): Add experimental account storage API

This adds an experimental API for storing and loading account
credentials definitions from an external durable store such as a SQL
database. Secrets can be referenced through the existing Kork
SecretEngine API which will be fetched on demand. Initial support is for
Kubernetes accounts given the lack of existing Kubernetes cluster
federation standards compared to other cloud providers, though this API
is made generic to allow for other cloud provider APIs to participate in
this system.

* Combine AccountController with CredentialsController

* Fix account permissions and add comments

* Add alpha annotations

* Use correct annotations for rest APIs
nhtzr pushed a commit to armory/clouddriver that referenced this pull request Aug 18, 2022
* feat(core): Add experimental account storage API

This adds an experimental API for storing and loading account
credentials definitions from an external durable store such as a SQL
database. Secrets can be referenced through the existing Kork
SecretEngine API which will be fetched on demand. Initial support is for
Kubernetes accounts given the lack of existing Kubernetes cluster
federation standards compared to other cloud providers, though this API
is made generic to allow for other cloud provider APIs to participate in
this system.

* Combine AccountController with CredentialsController

* Fix account permissions and add comments

* Add alpha annotations

* Use correct annotations for rest APIs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto merged Merged automatically by a bot ready to merge Approved and ready for a merge target-release/1.28
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants