Using Kubernetes, I'm trying to map *.api requests to *.
I found this thread which helps me how to achieve this and it's working by updating the CoreDNS configuration.
But I would like to do this via a yaml apply so it can be easily deployed to different environments. Also if the CoreDNS config changes in a later release, I won't be getting those changes.
So my question is, how could I apply a yaml file to achieve this:
rewrite stop {
name regex (.*)\.api {1}.some-namespace.svc.cluster.local
answer name (.*)\.some-namespace\.svc\.cluster\.local {1}.api
}
I found this article: https://docs.microsoft.com/en-us/azure/aks/coredns-custom
But I'm unable to figure out how I can use that example for my use-case.
Given that there are no other answers yet, let me describe a possible approach...two, actually.
The main idea is to use CoreDNS' import directive - "...The import plugin can be used to include files into the main configuration". And from the CoreDNS manual - "...This plugin is a bit special in that it may be used anywhere in the Corefile".
One option (#1) is to edit the coredns
configMap to add import
directive to include configuration from another file like in these configMap-s for AKS and k3s; then add a new volume in the deployment config - see here and here.
Another option (#2) could be to add a new configMap with your configuration and that also imports the /etc/coredns/Corefile
file mounted as volume from the "stock" coredns
configMap; change the coredns
deployment configuration to add a volume from the new configMap and point the "-conf" argument to the file mounted as volume from the new configMap.
A drawback is that in both cases you'll have to re-implement the change if in a later release the coredns configMap and/or deployment configuration change.