coredns / coredns/helm

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

Open
#159 0 comments 2 reactions 0 assignees View on GitHub
Dominant language
Mustache
Stars
146
Forks
145
Avg merge
6d 5h
Merged PRs (30d)
2

Description

Given a simple helm values that looks like this:

```yaml
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](https://coredns.io/plugins/template/) 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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.