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

Cloudflare support #1278

Merged
merged 4 commits into from
Nov 15, 2023
Merged

Cloudflare support #1278

merged 4 commits into from
Nov 15, 2023

Conversation

ytsarev
Copy link
Member

@ytsarev ytsarev commented Sep 23, 2023

Cloudflare support

It is early stage PR and requires thorough end-to-end testing before the merge.

I made only very initial tests making sure that external-dns can access cloudflare API with the valid API token

How to test this PR:

  • deploy k8gb with
cloudflare:
  # -- Enable Cloudflare provider
  enabled: true
  # -- Cloudflare Zone ID
  zoneID: replaceme
  • create cloudflare API token in k8gb namespace
kubectl -n k8gb create secret generic cloudflare --from-literal=token=secret_token_value

Make sure that there is no newline character in the secret, otherwise the authentication will fail

  • k -n k8gb logs -f deploy/external-dns - you should see no authentication errors
time="2023-09-23T01:13:40Z" level=debug msg="zoneIDFilter configured. only looking up zone IDs defined"

That is the baseline.

Now we need to start creating Gslb objects and observe the actual DNS record population on Cloudflare side.

This part of the testing is not done yet, and we will need community help here.

@ytsarev
Copy link
Member Author

ytsarev commented Sep 23, 2023

I proceeded a bit further with testing.

Having this in external-dns logs

time="2023-09-23T09:46:05Z" level=error msg="failed to create record: DNS Validation Error (1004)" action=CREATE record=gslb-ns-eu-test.k8gb.io ttl=30 type=A zone=37c15d7c15808f1882bf168542d0d40b

Found possible root cause at https://wordathemes.com/cloudflare-dns-validation-error-code-1004/#:~:text=Ensure%20Correct%20TTL%20Value,to%20the%20DNS%20validation%20limit.

Ensure Correct TTL Value
Another major reason for the code 1004 error is an invalid TTL value. Cloudflare recommends using a TTL value between 120 and 2,147,483,647. However, some users may try to limit it to a much lower value to reduce the DNS propagation time. This can lead to the DNS validation limit. To avoid this, it’s recommended to set the TTL value to 1 or to use the automatic setting.

Standard low TTL values that are used in k8gb setup by default are too low for cloudflare.

I will try to play with TTL values.

@ytsarev
Copy link
Member Author

ytsarev commented Sep 23, 2023

Alight, after adding

  strategy:
    dnsTtlSeconds: 120

to Gslb spec I can see glue A records created for the zone delegation

image

Next challenge: teach extenrnal-dns cloudflare provider to create NS records.

It looks like it is disabled and we need to create PR similar to kubernetes-sigs/external-dns#2835

@ytsarev
Copy link
Member Author

ytsarev commented Oct 8, 2023

I've found the root cause for NS records not being created and fixed it in 8e9035e

It looks great after the fix:
image

PR is ready for the full e2e test

Copy link

netlify bot commented Nov 12, 2023

Deploy Preview for k8gb-preview ready!

Name Link
🔨 Latest commit 10e0ffa
🔍 Latest deploy log https://app.netlify.com/sites/k8gb-preview/deploys/655156e05cc8950008b04c3e
😎 Deploy Preview https://deploy-preview-1278--k8gb-preview.netlify.app/docs/deploy_cloudflare
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Add Cloudflare support following the https://github.com/kubernetes-sigs/external-dns/blob/master/docs/tutorials/cloudflare.md

Switch to new CF_API_TOKEN, fix external-dns RBAC for cloudflare

Enable ext dns flag for cloudflare

Signed-off-by: Yury Tsarev <yury@upbound.io>
* Add custom prefix for TXT meta records for external-dns
* The reason is to avoid the clash in Cloudflare during NS record
  creation:
```
level=error msg="failed to create record: Non-NS records with that host already exist. (81055)" action=CREATE record=test.k8gb.io ttl=120 type=NS zone=37c15d7c15808f1882bf168542d0d40b
```

Signed-off-by: Yury Tsarev <yury@upbound.io>
Signed-off-by: Yury Tsarev <yury@upbound.io>
Signed-off-by: Yury Tsarev <yury@upbound.io>
@ytsarev
Copy link
Member Author

ytsarev commented Nov 12, 2023

Documentation preview is available at https://deploy-preview-1278--k8gb-preview.netlify.app/docs/deploy_cloudflare, the PR is fully ready for the review

@ytsarev ytsarev merged commit 5e7c60d into k8gb-io:master Nov 15, 2023
10 checks passed
ytsarev added a commit to ytsarev/k8gb that referenced this pull request Dec 18, 2023
* Release `v0.12.0` with
  Cloudflare(k8gb-io#1278) and GSS-TSIG
  support(k8gb-io#1064)
* Inline maintainer list update to be aligned with https://github.com/k8gb-io/k8gb/blob/master/CODEOWNERS

Signed-off-by: Yury Tsarev <yury@upbound.io>
@ytsarev ytsarev mentioned this pull request Dec 18, 2023
ytsarev added a commit to ytsarev/k8gb that referenced this pull request Dec 19, 2023
* Release `v0.12.0` with
  Cloudflare(k8gb-io#1278) and GSS-TSIG
  support(k8gb-io#1064)
* Inline maintainer list update to be aligned with https://github.com/k8gb-io/k8gb/blob/master/CODEOWNERS

Signed-off-by: Yury Tsarev <yury@upbound.io>
ytsarev added a commit that referenced this pull request Dec 19, 2023
* Release `v0.12.0` with
  Cloudflare(#1278) and GSS-TSIG
  support(#1064)
* Inline maintainer list update to be aligned with https://github.com/k8gb-io/k8gb/blob/master/CODEOWNERS

Signed-off-by: Yury Tsarev <yury@upbound.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cloudflare GSLB support
2 participants