Page MenuHomePhabricator

Remove `.cluster.local.` suffix in PTR responses
Open, LowPublic

Description

When reverse-resolving a k8s pod IP it'd be really really nice to know at a glance what k8s cluster it comes from.

Right now, the PTRs return the endpoint names in the .cluster.local pseudospace, for example:

21.75.192.10.in-addr.arpa. 5    IN      PTR     10-192-75-21.eventstreams-production-tls-service.eventstreams.svc.cluster.local.

This is actually "eventstreams-production" on the staging-codfw cluster. Impossible to tell from this DNS response.

CoreDNS's rewrite plugin supports modifying the values of returned PTRs ... as of this pull request, first released in v1.9.4.

We run v1.8.7.

  • Upgrade to at least v1.9.4
  • Modify helm chart to add rewrite rule for PTR responses to replace .cluster.local suffix with something like $CLUSTERNAME.k8s.wmnet e.g. staging-codfw.k8s.wmnet

Another option:

Remove cluster.local at the kubelet / cluster configuration level. Requires at least kubelet and workload container restarts, possibly more.

Event Timeline

I'm fine with that. We'll have to do a CoreDNS update during T341984: Update Kubernetes clusters to 1.31 anyways. We used to stick to versions that are installed by kubeadm by default (https://github.com/coredns/deployment/blob/master/kubernetes/CoreDNS-k8s_version.md) which does not look feasible in this particular case (as we already run the more or less matching version).
But as long as there is nothing obvious in CoreDNS release nodes regarding old k8s versions (or new k8s features it requires - which I doubt) I'd opt to go 1.11.1 right away.

I'm fine with that. We'll have to do a CoreDNS update during T341984: Update Kubernetes clusters to 1.31 anyways. We used to stick to versions that are installed by kubeadm by default (https://github.com/coredns/deployment/blob/master/kubernetes/CoreDNS-k8s_version.md) which does not look feasible in this particular case (as we already run the more or less matching version).
But as long as there is nothing obvious in CoreDNS release nodes regarding old k8s versions (or new k8s features it requires - which I doubt) I'd opt to go 1.11.1 right away.

+1

I'm not sure though what implications the rewrite might have for cluster internal clients (where .cluster.local is perfectly valid and recommended to use). Can we make it so that the rewrite only happens for external clients?

I'm not sure though what implications the rewrite might have for cluster internal clients (where .cluster.local is perfectly valid and recommended to use). Can we make it so that the rewrite only happens for external clients?

I was going to make it only happen on PTR queries, which I think should be a no-op for in-cluster purposes?

We could also add a rewrite rule on incoming queries to effectively make the rewritten suffix an alias for .cluster.local.

I guess another option would be to open up a new listener on CoreDNS and serve that one externally instead.

+1 on an upgrade regardless of the rest.

As for the rewrite part, we are currently setting cluster.local via hiera (it is also the default). There is a discussion we can have here about whether we want that setting to be the same across all clusters or whether it makes sense to have it per cluster. We probably should have had this conversation a bit earlier before we started using it more extensively, but it's probably not too late. Does it make sense to make this unique and per cluster? This would mean some deployments will need overrides per cluster in helmfile.d, but that's probably not too bad? I am not super fond of rewriting DNS replies for what is worth, I 'd rather we didn't end up with extended split horizons of inside/outside cluster. I could see it as a stopgap for solely PTR records though.

As for the rewrite part, we are currently setting cluster.local via hiera (it is also the default). There is a discussion we can have here about whether we want that setting to be the same across all clusters or whether it makes sense to have it per cluster. We probably should have had this conversation a bit earlier before we started using it more extensively, but it's probably not too late. Does it make sense to make this unique and per cluster? This would mean some deployments will need overrides per cluster in helmfile.d, but that's probably not too bad?

I took a quick look at it and once I realized it was part of Kubelet configuration -- and thus would probably require full cluster rebuilds? -- I gave up on the idea of changing it, at least for now.

But OTOH: we already went through the trouble to not reuse IP spaces between different k8s clusters in our infra. It seems quite reasonable to me to make their DNS names also globally unique.

I'm not strictly against changing then name, but I think it's a bit of work.
Adding chart value overrides for deployments is one thing, changes to helm chart modules another (ingress and mesh module, as well as certs IIRC). And while I don't think changing the kubelet parameter will require a full rebuild, a kubelet restart is required for sure and probably a restart of all containers running. New containers will come up with the new domain, so both need to be supported in parallel during the transition.

It won't require full rebuilds indeed. But it will require restarting all containers so that they pick up the new domain name. Which for most should be a noop cause, on purpose (due to discovery), we don't rely on these DNS records for most workloads. The hard part is probably figure out what (if anything) will break across all clusters and amend proactively.

Should we attempt this on a cluster or two? One of the stagings, and then perhaps aux?

CDanis renamed this task from CoreDNS upgrade so we can rewrite `.cluster.local.` suffix in PTR responses to Remove `.cluster.local.` suffix in PTR responses.Oct 21 2024, 1:50 PM
CDanis updated the task description. (Show Details)

Should we attempt this on a cluster or two? One of the stagings, and then perhaps aux?

Fine by me.

As an extra minor rant, which doesn't really impact the rest of the discussion much.

21.75.192.10.in-addr.arpa. 5 IN PTR 10-192-75-21.eventstreams-production-tls-service.eventstreams.svc.cluster.local.
This is actually "eventstreams-production" on the staging-codfw cluster. Impossible to tell from this DNS response.

This is badly named.

21.75.192.10.in-addr.arpa. 5 IN PTR 10-192-75-21.eventstreams-production-tls-service.eventstreams.svc.cluster.local.
This is actually "eventstreams-production" on the staging-codfw cluster. Impossible to tell from this DNS response.

This is badly named.

Totally agree. But it isn't the only example, there's many such cases.

💙root@deploy1003.eqiad.wmnet ~ 🕦🙃 kubectl cluster-info 
Kubernetes control plane is running at https://kubestagemaster.svc.eqiad.wmnet:6443
kube-dns is running at https://kubestagemaster.svc.eqiad.wmnet:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
💙root@deploy1003.eqiad.wmnet ~ 🕦🙃 kubectl get pods -A | grep production
eventgate-analytics-external    eventgate-production-666b767759-khk97                      2/2     Running   0                10d
eventgate-analytics             eventgate-production-5f9fbf46db-r8gw4                      2/2     Running   0                11d
eventgate-logging-external      eventgate-production-6588676f45-42b7l                      2/2     Running   1 (11d ago)      11d
eventgate-main                  eventgate-production-7d648ffccf-fm62q                      2/2     Running   0                11d
eventstreams                    eventstreams-production-5568888cf5-586jk                   2/2     Running   0                11d
proton                          chromium-render-production-6db4ddff7d-zcgpj                2/2     Running   0                3d5h
recommendation-api              recommendation-api-production-7fd9d87886-vmhpc             2/2     Running   0                11d