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

[draft] expose coredns as loadbalancer service in local setup #1828

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

abaguas
Copy link
Collaborator

@abaguas abaguas commented Feb 9, 2025

Before this PR, the local setup was exposing coreDNS using a nodeport service. To expose it outside of k3d it required mapping the exposed DNS port 5053/5054 (for cluster1 and cluster2, respectively) to a single node and making sure coredns is running there. This is a bit hacky and not the usual way to expose a service outside of a cluster.

k get svc -n k8gb
NAME               TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)         AGE
...
k8gb-coredns-tcp   NodePort    10.43.37.190   <none>        53:30053/TCP    117s

This PR changes the setup to using the more common loadbalancer service, obtaining the same result with a bit less configuration.

[k3d-test-gslb1|k8gb] ➜  k get svc k8gb-coredns
NAME           TYPE           CLUSTER-IP     EXTERNAL-IP             PORT(S)                     AGE
k8gb-coredns   LoadBalancer   10.43.59.251   172.18.0.6,172.18.0.7   53:32301/UDP,53:32301/TCP   16m

Additionally, DNS queries to the clusters now work using UDP and TCP, before only TCP was possible:

➜  ~ dig -p 5053 +tcp @localhost localtargets-failover.cloud.example.com +short
172.18.0.6
172.18.0.7
➜  ~ dig -p 5053 @localhost localtargets-failover.cloud.example.com +short
172.18.0.6
172.18.0.7
➜  ~ dig -p 5054 @localhost localtargets-failover.cloud.example.com +short
172.18.0.11
172.18.0.12
➜  ~ dig -p 5054 +tcp @localhost localtargets-failover.cloud.example.com +short
172.18.0.11
172.18.0.12

Note: k3d behaves a bit different than the usual kubernetes cluster since it uses a daemon set behind the scenes. That is why the load balancer has multiple external IPs. Nonetheless, the functionality for the user is the exact same.

[k3d-test-gslb1|k8gb] ➜  ~/code/k8gb git:(coredns/loadbalancer) kgp -n kube-system -o wide | grep coredns
svclb-k8gb-coredns-15f61200-ljxxx           2/2     Running   0          18m   10.42.1.3   k3d-test-gslb1-server-0   <none>           <none>
svclb-k8gb-coredns-15f61200-vcz6l           2/2     Running   0          18m   10.42.0.2   k3d-test-gslb1-agent-0    <none>           <none>

@abaguas abaguas force-pushed the coredns/loadbalancer branch 7 times, most recently from f950b26 to 1cb1ecc Compare February 9, 2025 22:38
@abaguas abaguas force-pushed the coredns/loadbalancer branch from 1cb1ecc to 9d2d4c6 Compare March 2, 2025 22:13
@k0da
Copy link
Collaborator

k0da commented Mar 3, 2025

@abaguas any blockers with this?

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.

2 participants