How to Add Custom Host Entries to CoreDNS in Kubernetes?

0
13
Asked By CloudySky99 On

Hey folks! I'm trying to inject some local host entries into the CoreDNS engine for my Kubernetes setup. I've crafted a YAML file to add these custom entries, which looks like this:

```
apiVersion: v1
kind: ConfigMap
metadata:
name: coredns-custom
namespace: kube-system
data:
# The key name can be anything, but must end with .override
local-containers.override: |
hosts {
192.168.12.6 oracle.fedora.local broker01.fedora.local broker02.fedora.local broker03.fedora.local oracle broker01 broker02 broker03

fallthrough
}
```

After creating this, I launched a Fedora container, but I can't seem to see those entries in the host table. It looks like the config map is expecting `/etc/coredns/custom/*.override`, and I'm not sure if what I've created matches that requirement.

I also tried adding a custom host block, but that caused DNS issues in the containers. I attempted to create a block for docker hosts similar to the node hosts, but that didn't persist either. All I want is custom name resolution without needing a full DNS server setup. Any advice would be greatly appreciated! Another thing—I noticed the coredns pod won't even start after I added my entries. Help!

2 Answers

Answered By NodeNinja88 On

Another option is to utilize the hostAlias feature directly in your deployment definition. It might streamline the process for you. You can find more about it here: https://kubernetes.io/docs/tasks/network/customize-hosts-file-for-pods/.

Answered By TechieTurtle42 On

You might want to check this guide out; it could provide the clarity you need: [Adding Custom Host to Kubernetes](https://hjrocha.medium.com/add-a-custom-host-to-kubernetes-a06472cedccb).

Also, `local-containers.override` doesn't seem to be standard in Kubernetes, so that could be part of the issue.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.