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

[FEATURE] Allow CoreDNS extension with custom configuration #816

Open
johgoe opened this issue Oct 25, 2021 · 8 comments
Open

[FEATURE] Allow CoreDNS extension with custom configuration #816

johgoe opened this issue Oct 25, 2021 · 8 comments
Assignees
Labels
enhancement New feature or request k3s This is likely an issue with k3s not k3d itself priority/high
Milestone

Comments

@johgoe
Copy link

johgoe commented Oct 25, 2021

We want to add add a custom core dns configuration

e.g.

rewrite name regex (.*)\.local\.kyma\.dev istio-ingressgateway.istio-system.svc.cluster.local

to core dns configmap. Currently we have to patch the coredns configmap after every start again.

@johgoe johgoe added the enhancement New feature or request label Oct 25, 2021
@johgoe
Copy link
Author

johgoe commented Oct 25, 2021

I saw in an different product a coredns configuration like this one

apiVersion: v1
data:
  Corefile: |
    .:53 {
        errors
        ready
        health
        kubernetes cluster.local in-addr.arpa ip6.arpa {
          pods insecure
          fallthrough in-addr.arpa ip6.arpa
        }
        prometheus :9153
        forward . /etc/resolv.conf
        cache 30
        loop
        reload
        loadbalance
        import custom/*.override
    }
    import custom/*.server

which allows overides by imports (https://coredns.io/plugins/import/)

Maybe this could be a solution to solve this feature request.

@iwilltry42
Copy link
Member

Hi @johgoe , thanks for opening this issue and thanks for the suggestion.
In fact, I'm currently discussing this with the K3s developers. More concretely, I'd like to get k3s-io/k3s#743 revived, so we don't have to hack this into k3d (as K3s does some templating etc. when rendering the CoreDNS template on K3s server startup).
Maybe you can add your opinion and input (e.g. the wildcard way you proposed) there? 👍

@iwilltry42 iwilltry42 added k3s This is likely an issue with k3s not k3d itself priority/medium labels Oct 25, 2021
@iwilltry42 iwilltry42 self-assigned this Oct 25, 2021
@iwilltry42 iwilltry42 added this to the v5.1.0 milestone Oct 25, 2021
@johgoe
Copy link
Author

johgoe commented Oct 25, 2021

I added a note to k3s-io/k3s#462

@iwilltry42
Copy link
Member

Following up on this in k3s-io/k3s#4397

@iwilltry42
Copy link
Member

Moving this to Milestone v5.5.0 as I'd like to integrate it with some larger changes that require detecting the used K3s version first and matching it against a map of supported features.

@iwilltry42 iwilltry42 modified the milestones: v5.4.0, v5.5.0 Mar 26, 2022
@rassie
Copy link

rassie commented Jul 22, 2022

Is there any new status on this? It seems that adding coredns-custom config map does something, but I couldn't get it to rewrite my domains. Adding the same entry into the main server block works immediately.

@msaunois-dzr
Copy link

msaunois-dzr commented Jul 27, 2022

Is there any new status on this? It seems that adding coredns-custom config map does something, but I couldn't get it to rewrite my domains. Adding the same entry into the main server block works immediately.

I'm facing the same issue. I don't know that much about coredns, if I patch the ConfigMap to add a rewrite in the Corefile before the kubernetes plugin, my rule works fine. But if I create a coredns-custom ConfigMap with a server and the same rewrite, my requests fail.

The patched main ConfigMap that works:

apiVersion: v1
data:
  Corefile: |
    .:53 {
        errors
        health
        ready
        # That rewrite rule is working fine in the Corefile
        rewrite name my-internal.domain.com host.k3d.internal
        kubernetes cluster.local in-addr.arpa ip6.arpa {
          pods insecure
          fallthrough in-addr.arpa ip6.arpa
        }
        # etc...

My attempt with a custom ConfigMap:

apiVersion: v1
kind: ConfigMap
metadata:
  name: coredns-custom
  namespace: kube-system
data:
  my-internal.domain.server: |
    my-internal.domain.com {
        log
        rewrite name my-internal.domain.com host.k3d.internal
    }

Am I doing it wrong?

Edit: I added the errors plugin in my server block, and the rewrite plugin returns an error in the coredns logs:
[ERROR] plugin/errors: 0 host.k3d.internal. AAAA: plugin/rewrite: no next plugin found

So host.k3d.internal does not seem to be reachable inside server blocks.

Edit 2: I finally fixed my issue with the following ConfigMap:

apiVersion: v1
kind: ConfigMap
metadata:
  name: coredns-custom
  namespace: kube-system
data:
  my-internal.domain.server: |
    my-internal.domain.com {
        log
        rewrite name my-internal.domain.com host.k3d.internal
        forward . 127.0.0.1
    }

@iwilltry42 iwilltry42 modified the milestones: v5.5.0, v5.6.0 May 17, 2023
@rassie
Copy link

rassie commented Jul 26, 2023

It seems like this has been addressed upstream at k3s (k3s-io/k3s#7639). In my limited testing, it's working like it should!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request k3s This is likely an issue with k3s not k3d itself priority/high
Projects
Status: To do
Development

No branches or pull requests

4 participants