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

dns/route53: change accessKey to be a secret ref #197

Closed
wants to merge 4 commits into from

Conversation

euank
Copy link
Contributor

@euank euank commented Nov 13, 2017

What this PR does / why we need it:

It's not unusual to store the aws access and secret keys together in the
same secret under different keys. This allows conveniently using that
same secret for both.

I have not yet deployed and manually tested this change, but I plan to fairly soon. Feel free to wait on that.

The AWS Route53 dns01 provider's Access Key must now be configured as a secret reference. If you have any Issuers or CluserIssuers configured with AWS IAM credentials, they **must** be updated to use the new `accessKeyIDSecretRef` field.

Note, this incidentally improves error handling for the other dns providers by refactoring secret-key-data-has-that-key checking into its own function

@jetstack-bot jetstack-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Nov 13, 2017
@jetstack-bot
Copy link
Contributor

Hi @euank. Thanks for your PR.

I'm waiting for a jetstack 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.

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. I understand the commands that are listed here.

@jetstack-bot jetstack-bot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Nov 13, 2017
@jetstack-ci-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
We suggest the following additional approver: munnerz

Assign the PR to them by writing /assign @munnerz in a comment when ready.

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

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@euank
Copy link
Contributor Author

euank commented Nov 19, 2017

I've deployed this change to my cluster and insured that the route53 provider config, using the accessKeyIDSecretRef, works for me.

Copy link
Member

@munnerz munnerz left a comment

Choose a reason for hiding this comment

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

Sorry, I've had a review of this sitting in my GitHub but not submitted for almost a week now!

Thanks for this change - as we do not yet provide a stable API, I think we're best to remove the old field for this and instead require the accessKeyIDSecretRef is specified on issuers. wdyt?

@@ -126,12 +126,17 @@ clouddns:
```yaml
route53:
accessKeyID: AKIAIOSFODNN7EXAMPLE
Copy link
Member

Choose a reason for hiding this comment

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

I think we should remove the accessKeyID field altogether. I'd rather have a smaller API surface than provide countless options that aren't that useful 😄

@@ -126,12 +126,17 @@ clouddns:
```yaml
route53:
accessKeyID: AKIAIOSFODNN7EXAMPLE
accessKeyIDRef:
Copy link
Member

Choose a reason for hiding this comment

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

This should be accessKeyIDSecretRef (from types.go below)

@@ -36,6 +36,7 @@ spec:
- name: route53
route53:
# The Route53 access key ID
# optionally, 'accessKeyIDRef' may be used instead to reference a secret
Copy link
Member

Choose a reason for hiding this comment

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

accessKeyIDSecretRef

region: eu-west-1
secretAccessKeySecretRef:
name: prod-route53-credentials-secret
key: secret-access-key
```

*Note*: Only one of `accessKeyID` and `accessKeyIDRef` should be specified.
Copy link
Member

Choose a reason for hiding this comment

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

This can be removed

@@ -36,6 +36,7 @@ spec:
- name: route53
route53:
# The Route53 access key ID
# optionally, 'accessKeyIDRef' may be used instead to reference a secret
accessKeyID: AKIADKOU3GLWAQM8WQKJ
Copy link
Member

Choose a reason for hiding this comment

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

Replace with accessKeyIDSecretRef specification

HostedZoneID string `json:"hostedZoneID"`
Region string `json:"region"`
AccessKeyID string `json:"accessKeyID,omitempty"`
AccessKeyIDRef SecretKeySelector `json:"accessKeyIDSecretRef,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

I think we want to remove omitempty here

@euank euank force-pushed the akid-ref branch 2 times, most recently from 1f1a09e to 84107a9 Compare December 23, 2017 02:27
@euank euank changed the title dns/route53: allow accessKey to be a secret ref dns/route53: change accessKey to be a secret ref Dec 23, 2017
@euank
Copy link
Contributor Author

euank commented Dec 23, 2017

Apologies for being slow to get back to this; I've addressed your comments.

I agree it makes sense to require the secret ref if we're okay with the API breakage.

@euank
Copy link
Contributor Author

euank commented Jan 11, 2018

/hold

This change will merge conflict with #243. Let's land that one first. I'll remove the hold and do the rebase/merging once that one lands.

@euank
Copy link
Contributor Author

euank commented Jan 11, 2018

/hold

(last time I had trailing stuff after /hold, I don't know if that breaks it or not)

@jetstack-bot jetstack-bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 11, 2018
@munnerz munnerz removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jan 11, 2018
# The Route53 access key ID
accessKeyID: AKIADKOU3GLWAQM8WQKJ
# A secretKeyRef to a the route53 secret access key
# A secretKeyRef to a the AWS IAM credentials
Copy link
Contributor

Choose a reason for hiding this comment

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

to a the -> to the

(driveby, hi euank!)

@jetstack-bot jetstack-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 15, 2018
@Capitrium
Copy link

@euank Is this still on hold? Seems like #243 was superseded by #363, it'd be great to get this merged in as well.

@euank
Copy link
Contributor Author

euank commented Apr 18, 2018

Thanks for the reminder @Capitrium; I'll pick this back up

@euank
Copy link
Contributor Author

euank commented Apr 19, 2018

/hold cancel

@jetstack-bot jetstack-bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 19, 2018
@jetstack-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To fully approve this pull request, please assign additional approvers.
We suggest the following additional approver: munnerz

Assign the PR to them by writing /assign @munnerz in a comment when ready.

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

@jetstack-bot jetstack-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 19, 2018
@euank
Copy link
Contributor Author

euank commented Apr 19, 2018

I've updated the code, but haven't updated my deployment to gain as much confidence as before.
I also made the release-note wording stronger since it's a breaking change.

I'll be away for the next two weeks; feel free to make changes or take it over if that's preferable to waiting.

@munnerz munnerz added area/acme Indicates a PR directly modifies the ACME Issuer code and removed area/acme Indicates a PR directly modifies the ACME Issuer code labels Apr 25, 2018
@euank
Copy link
Contributor Author

euank commented May 17, 2018

/retest

prow appears to be wedged

@jetstack-bot
Copy link
Contributor

@euank: you can't request testing unless you are a jetstack member.

In response to this:

/retest

prow appears to be wedged

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.

euank added 4 commits May 19, 2018 18:40
It's not unusual to store the aws access and secret keys together in the
same secret under different keys. This allows conveniently using that
same secret for both.
This introduces better error handling for the case where the value was
not present since the helper checks the `, ok` value for the map
accesses, but the existing code didn't.
It is preferable to use the 'accessKeyIDSecretRef' instead of the
'accessKeyID' field.

This is primarily because in real-world deployments those two items are
typically stored as two keys in a secret. This change matches host most
users store aws secrets in K8s now.
@euank
Copy link
Contributor Author

euank commented May 20, 2018

Rebased again, seems to be working fine on my cluster... ping @munnerz for review since you did the last round several months ago :)

@jetstack-bot jetstack-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 7, 2018
@jetstack-bot
Copy link
Contributor

@euank: PR needs rebase.

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.

Copy link
Member

@munnerz munnerz left a comment

Choose a reason for hiding this comment

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

Sorry for the massive delay on this - it's just been buried in my list of assigned PRs/issues 😬

I've added a couple of extra thoughts - I think we should probably introduce this in a backwards compatible way, as it won't be too difficult to do.

We also now have API validations defined in pkg/apis/certmanager/validations. Could you update these accordingly for the new field?

You may also need to make some changes to the new resolveSecretKeyRef function since there have been some recently changes to how DNS providers detect the 's.resourceNamespace` field.

Again, very sorry for the delay here! I think if we can make this backwards compatible, we can get this merged straight away :)

SecretAccessKey SecretKeySelector `json:"secretAccessKeySecretRef"`
HostedZoneID string `json:"hostedZoneID"`
Region string `json:"region"`
AccessKeyIDRef SecretKeySelector `json:"accessKeyIDSecretRef"`
Copy link
Member

Choose a reason for hiding this comment

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

Can we update this PR to not be a breaking change? i.e. if a user specifies accessKeyID, it is still used. But if a user specifies accessKeyIDSecretRef, it takes precedence?

Copy link
Member

Choose a reason for hiding this comment

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

In a later release we can then add validation to prevent both being set, before removing the old field altogether for 1.0.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I can revert it back to what I originally had.

I think at this point, this is blocked on making sure this is a step in the right direction via discussion in #687 though

@retest-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close.
Send feedback to jetstack.
/lifecycle stale

@jetstack-bot jetstack-bot added lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. dco-signoff: no Indicates that at least one commit in this pull request is missing the DCO sign-off message. labels Nov 6, 2018
@retest-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.
If this issue is safe to close now please do so with /close.
Send feedback to jetstack.
/lifecycle rotten
/remove-lifecycle stale

@jetstack-bot jetstack-bot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Dec 6, 2018
@retest-bot
Copy link

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.
Send feedback to jetstack.
/close

@jetstack-bot
Copy link
Contributor

@retest-bot: Closing this PR.

In response to this:

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.
Send feedback to jetstack.
/close

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.

@Sinjo
Copy link

Sinjo commented Aug 5, 2021

Hey, sorry to revive the comment thread on such an old PR, but I recently ran into a situation where I wanted to do this (read the accessKeyID from a secret rather than having to put it in the Issuer resource itself).

I figure the ship has long since sailed on replacing accessKeyID altogether, but I was wondering if you'd be open to a PR that lets you provide one or the other (i.e. either accessKeyID or accessKeyIDSecretRef, exclusively).

I ended up using ambient credentials, but that does mean using one AWS user for the whole cert-manager installation. Not a problem for now, but could be a limiting factor in future as our setup evolves.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/acme Indicates a PR directly modifies the ACME Issuer code dco-signoff: no Indicates that at least one commit in this pull request is missing the DCO sign-off message. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. release-note Denotes a PR that will be considered when it comes time to generate release notes. 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.

9 participants