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

Configmap Helm template doesn't play well with the CoreDNS "template" plugin #159

Open
c-p-b opened this issue Jan 28, 2024 · 0 comments
Open

Comments

@c-p-b
Copy link

c-p-b commented Jan 28, 2024

Given a simple helm values that looks like this:

isClusterService: false
servers:
- zones:
  - zone: my.internal.zone
  port: 53
  plugins:
  - name: template ANY ANY 
    configBlock: |-
        answer "{{ .Name }} 60 IN A 10.0.0.1" 
        }                                                                                                                                              
  - name: errors
  # Serves a /health endpoint on :8080, required for livenessProbe
  - name: health
    configBlock: |-
      lameduck 5s
  # Serves a /ready endpoint on :8181, required for readinessProbe
  - name: ready
  # Required to query kubernetes API for data
  - name: kubernetes
    parameters: cluster.local in-addr.arpa ip6.arpa
    configBlock: |-
      pods insecure
      fallthrough in-addr.arpa ip6.arpa
      ttl 30
  # Serves a /metrics endpoint on :9153, required for serviceMonitor
  - name: prometheus
    parameters: 0.0.0.0:9153
  - name: forward
    parameters: . /etc/resolv.conf
  - name: cache
    parameters: 30
  - name: loop
  - name: reload
  - name: loadbalance
  - name: log

If you can see, we get a nice Corefile templated out from that, that is appropriate

 Corefile: "my.internal.zone:53 {\n    template
    ANY ANY {\n        answer \"{{ .Name }} 60 IN A 10.0.0.1\" \n        }                                                                                                                                              \n
    \   }\n    errors\n    health {\n        lameduck 5s\n    }\n    ready\n    kubernetes
    cluster.local in-addr.arpa ip6.arpa {\n        pods insecure\n        fallthrough
    in-addr.arpa ip6.arpa\n        ttl 30\n    }\n    prometheus 0.0.0.0:9153\n    forward
    . /etc/resolv.conf\n    cache 30\n    loop\n    reload\n    loadbalance\n    log\n}"

BUT, as you can see, quite a bit of a hack is required (template ANY ANY) in order to use the template plugin syntax appropriately. This is because of two reasons.

  • The first reason is that the template plugin syntax is newline sensitive, so we cannot just stuff everything into a single line using parameters (which would be a bit of a hack in of itself).
  • The second is that configblock, the only current way in the chart to insert multiline, automatically inserts a bracket after the plugin name. This works for a lot of plugins, I assume (I'm kind of new to CoreDNS), but it does not work for this one. It will give you an error for invalid syntax instead.

I'm not exactly sure the recommended restructuring of plugin templating based on this, but I imagine removing the preceding bracket is a breaking change, so perhaps introduction of another field is a viable option for those of us who want to use the coredns template plugin and configure it in values without this dirty hack

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

No branches or pull requests

1 participant