Hello, I am kinda new to kubernetes and never used coredns before, so apology in advance if any of my question may be dumb.
I am running on k3s v1.28.5+k3s1 and coredns-1.29.0 installed using helm.
I am just trying to achieve basic DNS functionality between the pods and to forward public DNS requests to google.
Currently clients can indeed reach external/public urls, however internal DNS resolution doesn’t seem to be working.
Here is the servers part of the coredns helm values.yaml file.
Full values.yaml config file can be found here.
servers:
- zones:
- zone: .
port: 53
# If serviceType is nodePort you can specify nodePort here
# nodePort: 30053
# hostPort: 53
plugins:
# Allows public DNS resolution
- name: forward
parameters: . 8.8.8.8 9.9.9.9
#
- 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: intranet.local in-addr.arpa ip6.arpa
configBlock: |-
pods verified
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
Simple nginx deployment which uses coredns as dns server
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: httpd-test
spec:
replicas: 3
selector:
matchLabels:
app: httpd-test
template:
metadata:
labels:
app: httpd-test
spec:
dnsPolicy: "None" # Set to "None" to use custom DNS settings
dnsConfig:
nameservers:
- 10.43.122.198 # Replace with the IP of the CoreDNS service
searches:
- httpd-test.default.svc.intranet.local # replace with yours
containers:
- name: nginx
image: nginx
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: httpd-test
spec:
selector:
app: httpd-test
ports:
- protocol: TCP
port: 80
targetPort: 80
Internal dns resolution does not work
admin@store0:~$ sudo kubectl get pods
NAME READY STATUS RESTARTS AGE
coredns-55c557f5f9-p2c55 1/1 Running 0 4h35m
httpd-test-67cf9c55b8-8mhzp 1/1 Running 0 4h19m
httpd-test-67cf9c55b8-2g4dx 1/1 Running 0 4h19m
httpd-test-67cf9c55b8-2dbzp 1/1 Running 0 4h19m
admin@store0:~$ sudo kubectl exec -it httpd-test-67cf9c55b8-8mhzp -- bash
root@httpd-test-67cf9c55b8-8mhzp:/# curl httpd-test-67cf9c55b8-2g4dx
curl: (6) Could not resolve host: httpd-test-67cf9c55b8-2g4dx
root@httpd-test-67cf9c55b8-8mhzp:/# curl httpd-test-67cf9c55b8-2g4dx.httpd-test.default.svc.intranet.local
curl: (6) Could not resolve host: httpd-test-67cf9c55b8-2g4dx.httpd-test.default.svc.intranet.local
root@httpd-test-67cf9c55b8-8mhzp:/# cat /etc/resolv.conf
search httpd-test.default.svc.intranet.local
nameserver 10.43.122.198
root@httpd-test-67cf9c55b8-8mhzp:/#
Any help will be greatly appreciated.
Thanks