-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Support SRV record creation with cloudflare provider #4754
base: master
Are you sure you want to change the base?
Support SRV record creation with cloudflare provider #4754
Conversation
Welcome @starcraft66! |
Hi @starcraft66. 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 Once the patch is verified, the new status will be reflected by the 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-sigs/prow repository. |
78a12d5
to
5f828ae
Compare
return nil, fmt.Errorf("invalid port in SRV record content: %s", parts[2]) | ||
} | ||
|
||
target := parts[3] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wdyt of checking IP format with ParseIP ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It wouldn't really make sense here afaik because the the target could be a hostname that would have to be resolved, so pretty much anything goes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this PR. Overall it looks good, and it's tested 👍.
Wdyt of updating documentation in order to show how to create a SRV record ?
/ok-to-test |
Just added documentation |
docs/sources/srv-record.md
Outdated
# SRV record with CRD source | ||
|
||
You can create and manage SRV records with the help of [CRD source](../contributing/crd-source.md) | ||
and `DNSEndpoint` CRD. The implementation of this feature depends on provider API support, this feature is currently known to be supported supported by `akamai`, `civo`, `cloudflare`, `ibmcloud`, `linode`, `rfc2136` and `pdns` providers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might not be completely accurate but I can't test every provider, I just built this list by grepping for mentions of SRV
in the providers folder and searching the issue tracker.
@starcraft66 Thanks for the documentation. See my comments for a first review of the code. |
@starcraft66 Do you need any help with this PR, glad to help if possible. |
I was going to take a look at this as soon as I have some time but haven't gotten to it yet. Feel free to link some commits and I can push them to my branch, I love open source collaboration |
It seems we can proceed with final review and merge for this one. @starcraft66 Do you think you can address the last comments and rebase this PR ? |
Hey sorry, I was on vacation. Will rebase this asap. |
Signed-off-by: Tristan Gosselin-Hane <[email protected]>
8dd6fe6
to
7372d50
Compare
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@mloiseleur ready for review |
Hi. Nice on, I'll do an initial review. /label tide/merge-method-squash |
In order to start managing MX records you need to set the `--managed-record-types SRV` flag. | ||
|
||
```console | ||
external-dns --source crd --provider {akamai|civo|cloudflare|ibmcloud|linode|rfc2136|pdns} --managed-record-types A --managed-record-types CNAME --managed-record-types SRV |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are we sure all this providers support SRV?
- dnsName: _sip._udp.example.com | ||
recordTTL: 180 | ||
recordType: SRV | ||
targets: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to share smoke tests as well, could you please also provide a way to test this manually with manifests and kubectl commands? Similar to this example #5111 (comment)
for cloudflare is enough, I'll do for aws or google?
I'm unsure where or not multiple targets supported, never tried that case.
} | ||
|
||
if cfc.ResourceRecord.Type == "SRV" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems identical to cloudflare.CreateDNSRecordParams. Shell we create a shared method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
|
||
// parseSRVContent parses the SRV record content string into the structured data required by the Cloudflare API | ||
func parseSRVContent(content string) (map[string]interface{}, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
target := parts[3] | ||
|
||
return map[string]interface{}{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we have a struct instead?
if endpoint.RecordType == "SRV" { | ||
srvData, err := parseSRVContent(target) | ||
if err != nil { | ||
log.Errorf("Error parsing SRV content: %v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -707,7 +765,19 @@ func groupByNameAndTypeWithCustomHostnames(records []cloudflare.DNSRecord, chs [ | |||
} | |||
targets := make([]string, len(records)) | |||
for i, record := range records { | |||
targets[i] = record.Content | |||
if record.Type == "SRV" { | |||
if dataMap, ok := record.Data.(map[string]interface{}); ok { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
targets[i] = record.Content | ||
if record.Type == "SRV" { | ||
if dataMap, ok := record.Data.(map[string]interface{}); ok { | ||
priority, _ := dataMap["priority"].(float64) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same apply, could we have a concrete struct, so we do not need to cast?
Description
Implements SRV record creation when using the cloudflare provider. Cloudflare's API requires sending SRV record data in structured fields rather than a bare string with the record.
I'm not a Go developer and just did the bare minimum to get this working and tested, I've confirmed this works on my personal cluster. Feel free to suggest improvements.
Fixes #4751
Checklist