Open fragolinux opened 2 years ago
Any way to implement in k3d the official "coredns-custom" cm, to be created when in config.yaml you define custom hosts or other coredns related mods, instead of the actual method that patches directly the default cm? This would solve the issue, probably...
https://docs.digitalocean.com/products/kubernetes/how-to/customize-coredns/
@fragolinux see https://github.com/k3d-io/k3d/issues/816
Defining a custom DNS config would not fix my problem. I am trying to manage one k3d cluster from another k3d cluster. For this, I needed to add the server from the managed k3d cluster to the network of the cluster running argocd. After starting up the clusters using k3d cluster start
, the config map show the correct entries.
However, after restarting docker, the config map is reset as mentioned above.
Is there a way to prevent k3d from resetting the coredns configmap upon startup?
@fragolinux Unfortunately this is expected behavior with regard to Rancher K3s and is not a k3d issue per se. Rancher K3s rewrites the manifest files whenever it is started and the documentation states that they shouldn't be altered:
Manifests for packaged components are managed by K3s, and should not be altered. The files are re-written to disk whenever K3s is started, in order to ensure their integrity.
When k3d creates a cluster (k3d cluster create
), it injects entries into the CoreDNS config map by updating the manifest file /var/lib/rancher/k3s/server/manifests/coredns.yaml
, however, when the container is restarted, K3s will rewrite the manifest file (as seen in the log entry: level=info msg="Writing manifest: /var/lib/rancher/k3s/server/manifests/coredns.yaml
) and so all the NodeHosts entries in the ConfigMap are removed. You can't, despite the k3d documentation, even map a volume with a custom coredns.yaml
file to this path as K3s will still overwrite it (I've proved this myself).
A workaround for this issue is to run k3d cluster stop <cluster name>
and then 'k3d cluster start
It is possible to disable the Rancher K3s CoreDNS manifests and replace with your own but, unfortunately, k3d doesn't have an option for injecting the NodeHosts entries into a different manifest file (e.g., /var/lib/rancher/k3s/server/manifests/custom/mycoredns.yaml
).
Solved 2 years ago 😅 I just save the coredns cm after 1st start, and reapply on restart Thanks BTW!
Host entries to the CoreDNS config are now managed via the coredns-custom configmap as per https://github.com/k3d-io/k3d/pull/1453 so they survive restarts of the cluster and host system.
This is released in https://github.com/k3d-io/k3d/releases/tag/v5.7.0
What did you do
How was the cluster created?
k3d cluster create --config cluster.yaml
i then restarted docker (desktop, on mac), container started but the configmap was completely emptied, it now contains just this:
What did you expect to happen
configmap survives a simple docker restart... i confirm this happens even on k3s container stop and restart...
Screenshots or terminal output
Which OS & Architecture
Which version of
k3d
PLEASE note that even the k3s version is wrong, as the cluster config has this ENV... K3SVERSION=v1.21.14-k3s1 export IMAGE=k3s:"${K3SVERSION}"
Which version of docker