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

DigitalOcean DNS-01 support #345

Closed
wants to merge 0 commits into from
Closed

DigitalOcean DNS-01 support #345

wants to merge 0 commits into from

Conversation

dl00
Copy link

@dl00 dl00 commented Feb 24, 2018

What this PR does / why we need it:

This PR adds DigitalOcean DNS-01 challenge support.

Which issue this PR fixes

No issue, I just wanted it.

Special notes for your reviewer:

  • There are included tests for the DigitalOcean API, using the DIGITALOCEAN_TOKEN and DIGITALOCEAN_DOMAIN environment variables to run live.
  • I have not tested E2E in a real system yet, partially because I was not able to find any docs on how to build the image in this repo
  • There is a license file some of the other DNS-01 challenge implementations, and I was not sure what to do with it :) I am of course happy to put this code on whatever the most appropriate license is supposed to be for this project.

Release note:

@jetstack-bot jetstack-bot added do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Feb 24, 2018
@jetstack-bot jetstack-bot added release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Feb 24, 2018
@munnerz
Copy link
Member

munnerz commented Feb 27, 2018

/ok-to-test

@jetstack-bot jetstack-bot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Feb 27, 2018
@dl00
Copy link
Author

dl00 commented Feb 27, 2018

W0227 08:20:46.640] The Service "nginx-ingress-controller" is invalid: spec.clusterIP: Invalid value: "10.0.0.15": provided IP is already allocated

Any idea how I can cause an error like that? That appears to be the root cause.

@munnerz
Copy link
Member

munnerz commented Feb 27, 2018

That's a really unfortunate test flake that occasionally comes up. I've not had a chance to fix it yet 😬

/retest

@munnerz
Copy link
Member

munnerz commented Mar 8, 2018

I have not tested E2E in a real system yet, partially because I was not able to find any docs on how to build the image in this repo

There's been some work by @euank here: #381 to document how to build/deploy a custom version of cert-manager if you're able to try this out on DigitialOcean!

I've not got an account, nor anything set up over there so if you could test it and let me know, I'd be happy to merge this if all is okay! (I've taken a look, and there's nothing really to change! 😄 💯)

return nil, fmt.Errorf("No existing record found for %s", fqdn)
}

func (c *DNSProvider) makeRequest(method, uri string, body io.Reader) (json.RawMessage, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason for hand-writing the 50 lines of client code we need vs using the digital ocean godo library to make these calls?

Copy link
Author

Choose a reason for hiding this comment

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

I am aware of the godo library. However, it is a library for the entire DO API, vs just 50 lines to make the 1 or 2 API calls needed. I was also observing the convention of the other DNS providers making similar choices.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the other DNS providers all use the cloud-provider provided library, excepting cloudflare.

I'm personally in favour of using those libraries when possible since auth and retry logic can be a bit tricky otherwise.
I'll defer to @munnerz if he wishes to weigh in differently.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 using the official go library reduces the amount of testing and maintenance for this area of code

Copy link
Member

Choose a reason for hiding this comment

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

I'm open to doing this in future - so far, we've copied across all the DNS providers from xenolf/lego when implementing them here. There's nothing wrong with us changing/improving them, but I don't think it's a requirement in order to accept it initially.

return nil, err
}

return nil, fmt.Errorf("DigitalOcean API Error \n%d: %s", r.Code, r.Message)
Copy link
Contributor

Choose a reason for hiding this comment

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

In general, it's preferable to not have newlines in error strings.

Copy link
Author

Choose a reason for hiding this comment

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

I don't know go very well, I was just copying from the other DNS providers. Will fix if @munnerz agrees.

Copy link
Member

Choose a reason for hiding this comment

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

yep could you remove the \n 😄

case providerConfig.DigitalOcean != nil:
apiTokenSecret, err := s.secretLister.Secrets(s.resourceNamespace).Get(providerConfig.DigitalOcean.Token.Name)
if err != nil {
return nil, fmt.Errorf("error getting digitalocean token: %s", err.Error())
Copy link
Contributor

Choose a reason for hiding this comment

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

There's no need to call .Error here (I know other parts of this file do too, they should be fixed as well).

The %s format string will automatically call .Error for anything that implements error (with a higher priority than calling .String even, see playground)

@sylvainfilteau
Copy link

I would really like to test this PR, what are the steps to run this branch locally ?

I tried the doc/devel instructions without success. I'm unfortunately completely in the dark with the go development stack.

@dl00
Copy link
Author

dl00 commented Mar 18, 2018

@sylvainfilteau seems like what you have to do is run make build. You can then push whatever images it generates to your registry or wherever. You may need to download the repository using go get github.com/jetstack/cert-manager/... before that works though.

Your testing would really help out, since I have been too busy! I also still have to do a couple small corrections in the code as mentioned earlier anyway. Since munnerz has voiced support for using godo, I will probably add it.

@munnerz
Copy link
Member

munnerz commented Mar 19, 2018

@dl00 if it's easy enough to switch to godo, I'm happy for it to happen, although would like to see some automated tests running to ensure it works if you do.

Otherwise I'm happy to accept this as is given it's been verified in the upstream xenolf/lego repo.

@sylvainfilteau
Copy link

I opened an issue #401 because of my incapacity to build the code.

@jetstack-bot jetstack-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 5, 2018
@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
@ulrichSchreiner
Copy link

hi,

i would really appreciate to see this code in cert-manager ... is anything that can be done to get this merged?

@dl00
Copy link
Author

dl00 commented May 24, 2018 via email

@oliverkane
Copy link

Nothing to add except I was looking at forking this myself, and then saw there was much progress. Commenting to subscribe to updates as this is something I'm interested in.

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

dl00 commented May 29, 2018

@munnerz what is the appropriate way to run the E2E tests on my local machine? If I try to run make e2e_test, it says error installing cm.

I am nearly done with the switch to Godo, just testing.

@katcheLS
Copy link

katcheLS commented Jul 1, 2018

What’s the status on this PR? I’m interested in using digital ocean DNS-01 challenge later this year, and I hope this hasn’t dropped off the radar too far. If no one is working on it, I might be able to contribute in a couple months.

@dl00
Copy link
Author

dl00 commented Jul 1, 2018

i have made some changes, but I am unsure why the checks are failing. and then I forgot about this issue again because of life. I can take another look in a few days.

@Richard87
Copy link

I'm testing a little bit, I would love to se DO-DNS provider!

@dl00 to fix the cm errors, I had to create a namespace "cert-manager" , and update tiller with a proper service account :)

@jetstack-bot jetstack-bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 14, 2018
@jetstack-bot jetstack-bot added lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Aug 3, 2018
@kragniz
Copy link
Contributor

kragniz commented Aug 3, 2018

@dl00 thanks!

@dl00
Copy link
Author

dl00 commented Aug 3, 2018

/retest

@retest-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to jetstack).
Review the full test history for this PR.
Silence the bot with an /lgtm cancel comment for consistent failures.

1 similar comment
@retest-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to jetstack).
Review the full test history for this PR.
Silence the bot with an /lgtm cancel comment for consistent failures.

@dl00
Copy link
Author

dl00 commented Aug 3, 2018

/lgtm cancel

@jetstack-bot jetstack-bot removed the lgtm Indicates that a PR is ready to be merged. label Aug 3, 2018
context.Background(),
util.UnFqdn(zoneName),
createRequest,
)
Copy link
Member

Choose a reason for hiding this comment

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

Will this return an error if the record already exists?

Copy link
Member

Choose a reason for hiding this comment

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

(it should 'upsert', i.e. absorb errors if the record already exists)

Copy link
Author

Choose a reason for hiding this comment

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

In my testing digital ocean will simply post a duplicate of the record without error even if the challenge is exactly the same. Later it deletes any matching records found during clean up.

This can be added to the tests explicitly if you prefer.

@munnerz
Copy link
Member

munnerz commented Aug 3, 2018

@dl00 I've resolved the issues with the e2e environment that have hit all PRs this evening. A domain used during e2e tests had expired..!

I've just got that one Q, and if that's all okay then we can go ahead and apply lgtm again 😄

@dl00
Copy link
Author

dl00 commented Aug 3, 2018

I've responded, thanks for your help!

@dl00
Copy link
Author

dl00 commented Aug 4, 2018

/retest

@Noah-Huppert
Copy link

Noah-Huppert commented Aug 5, 2018

Super excited for this PR!

Being able to move over from kube-lego -> cert-manager with DigitalOcean DNS-01 will solve an issue I have been having with kube-lego for a while now.

🙌

If there is anything I can do to help please let me know!

@dl00
Copy link
Author

dl00 commented Aug 7, 2018

@munnerz ready to merge when you are

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

@dl00: 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.

@munnerz
Copy link
Member

munnerz commented Aug 7, 2018

Hey - sorry there's been a few PRs merged today and this was obviously not merged beforehand! 😬

I'll drop a merge commit on top of your branch to bring this up to speed with the latest changes if you've got the 'Allow edits from maintainers' option enabled and get this merged to save you having to do more work!

Again, sorry for all the hassle!

@dl00
Copy link
Author

dl00 commented Aug 7, 2018

@munnerz the setting you mentioned is enabled, thanks for your help.

@kragniz kragniz closed this Aug 13, 2018
@jetstack-bot jetstack-bot added retest-not-required-docs-only size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Aug 13, 2018
@jetstack-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kragniz

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

@munnerz munnerz removed the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 13, 2018
@kragniz
Copy link
Contributor

kragniz commented Aug 13, 2018

Sorry, I pushed the wrong branch by mistake and closed this. I've continued in #821 since I can't push to this branch anymore.

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 needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. release-note-none Denotes a PR that doesn't merit a release note. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet