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: SRV record on headless service #4055

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

theloneexplorerquest
Copy link
Contributor

@theloneexplorerquest theloneexplorerquest commented Nov 19, 2023

Description

Support creating SRV records in headless services (ClusterIP).
SRV record form: _container-port-name._port-protocol.my-svc.my-namespace.svc.cluster-domain.example
target form: pod-hostname.my-svc.my-namespace.svc.cluster-domain.example
SRV record:
_container-port-name._port-protocol.my-svc.my-namespace.svc.cluster-domain.example 0 IN SRV 0 50 container-port pod-hostname.my-svc.my-namespace.svc.cluster-domain.example

This is referenced from https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/#srv-records. However, I have notice it does not quite align with the convention of external-dns. Can anyone tell me the properly form of SRV record in the context of external-dns?

I have identified that the test needs to be updated, happy to make update test after someone take a quick look at my PR.

An example:
namespace: default
service name: cassandra
hostname (annotation): example.org

pod1: cassandra-0
container port/name/protocol: 7000, intra-node, TCP, 7001,tls-intra-node, TCP ,7199, jmx, TCP, 9042, cql, TCP

pod2: cassandra-1
container port/name/protocol: 7000, intra-node, TCP, 7001,tls-intra-node, TCP ,7199, jmx, TCP, 9042, cql, TCP

SRV records created:

_cql._tcp.cassandra.default.svc.example.org 0 IN SRV  0 50 9042 cassandra-0.cassandra.default.svc.exa
mple.org;0 50 9042 cassandra-1.cassandra.default.svc.example.org []
_intra-node._tcp.cassandra.default.svc.example.org 0 IN SRV  0 50 7000 cassandra-0.cassandra.default.
svc.example.org;0 50 7000 cassandra-1.cassandra.default.svc.example.org []
_jmx._tcp.cassandra.default.svc.example.org 0 IN SRV  0 50 7199 cassandra-0.cassandra.default.svc.exa
mple.org;0 50 7199 cassandra-1.cassandra.default.svc.example.org []
_tls-intra-node._tcp.cassandra.default.svc.example.org 0 IN SRV  0 50 7001 cassandra-0.cassandra.defa
ult.svc.example.org;0 50 7001 cassandra-1.cassandra.default.svc.example.org []

Fixes #3993

Checklist

  • Unit tests updated
  • End user documentation updated

@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 19, 2023
Copy link

linux-foundation-easycla bot commented Nov 19, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Nov 19, 2023
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 19, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign szuecs for approval. For more information see the Kubernetes Code Review Process.

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot
Copy link
Contributor

Welcome @theloneexplorerquest!

It looks like this is your first PR to kubernetes-sigs/external-dns 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/external-dns has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Nov 19, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @theloneexplorerquest. 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 /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.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Nov 19, 2023
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Nov 19, 2023
@theloneexplorerquest
Copy link
Contributor Author

theloneexplorerquest commented Nov 19, 2023

happy to update PR for test/doc/conflict once the form of SRV record in headless service has been confirmed.

@theloneexplorerquest theloneexplorerquest marked this pull request as ready for review November 19, 2023 12:00
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 19, 2023
@mloiseleur
Copy link
Contributor

mloiseleur commented Nov 23, 2023

@theloneexplorerquest For SRV record, there is a PR aiming to change it, see #4001. It's also using port name for the SRV record.

Correct me if I'm wrong, but it seems this kind of SRV record is already created by Kubernetes. The SRV record format you suggest is interesting mainly inside a k8s cluster.

External-DNS is about creating DNS records outside the k8s cluster.

Would you please detail your use case ?

@theloneexplorerquest
Copy link
Contributor Author

@theloneexplorerquest For SRV record, there is a PR aiming to change it, see #4001. It's also using port name for the SRV record.

Correct me if I'm wrong, but it seems this kind of SRV record is already created by Kubernetes. The SRV record format you suggest is interesting mainly inside a k8s cluster.

External-DNS is about creating DNS records outside the k8s cluster.

Would you please detail your use case ?

I could be wrong here, disclaim I am not using this feature. Just wanna to contribute the project to learning propose, will take a look!

@kwohlfahrt
Copy link

kwohlfahrt commented Nov 25, 2023

I opened the initial request for this in #3993. The request is different to #4001 - that PR changes the behaviour of SRV records for NodePort services, I'm interested in creating SRV records for headless services. AFAIK, only A and AAAA records are created for headless services at the moment.

The first service I'd like to use this for is etcd, which supports the client discovering the server SRV records, so I'd like to see the following records created if my service is configured with a hostname of example.com and has a port named etcd-client-ssl:

  • Type A or AAAA, etcd-${i}.example.com, for each pod ${i} in my service. This is already supported by external-dns.
  • Type SRV, _etcd-client-ssl._tcp.example.com, pointing to the port and the name of the A/AAAA record created above.

I think this could also be useful for LoadBalancer type services, as mentioned by @melnikovx, but I don't have an immediate use-case for that.

@theloneexplorerquest
Copy link
Contributor Author

@mloiseleur do you think above use case is justified? Happy to progress further on this PR 😃

@mloiseleur
Copy link
Contributor

mloiseleur commented Nov 30, 2023

Looking again at kubernetes doc on headless service, it does not says anything about SRV records.
Looking at this comment on a kubernetes issue, it seems it's already possible without external-dns for network inside the cluster.

At the end, TBH, I do not have a strong opinion on this matter. As long as it can be useful for some use case and it's not breaking or overcomplexify source code, why not ?

cc @johngmyers @Raffo @szuecs

@joryirving
Copy link

My use case is far less technical. I just want to create SRV records for minecraft servers I'm hosting on my k8s cluster.
Basically you need an A or CNAME record for the hostname, but you also need a supporting SRV record to map the port properly.

---
apiVersion: externaldns.k8s.io/v1alpha1
kind: DNSEndpoint
metadata:
  name: mc-cname
spec:
  endpoints:
    - dnsName: mc.domain.tld
      recordType: CNAME
      targets: ["ipv4.domain.tld"]
---
apiVersion: externaldns.k8s.io/v1alpha1
kind: DNSEndpoint
metadata:
  name: srv-record
spec:
  endpoints:
  - dnsName: 	_minecraft._tcp
    recordTTL: 300
    recordType: SRV
    targets:
    - "10 5 25565 mc.domain.tld"

https://www.namecheap.com/support/knowledgebase/article.aspx/9765/2208/how-can-i-link-my-domain-name-to-a-minecraft-server/

@dcplaya
Copy link

dcplaya commented Jan 25, 2024

My use case is to use a Rook Ceph cluster to look up the monitor IP addresses via SRV DNS entries.

@mloiseleur
Copy link
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jan 25, 2024
@mloiseleur
Copy link
Contributor

@theloneexplorerquest Do you think you can rebase this PR ?

@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 7, 2024
@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 7, 2024
@mloiseleur
Copy link
Contributor

@theloneexplorerquest test and documentation are needed on this PR

@mloiseleur
Copy link
Contributor

/retitle feat: SRV record on headless service

@k8s-ci-robot k8s-ci-robot changed the title support SRV record on headless service feat: SRV record on headless service Mar 12, 2024
@k8s-ci-robot
Copy link
Contributor

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.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support SRV records for ClusterIP services
6 participants